| | |
| | | using DevExpress.XtraEditors; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace HStation.WinFrmUI.Auth.Core._01_Role |
| | | namespace HStation.WinFrmUI.Auth |
| | | { |
| | | public partial class AddRoleDlg : DevExpress.XtraEditors.XtraForm |
| | | { |
| | |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | Yw.BLL.Role _service = new Yw.BLL.Role(); |
| | | //确定 |
| | | private void simpleButtonQueDing_Click(object sender, EventArgs e) |
| | | 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<Yw.Vmo.Role> 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(); |
| | | } |
| | | //取消 |
| | |
| | | { |
| | | return; |
| | | } |
| | | this.DialogResult = DialogResult.Cancel; |
| | | this.Close(); |
| | | } |
| | | } |