lixiaojun
5 天以前 3c8e996db701f2744af261e876455754ad182b62
WinFrmUI/HStation.WinFrmUI.Auth.Core/01-Role/AddRoleDlg.cs
@@ -1,15 +1,4 @@
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
    {
@@ -17,13 +6,40 @@
        {
            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();
        }
        //取消
@@ -33,6 +49,7 @@
            {
                return;
            }
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }