private void btnBooking_Click(object sender, EventArgs e) { try { BookingTableAdapter bookingTableAdapter = new BookingTableAdapter(); bookingTableAdapter.Insert( tbxFirstname.Text, tbxLastname.Text, tbxAddress.Text, cbxProvince.Text, tbxTelephone.Text, tbxEmail.Text, Convert.ToInt32(cbxCustomerType.SelectedValue), Convert.ToInt32(cbxRoomType.SelectedValue), Convert.ToInt32(cbxRoom.SelectedValue), DateTime.Now, 0, dtpStarStay.Value, dtpEndStay.Value); MessageBox.Show("บันทึกการจองห้องเสร็จสมบูรณ์", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.Yes; } catch (Exception ex) { MessageBox.Show("ไม่สามารถบันทึกการจองห้องได้, กรุณาลองใหม่อีกครั้ง", "ข้อผิดผลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning); Console.WriteLine(ex.ToString()); this.DialogResult = System.Windows.Forms.DialogResult.No; } }
private void loadDataSource() { if (BookingID == 0) { this.roomDetailPanel.roomsTableAdapter.FillByRoomCheckInCheck(roomDetailPanel.apartmentDataSet.Rooms, roomDetailPanel.dtpStarStay.Value, roomDetailPanel.dtpEndStay.Value); } else { BookingTableAdapter bookingTableAdapter = new BookingTableAdapter(); Apartmant.Database.ApartmentDataSet.BookingDataTable booking = bookingTableAdapter.GetDataByID(BookingID); this.roomDetailPanel.Booking = true; this.roomDetailPanel.roomsTableAdapter.FillByID(roomDetailPanel.apartmentDataSet.Rooms, booking[0].RoomID); this.roomDetailPanel.dtpStarStay.Value = booking[0].StartStay; this.roomDetailPanel.dtpStarStay.Enabled = false; this.roomDetailPanel.dtpEndStay.Value = booking[0].EndStay; this.roomDetailPanel.dtpEndStay.Enabled = false; this.customerDetailPanel.tbxFirstname.Text = booking[0].Firstname; this.customerDetailPanel.tbxLastname.Text = booking[0].Lastname; this.customerDetailPanel.tbxAddress.Text = booking[0].Address; this.customerDetailPanel.cbxProvince.SelectedItem = booking[0].Province; } this.roomDetailPanel.roomTypesTableAdapter.Fill(roomDetailPanel.apartmentDataSet.RoomTypes); this.roomDetailPanel.customerTypesTableAdapter.Fill(roomDetailPanel.apartmentDataSet.CustomerTypes); this.roomDetailPanel.ChangeDateCallback = this; }
private void btnCancelBooking_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("คุณต้องการยกเลิกการจองใช้หรือไม่", "ยกเลิกการจอง", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result.Equals(System.Windows.Forms.DialogResult.Yes)) { BookingTableAdapter bookingTableAdapter = new BookingTableAdapter(); bookingTableAdapter.CancelBooking(BookingID); MessageBox.Show("ยกเลิกการจองเสร็จสมบูรณ์", "ยกเลิกการจองเสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information); } loadDataSource(); }