Exemple #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Model.T_SysUser model = new Model.T_SysUser();

        model.UserAccount = this.txtUserAccount.Text;
        model.Pwd = this.txtPwd.Text;
        model.DisplayName = this.txtDisplayName.Text;
        model.Sex = this.ddSex.SelectedValue =="1";

        Model.ResultModel rm;

        if (ID == null)
        {
            rm = BLL.SysUser.bll.Add(model);
        }
        else
        {
            model.Id = (int)ID;
            rm = BLL.SysUser.bll.Update(model);
        }

        if (rm.Result)
        {
            WebHelper.ResponseScript(this, string.Format("alert('{0}');parent.Close();parent.Refrash();", rm.Message));
        }
        else
        {
            WebHelper.ResponseScript(this, string.Format("alert('{0}');", rm.Message));
        }
    }
    /// <summary>
    /// 更改密码
    /// </summary>
    private void ChangePwd()
    {
        string oldPwd = this.txtOldPwd.Text;
        Model.T_SysUser user = BLL.Login.bll.GetUser();
        if (!string.Equals(user.Pwd, oldPwd))
        {
            WebHelper.ResponseScript(this, string.Format("alert('{0}');", "与原有密码不匹配"));
            return;
        }

        string newPwd1 = this.txtNewPwd1.Text;
        string newPwd2 = this.txtNewPwd2.Text;
        if (!string.Equals(newPwd1, newPwd2))
        {
            WebHelper.ResponseScript(this, string.Format("alert('{0}');", "两次新密码不匹配"));
            return;
        }
        Model.T_SysUser u = new Model.T_SysUser();
        u.Id = user.Id;
        u.UserAccount = user.UserAccount;
        u.Pwd = this.txtNewPwd1.Text;
        Model.ResultModel rm = BLL.SysUser.bll.UpdatePwd(u);
        BLL.Login.bll.LoginUser(u);
        WebHelper.ResponseScript(this, string.Format("alert('{0}');", rm.Message));
    }