我有两种形式,分别为Frm_Department
和Frm_Employee
如何将文本框(Frm_Department
)中的数据传输到ComboBox(Frm_Employee
)?下面的图片是我从TextBox
传输数据的地方。
以下是表格。
表格部门代码:
if (txtDepname.Text != "" && txtDepLocation.Text != "" && txtDepLocal.Text != "" )
{
DataClasses1DataContext db = new DataClasses1DataContext();
tbldepartment dep = new tbldepartment();
dep.DepID = txtDepID.Text;
dep.Depname = txtDepname.Text;
dep.Location = txtDepLocation.Text;
dep.LocalPhone = txtDepLocal.Text;
Insert.sp_insertdepartment(dep);
MessageBox.Show("Successfully Saved!");
AutoGenerate();
}
else
{
MessageBox.Show("Input all Details....");
}
表格员工代码:
if (txtempLname.Text != "" && txtempFname.Text != "" && txtempMname.Text != "" && txtempPossition.Text != "")
{
DataClasses1DataContext db = new DataClasses1DataContext();
tblemployee emp = new tblemployee();
emp.EmpID = txtempnum.Text;
emp.Lname = txtempLname.Text;
emp.Fname = txtempFname.Text;
emp.Mname = txtempMname.Text;
emp.Position = txtempPossition.Text;
Insert.sp_insertemployee(emp);
MessageBox.Show("Successfully Saved!");
AutoGenerate();
}
else
{
MessageBox.Show("Input all Details....");
}