private void editDepToolStripMenuItem_Click(object sender, EventArgs e) { Department dep = new Department(); if (treeViewDepEmpl.SelectedNode != null) { for (int i = 0; i < _db._ds.Tables["Department"].Rows.Count; i++) { string depName = _db._ds.Tables["Department"].Rows[i]["Name"].ToString(); if (depName == treeViewDepEmpl.SelectedNode.Text) { dep.SetValues( Convert.ToInt32(_db._ds.Tables["Department"].Rows[i]["Id"]), _db._ds.Tables["Department"].Rows[i]["Name"].ToString()); DepartmentForm df = new DepartmentForm(dep); df.ShowDialog(); dep = df.dep; if (dep.Id != 0) { _db._ds.Tables["Department"].Rows[i]["Name"] = dep.Name; _db._adapterDepartment.Update(_db._ds.Tables["Department"]); } treeViewDepEmpl.BeginUpdate(); treeViewDepEmpl.SelectedNode.Text = dep.Name; treeViewDepEmpl.EndUpdate(); } } } }
public void SetDepartment(Department department) { DataRow row = _db._ds.Tables["Department"].Rows.Find(department.Id); if (row == null) { row = _db._ds.Tables["Department"].NewRow(); row["Id"] = department.Id; row["Name"] = department.Name; _db._ds.Tables["Department"].Rows.Add(row); } else { row["Id"] = department.Id; row["Name"] = department.Name; } _db._adapterDepartment.Update(_db._ds.Tables["Department"]); OnDBChanged(_db); }
private void newDepToolStripMenuItem_Click(object sender, EventArgs e) { Department dep = new Department(); dep.SetId(client.GetCurIdentity("Department") + 1); DepartmentForm df = new DepartmentForm(dep); df.ShowDialog(); dep = df.dep; if (dep.Id != 0) { client.SetDepartment(dep); //_waitForResponse.WaitOne(); treeViewDepEmpl.BeginUpdate(); treeViewDepEmpl.Nodes.Add(new TreeNode(dep.Name)); treeViewDepEmpl.EndUpdate(); } }
public DepartmentForm(Department department) { InitializeComponent(); dep = department; }