lixiaojun
2024-11-05 e6880d3fcc4b83c5c53166d1404e24b7513b7f9a
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/SetHydroNozzleDlg.cs
@@ -1,6 +1,4 @@
using DevExpress.XtraSpreadsheet.Model;
namespace Yw.WinFrmUI
namespace Yw.WinFrmUI
{
    public partial class SetHydroNozzleDlg : DevExpress.XtraEditors.XtraForm
    {
@@ -8,26 +6,39 @@
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
        }
        /// <summary>
        /// 返回数据事件
        /// </summary>
        public event Action<List<Yw.Model.HydroNozzleInfo>> ReloadDataEvent;
        private List<Yw.Model.HydroNozzleInfo> _allNozzleList = null;
        //所有构件列表
        private List<Yw.Model.HydroNozzleInfo> _allParterList = null;
        /// <summary>
        ///
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroNozzleInfo parter)
        {
            var allParterList = parter == null ? null : new List<Yw.Model.HydroNozzleInfo>() { parter };
            SetBindingData(allParterList);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroNozzleInfo> allNozzleList)
        {
            _allNozzleList = allNozzleList;
            if (_allNozzleList != null && _allNozzleList.Count == 1)
            _allParterList = allNozzleList;
            if (_allParterList != null && _allParterList.Count == 1)
            {
                var hydrant = _allNozzleList.First();
                this.txtElev.EditValue = hydrant.Elev;
                this.txtMinorLoss.EditValue = hydrant.MinorLoss;
                this.txtDemand.EditValue = hydrant.Demand;
                this.txtCoefficient.EditValue = hydrant.Coefficient;
                var parter = _allParterList.First();
                this.txtElev.EditValue = Math.Round(parter.Elev, 4);
                this.txtMinorLoss.EditValue = parter.MinorLoss;
                this.txtCoefficient.EditValue = parter.Coefficient;
                this.txtDemand.EditValue = parter.Demand;
            }
        }
@@ -51,7 +62,7 @@
        //
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (_allNozzleList == null || _allNozzleList.Count < 1)
            if (_allParterList == null || _allParterList.Count < 1)
            {
                return;
            }
@@ -63,14 +74,14 @@
            double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
            double? demand = this.txtDemand.EditValue == null ? null : double.Parse(this.txtDemand.EditValue.ToString());
            var coefficient = double.Parse(this.txtCoefficient.EditValue.ToString());
            _allNozzleList.ForEach(x =>
            _allParterList.ForEach(x =>
            {
                x.Elev = elev;
                x.MinorLoss = minorLoss;
                x.Demand = demand;
                x.Coefficient = coefficient;
            });
            this.ReloadDataEvent?.Invoke(_allNozzleList);
            this.ReloadDataEvent?.Invoke(_allParterList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }