lixiaojun
2024-09-26 158292021eb0b31e494b5fdc26a31c58af0bf01b
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
namespace HStation.WinFrmUI.Xhs
{
    public partial class AssetsMainChoicePage : DevExpress.XtraEditors.XtraUserControl
    {
        public AssetsMainChoicePage()
        {
            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)
        {
            FormRowClickEvent.Invoke(code);
        }
 
        public event Action<string> FormRowClickEvent = null;
 
        public event Func<AssetsAutoMatchingViewModel, bool> RelaodEvent = null;
 
        private BLL.PumpMain _pumpMain = null;
 
        private BLL.AdaptingManage _adaptingManage = null;
 
        private BLL.PipeLineManage _pipeLineManage = null;
 
        private BLL.ValveMain _valveMain = null;
 
        private AssetsAutoMatchingViewModel _assetsAutoMatching = null;
 
        public async void SetBindingData(AssetsAutoMatchingViewModel inputViewModel)
        {
            _assetsAutoMatching = inputViewModel;
            this.elbowsMatchingCtrl1.SetBindingData(inputViewModel.ElbowsMatchingModels);
            this.pipeLineMatchingCtrl1.SetBindingData(inputViewModel.PipeLineMatchingModels);
            this.pumpMatchingCtrl1.SetBindingData(inputViewModel.PumpMatchingModels);
            this.threeLinkMatchingCtrl1.SetBindingData(inputViewModel.ThreeLinkMatchingModels);
            this.fourLinkMatchingCtrl1.SetBindingData(inputViewModel.FourLinkMatchingModels);
            this.valveMatchingCtrl1.SetBindingData(inputViewModel.ValveMatchingModels);
            await SetMatching(inputViewModel);
        }
 
        /// <summary>
        /// 自动匹配
        /// </summary>
        public async Task<AssetsAutoMatchingViewModel> SetMatching(AssetsAutoMatchingViewModel input)
        {
            if (input == null)
                return null;
            _pumpMain = new BLL.PumpMain();
            _adaptingManage = new BLL.AdaptingManage();
            _pipeLineManage = new BLL.PipeLineManage();
            _valveMain = new BLL.ValveMain();
            var allPump = await _pumpMain.GetAll();
            var allAdapting = await _adaptingManage.GetAll();
            var allPipeLine = await _pipeLineManage.GetAll();
            var allValve = await _valveMain.GetAll();
            var assetsAutoMatching = new AssetsAutoMatchingViewModel();
            //泵匹配
            var pumpMatching = await this.pumpMatchingCtrl1.SetMatching(input.PumpMatchingModels, allPump);
            //三通匹配
            var threeLinkMatching = this.threeLinkMatchingCtrl1.SetMatching(input.ThreeLinkMatchingModels, allAdapting);
            //四通匹配
            var fourLinkMatching = this.fourLinkMatchingCtrl1.SetMatching(input.FourLinkMatchingModels, allAdapting);
            //管道匹配
            var pipeLineMatching = this.pipeLineMatchingCtrl1.SetMatching(input.PipeLineMatchingModels, allPipeLine);
            //阀门匹配
            var valveMatching = this.valveMatchingCtrl1.SetMatching(input.ValveMatchingModels, allValve);
            //弯头匹配
            var elbowsMatching = this.elbowsMatchingCtrl1.SetMatching(input.ElbowsMatchingModels, allAdapting);
 
            assetsAutoMatching.PumpMatchingModels = pumpMatching;
            assetsAutoMatching.ThreeLinkMatchingModels = threeLinkMatching;
            assetsAutoMatching.FourLinkMatchingModels = fourLinkMatching;
            assetsAutoMatching.ElbowsMatchingModels = elbowsMatching;
            assetsAutoMatching.PipeLineMatchingModels = pipeLineMatching;
            assetsAutoMatching.ValveMatchingModels = valveMatching;
            return assetsAutoMatching;
        }
 
        //确定
        private void btnComplete_Click(object sender, EventArgs e)
        {
            if (RelaodEvent.Invoke(_assetsAutoMatching))
            {
                TipFormHelper.ShowSucceed("修改成功!");
            }
            else
            {
                TipFormHelper.ShowError("修改失败!");
            }
        }
    }
}