//构造函数 public DepartmentForm(BathDBDataContext dc, Department department, DepartLogMgForm form) { db = dc; m_form = form; if (department != null) { newDepartment = false; m_Department = department; } InitializeComponent(); }
partial void DeleteDepartment(Department instance);
partial void UpdateDepartment(Department instance);
partial void InsertDepartment(Department instance);
//确定 private void okBtn_Click(object sender, EventArgs e) { if (TextName.Text.Trim() == "") { BathClass.printErrorMsg("需要输入部门名称"); TextName.SelectAll(); TextName.Focus(); return; } m_Department.name = TextName.Text.Trim(); if (TextNote.Text.Trim() != "") m_Department.note = TextNote.Text.Trim(); if (newDepartment) { if (db.Department.FirstOrDefault(x => x.name == TextName.Text) != null) { BathClass.printErrorMsg("已经存在此名称的部门"); TextName.SelectAll(); TextName.Focus(); return; } db.Department.InsertOnSubmit(m_Department); db.SubmitChanges(); m_form.createTree(); m_Department = new Department(); TextName.Text = ""; TextNote.Text = ""; TextName.Focus(); } else { db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }