/// <summary> /// 保存数据 /// </summary> private void SaveData() { if (!ValidatorData()) { return; } if (this.OpType == "Add")//添加 { BLL.T_Users_BLL userBLL = new T_Users_BLL(); IList <MDL.T_Users> userList = userBLL.FindBylogin(txtLogin.Text); if (userList.Count <= 0) { MDL.T_Users userMDL = GetData(); userBLL.Add(userMDL); this.DialogResult = DialogResult.OK; } else { TXMessageBoxExtensions.Info("用户名已经存在!"); this.txtLogin.Focus(); return; } } else//编辑 { MDL.T_Users userMDL = GetData(); userMDL.userid = userid; BLL.T_Users_BLL userBLL = new T_Users_BLL(); userBLL.Update(userMDL); this.DialogResult = DialogResult.OK; } }
/// <summary> /// 给控件赋值 /// </summary> private void SetData() { BLL.T_Users_BLL userBLL = new T_Users_BLL(); MDL.T_Users users = userBLL.Find(this.userid); this.txtLogin.Text = users.login; this.txtpasswd.Text = HandlePwd.Decrypt(users.password); this.txtpasswd2.Text = HandlePwd.Decrypt(users.password); this.txtFullname.Text = users.fullname; this.txtTitle.Text = users.title; this.txtphone.Text = users.phone; this.cmbUnits.Text = users.units; this.cmbUnitsType.Text = users.unitstype; }