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(); } } } }
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(); } }