Ejemplo n.º 1
0
        private void calculateCost(int range)
        {
            lblBookingId.Text = EditBooking2.TBookingID;

            HotelReservationEntities3 h = new HotelReservationEntities3();
            var book = from x in h.bookings
                       where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail
                       select x;
            booking b1       = book.FirstOrDefault();
            string  roomType = "";

            switch (lblRoomType.Text)
            {
            case "Single": roomType = "s";
                break;

            case "Double": roomType = "d";
                break;

            case "Deluxe": roomType = "du";
                break;

            case "Superior": roomType = "su";
                break;
            }
            b1.roomid            = roomType;
            lblNumberOfRoom.Text = "1";
            var room = from x in h.roomfacilities
                       where x.roomid == b1.roomid
                       select x;
            roomfacility rm = room.FirstOrDefault();

            lblPrice.Text = "$" + rm.roomrent.ToString() + " per room";
            lblTotal.Text = "$" + (rm.roomrent * range).ToString();
        }
Ejemplo n.º 2
0
        private Boolean showBookingInformation()
        {
            lblBookingId.Text = EditBooking2.TBookingID;
            txtPhoneNo.Text   = EditBooking2.TEmail;
            HotelReservationEntities3 h = new HotelReservationEntities3();

            var book = from x in h.bookings
                       where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail
                       select x;
            booking b1 = book.FirstOrDefault();

            if (book.FirstOrDefault() != null)
            {
                RegularExpressionValidator2.Visible = false;
                txtName.Text         = b1.name;
                txtPassportNo.Text   = b1.passportno;
                txtEmail.Text        = b1.email;
                txtPhoneNo.Text      = b1.Phone;
                txtCheckInDate.Text  = b1.datecheckin.ToShortDateString();
                txtCheckOutDate.Text = b1.datecheckout.ToShortDateString();
                int range = b1.datecheckout.DayOfYear - b1.datecheckin.DayOfYear + 1;
                if (range >= 0)
                {
                    lblDurantionOut.Text = range.ToString();
                }
                else
                {
                    lblDurantionOut.Text = "0";
                }
                string roomType = "";
                switch (b1.roomid)
                {
                case "s": roomType = "Single";
                    break;

                case "d": roomType = "Double";
                    break;

                case "du": roomType = "Deluxe";
                    break;

                case "su": roomType = "Superior";
                    break;
                }
                lblRoomType.Text     = roomType;
                lblNumberOfRoom.Text = b1.roomno.ToString();
                var room = from x in h.roomfacilities
                           where x.roomid == b1.roomid
                           select x;
                roomfacility rm = room.FirstOrDefault();
                lblPrice.Text     = "$" + rm.roomrent.ToString() + " per room";
                lblTotal.Text     = "$" + (rm.roomrent * range).ToString();
                infoPanel.Visible = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        private void changeBooking()
        {
            lblBookingId.Text = EditBooking2.TBookingID;

            HotelReservationEntities3 h = new HotelReservationEntities3();
            var book = from x in h.bookings
                       where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail
                       select x;
            booking b1       = book.FirstOrDefault();
            string  roomType = "";

            switch (lblRoomType.Text)
            {
            case "Single": roomType = "s";
                break;

            case "Double": roomType = "d";
                break;

            case "Deluxe": roomType = "du";
                break;

            case "Superior": roomType = "su";
                break;
            }

            // int beforeRoomAmounts = Convert.ToInt32(lblNumberOfRoom.Text);
            var avail = from x in h.availablities
                        where x.dateofavailablity >= b1.datecheckin && x.dateofavailablity <= b1.datecheckout && //&& x.roomsavailable >= beforeRoomAmounts
                        x.roomid == roomType
                        select x;

            foreach (availablity a in avail)
            {
                a.roomsavailable += 1;
            }
            b1.name       = txtName.Text;
            b1.passportno = txtPassportNo.Text;
            b1.email      = txtEmail.Text;
            b1.Phone      = txtPhoneNo.Text;
            // lblAfterChange.Text = txtPhoneNo.Text;
            b1.datecheckin  = Convert.ToDateTime(txtCheckInDate.Text);
            b1.datecheckout = Convert.ToDateTime(txtCheckOutDate.Text);

            b1.roomid            = roomType;
            lblNumberOfRoom.Text = "1";
            var room = from x in h.roomfacilities
                       where x.roomid == b1.roomid
                       select x;
            roomfacility rm = room.FirstOrDefault();

            lblPrice.Text = "$" + rm.roomrent.ToString() + " per room";
            lblTotal.Text = "$" + (rm.roomrent).ToString();
            //int afterRoomAmounts = Convert.ToInt32(lblNumberOfRoom.Text);
            var avail2 = from x in h.availablities
                         where x.dateofavailablity >= b1.datecheckin && x.dateofavailablity <= b1.datecheckout && //&& x.roomsavailable >= afterRoomAmounts
                         x.roomid == roomType
                         select x;

            foreach (availablity a in avail2)
            {
                a.roomsavailable -= 1;
            }
            h.SaveChanges();
        }