private void add_provider_button_Click(object sender, EventArgs e) { var form = new ProviderForm(); var res = form.ShowDialog(); if (res == DialogResult.OK) { var name = form.name_provider_textbox.Text; var score = form.score_provider_textbox.Text; var connection = new SqlConnection(connectionString); connection.Open(); var request = @"INSERT INTO Mikolaichuk_Provider (name, score) VALUES ('" + name + "','" + score + "')"; var command = new SqlCommand(request, connection); command.ExecuteNonQuery(); connection.Close(); updateProviderDGV(); } }
private void edit_provider_button_Click(object sender, EventArgs e) { var row = provider_grid.SelectedRows.Count > 0 ? provider_grid.SelectedRows[0] : null; if (row == null) { MessageBox.Show("Сначала укажите строку!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var form = new ProviderForm(); form.name_provider_textbox.Text = row.Cells["name"].Value.ToString(); form.score_provider_textbox.Text = row.Cells["score"].Value.ToString(); var res = form.ShowDialog(); if (res == DialogResult.OK) { var name = form.name_provider_textbox.Text; var score = form.score_provider_textbox.Text; var id = row.Cells["id"].Value.ToString(); var connection = new SqlConnection(connectionString); connection.Open(); var request = @"UPDATE Mikolaichuk_Provider SET name='" + name + "', score='" + score + "' WHERE id='" + id + "'"; var command = new SqlCommand(request, connection); command.ExecuteNonQuery(); connection.Close(); updateProviderDGV(); updateContactDGV(); updatePhoneHelpDGV(); } }