duheng
2024-06-20 1d35b151e33d8919d578e3db321067b881eac1d5
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
using HStation.Dto;
using HStation.WinFrmUI.Xhs.Project;
using ISupply.WinFrmUI;
 
namespace HStation.WinFrmUI
{
    public partial class XhsProjectListPage : DocumentPage
    {
        public XhsProjectListPage()
        {
            InitializeComponent();
            this.PageTitle.Caption = "项目管理";
        }
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public override void InitialDataSource()
        {
            SetBindingData();
        }
 
        private new BLL.XhsProject _bll = new BLL.XhsProject();
 
        private List<ProjectViewModel> _allBindingList = new List<ProjectViewModel>();
 
        private async void SetBindingData()
        {
            var alllist = await _bll.GetAll();
            if (alllist != null)
            {
                foreach (var item in alllist)
                {
                    _allBindingList.Add(new ProjectViewModel(item));
                }
            }
            this.projectViewModelBindingSource.DataSource = _allBindingList;
            this.projectViewModelBindingSource.ResetBindings(false);
        }
 
        //添加
        private async void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new AddProjectDlg();
            dlg.ReloadEvent += async (rhs) =>
            {
                var id = await _bll.Insert(rhs);
                if (id > 0)
                {
                    var vmmodel = await _bll.GetByID(id);
                    _allBindingList.Add(new ProjectViewModel(vmmodel));
                    this.projectViewModelBindingSource.ResetBindings(false);
                    return true;
                }
                return false;
            };
            dlg.ShowDialog();
        }
 
        //修改
        private void BtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //var dlg=new EditProjectDlg();
        }
    }
}