private void Insertion_Click(object sender, EventArgs e) { if (HostelAd.Text == "") { MessageBox.Show("Вы не сможете контролировать постояльцами гостиницы, так как вы к ней не привязаны"); return; } ChangeGuests changeGuests = new ChangeGuests(); if (changeGuests.ShowDialog() == DialogResult.OK) { string Up_to_Date = "Insert into Guests (Фамилия, Имя, Отчество, [Дата рождения], Пол, [Номер телефона], [Паспортные данные], ID, Гостиница) Values (" + "'" + changeGuests.Familia.Text + "'," + "'" + changeGuests.Imya.Text + "'," + "'" + changeGuests.Otchestvo.Text + "'," + "'" + changeGuests.WasBorn.Text + "'," + "'" + changeGuests.Floor.Text + "'," + "'" + changeGuests.Number.Text + "'," + "'" + changeGuests.Pachport.Text + "'," + (GridGuests.Rows.Count + 1) + "," + HostelAd.Text + ")"; OleDbConnection sql_conn = new OleDbConnection(ConnectionString); OleDbCommand sql_comm = new OleDbCommand(Up_to_Date, sql_conn); sql_conn.Open(); sql_comm.ExecuteNonQuery(); sql_conn.Close(); ShowGuests(); changeGuests.Close(); } }
private void Change_Click(object sender, EventArgs e) { if (HostelAd.Text == "") { MessageBox.Show("Вы не сможете контролировать постояльцами гостиницы, так как вы к ней не привязаны"); return; } ChangeGuests changeGuests = new ChangeGuests(); int index = GridGuests.CurrentRow.Index; int Id = (int)GridGuests[9, index].Value; changeGuests.Familia.Text = Convert.ToString(GridGuests[1, index].Value); changeGuests.Imya.Text = Convert.ToString(GridGuests[2, index].Value); changeGuests.Otchestvo.Text = Convert.ToString(GridGuests[3, index].Value); changeGuests.WasBorn.Text = GridGuests[4, index].Value.ToString(); changeGuests.Floor.Text = GridGuests[5, index].Value.ToString(); changeGuests.Number.Text = GridGuests[6, index].Value.ToString(); changeGuests.Pachport.Text = GridGuests[7, index].Value.ToString(); if (changeGuests.ShowDialog() == DialogResult.OK) { string Up_to_Date = "UPDATE Guests SET " + "Фамилия='" + changeGuests.Familia.Text + "'," + "Имя='" + changeGuests.Imya.Text + "'," + "Отчество='" + changeGuests.Otchestvo.Text + "'," + "[Дата рождения]='" + changeGuests.WasBorn.Text + "'," + "Пол='" + changeGuests.Floor.Text + "'," + "[Номер телефона]='" + changeGuests.Number.Text + "'," + "[Паспортные данные]='" + changeGuests.Pachport.Text + "'" + " Where ID=" + Id + " And Гостиница=" + HostelAd.Text; OleDbConnection sql_conn = new OleDbConnection(ConnectionString); OleDbCommand sql_comm = new OleDbCommand(Up_to_Date, sql_conn); sql_conn.Open(); sql_comm.ExecuteNonQuery(); sql_conn.Close(); ShowGuests(); changeGuests.Close(); } }