From d5a2d7e66f9c8046bd88b8269e61aac5a2a265e2 Mon Sep 17 00:00:00 2001 From: duheng <2286773002@qq.com> Date: 星期五, 28 三月 2025 10:49:55 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/15-pipe/HydroPipeListCtrl.cs | 128 +++++++++++++++++++++++++++++++++--------- 1 files changed, 101 insertions(+), 27 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/15-pipe/HydroPipeListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/15-pipe/HydroPipeListCtrl.cs index f9a3593..e46fd84 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/15-pipe/HydroPipeListCtrl.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/15-pipe/HydroPipeListCtrl.cs @@ -1,4 +1,6 @@ -锘縰sing Yw.Model; +锘縰sing DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraPrinting; +using Yw.Model; namespace Yw.WinFrmUI { @@ -32,6 +34,7 @@ /// </summary> public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent; + /// <summary> /// 鏄惁鎷ユ湁姘村姏鍒楄〃 /// </summary> @@ -40,34 +43,54 @@ get { return _allList != null && _allList.Count > 0; } } - //鎵�鏈夊垪琛� - private List<HydroPipeViewModel> _allList = null; - //鎵�鏈夌粦瀹氬垪琛� - private List<HydroPipeViewModel> _allBindingList = null; + + private List<HydroPipeViewModel> _allList = null;//鎵�鏈夊垪琛� + private List<HydroPipeViewModel> _allBindingList = null;//鎵�鏈夌粦瀹氬垪琛� + private HydroChangeHelper _changeHelper = null;//鏀瑰彉杈呭姪绫� + private HydroPropStatusHelper _propStatusHelper = null;//灞炴�х姸鎬佽緟鍔╃被 /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) + public void SetBindingData + ( + Yw.Model.HydroModelInfo hydroInfo, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - SetBindingData(hydroInfo, allCalcuResultVisualDict: null); + SetBindingData(hydroInfo, allCalcuResultVisualDict: null, changeHelper, propStatusHelper); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList) + public void SetBindingData + ( + Yw.Model.HydroModelInfo hydroInfo, + List<HydroCalcuVisualResult> allCalcuResultList, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code); - SetBindingData(hydroInfo, allCalcuResultVisualDict); + SetBindingData(hydroInfo, allCalcuResultVisualDict, changeHelper, propStatusHelper); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict) + public void SetBindingData + ( + HydroModelInfo hydroInfo, + Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { _allList = new List<HydroPipeViewModel>(); + _changeHelper = changeHelper; + _propStatusHelper = propStatusHelper; if (hydroInfo != null && hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0) { foreach (var visual in hydroInfo.Pipes) @@ -87,9 +110,16 @@ /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList) + public void SetBindingData + ( + List<HydroVisualViewModel> allVisualViewModelList, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { _allList = new List<HydroPipeViewModel>(); + _changeHelper = changeHelper; + _propStatusHelper = propStatusHelper; allVisualViewModelList?.ForEach(x => { if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Pipe) @@ -205,21 +235,32 @@ { return; } - var name = this.txtName.Text.Trim(); - var code = this.txtCode.Text.Trim(); - var modelType = this.txtModelType.Text.Trim(); _allBindingList = _allList; + + var name = this.txtName.Text.Trim(); if (!string.IsNullOrEmpty(name)) { _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList(); } + var code = this.txtCode.Text.Trim(); if (!string.IsNullOrEmpty(code)) { _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList(); } + var modelType = this.txtModelType.Text.Trim(); if (!string.IsNullOrEmpty(modelType)) { _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList(); + } + double? diameterMin = this.txtDiameterMin.EditValue == null ? null : double.Parse(this.txtDiameterMin.EditValue.ToString()); + if (diameterMin.HasValue) + { + _allBindingList = _allBindingList.Where(x => x.Diameter >= diameterMin.Value).ToList(); + } + double? diameterMax = this.txtDiameterMax.EditValue == null ? null : double.Parse(this.txtDiameterMax.EditValue.ToString()); + if (diameterMax.HasValue) + { + _allBindingList = _allBindingList.Where(x => x.Diameter <= diameterMax.Value).ToList(); } this.hydroPipeViewModelBindingSource.DataSource = _allBindingList; this.hydroPipeViewModelBindingSource.ResetBindings(false); @@ -244,9 +285,13 @@ return; } var dlg = new SetHydroPipeDlg(); - dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); + dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList(), _changeHelper, _propStatusHelper); dlg.ReloadDataEvent += (list) => { + if (list == null || list.Count < 1) + { + return; + } _allBindingList.ForEach(x => x.UpdateProperty()); this.hydroPipeViewModelBindingSource.ResetBindings(false); var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList(); @@ -257,7 +302,7 @@ dlg.ShowDialog(); } - + //琛屽崟鍏冪偣鍑讳簨浠� private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as HydroPipeViewModel; @@ -269,9 +314,13 @@ if (e.Column == this.colSet) { var dlg = new SetHydroPipeDlg(); - dlg.SetBindingData(row.Vmo); + dlg.SetBindingData(row.Vmo, _changeHelper, _propStatusHelper); dlg.ReloadDataEvent += (list) => { + if (list == null || list.Count < 1) + { + return; + } row.UpdateProperty(); this.gridView1.RefreshRow(e.RowHandle); this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row }); @@ -294,6 +343,7 @@ { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; this.colDbLocked.Visible = false; + this.colBeginGroup.Visible = false; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; @@ -301,7 +351,6 @@ this.colDiameter.Visible = true; this.colLength.Visible = false; this.colRoughness.Visible = false; - this.colMinorLoss.Visible = false; this.colHasDb.Visible = false; this.colFlags.Visible = true; this.colDescription.Visible = true; @@ -309,7 +358,6 @@ this.colCalcuPr1.Visible = false; this.colCalcuPr2.Visible = false; this.colCalcuVelocity.Visible = false; - this.colCalcuMinorLoss.Visible = false; this.colCalcuFrictionLoss.Visible = false; this.colSet.Visible = false; } @@ -321,6 +369,7 @@ { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; this.colDbLocked.Visible = true; + this.colBeginGroup.Visible = true; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; @@ -328,7 +377,6 @@ this.colDiameter.Visible = true; this.colLength.Visible = true; this.colRoughness.Visible = true; - this.colMinorLoss.Visible = true; this.colHasDb.Visible = true; this.colFlags.Visible = true; this.colDescription.Visible = true; @@ -336,7 +384,6 @@ this.colCalcuPr1.Visible = false; this.colCalcuPr2.Visible = false; this.colCalcuVelocity.Visible = false; - this.colCalcuMinorLoss.Visible = false; this.colCalcuFrictionLoss.Visible = false; this.colSet.Visible = true; } @@ -348,6 +395,7 @@ { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; this.colDbLocked.Visible = true; + this.colBeginGroup.Visible = true; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; @@ -355,12 +403,10 @@ this.colDiameter.Visible = true; this.colLength.Visible = true; this.colRoughness.Visible = true; - this.colMinorLoss.Visible = true; this.colHasDb.Visible = true; this.colFlags.Visible = true; this.colDescription.Visible = true; this.colCalcuFrictionLoss.Visible = true; - this.colCalcuMinorLoss.Visible = true; this.colCalcuVelocity.Visible = true; this.colCalcuPr2.Visible = true; this.colCalcuPr1.Visible = true; @@ -375,6 +421,7 @@ { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; this.colDbLocked.Visible = true; + this.colBeginGroup.Visible = true; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; @@ -382,7 +429,6 @@ this.colDiameter.Visible = true; this.colLength.Visible = true; this.colRoughness.Visible = true; - this.colMinorLoss.Visible = true; this.colHasDb.Visible = true; this.colFlags.Visible = true; this.colDescription.Visible = true; @@ -390,7 +436,6 @@ this.colCalcuPr1.Visible = false; this.colCalcuPr2.Visible = false; this.colCalcuVelocity.Visible = false; - this.colCalcuMinorLoss.Visible = false; this.colCalcuFrictionLoss.Visible = false; this.colSet.Visible = true; } @@ -402,6 +447,7 @@ { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; this.colDbLocked.Visible = true; + this.colBeginGroup.Visible = true; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; @@ -409,17 +455,45 @@ this.colDiameter.Visible = true; this.colLength.Visible = true; this.colRoughness.Visible = true; - this.colMinorLoss.Visible = true; this.colHasDb.Visible = true; this.colFlags.Visible = true; this.colDescription.Visible = true; this.colCalcuFrictionLoss.Visible = true; - this.colCalcuMinorLoss.Visible = true; this.colCalcuVelocity.Visible = true; this.colCalcuPr2.Visible = true; this.colCalcuPr1.Visible = true; this.colCalcuQ.Visible = true; this.colSet.Visible = false; } + + /// <summary> + /// + /// </summary> + public GridView GetGridView() + { + return this.gridView1; + } + + /// <summary> + /// + /// </summary> + public void ExportToXlsx() + { + var filePath = FileDialogHelper.SaveFile("瀵煎嚭Excel鏂囦欢", "Excel鏂囦欢|*.xlsx"); + if (string.IsNullOrEmpty(filePath)) + { + return; + } + var options = new XlsxExportOptions + { + ExportMode = XlsxExportMode.SingleFile, // 瀵煎嚭妯″紡 + ShowGridLines = true, // 鏄剧ず缃戞牸绾� + TextExportMode = TextExportMode.Value, // 瀵煎嚭鏂囨湰妯″紡 + SheetName = "绠¢亾" // 宸ヤ綔琛ㄥ悕绉� + }; + this.gridView1.ExportToXlsx(filePath, options); + } + + } } -- Gitblit v1.9.3