duheng
2024-10-14 05d57af48f51d2ac8292bc3faaa01ca753763790
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
namespace HStation.WinFrmUI
{
    public partial class PumpPropViewCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public PumpPropViewCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView();
            this.gridView1.RegistCustomDrawRowIndicator();
        }
 
        private List<PropGroupChoiceViewModel> _allBindingList;
 
        public async void SetBindingData(string DbId)
        {
            if (!long.TryParse(DbId, out long pumpId))
            {
                return;
            }
            var pumpBll = new BLL.AssetsPumpMain();
            var pump = await pumpBll.GetByID(pumpId);
            var series = await new BLL.AssetsPumpSeries().GetByID(pump.PumpSeriesID);
            _allBindingList = new List<PropGroupChoiceViewModel>();
            var catlog = await new Yw.BLL.SysPropStruct().GetByCatalogID(series.CatalogID);
            if (catlog == null)
            {
                this.propGroupChoiceViewModelBindingSource.ResetBindings(false);
                return;
            }
            foreach (var item in catlog)
            {
                foreach (var prop in item.PropList)
                {
                    _allBindingList.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID });
                }
            }
            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)
            {
                _allBindingList.Find(x => x.ID == item.PropID).Value = item.PropValue;
            }
            this.propGroupChoiceViewModelBindingSource.DataSource = _allBindingList;
            this.propGroupChoiceViewModelBindingSource.ResetBindings(false);
        }
    }
}