duheng
2024-11-17 a2a57963e160a319276c5c8499f16c9809056e4c
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
using HStation.Vmo;
 
namespace HStation.WinFrmUI
{
    public partial class PumpPropViewCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public PumpPropViewCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView();
            this.gridView1.RegistCustomDrawRowIndicator();
        }
 
        private List<PropGroupChoiceViewModel> _allBindingList;
 
        public static long _typeId;
 
        public static long _pumpId;
 
        public static Vmo.AssetsPumpMainVmo _assetsPumpMainVmo;
 
        public static Vmo.AssetsPumpMainVmo GetPumpMainVmo()
        {
            return _assetsPumpMainVmo;
        }
 
        public static long GetPumpTypeId()
        {
            return _typeId;
        }
 
        public async void SetBindingData(string DbId)
        {
            if (!long.TryParse(DbId, out long pumpId))
            {
                return;
            }
            _pumpId = pumpId;
            var pumpBll = new BLL.AssetsPumpMain();
            var pump = await pumpBll.GetByID(pumpId);
            _assetsPumpMainVmo = pump;
            var series = await new BLL.AssetsPumpSeries().GetByID(pump.SeriesID);
            _allBindingList = new List<PropGroupChoiceViewModel>();
            var catlog = await new Yw.BLL.SysPropStruct().GetByCatalogID(series.CatalogID);
            if (catlog == null || catlog.Count == 0)
            {
                this.propGroupChoiceViewModelBindingSource.ResetBindings(false);
                return;
            }
            _typeId = catlog.First().TypeID;
            _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = "铭牌参数", PropName = "流量", Value = pump.RatedFlow.ToString(), KeyWorldType = "Basic" });
            _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = "铭牌参数", PropName = "扬程", Value = pump.RatedHead.ToString(), KeyWorldType = "Basic" });
            _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = "铭牌参数", PropName = "功率", Value = pump.RatedPower.ToString(), KeyWorldType = "Basic" });
            _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = "铭牌参数", PropName = "转速", Value = pump.RatedSpeed.ToString(), KeyWorldType = "Basic" });
            foreach (var item in catlog)
            {
                foreach (var prop in item.PropList)
                {
                    _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID, KeyWorldType = "Prop" });
                }
            }
            var propbll = new BLL.PumpPartPropContent();
            var partList = await pumpBll.GetPartByID(pumpId);
            if (partList.Count <= 0)
                return;
            var alllist = await propbll.GetByPumpPartID(partList.First().ID);
            foreach (var item in alllist)
            {
                var selectProp = _allBindingList.Find(x => x.ID == item.PropID);
                if (selectProp != null)
                {
                    selectProp.Value = item.PropValue;
                }
            }
            this.propGroupChoiceViewModelBindingSource.DataSource = _allBindingList;
            this.propGroupChoiceViewModelBindingSource.ResetBindings(false);
        }
 
        public void RefreshData()
        {
            SetBindingData(_pumpId.ToString());
        }
    }
}