| | |
| | | /// </summary> |
| | | public event Action<List<Yw.Model.HydroNozzleInfo>> ReloadDataEvent; |
| | | |
| | | //所有构件列表 |
| | | private List<Yw.Model.HydroNozzleInfo> _allParterList = null; |
| | | private List<Yw.Model.HydroNozzleInfo> _allVisualList = null;//所有构件列表 |
| | | private HydroChangeHelper _changeHelper = null;//改变辅助类 |
| | | private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类 |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Yw.Model.HydroNozzleInfo parter) |
| | | public void SetBindingData |
| | | ( |
| | | Yw.Model.HydroNozzleInfo visual, |
| | | HydroChangeHelper changeHelper = null, |
| | | HydroPropStatusHelper propStatusHelper = null |
| | | ) |
| | | { |
| | | var allParterList = parter == null ? null : new List<Yw.Model.HydroNozzleInfo>() { parter }; |
| | | SetBindingData(allParterList); |
| | | var allVisualList = visual == null ? null : new List<Yw.Model.HydroNozzleInfo>() { visual }; |
| | | SetBindingData(allVisualList, changeHelper, propStatusHelper); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(List<Yw.Model.HydroNozzleInfo> allNozzleList) |
| | | public void SetBindingData |
| | | ( |
| | | List<Yw.Model.HydroNozzleInfo> allNozzleList, |
| | | HydroChangeHelper changeHelper = null, |
| | | HydroPropStatusHelper propStatusHelper = null |
| | | ) |
| | | { |
| | | _allParterList = allNozzleList; |
| | | if (_allParterList != null && _allParterList.Count == 1) |
| | | _allVisualList = allNozzleList; |
| | | _changeHelper = changeHelper; |
| | | _propStatusHelper = propStatusHelper; |
| | | if (_allVisualList != null && _allVisualList.Count == 1) |
| | | { |
| | | 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; |
| | | var visual = _allVisualList.First(); |
| | | this.txtElev.EditValue = Math.Round(visual.Elev, 4); |
| | | this.txtMinorLoss.EditValue = visual.MinorLoss; |
| | | this.txtCoefficient.EditValue = visual.Coefficient; |
| | | this.txtDemand.EditValue = visual.Demand; |
| | | } |
| | | } |
| | | |
| | | //验证 |
| | | private bool Valid() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | if (this.txtElev.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtElev, "必填项"); |
| | | return false; |
| | | } |
| | | if (this.txtCoefficient.EditValue == null) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtCoefficient, "必填项"); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //确定 |
| | | private void GeneralOkAndCancelCtrl1_OkEvent() |
| | | { |
| | | if (_allParterList == null || _allParterList.Count < 1) |
| | | if (_allVisualList == null || _allVisualList.Count < 1) |
| | | { |
| | | 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()); |
| | | double? demand = this.txtDemand.EditValue == null ? null : double.Parse(this.txtDemand.EditValue.ToString()); |
| | | var coefficient = double.Parse(this.txtCoefficient.EditValue.ToString()); |
| | | _allParterList.ForEach(x => |
| | | double? coefficient = this.txtCoefficient.EditValue == null ? null : double.Parse(this.txtCoefficient.EditValue.ToString()); |
| | | _allVisualList.ForEach(x => |
| | | { |
| | | x.Elev = elev; |
| | | x.MinorLoss = minorLoss; |
| | | x.Demand = demand; |
| | | x.Coefficient = coefficient; |
| | | 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 (demand.HasValue) |
| | | { |
| | | if (x.Demand != demand.Value) |
| | | { |
| | | _changeHelper.Append(x, eChangeType.Update); |
| | | _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Demand), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改"); |
| | | } |
| | | x.Demand = demand.Value; |
| | | } |
| | | if (coefficient.HasValue) |
| | | { |
| | | if (x.Coefficient != coefficient.Value) |
| | | { |
| | | _changeHelper.Append(x, eChangeType.Update); |
| | | _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Coefficient), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改"); |
| | | } |
| | | x.Coefficient = coefficient.Value; |
| | | } |
| | | }); |
| | | this.ReloadDataEvent?.Invoke(_allParterList); |
| | | this.ReloadDataEvent?.Invoke(_allVisualList); |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | } |