private void btnAddReservation_Click(object sender, EventArgs e) { string guestQuery = "INSERT INTO reservations (DateIn, DateOut, RoomNumber, GuestId, RoomType) " + "VALUES (@DateIn, @DateOut, @RoomNumber, @GuestId, @RoomType); " + "INSERT INTO guests (Id, Name, Surname, Phone, RoomNumber) " + "VALUES (@GuestId, @Name, @Surname, @Phone, @RoomNumber)"; Guest_Form form = new Guest_Form(); using (Connection = new MySqlConnection(ConnectionString)) using (MySqlCommand command = new MySqlCommand(guestQuery, Connection)) using (MySqlDataAdapter adapter = new MySqlDataAdapter(command)) { Connection.Open(); command.Parameters.AddWithValue("@DateIn", dtTmPickArrival.Value.ToString("yyyy-MM-dd")); command.Parameters.AddWithValue("@DateOut", dtTmPickDeparture.Value.ToString("yyyy-MM-dd")); command.Parameters.AddWithValue("@RoomNumber", txtbxRoomNumber.Text); command.Parameters.AddWithValue("@RoomType", cmbBxRoomSize.SelectedIndex + 1); command.Parameters.AddWithValue("@GuestId", txtbxGuestId.Text); command.Parameters.AddWithValue("@Name", txtBxName.Text); command.Parameters.AddWithValue("@Surname", txtBxSurname.Text); command.Parameters.AddWithValue("@Phone", txtBxPhone.Text); command.ExecuteNonQuery(); } PopulateReservations(); }
private void btnDelete_Click(object sender, EventArgs e) { string guestQuery = "DELETE FROM reservations WHERE Id = @Id"; Guest_Form form = new Guest_Form(); using (Connection = new MySqlConnection(ConnectionString)) using (MySqlCommand command = new MySqlCommand(guestQuery, Connection)) { Connection.Open(); command.Parameters.AddWithValue("@Id", grdViewReservations.SelectedCells[0].Value); command.ExecuteNonQuery(); } PopulateReservations(); }
private void tlstrpbtnGuests_Click(object sender, EventArgs e) { Guest_Form guest_Form = new Guest_Form(); guest_Form.Show(); }