private void btnSave_Click(object sender, EventArgs e)
        {
            if (formValid.IsValid)
            {
                DASP.Domain.Entitys.TBUserEntity curUser = Global.UserInfoInstance.CurrentLoginUser;
                string oldPwd = EncryptUtils.EncryptFromInputString(txtProtoPwd.Text.Trim());
                if (!curUser.UserPassword.Equals(oldPwd))
                {
                    ZMessageBox.Show(this, "旧密码输入错误!", "提示", ZMessageBoxIcon.Information,
                                     ZMessageBoxButtons.OK);
                    this.DialogResult = DialogResult.None;
                    return;
                }

                curUser.UserPassword = EncryptUtils.EncryptFromInputString(txtNewPwd.Text.Trim());

                try
                {
                    userManager.Update(curUser);
                    ZMessageBox.Show(this, "修改密码成功!", "提示", ZMessageBoxIcon.Information,
                                     ZMessageBoxButtons.OK);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (formValid.IsValid)
            {
                try
                {
                    DASP.Domain.Entitys.TBUserEntity entity = null;
                    bool isUpdate = false;
                    if (this.userEntity != null)
                    {
                        entity   = this.userEntity;
                        isUpdate = true;
                    }
                    else
                    {
                        entity            = new DASP.Domain.Entitys.TBUserEntity();
                        entity.UserId     = Guid.NewGuid();
                        entity.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        isUpdate          = false;
                    }

                    string userName   = txtUserName.Text.Trim();
                    string loginName  = txtLoginName.Text.Trim();
                    string loginPwd   = EncryptUtils.EncryptFromInputString(txtLoginPwd.Text.Trim());
                    string userRemark = txtAreaRemark.Text.Trim();


                    entity.UserName     = userName;
                    entity.LoginName    = loginName;
                    entity.UserPassword = loginPwd;
                    entity.UserRemark   = userRemark;
                    entity.UserEmail    = txtEmail.Text.Trim();
                    entity.UserAddress  = txtAddress.Text.Trim();
                    entity.UserTel      = txtTel.Text.Trim();
                    entity.UpdateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    IList <DASP.Domain.Entitys.TBRoleEntity> roleList = roleManager.GetAll();

                    if (rdBtnAdmin.Checked)
                    {
                        var role = roleList.Where(it => it.RoleCode.Equals("0001")).FirstOrDefault();
                        entity.Role = role;
                    }
                    else
                    {
                        var role = roleList.Where(it => it.RoleCode.Equals("0002")).FirstOrDefault();
                        entity.Role = role;
                    }
                    if (isUpdate)
                    {
                        userManager.Update(entity);
                    }
                    else
                    {
                        userManager.Save(entity);
                    }

                    this.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }