lixiaojun
2024-12-30 c22cc4c60e9ff156fc25b39a5c024cc758df354b
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
107
108
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationMatchingListCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectSimulationMatchingListCtrl()
        {
            InitializeComponent();
            this.elbowsMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.fourLinkMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.pipeLineMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.pumpMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.threeLinkMatchingCtrl1.RowClickEvent += RowClickEvent;
            this.valveMatchingCtrl1.RowClickEvent += RowClickEvent;
        }
 
        private void RowClickEvent(string code)
        {
            HydroClickEvent.Invoke(code);
        }
 
        public event Action<string> HydroClickEvent;
 
        public event Func<AssetsMatchingViewModel, bool> ApplyMatchingEvent;
 
        private BLL.AssetsPumpMain _AssetsPumpMain = null;
 
        private BLL.AdaptingManage _adaptingManage = null;
 
        private BLL.AssetsPipeMain _pipeLineManage = null;
 
        private BLL.AssetsValveMain _AssetsValveMain = null;
 
        private AssetsMatchingViewModel _assetsAutoMatching = null;
 
        public async void SetBindingData(AssetsMatchingViewModel inputViewModel)
        {
            _assetsAutoMatching = inputViewModel;
            this.elbowsMatchingCtrl1.SetBindingData(inputViewModel.ElbowMatchingList);
            this.pipeLineMatchingCtrl1.SetBindingData(inputViewModel.PipeMatchingList);
            this.pumpMatchingCtrl1.SetBindingData(inputViewModel.PumpMatchingList);
            this.threeLinkMatchingCtrl1.SetBindingData(inputViewModel.ThreelinkMatchingList);
            if (inputViewModel.FourlinkMatchingList == null || inputViewModel.FourlinkMatchingList.Count == 0)
            {
                tabNavigationPageFourlink.PageVisible = false;
            }
            else
            {
                this.fourLinkMatchingCtrl1.SetBindingData(inputViewModel.FourlinkMatchingList);
            }
            this.valveMatchingCtrl1.SetBindingData(inputViewModel.ValveMatchingList);
            await SetMatching(inputViewModel);
        }
 
        /// <summary>
        /// 自动匹配
        /// </summary>
        public async Task<AssetsMatchingViewModel> SetMatching(AssetsMatchingViewModel input)
        {
            if (input == null)
                return null;
            _AssetsPumpMain = new BLL.AssetsPumpMain();
            _adaptingManage = new BLL.AdaptingManage();
            _pipeLineManage = new BLL.AssetsPipeMain();
            _AssetsValveMain = new BLL.AssetsValveMain();
            var allPump = await _AssetsPumpMain.GetAll();
            var allAdapting = await _adaptingManage.GetAll();
            var allPipeLine = await _pipeLineManage.GetAll();
            var allValve = await _AssetsValveMain.GetAll();
            var allElbow = await new BLL.AssetsElbowMain().GetAll();
            var allThreeLink = await new BLL.AssetsThreelinkMain().GetAll();
            var allFourLink = await new BLL.AssetsFourlinkMain().GetAll();
            var assetsAutoMatching = new AssetsMatchingViewModel();
            //泵匹配
            var pumpMatching = await this.pumpMatchingCtrl1.SetMatching(input.PumpMatchingList, allPump);
            //三通匹配
            var threeLinkMatching = this.threeLinkMatchingCtrl1.SetMatching(input.ThreelinkMatchingList, allThreeLink);
            //四通匹配
            var fourLinkMatching = this.fourLinkMatchingCtrl1.SetMatching(input.FourlinkMatchingList, allFourLink);
            //管道匹配
            var pipeLineMatching = this.pipeLineMatchingCtrl1.SetMatching(input.PipeMatchingList, allPipeLine);
            //阀门匹配
            var valveMatching = this.valveMatchingCtrl1.SetMatching(input.ValveMatchingList, allValve);
            //弯头匹配
            var elbowsMatching = this.elbowsMatchingCtrl1.SetMatching(input.ElbowMatchingList, allElbow);
 
            assetsAutoMatching.PumpMatchingList = pumpMatching;
            assetsAutoMatching.ThreelinkMatchingList = threeLinkMatching;
            assetsAutoMatching.FourlinkMatchingList = fourLinkMatching;
            assetsAutoMatching.ElbowMatchingList = elbowsMatching;
            assetsAutoMatching.PipeMatchingList = pipeLineMatching;
            assetsAutoMatching.ValveMatchingList = valveMatching;
            return assetsAutoMatching;
        }
 
        //确定
        private void btnComplete_Click(object sender, EventArgs e)
        {
            if (ApplyMatchingEvent.Invoke(_assetsAutoMatching))
            {
                TipFormHelper.ShowSucceed("修改成功!");
            }
            else
            {
                TipFormHelper.ShowError("修改失败!");
            }
        }
    }
}