示例#1
0
    protected void btnLogIn_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text != String.Empty)
        {
            if (txtPassword.Text != String.Empty)
            {
                SEC_UserDAL dalSEC_Admin = new SEC_UserDAL();
                DataTable   dt           = dalSEC_Admin.UserLogIn(txtUserName.Text.Trim(), txtPassword.Text.Trim());

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["UserID"].ToString() != String.Empty)
                        {
                            Session["UserID"] = Convert.ToInt32(dr["UserID"]);
                        }
                        if (dr["UserName"].ToString() != String.Empty)
                        {
                            Session["UserName"] = dr["UserName"].ToString();
                        }
                        //if (dr["Email"].ToString() != String.Empty)
                        //{
                        //    Session["Email"] = dr["Email"].ToString();
                        //}
                    }
                    Response.Redirect("~/AdminPanel/Default.aspx");
                }
                else
                {
                    lblMessage.Text = "The username or password you entered is incorrect.";
                }
            }
            else
            {
                lblMessage.Text = "Enter your Password.";
            }
        }
        else
        {
            lblMessage.Text = "Enter your Username.";
        }
    }
        public DataTable UserLogIn(SqlString UserName, SqlString Password)
        {
            SEC_UserDAL dalSEC_User = new SEC_UserDAL();

            return(dalSEC_User.UserLogIn(UserName, Password));
        }