Esempio n. 1
0
        protected void View_Init(object sender, EventArgs e)
        {
            // *** Auto Log In Code ***
            string svUserId      = (string)(Session["UserId"]);
            string svDisplayName = (string)(Session["DisplayName"]);

            // If one of the session vars is empty -- Meaning NOT logged in
            if ((string.IsNullOrEmpty(svUserId) == true) || (string.IsNullOrEmpty(svDisplayName) == true))
            {
                // Try to get UserId from Cookie
                string strUserId = GlobalClass.readUserIdFromCookie();
                if (strUserId != null)
                {
                    // If valid User Id try to look up User in DB & populate session vars
                    if (GlobalClass.getUserInfo(strUserId) == true)
                    {
                        svDisplayName = (string)(Session["DisplayName"]);
                        GlobalClass.checkFavorites();
                        GlobalClass.logLogin("Shopping");
                    }
                    else
                    {
                        Response.Redirect("SignIn.aspx");
                    }
                }
                else
                {
                    // If session vars do not have valid values then back to the home page
                    Response.Redirect("SignIn.aspx");
                }
            }

            lblDisplayName1.Text = svDisplayName;
            lblDisplayName2.Text = svDisplayName;
            // *** Auto Log In Code ***

            if (IsPostBack == false)
            {
                LoadSendTo();
            }
            LoadGrid();
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (Request.Browser["IsMobileDevice"] == "true")
            //{
            //    Response.Redirect("MobileShopping.aspx");
            //}
            //else
            //{
            //    Response.Redirect("Home.aspx");
            //}

            // *** Auto Log In Code ***
            string svUserId      = (string)(Session["UserId"]);
            string svDisplayName = (string)(Session["DisplayName"]);

            // If one of the session vars is empty -- Meaning NOT logged in
            if ((string.IsNullOrEmpty(svUserId) == true) || (string.IsNullOrEmpty(svDisplayName) == true))
            {
                // Try to get UserId from Cookie
                string strUserId = GlobalClass.readUserIdFromCookie();
                if (strUserId != null)
                {
                    // If valid User Id try to look up User in DB & populate session vars
                    if (GlobalClass.getUserInfo(strUserId) == false)
                    {
                        Response.Redirect("Home.aspx");
                    }
                }
                else
                {
                    // If session vars do not have valid values then back to the home page
                    Response.Redirect("Home.aspx");
                }
            }

            GlobalClass.checkFavorites();
            GlobalClass.logLogin("Default");
            Response.Redirect("Shopping.aspx");
            // *** Auto Log In Code ***
        }
Esempio n. 3
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            // Validation Code
            // Set flag to false
            flgValidationError = false;

            // If built in validation finds an error
            //if (IsValid != true) { flgValidationError = true; }

            // ** Email validation **
            lblErrorEmail.Visible = false;
            // Check for blank email
            if (txtEmail.Text.Trim() == "")
            {
                lblErrorEmail.Visible = true;
                flgValidationError    = true;
                ValidationError.Display("Email address is blank");
            }
            else
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtEmail.Text) == false)
                {
                    lblErrorEmail.Visible = true;
                    flgValidationError    = true;
                    ValidationError.Display("Email address is formatted incorrectly");
                }
            }

            // ** Password validation **
            lblErrorPassword.Visible = false;
            // Check for blank password
            if (txtPassword.Text.Trim() == "")
            {
                lblErrorPassword.Visible = true;
                flgValidationError       = true;
                ValidationError.Display("Password is blank");
            }

            if (flgValidationError == true)
            {
                return;
            }

            // Try to sign in user
            if (SignInUser(txtEmail.Text, GlobalClass.encodePassword(txtPassword.Text)) == false)
            {
                flgValidationError = true;
                ValidationError.Display("Email address or Password is incorrect");
            }
            else
            {
                GlobalClass.checkFavorites();
                GlobalClass.logLogin("SignIn");

                if (Request.QueryString["page"] == "List")
                {
                    Response.Redirect("List.aspx");
                }
                else if (Request.QueryString["page"] == "Preferences")
                {
                    Response.Redirect("Preferences.aspx");
                }
                else if (Request.QueryString["page"] == "PreferencesReset")
                {
                    Response.Redirect("Preferences.aspx?page=PreferencesReset");
                }
                else
                {
                    Response.Redirect("Shopping.aspx");
                }
            }
        }