namespace HStation.WinFrmUI.Auth { public partial class AddRoleDlg : DevExpress.XtraEditors.XtraForm { public AddRoleDlg() { InitializeComponent(); } Yw.BLL.Role _service = new Yw.BLL.Role(); //确定 private async void simpleButtonQueDing_Click(object sender, EventArgs e) { if (e == null) { return; } string error; Yw.Vmo.Role role = new Yw.Vmo.Role(); role = roleFrom.OperateData(out error, role); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error); return; } List AllRole = await _service.GetAll(); foreach (Yw.Vmo.Role emp in AllRole) { if (emp.Code == role.Code) { MessageBox.Show("编号重复!"); return; } } var id = await _service.Insert(role); if (id == 0) { MessageBox.Show("添加失败!可能数据库连接失败!"); return; } this.DialogResult = DialogResult.OK; MessageBox.Show("添加成功!"); this.Close(); } //取消 private void simpleButtonQuXiao_Click(object sender, EventArgs e) { if (e == null) { return; } this.DialogResult = DialogResult.Cancel; this.Close(); } } }