Exemple #1
0
 public void Update(UserModel userModel)
 {
     var bizUser = GetBizModel(userModel);
     _bizUser.Update(bizUser);
 }
Exemple #2
0
 public UserModel GetEntityFromBiz(BizLayer.User bizUser)
 {
     UserModel user = null;
     if (bizUser != null)
     {
         user = new UserModel();
         user.Id = bizUser.Id;
         user.Name = bizUser.Name;
         user.Account = bizUser.Account;
         user.Password = bizUser.Password;
         user.Department = bizUser.Demartment;
         user.Status = bizUser.Enabled == 1;
         user.CreatedBy = bizUser.CreatedBy;
         user.CreatedDate = bizUser.CreatedDate;
         user.UpdatedBy = bizUser.UpdatedBy;
         user.UpdatedDate = bizUser.UpdatedDate;
     }
     return user;
 }
Exemple #3
0
 public void Create(UserModel userModel)
 {
     var bizUser = GetBizModel(userModel);
     _bizUser.Create(bizUser);
 }
Exemple #4
0
 public BizLayer.User GetBizModel(UserModel userModel)
 {
     BizLayer.User bizUser = null;
     if (userModel != null)
     {
         bizUser = new BizLayer.User();
         bizUser.Id = userModel.Id;
         bizUser.Name = userModel.Name;
         bizUser.Account = userModel.Account;
         bizUser.Password = userModel.Password;
         bizUser.Demartment = userModel.Department;
         bizUser.Enabled = userModel.Status ? 1 : 0;
         bizUser.CreatedBy = userModel.CreatedBy;
         bizUser.CreatedDate = userModel.CreatedDate;
         bizUser.UpdatedBy = userModel.UpdatedBy;
         bizUser.UpdatedDate = userModel.UpdatedDate;
     }
     return bizUser;
 }
Exemple #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var btnSave = sender as Button;
            var userModel = btnSave.Tag as UserModel;
            if (userModel != null)
            {
                //Update
                if (this.txtPwd.Text.Trim() != string.Empty)
                {
                    userModel.Password = CryptographyHelper.SHA256(this.txtPwd.Text);
                }
                userModel.Status = this.chkStatus.Checked;
                userModel.Name = this.txtName.Text.Trim();
                userModel.Department = this.cboDept.SelectedValue.ToString();
                userModel.UpdatedBy = UIContext.LoginUser.Account;
                userModel.UpdatedDate = DateTime.Now;
                _userModel.Update(userModel);

            }
            else
            {
                //Add
                userModel = new UserModel();
                userModel.Account = this.txtAccount.Text.Trim();
                userModel.Password = CryptographyHelper.SHA256(this.txtPwd.Text.Trim());
                userModel.Name = this.txtName.Text.Trim();
                userModel.Department = this.cboDept.SelectedValue.ToString();
                userModel.Status = this.chkStatus.Checked;
                userModel.CreatedBy = UIContext.LoginUser.Account;
                userModel.CreatedDate = DateTime.Now;
                userModel.UpdatedBy = UIContext.LoginUser.Account;
                userModel.UpdatedDate = DateTime.Now;
                _userModel.Create(userModel);

            }

            btnClear_Click(null, null);
            this.grdUser.DataSource = _userModel.GetAll();
        }