yangyin
2024-08-12 2bc7800e9f02fed6652f6b0defe1d978f186e914
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
using DevExpress.CodeParser;
using DevExpress.XtraEditors.TextEditController.Win32;
using DevExpress.XtraGrid;
using HStation.Vmo;
using HStation.WinFrmUI.Organize.Core._00_UserControl;
using HStation.WinFrmUI.Organize.Core._02_Employee;
using Mapster;
using Yw.WinFrmUI;
using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
 
namespace HStation.WinFrmUI.Organize
{
    public partial class EmployeeMgrMainPanel : DocumentPage
    {
        public EmployeeMgrMainPanel()
        {
            InitializeComponent();
            DateShow();
            //ShowEmloyee();
        }
 
        List<HStation.Vmo.EmployeeMain> _AllEmployee = new List<HStation.Vmo.EmployeeMain>();
 
        private async void DateShow()
        {
            HStation.BLL.EmployeeMain _service = new();
            _AllEmployee.Clear();
            var _All = await _service.GetAll();
            foreach (HStation.Vmo.EmployeeMain emp in _All)
            {
                _AllEmployee.Add(emp);
            }
            employeeViewModelBindingSource.DataSource = _AllEmployee;
            this.employeeViewModelBindingSource.ResetBindings(false);
        }
 
 
 
        //添加
        private void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new AddEmployeeDlg(); 
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DateShow();
            this.employeeViewModelBindingSource.ResetBindings(false);
        }
 
        //编辑
        private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new UpdateEmployeeDlg();
            var currentVm = this.gridView1.GetCurrentViewModel(_AllEmployee);
            if (currentVm == null)
            {
                MessageBoxHelper.ShowWarning("请选择数据行");
                return;
            }
            dlg.IncomingData(currentVm);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                DateShow();
                this.employeeViewModelBindingSource.ResetBindings(false);
            }
 
        }
 
        ////删除
        //private async void BtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        //{
        //    var bll = new BLL.EmployeeMain();
        //    var currentVm = this.gridView1.GetCurrentViewModel(_AllEmployee);
        //    if (currentVm == null)
        //    {
        //        MessageBox.Show("请选择数据行!");
        //    }
        //    else
        //    {
 
        //        if (MessageBox.Show("确认删除员工" + currentVm.ID + "吗?", "删除", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
        //        {
        //            return;
        //        }
        //        if (await bll.DeleteByID(currentVm.ID))
        //        {
        //            _AllEmployee.Remove(currentVm);
        //            this.employeeViewModelBindingSource.ResetBindings(false);
        //            MessageBox.Show("删除成功!");
        //        }
        //    }
        //}
    }
}