Beispiel #1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            Property objProp = new Property();
            UserLoginBLL userLog = new UserLoginBLL();

            EncryptPassword encPwd = new EncryptPassword();

            TextBox txtUserID = (TextBox)phLogin.FindControl("txtUserID");
            TextBox txtPwd = (TextBox)phLogin.FindControl("txtPassword");

            string encPassword = encPwd.EncryptText(txtPwd.Text, "helloworld");
            objProp.UserID = txtUserID.Text.Trim();
            objProp.Password = encPassword.Trim();

            if (userLog.LoginUser(objProp))
            {
                Session["User"] = objProp.UserID;
                if ((string)Session["Role"] == "D")
                    Response.Redirect("Home/DoctorHome.aspx");
                else if ((string)Session["Role"] == "N")
                    Response.Redirect("Home/NurseHome.aspx");
                else if ((string)Session["Role"] == "P" || (string)Session["Role"] == "T")
                    Response.Redirect("Home/PharmacistHome.aspx");
                else if ((string)Session["Role"] == "C")
                    Response.Redirect("Home/CSRHome.aspx");
                else
                    Response.Redirect("Patient/AllPatientProfile.aspx");
            }
            else
            {
                Session["User"] = null;
                Label lblStatus = (Label)phLogin.FindControl("lblStatus");
                lblStatus.Visible = true;
                lblStatus.Text = "Invalid UserID/Password..!";
                objNLog.Error("Login failed for the user - " + txtUserID.Text);
            }
        }
        catch (Exception ex)
        {
            objNLog.Error("Error : " + ex.Message);
        }
    }