Shuxia Ning
2024-11-09 d2f89d47afad3f3fe2f4266658b25f5baa101ea3
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/01-pump/SetSchemePumpListCtrl.cs
@@ -1,16 +1,29 @@
using Yw.Model;
using HStation.WinFrmUI.Xhs;
using Yw.Model;
namespace HStation.WinFrmUI
{
    public partial class SetSchemePumpListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList
    public partial class SetSchemePumpListCtrl : DevExpress.XtraEditors.XtraUserControl, ISetSchemeParterList
    {
        public SetSchemePumpListCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView(30);
            this.gridView1.RegistCustomDrawRowIndicator(40);
            this.gridView1.BorderStyle = BorderStyles.NoBorder;
            this.layoutControl1.SetupLayoutControl();
            this.gridView1.SetNormalView(30);
            this.gridView1.RegistCustomDrawRowIndicator(40);
            this.gridView1.BorderStyle = BorderStyles.NoBorder;
            this.generalSearchAndSelectCtrl1.SearchEvent += () =>
            {
                Search();
            };
            this.generalSearchAndSelectCtrl1.ClearEvent += () =>
            {
                Clear();
            };
            this.generalSearchAndSelectCtrl1.SelectEvent += () =>
            {
                TipFormHelper.Show(eTipStatus.Info, "批量选择待更新");
            };
        }
        /// <summary>
@@ -21,6 +34,10 @@
        /// 水力改变事件
        /// </summary>
        public event Action<List<HydroParterInfo>> HydroChangedEvent;
        /// <summary>
        /// 水力记录改变事件
        /// </summary>
        event Action<SetSchemeParterRecord> HydroRecordChangedEvent;
        /// <summary>
        /// 显示查询面板
@@ -42,16 +59,23 @@
            get { return _allList != null && _allList.Count > 0; }
        }
        //水力信息
        private Yw.Model.HydroModelInfo _hydroInfo = null;
        //水力信息(备份)
        private Yw.Model.HydroModelInfo _hydroInfo_bak = null;
        //所有列表
        private List<HydroPumpViewModel> _allList = null;
        //所有绑定列表
        private List<HydroPumpViewModel> _allBindingList = null;
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
        {
            _hydroInfo = hydroInfo;
            _allList = new List<HydroPumpViewModel>();
            if (hydroInfo != null && hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
            {
@@ -203,142 +227,36 @@
            Search();
        }
        //设置
        private void Set()
        //选择
        private void SelectChange()
        {
            if (_hydroInfo == null)
            {
                XtraMessageBox.Show("无水力信息");
                return;
            }
            Search();
            if (_allBindingList == null || _allBindingList.Count < 1)
            var row = this.gridView1.GetFocusedRow() as HydroPumpViewModel;
            if (row == null)
            {
                XtraMessageBox.Show("无可设置水泵数据");
                return;
            }
            var dlg = new SetHydroPumpDlg();
            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
            dlg.ReloadDataEvent += (list) =>
            var input = AssetsMatchingParasHelper.Create(_hydroInfo, row.Vmo, null);
            var dlg = new PumpMatchingDlg();
            dlg.SetBindingData(input);
            dlg.ReloadDataEvent += (output) =>
            {
                _allBindingList.ForEach(x =>
                var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, output);
                if (bol)
                {
                    x.UpdateProperty();
                });
                this.hydroPumpViewModelBindingSource.ResetBindings(false);
                var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList();
                this.HydroChangedEvent?.Invoke(allParterList);
                    UpdateProperty();
                }
            };
            dlg.ShowDialog();
        }
        /// <summary>
        /// 设置简单显示模式
        /// </summary>
        public void SetSimpleView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colCode.Visible = true;
            this.colName.Visible = true;
            this.colModelType.Visible = true;
            this.colLinkStatus.Visible = true;
            this.colCurrentHz.Visible = true;
            this.colRatedQ.Visible = false;
            this.colRatedH.Visible = false;
            this.colRatedP.Visible = false;
            this.colRatedN.Visible = false;
            this.colRatedHz.Visible = false;
            this.colCurve.Visible = false;
            this.colCalcuQ.Visible = false;
            this.colCalcuH.Visible = false;
            this.colCalcuP.Visible = false;
            this.colCalcuE.Visible = false;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = false;
        }
        /// <summary>
        /// 设置正常显示模式
        /// </summary>
        public void SetNormalView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colCode.Visible = true;
            this.colName.Visible = true;
            this.colModelType.Visible = true;
            this.colLinkStatus.Visible = true;
            this.colCurrentHz.Visible = true;
            this.colRatedQ.Visible = true;
            this.colRatedH.Visible = true;
            this.colRatedP.Visible = true;
            this.colRatedN.Visible = true;
            this.colRatedHz.Visible = true;
            this.colCurve.Visible = true;
            this.colCalcuQ.Visible = false;
            this.colCalcuH.Visible = false;
            this.colCalcuP.Visible = false;
            this.colCalcuE.Visible = false;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = true;
        }
        /// <summary>
        /// 设置计算显示模式
        /// </summary>
        public void SetCalcuView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colCode.Visible = true;
            this.colName.Visible = true;
            this.colModelType.Visible = true;
            this.colLinkStatus.Visible = true;
            this.colCurrentHz.Visible = true;
            this.colRatedQ.Visible = true;
            this.colRatedH.Visible = true;
            this.colRatedP.Visible = true;
            this.colRatedN.Visible = true;
            this.colRatedHz.Visible = true;
            this.colCurve.Visible = true;
            this.colCalcuQ.Visible = true;
            this.colCalcuH.Visible = true;
            this.colCalcuP.Visible = true;
            this.colCalcuE.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = true;
        }
        /// <summary>
        /// 设置批量设置模式
        /// </summary>
        public void SetBulkSetView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            this.colDbLocked.Visible = true;
            this.colCode.Visible = true;
            this.colName.Visible = true;
            this.colModelType.Visible = true;
            this.colLinkStatus.Visible = true;
            this.colCurrentHz.Visible = true;
            this.colRatedQ.Visible = true;
            this.colRatedH.Visible = true;
            this.colRatedP.Visible = true;
            this.colRatedN.Visible = true;
            this.colRatedHz.Visible = true;
            this.colCurve.Visible = true;
            this.colCalcuQ.Visible = false;
            this.colCalcuH.Visible = false;
            this.colCalcuP.Visible = false;
            this.colCalcuE.Visible = false;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = true;
        }
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
@@ -348,15 +266,26 @@
                return;
            }
            if (e.Column == this.colSet)
            if (e.Column == this.colSelect)
            {
                var dlg = new SetHydroPumpDlg();
                dlg.SetBindingData(row.Vmo);
                dlg.ReloadDataEvent += (list) =>
                var input = AssetsMatchingParasHelper.Create(_hydroInfo, row.Vmo, null);
                var dlg = new PumpMatchingDlg();
                dlg.SetBindingData(input);
                dlg.ReloadDataEvent += (output) =>
                {
                    row.UpdateProperty();
                    this.gridView1.RefreshRow(e.RowHandle);
                    this.HydroChangedEvent?.Invoke(new List<Yw.Model.HydroParterInfo>() { row.Vmo });
                    var record = new SetSchemeParterRecord();
                 /*   record.AfterDbId = row.Vmo.DbId;
                    record.BeforeCurveId*/
                    var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, output);
                    if (bol)
                    {
                        row.UpdateProperty();
                        this.gridView1.RefreshRow(e.RowHandle);
                        this.HydroChangedEvent?.Invoke(new List<Yw.Model.HydroParterInfo>() { row.Vmo });
                        this.HydroRecordChangedEvent?.Invoke();
                    }
                };
                dlg.ShowDialog();
            }
@@ -366,54 +295,8 @@
            }
        }
        #region BtnClick
        private void buttonEditSearch_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            var obj = e.Button.Tag;
            if (obj is string tag)
            {
                BtnClick(tag);
            }
        }
        private void buttonEditSet_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            var obj = e.Button.Tag;
            if (obj is string tag)
            {
                BtnClick(tag);
            }
        }
        private void BtnClick(string tag)
        {
            switch (tag)
            {
                case "Search":
                    {
                        Search();
                    }
                    break;
                case "Clear":
                    {
                        Clear();
                    }
                    break;
                case "Set":
                    {
                        Set();
                    }
                    break;
                default:
                    {
                    }
                    break;
            }
        }
        #endregion
    }
}