示例#1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (ddlQuestion.SelectedValue == "")
        {
            cvSecretQuestion.ErrorMessage = "You must select a secret question.";
            cvSecretQuestion.IsValid = false;
            cvSecretQuestion.Visible = true;
            return;
        }
        if (ddlRole.SelectedValue == "")
        {
            cvRole.ErrorMessage = "You must select a role.";
            cvRole.IsValid = false;
            cvRole.Visible = true;
            return;
        }

        DBMembershipProvider obj = new DBMembershipProvider(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
        MembershipCreateStatus mMStatus;
        MembershipUser mNewMemberStatus = obj.CreateUser(
            txtUserName.Text, txtPassword.Text, txtEmail.Text, ddlQuestion.SelectedItem.Text, txtAnswer.Text, true, null, out mMStatus, txtFirstName.Text.Trim(), txtLastName.Text.Trim(), Convert.ToInt32(ddlRole.SelectedValue));
        if (mNewMemberStatus == null)
        {
            Master.SetMessage("User could not be created due to " + mMStatus.ToString(), BaseCore.Enumerations.MessageBoxCss.ERROR);
        }
        else
        {
            Master.SetMessage("New User created successfully.", BaseCore.Enumerations.MessageBoxCss.SUCCESS);
        }
    }
示例#2
0
文件: Login.aspx.cs 项目: skgw/GWHRA
 protected void siteLogin_LoggedIn(object sender, EventArgs e)
 {
     DBMembershipProvider obj = new DBMembershipProvider(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
     if (obj.ValidateUser(this.siteLogin.UserName, this.siteLogin.Password))
     {
         Session["UserName"] = this.siteLogin.UserName;
         UserInfo loggedInUser = new UserInfo();
         loggedInUser.GetUserInfo(this.siteLogin.UserName, 1);
         if (!loggedInUser.IsLocked)
         {
             Session["LoggedInUserInfo"] = loggedInUser;
             Response.Redirect(string.IsNullOrEmpty(loggedInUser.Homepage) ? "default.aspx" : loggedInUser.Homepage);
         }
         else
         {
             Master.SetMessage("This account is Locked. Contact Administrator.", BaseCore.Enumerations.MessageBoxCss.NOTICE);
         }
     }
     else
     {
         Session["UserName"] = null;
         //this.siteLogin.FailureText = "Wrong username/password.";
         Master.SetMessage("Wrong username/password.", BaseCore.Enumerations.MessageBoxCss.ERROR);
     }
 }
示例#3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Session["UserName"] == null)
        {
            Master.SetMessage("You are not authorized to change Q&A.", BaseCore.Enumerations.MessageBoxCss.NOTICE);
            return;
        }
        string userName = (string)Session["UserName"];
        ErrorMessage.Text = "";
        DBMembershipProvider obj = new DBMembershipProvider(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

        Boolean res = obj.ChangePasswordQuestionAndAnswer(userName, txtPassword.Text, ddlQuestion.SelectedItem.Text, txtAnswer.Text);
        if (res == false)
        {
            Master.SetMessage("Your secret Q&A could not be changed.", BaseCore.Enumerations.MessageBoxCss.ERROR);
        }
        else
        {
            Master.SetMessage("Your secret Q&A is changed successfully.", BaseCore.Enumerations.MessageBoxCss.SUCCESS);
        }
    }
示例#4
0
 protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
 {
     if (Session["UserName"] == null)
     {
         //ErrorMessage.Text = "You are not authorized to change Q&A.";
         Master.SetMessage("You are not authorized to change Password.", BaseCore.Enumerations.MessageBoxCss.NOTICE);
         return;
     }
     string userName = (string)Session["UserName"];
     //ErrorMessage.Text = "";
     DBMembershipProvider obj = new DBMembershipProvider(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
     Boolean res = obj.ChangePassword(userName, ChangePassword1.CurrentPassword, ChangePassword1.NewPassword);
     if (res == false)
     {
         //ErrorMessage.Text = "Your password could not be changed.";
         Master.SetMessage("Your password could not be changed.", BaseCore.Enumerations.MessageBoxCss.ERROR);
     }
     else
     {
         //ErrorMessage.Text = "Your password is changed successfully.";
         Master.SetMessage("Your password is changed successfully.", BaseCore.Enumerations.MessageBoxCss.ERROR);
     }
 }