示例#1
0
    protected void ibtnSave_Click(object sender, EventArgs e)
    {
        register_addpwd common = new register_addpwd();
        string salt = common.GenerateSalt().ToString();
        string pwd = common.EncodePassword(txtNewPwd.Text, 1, salt);

        QueriesTableAdapter amtup = new QueriesTableAdapter();
        int count = amtup.aspnet_Membership_ResetPassword("/", txtUserName.Text, pwd, 1, 1, salt, DateTime.Now, 1, txtAnswer.Text);
        if (count != 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!\\n\\n密码设置成功!');", true);
            txtUserName.Text = "";
            txtNewPwd.Text = "";
            txtConfirmPwd.Text = "";
            txtAnswer.Text = "";
            //  Response.Write("<Script>alert('')</Script>");

            Response.Redirect("../Public/Index.aspx");
        }
        else
        {
            txtUserName.Text = "";
            txtNewPwd.Text = "";
            txtConfirmPwd.Text = "";
            txtAnswer.Text = "";
            ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('对不起!\\n\\n用户名和答案不匹配,请重新输入!');", true);
        }
    }
示例#2
0
    protected void ibtnSave_Click(object sender, EventArgs e)
    {
        register_addpwd common = new register_addpwd();
        string          salt   = common.GenerateSalt().ToString();
        string          pwd    = common.EncodePassword(txtNewPwd.Text, 1, salt);

        QueriesTableAdapter amtup = new QueriesTableAdapter();
        int count = amtup.aspnet_Membership_ResetPassword("/", txtUserName.Text, pwd, 1, 1, salt, DateTime.Now, 1, txtAnswer.Text);

        if (count != 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!\\n\\n密码设置成功!');", true);
            txtUserName.Text   = "";
            txtNewPwd.Text     = "";
            txtConfirmPwd.Text = "";
            txtAnswer.Text     = "";
            //  Response.Write("<Script>alert('')</Script>");

            Response.Redirect("../Public/Index.aspx");
        }
        else
        {
            txtUserName.Text   = "";
            txtNewPwd.Text     = "";
            txtConfirmPwd.Text = "";
            txtAnswer.Text     = "";
            ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('对不起!\\n\\n用户名和答案不匹配,请重新输入!');", true);
        }
    }
示例#3
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        if (txtNPwd0.Text != "" && txtNPwd1.Text != "" && txtOPwd.Text != "")
        {
            register_addpwd common = new register_addpwd();
            string          salt   = common.GenerateSalt().ToString();
            string          pwd    = common.EncodePassword(txtNPwd1.Text, 1, salt);

            string        connStr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
            SqlConnection conn    = new SqlConnection(connStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand("aspnet_Membership_SetPassword", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@ApplicationName", Membership.ApplicationName));
            cmd.Parameters.Add(new SqlParameter("@UserName", Session["name"].ToString()));
            cmd.Parameters.Add(new SqlParameter("@NewPassword", pwd));
            cmd.Parameters.Add(new SqlParameter("@PasswordSalt", salt));
            cmd.Parameters.Add(new SqlParameter("@CurrentTimeUtc", DateTime.Now));
            cmd.Parameters.Add(new SqlParameter("@PasswordFormat", Membership.Provider.PasswordFormat.GetHashCode()));
            SqlParameter returnValue = new SqlParameter();
            returnValue.ParameterName = "returnValue";
            returnValue.Direction     = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(returnValue);

            //=== 执行预存程序 ===
            cmd.ExecuteNonQuery();
            conn.Close();

            if (returnValue.Value.ToString() == "0")
            {
                Response.Write("<Script>alert('恭喜您!密码设置成功!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!密码设置成功!');", true);
            }
            else
            {
                Response.Write("<Script>alert('密码设置失败,请重试!')</Script>");
            }
            // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('密码设置失败,请重试!');", true);
        }
        else
        {
            Response.Write("<Script>alert('请确保填写完整!')</Script>");
            // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('请确保填写完整!');", true);
        }
    }
示例#4
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text != "" && txtRealName.Text != "" && txtQuestion.Text != "" && txtNewPwd.Text != "" && txtTelPhone.Text != "" && txtEmail.Text != "" && txtAnswer.Text != "" && txtStreet.Text != "" && txtAckPwd.Text != "")
        {
            string Password = txtAckPwd.Text;
            string roleId = "";

            //获取买家角色的ID
            PSysDSTableAdapters.aspnet_RolesTableAdapter roleDA = new PSysDSTableAdapters.aspnet_RolesTableAdapter();
            DataTable roleDT = roleDA.GetDataByRoleName("买家");
            if (roleDT.Rows.Count > 0)
            {
                roleId = roleDT.Rows[0][1].ToString();

            }

            //密码加密
            register_addpwd common = new register_addpwd();
            string salt = common.GenerateSalt();
            Password = common.EncodePassword(Password, 1, salt);
            string address = txtStreet.Text;

            PSysDSTableAdapters.QueriesTableAdapter registerDA = new PSysDSTableAdapters.QueriesTableAdapter();
            int result = registerDA.P_INSERT_USER_ROLES("/", txtUserName.Text, "", Password, salt, txtEmail.Text, txtQuestion.Text, txtAnswer.Text, 1, DateTime.UtcNow, DateTime.Now, 0, 1, roleId, txtRealName.Text, txtTelPhone.Text, address);

            if (result == -1)
            {
                Response.Write("<Script>alert('对不起!\\n用户名已存在!')</Script>");
               //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('对不起!\\n用户名已存在!');", true);
            }
            else
            {
                Response.Write("<Script>alert('恭喜您!注册成功!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!注册成功!');", true);
                //Response.Redirect("~/Public/Index.aspx");
            }
        }
        else
        {
            Response.Write("<Script>alert('请填写完整信息!')</Script>");
            //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('请填写完整信息!');", true);
        }
    }
示例#5
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        if (txtNPwd0.Text != "" && txtNPwd1.Text != "" && txtOPwd.Text != "")
        {
            register_addpwd common = new register_addpwd();
            string salt = common.GenerateSalt().ToString();
            string pwd = common.EncodePassword(txtNPwd1.Text, 1, salt);

            string connStr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand("aspnet_Membership_SetPassword", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@ApplicationName", Membership.ApplicationName));
            cmd.Parameters.Add(new SqlParameter("@UserName", Session["name"].ToString()));
            cmd.Parameters.Add(new SqlParameter("@NewPassword", pwd));
            cmd.Parameters.Add(new SqlParameter("@PasswordSalt", salt));
            cmd.Parameters.Add(new SqlParameter("@CurrentTimeUtc", DateTime.Now));
            cmd.Parameters.Add(new SqlParameter("@PasswordFormat", Membership.Provider.PasswordFormat.GetHashCode()));
            SqlParameter returnValue = new SqlParameter();
            returnValue.ParameterName = "returnValue";
            returnValue.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(returnValue);

            //=== 执行预存程序 ===
            cmd.ExecuteNonQuery();
            conn.Close();

            if (returnValue.Value.ToString() == "0")
            {
                Response.Write("<Script>alert('恭喜您!密码设置成功!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!密码设置成功!');", true);
            }
            else
                Response.Write("<Script>alert('密码设置失败,请重试!')</Script>");
               // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('密码设置失败,请重试!');", true);
        }
        else
        {
            Response.Write("<Script>alert('请确保填写完整!')</Script>");
           // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('请确保填写完整!');", true);
        }
    }
示例#6
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text != "" && txtRealName.Text != "" && txtQuestion.Text != "" && txtNewPwd.Text != "" && txtTelPhone.Text != "" && txtEmail.Text != "" && txtAnswer.Text != "" && txtStreet.Text != "" && txtAckPwd.Text != "")
        {
            string Password = txtAckPwd.Text;
            string roleId   = "";

            //获取买家角色的ID
            PSysDSTableAdapters.aspnet_RolesTableAdapter roleDA = new PSysDSTableAdapters.aspnet_RolesTableAdapter();
            DataTable roleDT = roleDA.GetDataByRoleName("买家");
            if (roleDT.Rows.Count > 0)
            {
                roleId = roleDT.Rows[0][1].ToString();
            }

            //密码加密
            register_addpwd common = new register_addpwd();
            string          salt   = common.GenerateSalt();
            Password = common.EncodePassword(Password, 1, salt);
            string address = txtStreet.Text;

            PSysDSTableAdapters.QueriesTableAdapter registerDA = new PSysDSTableAdapters.QueriesTableAdapter();
            int result = registerDA.P_INSERT_USER_ROLES("/", txtUserName.Text, "", Password, salt, txtEmail.Text, txtQuestion.Text, txtAnswer.Text, 1, DateTime.UtcNow, DateTime.Now, 0, 1, roleId, txtRealName.Text, txtTelPhone.Text, address);

            if (result == -1)
            {
                Response.Write("<Script>alert('对不起!\\n用户名已存在!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('对不起!\\n用户名已存在!');", true);
            }
            else
            {
                Response.Write("<Script>alert('恭喜您!注册成功!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('恭喜您!注册成功!');", true);
                //Response.Redirect("~/Public/Index.aspx");
            }
        }
        else
        {
            Response.Write("<Script>alert('请填写完整信息!')</Script>");
            //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('请填写完整信息!');", true);
        }
    }