private void editClientsToolStripMenuItem1_Click(object sender, EventArgs e) { EditClients newForm = new EditClients(); newForm.Owner = this; newForm.Show(); }
private void button1_Click(object sender, EventArgs e) { SqlConnectionStringBuilder connect = new SqlConnectionStringBuilder(); connect.InitialCatalog = "kleinkind"; connect.DataSource = @"ALEKSEY-PC"; connect.ConnectTimeout = 30; connect.IntegratedSecurity = true; using (SqlConnection cn = new SqlConnection()) { cn.ConnectionString = connect.ConnectionString; try { SqlCommand myCommand = new SqlCommand("Add_Client", cn); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@Name", comboBox1.Text); myCommand.Parameters.AddWithValue("@Adress", comboBox2.Text); cn.Open(); myCommand.ExecuteNonQuery(); } catch (SqlException ex) { // Протоколировать исключение MessageBox.Show(ex.Message); } finally { // Гарантировать освобождение подключения cn.Close(); } } comboBox1.Text = ""; comboBox2.Text = ""; EventOK(); EditClients main = this.Owner as EditClients; main.ReLoad(); Close(); }
private void viewClientsToolStripMenuItem_Click(object sender, EventArgs e) { EditClients newForm = new EditClients(); newForm.Show(); }