Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Id"] != null)
            {
                LinkButton2.Text = "SignOut";

                //get member name to display on Welcome
                Guest guest = new Guest();
                GuestController guestController = new GuestController();
                guest = guestController.getByMemberId(Session["Id"].ToString());
                string name = guest.Salutation + guest.FirstName + guest.FamilyName;
                lblWelcome.Text = "Welcome, " + name;
            }
        }
        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!";
        }
        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.";
                }

            }
        }
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            GuestController guestController = new GuestController();

            string salut = ddlSalutation.SelectedItem.Text;
            string familyName = txtFamilyName.Text;
            string fName = txtFirstName.Text;
            string password = txtPassword.Text;
            string conpwd = txtCPassword.Text;
            string email = txtEmail.Text;
            string address = txtAddress.Text;
            string ph = txtPhoneNo.Text;
            string country = ddlCountry.SelectedItem.Text;

            string id = guestController.MemberSave(salut, familyName, fName, password, email, address, ph, country);
            string full = fName + " " + familyName;

            Session["fullName"] = full;
            Session["Id"] = id;

            Response.Redirect("MemberProfile.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 = "";
            }
        }
        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();

                }
            }
        }