protected void btnCancelReservation_Click(object sender, EventArgs e)
        {
            if(ckCancel.Checked == true)
            {
                int bookingRef = Convert.ToInt32(Session["bookingRef"].ToString());

                ThreeHotelEntities ctx = new ThreeHotelEntities();
                //Booking booking = ctx.Bookings.Where(x => x.GuestId == id).FirstOrDefault();
                Booking booking = ctx.Bookings.Where(x => x.BookingReferenceId == bookingRef).FirstOrDefault();
                RoomBooked roomBooked = ctx.RoomBookeds.Where(r => r.BookingReferenceId == bookingRef).FirstOrDefault();
                if (booking != null && roomBooked != null)
                {
                    booking.Status = "Cancelled";
                    roomBooked.Status = "Cancelled";
                    ctx.SaveChanges();
                    lblMsg.Text = "Reservation successfully cancelled.";
                }
                else
                {
                    lblMsg.Text = "Kindly select the check box if you wish to cancel your reservation.";
                }

            }
            else
            {
                lblMsg.Text = "Kindly select the check box if you wish to cancel your reservation.";
            }
        }
Example #2
0
        public void MemberUpdate(string id, string salut, string familyName, string fName, string email, string address, string ph, string country)
        {
            ThreeHotelEntities ct = new ThreeHotelEntities();
            Guest g = new Guest();

            g = (from x in ct.Guests
                 where x.GuestId == id
                 select x).First();

            g.Salutation = salut;
            g.FamilyName = familyName;
            g.FirstName = fName;

            g.Email = email;
            g.Address = address;
            g.PhoneNo = ph;
            g.Country = country;

            ct.SaveChanges();
        }
Example #3
0
        public string MemberSave(string salut, string familyName, string fName, string pwd, string email, string address, string ph, string country)
        {
            string id;
            ThreeHotelEntities ct = new ThreeHotelEntities();
            Guest g = new Guest();
            User user = new User();

            id = getMemberId();
            g.GuestId = id;

            g.Salutation = salut;
            g.FamilyName = familyName;
            g.FirstName = fName;
            user.MembershipId = id;
            user.Password = Encrypt(pwd);
            g.Email = email;
            g.Address = address;
            g.PhoneNo = ph;
            g.Country = country;

            ct.Guests.Add(g);
            ct.Users.Add(user);
            ct.SaveChanges();

            SendMail(fName, familyName, email, id);
            return id;
        }
Example #4
0
        public void MemberChangePwd(string id, string newpwd)
        {
            ThreeHotelEntities ct = new ThreeHotelEntities();
            User g = new User();

            g = (from x in ct.Users
                 where x.MembershipId == id
                 select x).First();

            g.Password = Encrypt(newpwd);

            ct.SaveChanges();
        }
        protected void btnCompleteReservation_Click(object sender, EventArgs e)
        {
            if (Session["Id"] != null)
            {
                member = true;
            }

            ThreeHotelEntities ctx = new ThreeHotelEntities();

            char[] toTrim = { 'm', 'g', '0' };
            string guestID = "";

            //commit to database - Guest

            //if non-member, create new guest by addding row to Guest table
            if (!member)
            {
                Guest addGuest = new Guest();
                var guest = (from x in ctx.Guests where x.GuestId.Contains("G") orderby x.GuestId descending select x).First();

                if (guest != null)
                {
                    int lastNo = Int32.Parse(guest.GuestId.TrimStart("GMgm0".ToCharArray()));
                    int nextNo = lastNo + 1;
                    guestID = "G" + nextNo.ToString().PadLeft(4, '0');
                    addGuest.GuestId = guestID;
                }

                if (ddlSalutation.SelectedValue != string.Empty)
                {
                    addGuest.Salutation = ddlSalutation.SelectedValue;
                }

                if (txtFamilyName.Text != string.Empty)
                    addGuest.FamilyName = txtFamilyName.Text;

                if (txtFirstName.Text != string.Empty)
                    addGuest.FirstName = txtFirstName.Text;

                email = txtEmail.Text;
                if (email != string.Empty)
                    addGuest.Email = email;

                if (txtAddress.Text != string.Empty)
                    addGuest.Address = txtAddress.Text;

                if (txtPhoneNo.Text != string.Empty)
                    addGuest.PhoneNo = txtPhoneNo.Text;

                if (ddlCountry.SelectedValue != string.Empty)
                    addGuest.Country = ddlCountry.SelectedValue;

                ctx.Guests.Add(addGuest);

                ctx.SaveChanges();
            }

            //if member, add points earned to his account
            if(member)
            {
                //MemberID session is saved when member signs in
                guestID = Session["Id"].ToString();

                var guest = ctx.Guests.Where(g => g.GuestId == guestID).FirstOrDefault();
                if (guest != null)
                {
                    int currentPoints = Convert.ToInt16(guest.Points);
                    int newPoints = currentPoints + pointsEarned;
                    guest.Points = newPoints;
                    ctx.SaveChanges();
                }
            }

            //commit to database - Booking
            Booking addBooking = new Booking();

            if (Session["SpecialRateCode"] != string.Empty)
            {
                addBooking.SpecialRateCode = Session["SpecialRateCode"].ToString();
            }

            addBooking.CheckIn = Convert.ToDateTime(Session["CheckInDB"].ToString());
            addBooking.CheckOut = Convert.ToDateTime(Session["CheckOutDB"].ToString());
            addBooking.NoOfRooms = Convert.ToInt16(Session["RoomCount"].ToString());
            addBooking.Tax = taxRate;
            addBooking.ServiceCharge = serviceChargeRate;

            if (member)
            {
                addBooking.PointsEarned = pointsEarned;
            }
            else
            {
                addBooking.PointsEarned = 0;
            }

            addBooking.GuestId = guestID;

            if (txtCardNo.Text != string.Empty)
            {
                addBooking.CreditCardNo = Convert.ToInt64(txtCardNo.Text);
            }

            if (rbtnCardType.SelectedValue != string.Empty)
            {
                addBooking.CreditCardType = rbtnCardType.SelectedValue;
            }

            if (ddlMonth.SelectedValue != string.Empty && ddlYear.SelectedValue != string.Empty)
            {
                addBooking.CardExpiredDate = ddlMonth.SelectedValue + ddlYear.SelectedValue;
            }

            addBooking.TotalCost = totalCost;

            ctx.Bookings.Add(addBooking);
            ctx.SaveChanges();

            //commit to database - RoomBooked
            RoomBooked addRoomBooked = new RoomBooked();
            var booking = (from x in ctx.Bookings orderby x.BookingReferenceId descending select x).First();

            if (booking != null)
            {
                bookingRefId = Convert.ToInt32(booking.BookingReferenceId);
                addRoomBooked.BookingReferenceId = bookingRefId;
            }

            addRoomBooked.RoomType = Session["RoomType"].ToString();
            addRoomBooked.Rate = Convert.ToDouble(Session["Rate"].ToString());

            ctx.RoomBookeds.Add(addRoomBooked);
            ctx.SaveChanges();

            if (txtEmail.Text != string.Empty)
            {
                Session["Email"] = txtEmail.Text;
            }
            Session["BookingRefID"] = bookingRefId;
            Session["TotalCost"] = totalCost;
            Session["Email"] = txtEmail.Text;
            string mailadd = txtEmail.Text;
            Session["CostNights"] = costNights;
            Session["TaxSc"] = taxSC;
            Session["NoOfNights"] = noOfNights;
            if (txtFamilyName.Text != string.Empty)
            {
                Session["FamilyName"] = txtFamilyName.Text;
            }

            SendMail(bookingRefId, mailadd);
            Response.Redirect("RoomReservations-confirmation.aspx");
        }