private void tsmiAddCompany_Click(object sender, EventArgs e) { if (this.tvCompanies.SelectedNode != null) { DataRow pcmp = (DataRow)this.tvCompanies.SelectedNode.Tag; DataRow cmp = this.dataset.Tables[0].NewRow(); EditCompanyForm ecf = new EditCompanyForm(this.connection, cmp, pcmp); if (ecf.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string error = ""; if (!Brands.Companies.Insert(this.connection, ref cmp, out error)) { MessageBox.Show("Ошибка при обновлении компании!\n" + error, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { this.dataset.Tables[0].Rows.Add(cmp); this.AddChild(cmp); } } } }
private void tvCompanies_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.tvCompanies.SelectedNode != null) { DataRow cmp = (DataRow)this.tvCompanies.SelectedNode.Tag; DataRow pcmp = null; if (this.tvCompanies.SelectedNode.Level > 0) { pcmp = (DataRow)this.tvCompanies.SelectedNode.Parent.Tag; } EditCompanyForm ecf = new EditCompanyForm(this.connection, cmp, pcmp); if (ecf.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.tvCompanies.SelectedNode.Text = (string)cmp["CmpanyName"]; this.tvCompanies.SelectedNode.Tag = cmp; string error = ""; if (!Brands.Companies.Update(this.connection, cmp, out error)) { MessageBox.Show("Ошибка при обновлении компании!\n" + error, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return; }