lixiaojun
2025-01-22 ed1c76d4405f10adc4b4e000845c50ffcf37429c
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/06-elbow/SetHydroElbowDlg.cs
@@ -15,25 +15,37 @@
        /// </summary>
        public event Action<List<Yw.Model.HydroElbowInfo>> ReloadDataEvent;
        //所有构件列表
        private List<Yw.Model.HydroElbowInfo> _allVisualList = null;
        private List<Yw.Model.HydroElbowInfo> _allVisualList = null; //所有构件列表
        private HydroChangeHelper _changeHelper = null;//改变辅助类
        private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroElbowInfo visual)
        public void SetBindingData
            (
                Yw.Model.HydroElbowInfo visual,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var allVisualList = visual == null ? null : new List<Yw.Model.HydroElbowInfo>() { visual };
            SetBindingData(allVisualList);
            SetBindingData(allVisualList, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroElbowInfo> allVisualList)
        public void SetBindingData
            (
                List<Yw.Model.HydroElbowInfo> allVisualList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allVisualList = allVisualList;
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (_allVisualList != null && _allVisualList.Count == 1)
            {
                var visual = _allVisualList.First();
@@ -41,21 +53,9 @@
                this.txtCaliber.EditValue = visual.Caliber;
                this.txtBendingAngle.EditValue = visual.BendingAngle;
                this.txtElbowType.EditValue = visual.ElbowType;
                this.txtElev.EditValue = visual.Elev;
                this.txtElev.EditValue = Math.Round(visual.Elev, 4);
                this.txtMinorLoss.EditValue = visual.MinorLoss;
            }
        }
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (this.txtElev.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtElev, "必填项");
                return false;
            }
            return true;
        }
        //确定
@@ -65,24 +65,68 @@
            {
                return;
            }
            if (!Valid())
            {
                return;
            }
            var elev = double.Parse(this.txtElev.EditValue.ToString());
            double? elev = this.txtElev.EditValue == null ? null : double.Parse(this.txtElev.EditValue.ToString());
            double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
            var material = this.txtMaterial.Text.Trim();
            double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
            double? blendingAngle = this.txtBendingAngle.EditValue == null ? null : double.Parse(this.txtBendingAngle.EditValue.ToString());
            int? blendingAngle = this.txtBendingAngle.EditValue == null ? null : int.Parse(this.txtBendingAngle.EditValue.ToString());
            var elbowType = this.txtElbowType.Text.Trim();
            _allVisualList.ForEach(x =>
            {
                x.Elev = elev;
                x.MinorLoss = minorLoss;
                x.Material = material;
                x.Caliber = caliber;
                x.BendingAngle = blendingAngle;
                x.ElbowType = elbowType;
                if (elev.HasValue)
                {
                    if (x.Elev != elev.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Elev), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Elev = elev.Value;
                }
                if (minorLoss.HasValue)
                {
                    if (x.MinorLoss != minorLoss.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.MinorLoss), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.MinorLoss = minorLoss.Value;
                }
                if (!string.IsNullOrEmpty(material))
                {
                    if (x.Material != material)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Material), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Material = material;
                }
                if (caliber.HasValue)
                {
                    if (x.Caliber != caliber.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Caliber), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Caliber = caliber.Value;
                }
                if (blendingAngle.HasValue)
                {
                    if (x.BendingAngle != blendingAngle.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.BendingAngle), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.BendingAngle = blendingAngle.Value;
                }
                if (!string.IsNullOrEmpty(elbowType))
                {
                    if (x.ElbowType != elbowType)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.ElbowType), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.ElbowType = elbowType;
                }
            });
            this.ReloadDataEvent?.Invoke(_allVisualList);
            this.DialogResult = DialogResult.OK;