duheng
2024-08-23 14cccf079662c052b2e04d30b9d9082ada1272ff
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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.Organize.Core._02_Employee
{
    public partial class AddEmployeeDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddEmployeeDlg()
        {
            InitializeComponent();
        }
        //确定
        private async void simpleButtonOK_Click(object sender, EventArgs e)
        {
            var bll = new BLL.EmployeeMain();
            string error;
 
            HStation.Vmo.EmployeeMain employee =new Vmo.EmployeeMain(); 
            employee = emloyeeInfoCtrl.SetBindingData(employee, out error);
            //var a = employee.AddTime;
            //var b =employee.LastModifyTime;
            if (!string.IsNullOrEmpty(error))
            {
                MessageBox.Show(error);
                return;
            }
            var employeeDate = await bll.GetByErpCode(employee.ErpCode) ;
            if (employeeDate != null && !String.IsNullOrEmpty(employee.ErpCode))
            {
                MessageBox.Show("编号重复,请重新输入!");
                return;
            }
            var ids = await bll.InsertEx(employee);
            //var a =employee.FirstName;
            if (ids == null)
            {
                MessageBox.Show("添加失败!可能数据库连接失败!");
                return;
            }
            this.DialogResult = DialogResult.OK;
            MessageBox.Show("添加成功!");
            this.Close();
        }
        //取消
        private void simpleButtonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
 
 
        //private void AddEmployeeDlg_Load(object sender, EventArgs e)
        //{
        //    emloyeeInfoCtrl.SetBindingData(null);
        //}
 
 
 
 
        //private async void QueDingsimpleButton_Click(object sender, EventArgs e)
        //{
        //    string error;
        //    var employe = emloyeeInfoCtrl.GetBindingData(out error);
        //    if (employe == null)
        //    {
        //        MessageBox.Show(error);
        //        return;
        //    }
        //   
 
        //    var bll = new BLL.EmployeeMain();
        //    EmployeeMain employeeDate = await bll.GetByErpCode(emloyeeInfoCtrl.GetBindingData(out error).ErpCode);
        //    if (employeeDate != null && String.IsNullOrEmpty(emloyeeInfoCtrl.GetBindingData(out error).ErpCode))
        //    {
        //        MessageBox.Show("编号重复,请重新输入!");
        //        return;
        //    }
 
        //    var ids = await bll.InsertEx(employe);
        //    if (ids == null)
        //    {
        //        MessageBox.Show("添加失败!可能数据库连接失败");
        //        return;
        //    }
 
        //    MessageBox.Show("添加成功!");
        //    this.DialogResult = DialogResult.OK;
        //    this.Close();
        //}
 
        //private void QuXiaosimpleButton_Click(object sender, EventArgs e)
        //{
        //    this.DialogResult = DialogResult.Cancel;
        //    this.Close();
        //}
 
    }
}