コード例 #1
0
    protected void btnForgotPasword_Click(object sender, EventArgs e)
    {
        JaslokMailer      objMailer     = new JaslokMailer();
        List <Parameters> lstParameters = new List <Parameters>();
        string            lsEmailStatus = string.Empty;

        if (!IsNumber(txtForgotPasswordUserName.Text))
        {
            MembershipUser objUser = Membership.GetUser(txtForgotPasswordUserName.Text.Trim());
            if (objUser != null)
            {
                UserInfo objInfo = new UserInfo();
                objInfo = UserController.GetUserByName(objUser.UserName);
                string lsmobileNumber = objInfo.Profile.GetPropertyValue("PhoneNumber");
                string lsPassword;
                lsPassword = objUser.GetPassword();
                //sendmail(objUser.Email, lsPassword);
                if (!string.IsNullOrEmpty(lsmobileNumber))
                {
                    CommonFn.SendSMS(lsmobileNumber.Replace("-", ""), "Your password is: " + lsPassword);
                }
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text
                });
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Password", ShortCodeValue = lsPassword
                });
                lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, objInfo.Email, null);
                if (string.IsNullOrEmpty(lsEmailStatus))
                {
                    lblForgotPassError.Text     = "Password has been sent to your email address.";
                    lblForgotPassError.CssClass = "successText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                else
                {
                    lblForgotPassError.Text     = "Problem in sending email";
                    lblForgotPassError.CssClass = "errorText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                txtForgotPasswordUserName.Text = "";
                //lblGeneratedPassword.Text = lsPassword;
            }
            else
            {
                lblForgotPassError.CssClass    = "errorText";
                lblForgotPassError.Text        = "Username does not exist.";
                txtForgotPasswordUserName.Text = "";
                divLoginForm.Attributes.Add("style", "display:none;");
                divForgotPassword.Attributes.Add("style", "display:block;");
            }
        }
        else
        {
            PatIndex objPatIndex    = new PatIndex();
            var      PatientDetails = objPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtForgotPasswordUserName.Text.Trim());

            if (PatientDetails.WEBPWD != null)
            {
                if (!string.IsNullOrEmpty(PatientDetails.WEBPWD))
                {
                    CommonFn.SendSMS(PatientDetails.PatMobile.Replace("-", ""), "Your password is: " + PatientDetails.WEBPWD);
                }
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text
                });
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Password", ShortCodeValue = PatientDetails.WEBPWD
                });
                lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, PatientDetails.PatEmail, null);
                if (string.IsNullOrEmpty(lsEmailStatus))
                {
                    lblForgotPassError.Text     = "Password has been sent to your email address.";
                    lblForgotPassError.CssClass = "successText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                else
                {
                    lblForgotPassError.Text     = "Problem in sending email";
                    lblForgotPassError.CssClass = "errorText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                txtForgotPasswordUserName.Text = "";
            }
            else
            {
                lblForgotPassError.Text     = "MRNumber not found, Please enter valid MRNumber.";
                lblForgotPassError.CssClass = "errorText";
                divLoginForm.Attributes.Add("style", "display:none;");
                divForgotPassword.Attributes.Add("style", "display:block;");
            }
        }
    }
コード例 #2
0
    protected void LoginBtn_Click(object sender, EventArgs e)
    {
        //#region CSV Updation For User
        //DataSet dsUser = new DataSet();
        //DataAccessEntities oEntities = new DataAccessEntities();
        //oEntities.Email = "";
        //oEntities.MRNumber = txtLoginUsername.Text;
        //oEntities.UserName = "";
        //dsUser = objBusinessLogic.GetUserNameByMRNumber(oEntities);
        //string visitorId = string.Empty;
        //string AvailableMR = string.Empty;
        //if (dsUser != null && dsUser.Tables[0].Rows.Count > 0)
        //{
        //    visitorId = dsUser.Tables[0].Rows[0]["UserName"].ToString();
        //    Messege = dsUser.Tables[0].Rows[0]["Messege"].ToString();
        //    AvailableMR = dsUser.Tables[0].Rows[0]["AvailableMR"].ToString();
        //    Session["IsMR"] = Convert.ToString(AvailableMR);
        //}
        //#endregion


        if (Session["AppointmentDetail"] != null)
        {
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());
            if (IsNum == true)
            {
                UserInfo objUser = new UserInfo();
                objUser.Username = txtLoginUsername.Text.Trim();
                UserMembership objMembership = new UserMembership(objUser);
                objMembership.Username = txtLoginUsername.Text.Trim();
                objMembership.Password = txtLoginPassword.Text;
                objUser.Membership     = objMembership;

                PortalSettings  po          = new PortalSettings();
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                if (objUserInfo != null)
                {
                    UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    Response.Redirect("/Payment.aspx");
                }
                else
                {
                    if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                    {
                        lblLoginError.CssClass = "errorText";

                        lblLoginError.Visible = true;

                        lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                        return;
                    }

                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct password!";
                    return;
                }
            }
            else
            {
                Session["AppointmentDetail"] = null;
                lblLoginError.CssClass       = "errorText";
                lblLoginError.Visible        = true;
                lblLoginError.Text           = "Please Enter MR Number To Login!";
                return;
            }
        }
        else if (Session["ConsultationAppointment"] != null)
        {
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());
            if (IsNum == true)
            {
                UserInfo objUser = new UserInfo();
                objUser.Username = txtLoginUsername.Text.Trim();
                UserMembership objMembership = new UserMembership(objUser);
                objMembership.Username = txtLoginUsername.Text.Trim();
                objMembership.Password = txtLoginPassword.Text;
                objUser.Membership     = objMembership;

                PortalSettings  po          = new PortalSettings();
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                if (objUserInfo != null)
                {
                    UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    Response.Redirect("/Payment.aspx");
                }
                else
                {
                    if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                    {
                        lblLoginError.CssClass = "errorText";

                        lblLoginError.Visible = true;

                        lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                        return;
                    }

                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct password!";
                    return;
                }
            }
            else
            {
                Session["ConsultationAppointment"] = null;
                lblLoginError.CssClass             = "errorText";
                lblLoginError.Visible = true;
                lblLoginError.Text    = "Please Enter MR Number To Login!";
                return;
            }
        }
        else
        {
            JaslokMailer      objMailer     = new JaslokMailer();
            List <Parameters> lstParameters = new List <Parameters>();
            string            lsEmailStatus = string.Empty;
            PatIndex          objPatIndex   = new PatIndex();
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());

            if (IsNum == false)
            {
                // check for visitor id and MRNO
                string  MRNumber;
                string  Username;
                DataSet ds = objBusinessLogic.GetMRNumberByUserName(txtLoginUsername.Text.Trim());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    MRNumber = ds.Tables[0].Rows[0]["MRNumber"].ToString();
                    Username = ds.Tables[0].Rows[0]["Username"].ToString();
                }
                else
                {
                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct Id and Password!";
                    return;
                }
                if (string.IsNullOrEmpty(MRNumber) && !string.IsNullOrEmpty(Username))
                {
                    //loginStatus = UserLoginStatus.LOGIN_SUCCESS;


                    UserInfo objUser = new UserInfo();
                    objUser.Username = txtLoginUsername.Text.Trim();
                    UserMembership objMembership = new UserMembership(objUser);
                    objMembership.Username = txtLoginUsername.Text.Trim();
                    objMembership.Password = txtLoginPassword.Text;
                    objUser.Membership     = objMembership;

                    PortalSettings  po          = new PortalSettings();
                    UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                    UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                    if (objUserInfo != null)
                    {
                        UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);

                        Session["IsVisitor"] = true;

                        Response.Redirect("/redirect");

                        //Response.Redirect("/redirect");
                    }
                    else
                    {
                        if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                        {
                            lblLoginError.CssClass = "errorText";

                            lblLoginError.Visible = true;

                            lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                            return;
                        }

                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Please enter correct password!";
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(MRNumber))
                {
                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please Enter MR Number To Login!";
                    return;
                }
            }
            if (IsNum == true)
            {
                // check for Mr Number in db
                bool check = objBusinessLogic.IsExistMrNo(txtLoginUsername.Text.Trim());

                if (check == true)
                {
                    UserInfo objUser = new UserInfo();
                    objUser.Username = txtLoginUsername.Text.Trim();
                    UserMembership objMembership = new UserMembership(objUser);
                    objMembership.Username = objUser.Username.Trim();
                    objMembership.Password = txtLoginPassword.Text;
                    objUser.Membership     = objMembership;


                    PortalSettings  po          = new PortalSettings();
                    UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                    UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                    if (objUserInfo != null)
                    {
                        UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);



                        if (!string.IsNullOrEmpty(hdnRedirectUrl.Value))
                        {
                            if (hdnRedirectUrl.Value.ToLower() == "patientregistration")
                            {
                                Response.Redirect("/");
                            }
                            else
                            {
                                Response.Redirect("/" + hdnRedirectUrl.Value);
                            }
                        }
                        else
                        {
                            Response.Redirect("/redirect");
                        }
                    }
                    else
                    {
                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Please enter correct password!";
                        return;
                    }

                    //UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    //Response.Redirect("/redirect");
                }
                // If User enters MRNo. which we do not have
                else
                {
                    var PatientDetails = objPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtLoginUsername.Text.Trim());


                    if (PatientDetails.MRNO != null && PatientDetails.WEBPWD != null)
                    {
                        DataSet dsVal = InsertUpdateUserDetails(PatientDetails.MRNO, PatientDetails.PatFName, PatientDetails.PatLName, PatientDetails.PatEmail, PatientDetails.WEBPWD, PatientDetails.PatMobile, PatientDetails.PatSex, PatientDetails.PatAddr1, PatientDetails.PatAge);


                        if (dsVal.Tables[0].Rows.Count == 1)
                        {
                            // loginStatus = UserLoginStatus.LOGIN_SUCCESS;

                            Session["IsVisitor"] = null;
                            UserInfo objUser = new UserInfo();
                            objUser.Username = txtLoginUsername.Text.Trim();
                            UserMembership objMembership = new UserMembership(objUser);
                            objMembership.Username = txtLoginUsername.Text.Trim();
                            objMembership.Password = txtLoginPassword.Text;
                            objUser.Membership     = objMembership;

                            PortalSettings  po          = new PortalSettings();
                            UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                            UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                            if (objUserInfo != null)
                            {
                                UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);


                                //if (!string.IsNullOrEmpty(hdnRedirectUrl.Value))
                                //{
                                //    Response.Redirect("/" + hdnRedirectUrl.Value);
                                //}
                                //else
                                Response.Redirect("/redirect");
                            }
                            else
                            {
                                lblLoginError.CssClass = "errorText";
                                lblLoginError.Visible  = true;
                                lblLoginError.Text     = "Please enter correct password!";
                                return;
                            }
                        }
                    }
                    else
                    {
                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Login Failed! You are not authorized to access Jaslok Portal!";
                    }
                }
            }
        }
    }