lixiaojun
2024-11-11 7446de6efb5d353c1fa6a92b01a0f56685a4ee06
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
57
58
59
60
61
62
63
64
65
66
67
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
{
    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();
        }
    }
}