namespace Yw.WinFrmUI { public partial class SetHydroCoolingDlg : DevExpress.XtraEditors.XtraForm { public SetHydroCoolingDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; this.layoutControl1.SetupLayoutControl(); this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; } /// /// 返回数据事件 /// public event Action> ReloadDataEvent; private List _allVisualList = null; //所有构件列表 private HydroChangeHelper _changeHelper = null;//改变辅助类 private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类 /// /// 绑定数据 /// public void SetBindingData ( Yw.Model.HydroCoolingInfo visual, HydroChangeHelper changeHelper = null, HydroPropStatusHelper propStatusHelper = null ) { var allVisualList = visual == null ? null : new List() { visual }; SetBindingData(allVisualList, changeHelper, propStatusHelper); } /// /// 绑定数据 /// public void SetBindingData ( List allVisualList, HydroChangeHelper changeHelper = null, HydroPropStatusHelper propStatusHelper = null ) { _allVisualList = allVisualList; _changeHelper = changeHelper; _propStatusHelper = propStatusHelper; if (_allVisualList != null && _allVisualList.Count == 1) { var parter = _allVisualList.First(); this.txtMaterial.EditValue = parter.Material; this.txtCaliber.EditValue = parter.Caliber; this.txtCoefficient.EditValue = parter.Coefficient; this.txtLowerLimit.EditValue = parter.LowerLimit; } } //确定 private void GeneralOkAndCancelCtrl1_OkEvent() { if (_allVisualList == null || _allVisualList.Count < 1) { return; } string material = this.txtMaterial.Text.Trim(); double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString()); double? coefficient = this.txtCoefficient.EditValue == null ? null : double.Parse(this.txtCoefficient.EditValue.ToString()); double? lowerLimit = this.txtLowerLimit.EditValue == null ? null : double.Parse(this.txtLowerLimit.EditValue.ToString()); _allVisualList.ForEach(x => { 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 (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; } if (lowerLimit.HasValue) { if (x.LowerLimit != lowerLimit.Value) { _changeHelper.Append(x, eChangeType.Update); _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.LowerLimit), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改"); } x.LowerLimit = lowerLimit.Value; } }); this.ReloadDataEvent?.Invoke(_allVisualList); this.DialogResult = DialogResult.OK; this.Close(); } } }