Beispiel #1
0
        protected void Login()
        {
            string    userEmail    = emailtxt.Text.ToString();
            string    userPassword = passwordtxt.Text.ToString();
            Customers login        = new Customers();

            login = CustomersDB.GetPassword(userEmail, userPassword);
            if (login != null) //find matched userid and password
            {
                Session["userEmail"]    = login.CustEmail;
                Session["userPassword"] = login.CustPassword;
                Session["CustomerId"]   = login.CustomerId;

                Response.Redirect("home.aspx");
            }
            else //userid and password not match
            {
                emailtxt.Text    = "";
                passwordtxt.Text = "";
                errorLabel.Text  = "Login Attempt Failed. Please Try Again.";
            }
        }
        protected void Button1_Click1(object sender, EventArgs e)
        {
            Customers cust = new Customers();

            cust.CustFirstName = firstNametxt.Text;
            cust.CustLastName  = lastNametxt.Text;
            cust.CustAddress   = addresstxt.Text;
            cust.CustCity      = citytxt.Text;
            cust.CustProv      = DropDownList2.SelectedItem.Value;
            cust.CustPostal    = postalCodetxt.Text;
            cust.CustCountry   = CountryID.SelectedItem.Value;
            cust.CustHomePhone = phoneNumbertxt.Text;
            cust.CustBusPhone  = mobNumbertxt.Text;
            cust.CustEmail     = emailtxt.Text;
            cust.CustPassword  = passwordtxt.Text;

            List <Customers> cl        = CustomersDB.GetAll();
            List <string>    emailList = new List <string>();

            foreach (var c in cl)
            {
                emailList.Add(c.CustEmail.Trim());
            }
            if (emailList.Contains(cust.CustEmail))
            {
                lblError.Text      = "Duplicated Email!";
                emailtxt.Text      = "";
                lastNametxt.Text   = "";
                firstNametxt.Text  = "";
                passwordtxt.Text   = "";
                passwordRetxt.Text = "";
            }
            else
            {
                CustomersDB.Add(cust);
                Response.Redirect("login.aspx");
            }
        }