private void btn_Ok_Click(object sender, EventArgs e) { if(_viewType=="Add") { if(dxValidationProvider1.Validate()) { var userBll = new BLL.User(); _user=new User { Department = txt_Department.Text.Trim(), Name = txt_Name.Text.Trim(), Password = Common.DEncrypt.DESEncrypt.Encrypt(txt_Password.Text.Trim()), Phone = txt_Phone.Text.Trim(), Remark = txt_Remark.Text, Tel = txt_Remark.Text.Trim(), Type = commbox_UserRole.SelectedIndex, Username = txt_Username.Text.Trim() }; var userId = userBll.Add(_user); if(userId>0) { _user.Id = userId; XtraMessageBox.Show("添加成功!", "提示"); DialogResult = DialogResult.OK; } } else { XtraMessageBox.Show("添加失败!", "提示"); } } else if(_viewType=="Edit") { if (dxValidationProvider1.Validate()) { var userBll = new BLL.User(); _user.Department = txt_Department.Text.Trim(); if(txt_Password.Text.Trim()!="") { _user.Password = Common.DEncrypt.DESEncrypt.Encrypt(txt_Password.Text.Trim()); } _user.Phone = txt_Phone.Text.Trim(); _user.Remark = txt_Remark.Text; _user.Tel = txt_Remark.Text.Trim(); _user.Type = commbox_UserRole.SelectedIndex; _user.Username = txt_Username.Text.Trim(); if(userBll.Update(_user)) { XtraMessageBox.Show("编辑成功!", "提示"); DialogResult = DialogResult.OK; } else { XtraMessageBox.Show("编辑失败!", "提示"); } } } }
public MainForm(Workspace workspace,User user) { this.Visible = false; InitializeComponent(); _workspace = workspace; _user = user; }
public DlgUserInfo(User user,string viewType) { InitializeComponent(); _user = user; _viewType = viewType; InitForm(); }