예제 #1
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            LoginEntity _LoginEntity = new LoginEntity();

            _LoginEntity.UserName = txtUserName.Text;
            _LoginEntity.Password = objCommon.Encrypt(txtPassword.Text.Trim());

            BAL_Login _ballogin = new BAL_Login();
            DataTable _dtLogin  = _ballogin.getLoginDetails(_LoginEntity);


            if (Convert.ToInt32(_dtLogin.Rows[0][0].ToString()) == -1)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Login", "alert('Enter Correct User Name or Password')", true);
            }
            else if (_dtLogin.Rows[0]["RoleID"].ToString() == "4")
            {
                //string x = txtimgcode.Text;
                //string y = Session["CaptchaImageText"].ToString();
                //if (txtimgcode.Text == Session["CaptchaImageText"].ToString())
                //{
                //    //lblmsg.Text = "Excellent.......";
                //    if (CheckBoxRemember.Checked)
                //    {
                //        Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30);
                //        Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
                //    }
                //    else
                //    {
                //        Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                //        Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);

                //    }
                Response.Cookies["UserName"].Value = txtUserName.Text.Trim();
                Response.Cookies["Password"].Value = txtPassword.Text.Trim();
                Session["LoginID"] = int.Parse(_dtLogin.Rows[0]["ID"].ToString());

                Session["Role"]   = _dtLogin.Rows[0]["RoleID"].ToString();
                Session["Mobile"] = _dtLogin.Rows[0]["EmployeeCode"].ToString();

                Session["EmployeeName"] = _dtLogin.Rows[0]["EmployeeName"].ToString();
                /*admin */
                Response.Redirect("~/AdminDashBoard.aspx");
                //}
                //else
                //{
                //    lblmsg.Text = "image code is not valid.";
                //}
                //this.txtimgcode.Text = "";
            }

            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Login", "alert('Enter Correct User Name or Password')", true);
            }
        }
예제 #2
0
    protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e)
    {
        lblLoginError.Text = string.Empty;

        if (!string.IsNullOrEmpty(txtUsername.Text) && !string.IsNullOrEmpty(txtPassword.Text))
        {
            string Email, Password;
            Email    = txtUsername.Text;
            Password = txtPassword.Text;
            DataTable dt = BAL_Login.Login_Verify(Email, Password, "login", UserType);
            if (dt != null)
            {
                if (dt.Rows.Count == 1)
                {
                    UserSession us = new UserSession();
                    us.UserID     = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());
                    us.UserTypeID = Convert.ToInt32(dt.Rows[0]["UserTypeID"].ToString());
                    us.Email      = dt.Rows[0]["Email"].ToString();
                    us.Password   = dt.Rows[0]["Password"].ToString();
                    us.FirstName  = dt.Rows[0]["FirstName"].ToString();
                    us.LastName   = dt.Rows[0]["LastName"].ToString();

                    //store object into session
                    Session["AccountDetail"] = us;

                    if (us.UserTypeID == 1) // Admin Users
                    {
                        Response.Redirect("~/Admin/AdminHome.aspx");
                    }
                }
                else
                {
                    lblLoginError.Text = "Invalid UserName or Password";
                }
            }
            else
            {
                lblLoginError.Text = "Invalid UserName or Password";
            }
        }
    }