private void button2_Click(object sender, EventArgs e) { EditRoom form = new EditRoom(); form.TextBox1.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); form.TextBox2.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); form.TextBox3.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); form.TextBox4.Text = richTextBox1.Text; form.TextBox5.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString(); form.ShowDialog(); }
private void ChangeBtn_Click(object sender, EventArgs e) { refresh_method(); EditGuest EditGuestForm = new EditGuest(); EditRoom EditRoomForm = new EditRoom(); if (dataGridView1.Visible) { EditGuestForm.Show(); } if (dataGridView2.Visible) { EditRoomForm.Show(); } }
//Редактирование строки в БД public void editRoom() { string[] room = EditRoom.Edit(); string query = "UPDATE `номер` SET `Состояние` = '" + room[1] + "',`Цена за ночь` = '" + room[2] + "',`Оценка номера` = '" + room[3] + "',`id_набора особенностей` = '" + room[4] + "' WHERE(`Номер` = '" + room[0] + "')"; MySqlCommand command = new MySqlCommand(query, connection); command.CommandTimeout = 60; MySqlDataReader reader; try { connection.Open(); reader = command.ExecuteReader(); // Succesfully deleted connection.Close(); } catch (Exception ex) { // Ops, maybe the id doesn't exists ? MessageBox.Show(ex.Message); } }