Example #1
0
 /// <summary>
 /// When the button is clicked, this code uses the CustomerLogin class to validate the entered user name and password. If they are valid, it redirects to Default2.aspx. If they are invalid, it will display an invalid login message.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     CustomerLogin cl = new CustomerLogin();
     int pk = cl.Login(txtuser.Text, txtpassword.Text);
     if (pk != 0)
     {
         Session["person"] = pk;
         Response.Redirect("Default2.aspx");
     }
     else
     {
         lblmsg.Text = "Invalid Login";
     }
 }
Example #2
0
    protected void LogInBtn_Click(object sender, EventArgs e)
    {
        //This code uses the CustomerLogin class to validate the entered log in information, retrieve the Person Key of the user who logged in, and save the key in the "person" session, then redirect to Default5.aspx
        try
        {
            CustomerLogin cl = new CustomerLogin();
            int pk = cl.Login(txtuser.Text, txtpassword.Text);
            if (pk != 0)
            {
                Session["person"] = pk;
                Response.Redirect("Default5.aspx", false);
            }
            else
            {
                lblmsg.Text = "Invalid Login";
            }
           }

        catch (Exception ex)
        {
            Session["error"] = ex.Message;
            Response.Redirect("Default6.aspx");
        }
    }