Beispiel #1
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);
            }
        }
        protected void btnregister_Click(object sender, EventArgs e)
        {
            using (var db = new HotelReservationEntities3())
            {
                login login = new login();
                login.userid    = txtuname.Text;
                login.passsword = txtpassword.Text;

                userdetail user = new userdetail();
                user.userid        = txtuname.Text;
                user.name          = txtname.Text;
                user.passportno    = txtnirc.Text;
                user.email_phoneno = txtemail.Text;

                db.logins.Add(login);
                db.SaveChanges();
                db.userdetails.Add(user);
                db.SaveChanges();

                Session["user"]       = login;
                Session["userdetail"] = user;

                Response.Redirect("BookingConfirmation.aspx");
            }
        }
Beispiel #3
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();
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (HotelReservationEntities3 hr = new HotelReservationEntities3())
     {
         for (int i = 0; i < noofroom; i++)
         {
             if (noofroom < numgen)
             {
                 var booking1 = (from a in hr.bookings
                                 select a).ToList();
                 int     idgen = booking1.Count;
                 booking bk    = new booking();
                 int     no    = idgen;
                 no++;
                 bk.bookingid    = "bk" + no;
                 bk.name         = TextBox3.Text;
                 bk.Phone        = TextBox6.Text;
                 bk.passportno   = TextBox4.Text;
                 bk.email        = TextBox5.Text;
                 bk.datecheckin  = Convert.ToDateTime(Checkin.Text);
                 bk.datecheckout = Convert.ToDateTime(Checkout.Text);
                 //bk.noofpeople = Convert.ToInt16(Noofpeople.Text);
                 bk.roomid = Roomtype.Text;
                 string type = Roomtype.Text;
                 if (type.Equals("d"))
                 {
                     int temp1 = 60 - numgen;
                     temp1++;
                     bk.roomno = Roomtype.Text + temp1;
                     hr.bookings.Add(bk);
                     hr.SaveChanges();
                     numgen--;
                 }
                 else
                 {
                     int temp2 = 20 - numgen;
                     temp2++;
                     bk.roomno = Roomtype.Text + temp2;
                     hr.bookings.Add(bk);
                     hr.SaveChanges();
                     numgen--;
                 }
                 if (numgen == 0)
                 {
                     break;
                 }
             }
         }
     }
 }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     using (HotelReservationEntities3 dele = new HotelReservationEntities3())
     {
         var Delebook = (from x in dele.bookings
                         where x.bookingid == EditBooking1.TBookingID &&
                         x.email == EditBooking1.TEmail
                         select x).First();
         if (Delebook != null)
         {
             dele.bookings.Remove(Delebook);
             dele.SaveChanges();
             Clear();
             EditBooking1.Message = "Record Deleted Successfully";
         }
     }
 }
        void Retrieve_Submit(object sender, EventArgs e)
        {
            HotelReservationEntities3 h = new HotelReservationEntities3();
            var book = from x in h.bookings
                       where x.bookingid == EditBooking1.TBookingID &&
                       x.email == EditBooking1.TEmail
                       select x;

            if (book.FirstOrDefault() != null)
            {
                booking b = book.FirstOrDefault();
                PanelInfo.Visible = true;
                labName.Text      = b.name;
                labPss.Text       = b.passportno;
                labEmail.Text     = b.email;
                labTel.Text       = b.Phone;
                labIN.Text        = b.name;
                labOUT.Text       = b.datecheckin.ToString("dd/MM/yyyy");
                labIN.Text        = b.datecheckout.ToString("dd/MM/yyyy");
                labDuration.Text  = (b.datecheckout.Date.Day - b.datecheckin.Date.Day).ToString();
                if (b.roomid == "s")
                {
                    labRoomT.Text = "Single room";
                }
                else if (b.roomid == "d")
                {
                    labRoomT.Text = "Double room";
                }
                else if (b.roomid == "su")
                {
                    labRoomT.Text = "Superior";
                }
                else if (b.roomid == "du")
                {
                    labRoomT.Text = "Deluxe";
                }
                labRoomNo.Text = "1";
            }
            else
            {
                EditBooking1.Message = "No Record has been found";
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            using (HotelReservationEntities3 db = new HotelReservationEntities3())
            {
                var login = db.logins.Find(TextBox1.Text);
                if (login != null)
                {
                    if (login.passsword.Trim() == TextBox2.Text.Trim())
                    {
                        Session["user"] = login;

                        HotelReservationEntities3 context = new HotelReservationEntities3();

                        var query = from x in context.userdetails
                                    where x.userid == login.userid
                                    select x;


                        userdetail detail = query.First();
                        TextBox3.Text       = detail.name;
                        Session["MainName"] = detail.name;
                        TextBox4.Text       = detail.passportno;
                        TextBox5.Text       = detail.email_phoneno;

                        Session["userdetail"] = detail;
                        Label2.Text           = "Member Infromation";
                        Label6.Text           = "Member Name";

                        Label17.Visible = false;
                        //Response.Redirect("");
                    }
                    else
                    {
                        Label17.Visible = true;
                    }
                }
                else
                {
                    Label17.Visible = true;
                }
            }
        }
Beispiel #8
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();
        }
Beispiel #9
0
        private void checkDateAvailability()
        {
            DateTime checkIn            = Convert.ToDateTime(txtCheckInDate.Text);
            DateTime checkOut           = Convert.ToDateTime(txtCheckOutDate.Text);//Calendar2.SelectedDate;
            String   roomtypr           = lblRoomType.Text;
            int      roomAmounts        = 1;
            HotelReservationEntities3 h = new HotelReservationEntities3();
            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;
            }
            var avail = from x in h.availablities
                        where x.dateofavailablity >= checkIn && x.dateofavailablity <= checkOut && x.roomsavailable >= roomAmounts &&
                        x.roomid == roomType
                        select x;

            int range = checkOut.DayOfYear - checkIn.DayOfYear + 1;

            // int range = checkOut.Date.Day - checkIn.Date.Day+1;
            if (avail.FirstOrDefault() == null || avail.ToArray().Length != range)
            {
                confirmChangeButton.Enabled = false;
                var notAvail = from x in h.availablities
                               where x.dateofavailablity >= checkIn && x.dateofavailablity <= checkOut && x.roomsavailable < roomAmounts &&
                               x.roomid == roomType
                               select x;
                string message = "";

                foreach (availablity a in notAvail)
                {
                    message += a.dateofavailablity.ToShortDateString() + " ";
                }
                if (range >= 1)
                {
                    testLabel.Text = "Sorry! " + message + " is not available ";
                }
                else
                {
                    testLabel.Text = "Please choose vaild date !";
                }
                testLabel.Visible = true;
            }
            else
            {
                confirmChangeButton.Enabled = true;
                testLabel.Text    = "It is available ! ";
                testLabel.Visible = true;
            }
            if (range >= 1)
            {
                lblDurantionOut.Text = range.ToString();
                calculateCost(range);
            }
            else
            {
                lblDurantionOut.Text = "0";
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (HotelReservationEntities3 hr = new HotelReservationEntities3())
            {
                for (int i = 0; i < noofroom; i++)
                {
                    if (noofroom < numgen)
                    {
                        var booking1 = (from a in hr.bookings
                                        select a).ToList();
                        int     idgen = booking1.Count;
                        booking bk    = new booking();
                        int     no    = idgen;
                        //no++;
                        //bk.bookingid = "bk" + no;
                        var check = (from x in hr.bookings
                                     select x.bookingid).ToList();
                        List <int> listid = new List <int>();
                        foreach (String strbookingid in check)
                        {
                            int x = Convert.ToInt32(strbookingid.Substring(2));
                            listid.Add(x);
                        }
                        int maxid = listid.Max();
                        maxid++;
                        bk.bookingid = "bk" + maxid;
                        bk.name      = TextBox3.Text;
                        //bk.Phone = TextBox6.Text;
                        bk.passportno   = TextBox4.Text;
                        bk.email        = TextBox5.Text;
                        bk.datecheckin  = Convert.ToDateTime(Checkin.Text);
                        bk.datecheckout = Convert.ToDateTime(Checkout.Text);
                        //bk.noofpeople = Convert.ToInt16(Noofpeople.Text);
                        bk.roomid = Roomtype.Text;
                        string type = Roomtype.Text;
                        if (type.Equals("d"))
                        {
                            int temp1 = 60 - numgen;
                            temp1++;
                            bk.roomno     = Roomtype.Text + temp1;
                            bk.noofpeople = 2;
                            hr.bookings.Add(bk);
                            hr.SaveChanges();
                            //updating availablity table

                            avai[i] = numgen;

                            numgen--;
                        }

                        else if (type.Equals("s"))
                        {
                            int temp2 = 20 - numgen;
                            temp2++;
                            bk.roomno     = Roomtype.Text + temp2;
                            bk.noofpeople = 1;
                            hr.bookings.Add(bk);
                            hr.SaveChanges();

                            avai[i] = numgen;
                            numgen--;
                        }
                        else if (type.Equals("du"))
                        {
                            int temp2 = 20 - numgen;
                            temp2++;
                            bk.roomno     = Roomtype.Text + temp2;
                            bk.noofpeople = 3;
                            hr.bookings.Add(bk);
                            hr.SaveChanges();
                            avai[i] = numgen;
                            numgen--;
                        }
                        else if (type.Equals("su"))
                        {
                            int temp2 = 20 - numgen;
                            temp2++;
                            bk.roomno     = Roomtype.Text + temp2;
                            bk.noofpeople = 5;
                            hr.bookings.Add(bk);
                            hr.SaveChanges();
                            avai[i] = numgen;
                            numgen--;
                        }
                        else
                        {
                        }


                        //Jade

                        var avail2 = from x in hr.availablities
                                     where x.dateofavailablity >= bk.datecheckin && x.dateofavailablity <= bk.datecheckout && //&& x.roomsavailable >= afterRoomAmounts
                                     x.roomid == Roomtype.Text
                                     select x;
                        foreach (availablity a in avail2)
                        {
                            a.roomsavailable -= 1;
                        }
                        hr.SaveChanges();

                        //Thiru
                        //var availablity1 = (from a in hr.availablities
                        //                    select a).ToList();
                        //int idgen1 = availablity1.Count;

                        //int avgen = idgen1;
                        //avgen++;
                        //non = avai.Min();
                        //if (type.Equals("s"))
                        //{


                        //    availablity av = new availablity();

                        //    av.roomsavailable = non;
                        //    av.availablityid = "av"+avgen;
                        //    av.dateofavailablity = Convert.ToDateTime(Checkin.Text);
                        //    av.roomid = "s";
                        //    hr.availablities.Add(av);
                        //    hr.SaveChanges();
                        //}
                        //else if (type.Equals("d"))
                        //{

                        //    availablity av = new availablity();

                        //    av.roomsavailable = non;
                        //    av.availablityid = "av" + avgen;
                        //    av.dateofavailablity = Convert.ToDateTime(Checkin.Text);
                        //    av.roomid = "d";
                        //    hr.availablities.Add(av);
                        //    hr.SaveChanges();
                        //}
                        //else if (type.Equals("du"))
                        //{

                        //    availablity av = new availablity();

                        //    av.roomsavailable = non;
                        //    av.availablityid = "av"+avgen;
                        //    av.dateofavailablity = Convert.ToDateTime(Checkin.Text);
                        //    av.roomid = "s";
                        //    hr.availablities.Add(av);
                        //    hr.SaveChanges();
                        //}
                        //else if (type.Equals("su"))
                        //{

                        //    availablity av = new availablity();

                        //    av.roomsavailable = non;
                        //    av.availablityid = "av"+avgen;
                        //    av.dateofavailablity = Convert.ToDateTime(Checkin.Text);
                        //    av.roomid = "su";
                        //    hr.availablities.Add(av);
                        //    hr.SaveChanges();
                        //}
                        if (numgen == 0)
                        {
                            break;
                        }
                        String display = "Successfully Booked !!! Thank you for booking at our hotel. You will receive mail about the confirmation.";

                        ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('" + display + "')", true);

                        String toEmail = TextBox5.Text;

                        String subject = "Booking Confirmation.";

                        String body = "Successfully booked.";

                        sendemail(toEmail, subject, body);
                    }
                }
            }
        }
        public String search(DateTime find,DateTime find1, String temp)
        {
            int[] remaining = new int[30];

            int i = 0;
            //int diff= Convert.ToInt16(find1-find);
            if (find < find1)
            {
                using (HotelReservationEntities3 hr = new HotelReservationEntities3())
                {
                    for (DateTime check = find; check < find1; check = check.AddDays(1))
                    {

                        var book = (from b in hr.bookings
                                    where b.roomid == temp && b.datecheckin == find
                                    select b).ToList();
                        // booking bbb = book.FirstOrDefault<booking>();
                        if ((book.Count == 0) && (temp.Equals("s")) || (book.Count == 0) && (temp.Equals("su")) || (book.Count == 0) && (temp.Equals("du")))
                        {
                            remaining[i] = 20;
                            i++;
                            availablity aa = new availablity();
                            var check1 = (from x in hr.availablities
                                         select x.availablityid).ToList();
                            List<int> listid = new List<int>();
                            foreach (String strbookingid in check1)
                            {
                                int x = Convert.ToInt32(strbookingid.Substring(2));
                                listid.Add(x);

                            }
                            int maxid = listid.Max();
                            maxid++;
                            aa.availablityid = "av" +maxid;
                            aa.dateofavailablity = find;
                            aa.roomid = "s";
                            aa.roomsavailable = 19;
                            hr.availablities.Add(aa);
                            hr.SaveChanges();

                        }
                        else if ((book.Count == 0) && (temp.Equals("d")))
                        {
                            remaining[i] = 60;
                            i++;
                            availablity aa = new availablity();
                            var check1 = (from x in hr.availablities
                                          select x.availablityid).ToList();
                            List<int> listid = new List<int>();
                            foreach (String strbookingid in check1)
                            {
                                int x = Convert.ToInt32(strbookingid.Substring(2));
                                listid.Add(x);

                            }
                            int maxid = listid.Max();
                            maxid++;
                            aa.availablityid = "av" + maxid;
                            aa.dateofavailablity = find;
                            aa.roomid = "s";
                            aa.roomsavailable = 19;
                            hr.availablities.Add(aa);
                            hr.SaveChanges();
                        }
                        else if ((book.Count > 0) && (temp.Equals("d")))
                        {

                            remaining[i] = 60 - book.Count;
                            // String r= remaining.ToString();
                            // Label7.Text= r;

                            //var avi =( from a in hr.availablities
                            //          where a.roomid == temp && a.dateofavailablity == find
                            //          select a).ToList();
                            //   if((avi.Count>0)&&(temp.Equals("d")))
                            //{

                            //}
                            //    availablity aa = avi.FirstOrDefault<availablity>();
                            //    String r = aa.roomsavailable.ToString();
                            //    Label7.Text = r;
                            i++;
                        }
                        else if ((book.Count > 0) && (temp.Equals("su")) || (book.Count > 0) && (temp.Equals("du")) || (book.Count > 0) && (temp.Equals("s")))
                        {
                            remaining[i] = 20 - book.Count;
                            // String r1 = remaining.ToString();
                            i++;
                            // Label7.Text = r1;
                        }
                        else
                        r1 = "Coun't find the search";

                    }
                    //passing = Convert.ToInt16(remaining.Max());
                    r1 = Convert.ToString(remaining.Max());

                }
            }
            return r1;
        }