Exemplo n.º 1
0
        public string getGuestId()
        {
            ThreeHotelEntities ct = new ThreeHotelEntities();

            Guest guest = new Guest();
            guest = (from x in ct.Guests
                     where x.GuestId.Contains("G")
                     orderby x.GuestId descending
                     select x).First();

            string a = guest.GuestId;
            string b = a.Substring(4, 1);

            int d = Convert.ToInt32(b);
            string e = Convert.ToString(d + 1);
            string c = "";
            if (d + 1 > 999)
                c = "G" + e;
            else if (d + 1 > 99)
                c = "G0" + e;
            else if (d + 1 > 9)
                c = "G00" + e;
            else
                c = "G000" + e;

            return c;
        }
Exemplo n.º 2
0
        public Guest getByMemberId(string id)
        {
            ThreeHotelEntities ct = new ThreeHotelEntities();
            Guest guest = new Guest();

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

            return guest;
        }
Exemplo n.º 3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Guest guest = new Guest();
            guestController = new GuestController();

            string id = "", salu = "", familyname = "", fname = "", email = "", address = "", ph = "", country = "";

            if (Session["Id"].ToString() != null)
            {
                 id = Session["Id"].ToString();
            }

            if (ddlSalutation.SelectedValue != string.Empty)
            {
                 salu = ddlSalutation.SelectedValue;
            }
            if(txtFamilyName.Text != string.Empty)
            {
                 familyname = txtFamilyName.Text;
            }

            if(txtFamilyName.Text != string.Empty)
            {
                 fname = txtFirstName.Text;
            }

            if(txtEmail.Text != string.Empty)
            {
                 email = txtEmail.Text;
            }

            if(txtAddress.Text != string.Empty)
            {
                 address = txtAddress.Text;
            }

            if(txtPhoneNo.Text != string.Empty)
            {
                 ph = txtPhoneNo.Text;
            }

            if(ddlCountry.SelectedValue != string.Empty)
            {
                 country = ddlCountry.SelectedValue;
            }

            guestController.MemberUpdate(id, salu, familyname, fname, email, address, ph, country);
            lblMsg.Text = "Successfully saved changes!";
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Id"] == null)
            {
                Response.Redirect("SignIn.aspx");
            }

            else
            {
                string id = Session["Id"].ToString();
                lblMemberId.Text = id;

                Guest guest = new Guest();
                GuestController guestController = new GuestController();
                guest = guestController.getByMemberId(id);
                string points = Convert.ToString(guest.Points);
                if (points == null)
                {
                    points = "0";
                }
                lblPoints.Text = points;

                string name = guest.Salutation + guest.FirstName + guest.FamilyName;
                lblName.Text = name;

                //to populate the gridview
                ThreeHotelEntities ctx = new ThreeHotelEntities();
                List<PastTransaction> tl = ctx.PastTransactions.Where(x => x.Member_No == id).ToList();
                if (tl != null)
                {
                    GridView1.DataSource = tl;
                    GridView1.DataBind();
                }
                else
                {
                    lblPastTransaction.Text = "No reservations with the hotel has been made.";
                }

            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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;
        }
        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");
        }
        private void loadMemberInfo()
        {
            guestController = new GuestController();
            guest = guestController.getByMemberId(Session["Id"].ToString());

            ddlSalutation.Items[0].Text = guest.Salutation;
            txtFamilyName.Text = guest.FamilyName;
            txtFirstName.Text = guest.FirstName;
            txtEmail.Text = guest.Email;
            txtAddress.Text = guest.Address;
            txtPhoneNo.Text = guest.PhoneNo;
            ddlCountry.Items[0].Text = guest.Country;

            ddlSalutation.Enabled = false;
            txtFamilyName.Enabled = false;
            txtFirstName.Enabled = false;
            txtEmail.Enabled = false;
            txtAddress.Enabled = false;
            txtPhoneNo.Enabled = false;
            ddlCountry.Enabled = false;
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            guestController = new GuestController();
            guest = new Guest();
            Boolean chk;
            string username = txtusername.Text;
            string pwd = txtpwd.Text;

            chk = guestController.checkMember(username, pwd);

            if (chk == true)
            {
                Session["Id"] = txtusername.Text;
                loadMemberInfo();
            }

            else
            {
                lblMsg.Text = "Incorrect Membership Number or Password entered. Kindly try again.";
                txtusername.Text = "";
                txtpwd.Text = "";
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Id"] == null)
                {
                    Response.Redirect("SignIn.aspx");
                }
                else
                {
                    Guest guest = new Guest();
                    guestController = new GuestController();
                    guest = guestController.getByMemberId(Session["Id"].ToString());

                    lblMemberID.Text = guest.GuestId.ToString().Trim();
                    ddlSalutation.Items[0].Text = guest.Salutation;
                    ddlSalutation.SelectedValue = guest.Salutation.ToString().Trim();
                    txtFamilyName.Text = guest.FamilyName.ToString().Trim();
                    txtFirstName.Text = guest.FirstName.ToString().Trim();
                    txtEmail.Text = guest.Email.ToString().Trim();
                    txtAddress.Text = guest.Address.ToString().Trim();
                    txtPhoneNo.Text = guest.PhoneNo.ToString().Trim();

                    ddlCountry.SelectedValue = guest.Country.ToString().Trim();

                }
            }
        }