예제 #1
0
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(this.textUserName.Text) || string.IsNullOrWhiteSpace(this.comMode.Text) || string.IsNullOrWhiteSpace(this.textPassword.Text))
     {
         XtraMessageBox.Show("请填写完整信息!");
     }
     else
     {
         //更新
         if (userVo != null)
         {
             userVo.Name   = this.textUserName.Text;
             userVo.Role   = this.comMode.Text;
             userVo.Psword = this.textPassword.Text;
             UpdateDao.UpdateByID(userVo);
             XtraMessageBox.Show("保存成功!");
             this.DialogResult = DialogResult.OK;
             return;
         }
         //新增
         UserRoleVo vo = new UserRoleVo()
         {
             Name      = this.textUserName.Text,
             Role      = this.comMode.Text,
             Psword    = this.textPassword.Text,
             CompanyId = SystemConst.companyId
         };
         if (SelectDao.IsUserExist(vo.Name))
         {
             XtraMessageBox.Show("该用户已经存在!");
             return;
         }
         if (InsertDao.InsertData(vo, typeof(UserRoleVo)) > 0)
         {
             XtraMessageBox.Show("保存成功!");
             this.DialogResult = DialogResult.OK;
             return;
         }
     }
 }