Exemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string             name            = txtCusName.Text.Trim();
            string             password        = txtPassword.Text.Trim();
            CustomerController customerControl = new CustomerController();
            Customer           obj_customer    = new Customer();

            obj_customer = customerControl.CheckCustomerLogin(name, password);
            if (!String.IsNullOrEmpty(obj_customer.CustomerID))
            {
                Response.Cookies["CustomerID"].Value   = obj_customer.CustomerID;
                Response.Cookies["CustomerID"].Expires = DateTime.Now.AddMinutes(30);
                Response.Cookies["IsAdmin"].Value      = obj_customer.IsAdmin.ToString();
                Response.Cookies["IsAdmin"].Expires    = DateTime.Now.AddMinutes(30);

                Response.Redirect("Index.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock
                    (this, this.GetType(), "alertMessage", "alert('Name or Password is wrong. Please try again!')", true);
            }
        }