ningshuxia
58 分钟以前 71c12ff40d58c3dbdde6867396dd99224e57fc32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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<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();
        }
        //取消
        private void simpleButtonQuXiao_Click(object sender, EventArgs e)
        {
            if (e == null)
            {
                return;
            }
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}