Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string name = guestNameTextBox.Text;
            string nal  = nationTB.Text;

            Guest g = new Guest(null, name, nal, DateTime.Now);

            GuestBUS gBUS = new GuestBUS();

            g = gBUS.insertGuest(g);
            if (g != null)
            {
                MessageBox.Show(g.FullName + " " + g.Nationality);
            }
            else
            {
                return;
            }
            BookingBUS bBUS        = new BookingBUS();
            string     roomType    = roomTypeComboBox.Text;
            string     roomID      = roomComboBox.Text;
            string     bookingType = bookingTypeCombobox.Text;
            DateTime   dateIn      = dateCheckin.DateTime;
            DateTime   dateout     = dateCheckout.DateTime;

            if (bBUS.checkAvaiable(roomID, dateIn, dateout) == false)
            {
                MessageBox.Show("ADD BOOKING SUCCESS FAILED!! ROOM BOOKED", "CONFIRMATION",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool breakfast = false;

            if (breakfastCheckbox.Checked == true)
            {
                breakfast = true;
            }
            string type = "003";

            if (bookingType == "AGODA")
            {
                type = "001";
            }
            else if (bookingType == "Booking.com")
            {
                type = "002";
            }
            else
            {
            }
            DTO.Booking b = new DTO.Booking(0, roomID, g.InfoID, type, nv.NhanVienID, DateTime.Now, dateIn, dateout, breakfast);


            if (bBUS.InsertBooking(b))
            {
                MessageBox.Show("ADD BOOKING SUCCESS FULL", "CONFIRMATION",
                                MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("ADD BOOKING SUCCESS FAILED", "CONFIRMATION",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }