From 2de65e7ad262da695494122b547db604ca53b01a Mon Sep 17 00:00:00 2001 From: kyy <3283105747@qq.com> Date: 星期五, 15 八月 2025 17:40:09 +0800 Subject: [PATCH] 1、UtilityHelper通用类 (1、底部汇总新增选择时汇总 2、颜色设置) 2、到货条码打印设置检验结果颜色 3、采购到货(1、为GridView的鼠标抬起事件添加处理方法,实现自定义交互2、条件汇总:只对选中(打勾)的行进行汇总) --- DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemIns.cs | 18 + DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs | 35 ++ DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.Designer.cs | 27 DevApp/Gs.DevApp/UserControl/SelectCgMx.cs | 24 + DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.Designer.cs | 18 DevApp/Gs.DevApp/UserControl/SelectCgMx.Designer.cs | 24 DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 834 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 945 insertions(+), 35 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.Designer.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.Designer.cs index 111a308..24c5960 100644 --- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.Designer.cs +++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.Designer.cs @@ -778,7 +778,7 @@ // gv_demandDocumentId // this.gv_demandDocumentId.Caption = "闇�姹傚崟鎹彿"; - this.gv_demandDocumentId.FieldName = "SalesOrderId"; + this.gv_demandDocumentId.FieldName = "salesOrderId"; this.gv_demandDocumentId.Name = "gv_demandDocumentId"; this.gv_demandDocumentId.Tag = "query_a.SalesOrderId"; this.gv_demandDocumentId.Visible = true; @@ -2079,7 +2079,7 @@ // btnIpt // this.btnIpt.ImageOptions.Image = global::Gs.DevApp.Properties.Resources.calculatenow_32x32; - this.btnIpt.Location = new System.Drawing.Point(1057, 2); + this.btnIpt.Location = new System.Drawing.Point(1074, 2); this.btnIpt.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnIpt.Name = "btnIpt"; this.btnIpt.Size = new System.Drawing.Size(92, 27); @@ -2090,7 +2090,7 @@ // btnLoad // this.btnLoad.ImageOptions.Image = global::Gs.DevApp.Properties.Resources.refresh_32x321; - this.btnLoad.Location = new System.Drawing.Point(912, 2); + this.btnLoad.Location = new System.Drawing.Point(929, 2); this.btnLoad.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnLoad.Name = "btnLoad"; this.btnLoad.Size = new System.Drawing.Size(141, 27); @@ -2105,7 +2105,7 @@ this.txtJianYan.Name = "txtJianYan"; this.txtJianYan.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 15F); this.txtJianYan.Properties.Appearance.Options.UseFont = true; - this.txtJianYan.Size = new System.Drawing.Size(519, 30); + this.txtJianYan.Size = new System.Drawing.Size(530, 30); this.txtJianYan.StyleController = this.layoutMxMsg; this.txtJianYan.TabIndex = 2; // @@ -2137,7 +2137,7 @@ this.layoutControlGroup1.OptionsTableLayoutGroup.RowDefinitions.AddRange(new DevExpress.XtraLayout.RowDefinition[] { rowDefinition8}); this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0); - this.layoutControlGroup1.Size = new System.Drawing.Size(1151, 34); + this.layoutControlGroup1.Size = new System.Drawing.Size(1168, 34); this.layoutControlGroup1.TextVisible = false; // // layoutControlItem11 @@ -2147,7 +2147,7 @@ this.layoutControlItem11.Location = new System.Drawing.Point(0, 0); this.layoutControlItem11.Name = "layoutControlItem11"; this.layoutControlItem11.OptionsTableLayoutItem.ColumnSpan = 2; - this.layoutControlItem11.Size = new System.Drawing.Size(703, 34); + this.layoutControlItem11.Size = new System.Drawing.Size(714, 34); this.layoutControlItem11.Text = "褰曞叆妫�楠岀粨鏋滐紙OK-19,NG-19锛�"; this.layoutControlItem11.TextSize = new System.Drawing.Size(168, 14); // @@ -2155,7 +2155,7 @@ // this.layoutControlItem20.ContentHorzAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem20.Control = this.btnIpt; - this.layoutControlItem20.Location = new System.Drawing.Point(1055, 0); + this.layoutControlItem20.Location = new System.Drawing.Point(1072, 0); this.layoutControlItem20.MaxSize = new System.Drawing.Size(96, 31); this.layoutControlItem20.MinSize = new System.Drawing.Size(96, 31); this.layoutControlItem20.Name = "layoutControlItem20"; @@ -2170,12 +2170,12 @@ // this.layoutControlItem19.ContentHorzAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem19.Control = this.btnLoad; - this.layoutControlItem19.Location = new System.Drawing.Point(703, 0); + this.layoutControlItem19.Location = new System.Drawing.Point(714, 0); this.layoutControlItem19.MaxSize = new System.Drawing.Size(145, 31); this.layoutControlItem19.MinSize = new System.Drawing.Size(145, 31); this.layoutControlItem19.Name = "layoutControlItem19"; this.layoutControlItem19.OptionsTableLayoutItem.ColumnIndex = 2; - this.layoutControlItem19.Size = new System.Drawing.Size(352, 34); + this.layoutControlItem19.Size = new System.Drawing.Size(358, 34); this.layoutControlItem19.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom; this.layoutControlItem19.Text = "閲嶆柊鍔犺浇"; this.layoutControlItem19.TextSize = new System.Drawing.Size(0, 0); diff --git a/DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemIns.cs b/DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemIns.cs index 41affff..57e694e 100644 --- a/DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemIns.cs +++ b/DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemIns.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Drawing; using System.Threading.Tasks; using System.Windows.Forms; @@ -39,6 +40,23 @@ }, lbGuid); getPageList(1); pageBar1.PagerEvent += PageBar1_PagerEvent; + + // 浣跨敤鏂扮殑绠�鍖栨牸寮忚缃鏍哥姸鎬侀鑹� + this.Load += (s, e) => { + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = 1000; // 1绉掑悗鎵ц + timer.Tick += (sender, args) => { + timer.Stop(); + timer.Dispose(); + + // 璁剧疆瀹℃牳鐘舵�侀鑹� - 鏀寔澶氱bit绫诲瀷鐨勫�兼牸寮� + + UtilityHelper.SetSimpleGridColor(gridView1, "checkStatus", "=True", "Cell", Color.Blue); + + }; + timer.Start(); + }; + } private void GridView1_ColumnFilterChanged(object sender, EventArgs e) { diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.Designer.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.Designer.cs index 0fe3eb1..31f1af3 100644 --- a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.Designer.cs +++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.Designer.cs @@ -896,7 +896,7 @@ this.gridColumn51.Tag = "query_a.ebeln"; this.gridColumn51.Visible = true; this.gridColumn51.VisibleIndex = 1; - this.gridColumn51.Width = 92; + this.gridColumn51.Width = 79; // // gridColumn55 // @@ -907,7 +907,7 @@ this.gridColumn55.OptionsColumn.ReadOnly = true; this.gridColumn55.Visible = true; this.gridColumn55.VisibleIndex = 2; - this.gridColumn55.Width = 77; + this.gridColumn55.Width = 66; // // gridColumn56 // @@ -920,7 +920,7 @@ this.gridColumn56.Tag = "query_a.board_style"; this.gridColumn56.Visible = true; this.gridColumn56.VisibleIndex = 3; - this.gridColumn56.Width = 139; + this.gridColumn56.Width = 120; // // gridColumn57 // @@ -930,7 +930,7 @@ this.gridColumn57.Name = "gridColumn57"; this.gridColumn57.Visible = true; this.gridColumn57.VisibleIndex = 4; - this.gridColumn57.Width = 95; + this.gridColumn57.Width = 82; // // gridColumn58 // @@ -940,7 +940,7 @@ this.gridColumn58.Name = "gridColumn58"; this.gridColumn58.Visible = true; this.gridColumn58.VisibleIndex = 5; - this.gridColumn58.Width = 73; + this.gridColumn58.Width = 178; // // gridColumn59 // @@ -953,7 +953,7 @@ this.gridColumn59.Tag = "query_a.ok_rkqty"; this.gridColumn59.Visible = true; this.gridColumn59.VisibleIndex = 6; - this.gridColumn59.Width = 77; + this.gridColumn59.Width = 139; // // gridColumn60 // @@ -966,7 +966,7 @@ this.gridColumn60.Tag = "query_a.ebeln_qty"; this.gridColumn60.Visible = true; this.gridColumn60.VisibleIndex = 7; - this.gridColumn60.Width = 77; + this.gridColumn60.Width = 109; // // gridColumn61 // @@ -980,7 +980,7 @@ this.gridColumn61.Name = "gridColumn61"; this.gridColumn61.Visible = true; this.gridColumn61.VisibleIndex = 8; - this.gridColumn61.Width = 73; + this.gridColumn61.Width = 84; // // gridColumn62 // @@ -1000,7 +1000,7 @@ this.gridColumn63.OptionsColumn.ReadOnly = true; this.gridColumn63.Visible = true; this.gridColumn63.VisibleIndex = 9; - this.gridColumn63.Width = 73; + this.gridColumn63.Width = 44; // // gridColumn64 // @@ -1019,7 +1019,7 @@ this.gridColumn65.Name = "gridColumn65"; this.gridColumn65.Visible = true; this.gridColumn65.VisibleIndex = 10; - this.gridColumn65.Width = 73; + this.gridColumn65.Width = 44; // // gridColumn66 // @@ -1029,7 +1029,7 @@ this.gridColumn66.Name = "gridColumn66"; this.gridColumn66.Visible = true; this.gridColumn66.VisibleIndex = 11; - this.gridColumn66.Width = 80; + this.gridColumn66.Width = 44; // // gridColumn67 // @@ -1039,7 +1039,7 @@ this.gridColumn67.Name = "gridColumn67"; this.gridColumn67.Visible = true; this.gridColumn67.VisibleIndex = 12; - this.gridColumn67.Width = 82; + this.gridColumn67.Width = 22; // // gridColumn68 // @@ -1075,6 +1075,7 @@ this.gridColumn70.Name = "gridColumn70"; this.gridColumn70.Visible = true; this.gridColumn70.VisibleIndex = 13; + this.gridColumn70.Width = 20; // // gridColumn71 // @@ -1083,6 +1084,7 @@ this.gridColumn71.Name = "gridColumn71"; this.gridColumn71.Visible = true; this.gridColumn71.VisibleIndex = 14; + this.gridColumn71.Width = 20; // // gridColumn72 // @@ -1091,6 +1093,7 @@ this.gridColumn72.Name = "gridColumn72"; this.gridColumn72.Visible = true; this.gridColumn72.VisibleIndex = 15; + this.gridColumn72.Width = 20; // // repositoryItemButtonEdit5 // diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs index b605cc1..8d614d7 100644 --- a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs +++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Drawing; using System.Threading.Tasks; using System.Windows.Forms; @@ -221,7 +222,39 @@ UtilityHelper.SetupGridSummary(gvMx1, "quantity", "okRkqty"); UtilityHelper.SetupGridSummary(gvMxL1, "quantity", "okRkqty"); - + // 妫�鏌ユ暟鎹姞杞藉悗鍐嶈缃鑹� + this.Load += (s, e) => { + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = 1000; // 1绉掑悗鎵ц锛岀‘淇濇暟鎹凡鍔犺浇 + timer.Tick += (sender, args) => { + timer.Stop(); + timer.Dispose(); + + // 浣跨敤鏂扮殑绠�鍖栨牸寮忚缃楠岀粨鏋滈鑹� + UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains涓嶅悎鏍�", "Cell", Color.Red); + UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains鍚堟牸", "Cell", Color.Green); + UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains鍏嶆", "Cell", Color.Green); + + UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains涓嶅悎鏍�", "Cell", Color.Red); + UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains鍚堟牸", "Cell", Color.Green); + UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains鍏嶆", "Cell", Color.Green); + + UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains涓嶅悎鏍�", "Cell", Color.Red); + UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains鍚堟牸", "Cell", Color.Green); + UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains鍏嶆", "Cell", Color.Green); + + UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains涓嶅悎鏍�", "Cell", Color.Red); + UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains鍚堟牸", "Cell", Color.Green); + UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains鍏嶆", "Cell", Color.Green); + + // 瀛楁杩愮畻绀轰緥锛氬綋鏀惰揣鏁伴噺(quantity)澶т簬宸插叆搴撴暟閲�(okRkqty)鏃讹紝鏁磋鏄剧ず姗欒壊 + UtilityHelper.SetSimpleGridColor(gvMx1, "", "quantity-okRkqty>0", "Row", Color.Orange); + + // 瀛楁杩愮畻绀轰緥锛氬綋鍙墦鍗版暟閲�(kQty)灏忎簬绛変簬0鏃讹紝鏁磋鏄剧ず鐏拌壊 + UtilityHelper.SetSimpleGridColor(gvMx1, "", "kQty<=0", "Row", Color.Gray); + }; + timer.Start(); + }; } private void GridView1_ColumnFilterChanged(object sender, EventArgs e) diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs index 07579d0..f0e2c71 100644 --- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs @@ -2422,8 +2422,841 @@ } } } + + /// <summary> + /// 2025-08-15 kyy 蹇�熼厤缃瓽ridView鏉′欢姹囨�伙紙鍙眹鎬绘弧瓒虫潯浠剁殑琛岋級 + /// 浣跨敤绠�鍗曠殑鏍囩鏄剧ず鏂瑰紡锛岄伩鍏嶅鏉傜殑姹囨�婚」閰嶇疆 + /// </summary> + /// <param name="gridView">鐩爣GridView鎺т欢</param> + /// <param name="conditionFieldName">鏉′欢瀛楁鍚嶏紙濡俢hkInt锛�</param> + /// <param name="conditionValue">鏉′欢鍊硷紙濡倀rue銆�1绛夎〃绀洪�変腑锛�</param> + /// <param name="summaryColumns">闇�瑕佽繘琛屾眰鍜屾眹鎬荤殑鍒楀悕鏁扮粍</param> + public static void SetupGridSummaryWithCondition(DevExpress.XtraGrid.Views.Grid.GridView gridView, string conditionFieldName, object conditionValue, params string[] summaryColumns) + { + // 鍚敤搴曢儴姹囨�昏 + gridView.OptionsView.ShowFooter = true; + + // 瀛樺偍鏉′欢姹囨�婚厤缃埌GridView鐨凾ag涓� + var conditionSummaryConfig = new + { + ConditionField = conditionFieldName, + ConditionValue = conditionValue, + SummaryColumns = summaryColumns + }; + + // 灏嗛厤缃瓨鍌ㄥ埌GridView鐨凾ag涓紙濡傛灉宸叉湁鍏朵粬Tag锛岄渶瑕佸悎骞讹級 + if (gridView.Tag == null) + { + gridView.Tag = conditionSummaryConfig; + } + else + { + // 濡傛灉宸叉湁Tag锛屽垱寤轰竴涓鍚堝璞� + gridView.Tag = new { Existing = gridView.Tag, ConditionSummary = conditionSummaryConfig }; + } + + // 涓烘瘡涓寚瀹氬垪璁剧疆鑷畾涔夋眹鎬昏绠� + foreach (var columnName in summaryColumns) + { + if (gridView.Columns[columnName] != null) + { + // 浣跨敤鏍囧噯鐨勬眰鍜屾眹鎬伙紝浣嗘樉绀鸿嚜瀹氫箟鏍煎紡 + gridView.Columns[columnName].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; + gridView.Columns[columnName].SummaryItem.DisplayFormat = "閫変腑鍚堣: {0}"; + } + } + + // 缁戝畾鏁版嵁鍙樺寲浜嬩欢锛屾墜鍔ㄨ绠楁潯浠舵眹鎬� + gridView.CustomDrawFooterCell -= GridView_CustomDrawFooterForCondition; + gridView.CustomDrawFooterCell += GridView_CustomDrawFooterForCondition; + } + + /// <summary> + /// 鑷畾涔夌粯鍒堕〉鑴氬崟鍏冩牸锛屾樉绀烘潯浠舵眹鎬荤粨鏋� + /// </summary> + private static void GridView_CustomDrawFooterForCondition(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e) + { + var gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView; + if (gridView?.Tag == null) return; + + try + { + // 鑾峰彇鏉′欢姹囨�婚厤缃� + dynamic config = GetConditionSummaryConfig(gridView.Tag); + if (config == null) return; + + string conditionField = config.ConditionField; + object conditionValue = config.ConditionValue; + string[] summaryColumns = config.SummaryColumns; + + // 妫�鏌ュ綋鍓嶅垪鏄惁闇�瑕佹潯浠舵眹鎬� + if (summaryColumns != null && Array.IndexOf(summaryColumns, e.Column.FieldName) >= 0) + { + // 璁$畻鏉′欢姹囨�诲�� + decimal totalValue = CalculateConditionalSum(gridView, conditionField, conditionValue, e.Column.FieldName); + + // 璁剧疆鏄剧ず鏂囨湰 + e.Info.DisplayText = $"{totalValue:F2}"; + + // 鍙互鑷畾涔夋樉绀烘牱寮� + e.Appearance.ForeColor = System.Drawing.Color.Blue; + e.Appearance.Font = new System.Drawing.Font(e.Appearance.Font, System.Drawing.FontStyle.Bold); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"鏉′欢姹囨�荤粯鍒堕敊璇�: {ex.Message}"); + } + } + + /// <summary> + /// 鑾峰彇鏉′欢姹囨�婚厤缃� + /// </summary> + private static dynamic GetConditionSummaryConfig(object tag) + { + if (tag == null) return null; + + // 妫�鏌ユ槸鍚︽槸鐩存帴鐨勯厤缃璞� + var tagType = tag.GetType(); + if (tagType.GetProperty("ConditionField") != null) + { + return tag; + } + + // 妫�鏌ユ槸鍚︽槸澶嶅悎瀵硅薄 + if (tagType.GetProperty("ConditionSummary") != null) + { + dynamic composite = tag; + return composite.ConditionSummary; + } + + return null; + } + + /// <summary> + /// 璁$畻鏉′欢姹囨�诲�� + /// </summary> + private static decimal CalculateConditionalSum(DevExpress.XtraGrid.Views.Grid.GridView gridView, string conditionField, object conditionValue, string summaryField) + { + decimal total = 0; + + try + { + // 閬嶅巻鎵�鏈夊彲瑙佽 + for (int i = 0; i < gridView.DataRowCount; i++) + { + // 鑾峰彇鏉′欢瀛楁鍊� + object conditionFieldValue = gridView.GetRowCellValue(i, conditionField); + + // 妫�鏌ユ潯浠舵槸鍚﹀尮閰� + if (IsConditionMatched(conditionFieldValue, conditionValue)) + { + // 鑾峰彇姹囨�诲瓧娈靛�� + object summaryFieldValue = gridView.GetRowCellValue(i, summaryField); + + // 绱姞鏁板�� + if (summaryFieldValue != null && decimal.TryParse(summaryFieldValue.ToString(), out decimal value)) + { + total += value; + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"鏉′欢姹囨�昏绠楅敊璇�: {ex.Message}"); + } + + return Math.Round(total, 2); + } + + /// <summary> + /// 鎵嬪姩鍒锋柊鏉′欢姹囨�绘樉绀� - 浼樺寲鐗堟湰锛岀珛鍗崇敓鏁� + /// </summary> + public static void RefreshConditionalSummary(DevExpress.XtraGrid.Views.Grid.GridView gridView) + { + try + { + if (gridView != null) + { + // 鍏堝埛鏂版暟鎹粦瀹� + gridView.PostEditor(); + gridView.UpdateCurrentRow(); + + // 寮哄埗閲嶇粯搴曢儴姹囨�诲尯鍩� + gridView.InvalidateFooter(); + + // 绔嬪嵆鍒锋柊甯冨眬 + gridView.LayoutChanged(); + + // 寮哄埗閲嶇粯鏁翠釜瑙嗗浘 + gridView.Invalidate(); + + // 纭繚鐣岄潰绔嬪嵆鏇存柊 + System.Windows.Forms.Application.DoEvents(); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"鍒锋柊鏉′欢姹囨�婚敊璇�: {ex.Message}"); + } + } + + /// <summary> + /// 鍒ゆ柇鏉′欢鏄惁鍖归厤锛堢敤浜庢眹鎬伙級 + /// </summary> + private static bool IsConditionMatched(object fieldValue, object targetValue) + { + if (fieldValue == null && targetValue == null) return true; + if (fieldValue == null || targetValue == null) return false; + + string fieldStr = fieldValue.ToString().Trim(); + string targetStr = targetValue.ToString().Trim(); + + // 澶勭悊甯冨皵鍊肩被鍨嬬殑鍖归厤 + if (IsBooleanValue(fieldStr) || IsBooleanValue(targetStr)) + { + bool fieldBool = ConvertToBoolean(fieldStr); + bool targetBool = ConvertToBoolean(targetStr); + return fieldBool == targetBool; + } + + // 澶勭悊鏁板�肩被鍨嬬殑鍖归厤 + if (decimal.TryParse(fieldStr, out decimal fieldNum) && decimal.TryParse(targetStr, out decimal targetNum)) + { + return fieldNum == targetNum; + } + + // 瀛楃涓插尮閰� + return string.Equals(fieldStr, targetStr, StringComparison.OrdinalIgnoreCase); + } + + /// <summary> + /// 妫�鏌ユ槸鍚︿负甯冨皵鍊� + /// </summary> + private static bool IsBooleanValue(string value) + { + if (string.IsNullOrEmpty(value)) return false; + string lower = value.ToLower(); + return lower == "true" || lower == "false" || lower == "1" || lower == "0"; + } + + /// <summary> + /// 杞崲涓哄竷灏斿�� + /// </summary> + private static bool ConvertToBoolean(string value) + { + if (string.IsNullOrEmpty(value)) return false; + string lower = value.ToLower(); + return lower == "true" || lower == "1"; + } #endregion + #region 绠�鍖栫増GridView棰滆壊璁剧疆鏂规硶 - 鍒涘缓鏃堕棿锛�2024骞�8鏈�15鏃� 鍒朵綔浜猴細kyy + + /// <summary> + /// 涓�琛屼唬鐮佽缃瓽ridView棰滆壊鐨勬柟娉� + /// 鍒涘缓鏃堕棿锛�2024骞�8鏈�15鏃� 鍒朵綔浜猴細kyy + /// 浣跨敤绀轰緥锛� + /// SetSimpleGridColor(gridView1, "checkStatus", "=1", "Cell", Color.Blue); + /// SetSimpleGridColor(gridView1, "jyjg", "contains鍚堟牸", "Cell", Color.Green); + /// SetSimpleGridColor(gridView1, "status", "=宸插鏍�", "Row", Color.Blue); + /// SetSimpleGridColor(gridView1, "", "quantity-okRkqty>100", "Row", Color.Red); // 瀛楁杩愮畻琛ㄨ揪寮� + /// </summary> + /// <param name="gridView">GridView鎺т欢</param> + /// <param name="fieldName">瀛楁鍚嶏紙杩愮畻琛ㄨ揪寮忔椂鍙负绌哄瓧绗︿覆锛�</param> + /// <param name="condition">鏉′欢锛堟敮鎸�: =1, contains鍚堟牸, >5, >=10, 鎴栧瓧娈佃繍绠楀 fieldA+fieldB>100锛�</param> + /// <param name="scope">鑼冨洿锛圕ell/鍗曞厓鏍�, Row/琛�, Column/鍒楋級</param> + /// <param name="color">棰滆壊</param> + public static void SetSimpleGridColor(GridView gridView, string fieldName, string condition, string scope, Color color) + { + if (gridView == null || string.IsNullOrEmpty(condition)) + return; + + // 妫�鏌ユ槸鍚︿负杩愮畻琛ㄨ揪寮� + bool isCalculationExpression = IsCalculationExpression(condition); + + // 濡傛灉鏄繍绠楄〃杈惧紡浣嗘病鏈夋寚瀹歠ieldName锛宖ieldName璁句负绌� + if (isCalculationExpression && string.IsNullOrEmpty(fieldName)) + { + fieldName = ""; // 杩愮畻琛ㄨ揪寮忎笉闇�瑕佺壒瀹氬瓧娈靛悕 + } + else if (!isCalculationExpression && string.IsNullOrEmpty(fieldName)) + { + return; // 鏅�氭潯浠跺繀椤绘寚瀹氬瓧娈靛悕 + } + + // 绉婚櫎涔嬪墠鍙兘缁戝畾鐨勪簨浠讹紙閬垮厤閲嶅缁戝畾锛� + gridView.RowCellStyle -= SimpleGridColor_RowCellStyle; + + // 鍒涘缓绠�鍗曠殑棰滆壊閰嶇疆骞跺瓨鍌ㄥ埌Tag + var colorConfigs = gridView.Tag as List<SimpleColorConfig> ?? new List<SimpleColorConfig>(); + + // 娣诲姞鏂伴厤缃� + colorConfigs.Add(new SimpleColorConfig + { + FieldName = fieldName, + Condition = condition, + Scope = scope, + Color = color + }); + + gridView.Tag = colorConfigs; + + // 缁戝畾棰滆壊璁剧疆浜嬩欢 + gridView.RowCellStyle += SimpleGridColor_RowCellStyle; + } + + /// <summary> + /// 绠�鍗曢鑹查厤缃被 + /// </summary> + private class SimpleColorConfig + { + public string FieldName { get; set; } + public string Condition { get; set; } + public string Scope { get; set; } + public Color Color { get; set; } + } + + /// <summary> + /// 绠�鍖栫殑棰滆壊璁剧疆浜嬩欢澶勭悊 + /// </summary> + private static void SimpleGridColor_RowCellStyle(object sender, RowCellStyleEventArgs e) + { + var gridView = sender as GridView; + if (gridView?.Tag is List<SimpleColorConfig> configs) + { + foreach (var config in configs) + { + // 鍒ゆ柇鏄惁搴旇搴旂敤棰滆壊 + bool shouldApply = false; + + // 妫�鏌ユ槸鍚︿负杩愮畻琛ㄨ揪寮� + bool isCalculationExpression = IsCalculationExpression(config.Condition); + + if (isCalculationExpression) + { + // 杩愮畻琛ㄨ揪寮忔牴鎹寖鍥村喅瀹氭槸鍚﹀簲鐢� + if (config.Scope.ToLower() == "row") + shouldApply = true; // 鏁磋搴旂敤 + else if (config.Scope.ToLower() == "cell") + shouldApply = true; // 鎵�鏈夊崟鍏冩牸閮藉皾璇曞簲鐢� + else if (config.Scope.ToLower() == "column") + shouldApply = true; // 鎵�鏈夊垪閮藉皾璇曞簲鐢� + } + else + { + // 鏅�氬瓧娈垫潯浠� + if (config.Scope.ToLower() == "cell" && e.Column.FieldName == config.FieldName) + shouldApply = true; + else if (config.Scope.ToLower() == "row") + shouldApply = true; + else if (config.Scope.ToLower() == "column" && e.Column.FieldName == config.FieldName) + shouldApply = true; + } + + if (!shouldApply) continue; + + bool conditionMatched = false; + + if (isCalculationExpression) + { + // 澶勭悊瀛楁杩愮畻琛ㄨ揪寮� + try + { + decimal result = EvaluateExpression(gridView, e.RowHandle, config.Condition); + conditionMatched = result == 1; // 1琛ㄧず鏉′欢婊¤冻锛�0琛ㄧず涓嶆弧瓒� + + if (conditionMatched) + { + System.Diagnostics.Debug.WriteLine($"杩愮畻琛ㄨ揪寮忓尮閰嶆垚鍔� - 琛ㄨ揪寮�: {config.Condition}, 琛�: {e.RowHandle}"); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"杩愮畻琛ㄨ揪寮忚绠楀け璐� - 琛ㄨ揪寮�: {config.Condition}, 閿欒: {ex.Message}"); + } + } + else + { + // 澶勭悊鍗曞瓧娈垫潯浠� + object cellValue = gridView.GetRowCellValue(e.RowHandle, config.FieldName); + if (cellValue != null) + { + string stringValue = cellValue.ToString().Trim(); + + // 璋冭瘯淇℃伅锛氳緭鍑哄疄闄呯殑瀛楁鍊� + if (config.FieldName == "checkStatus" && e.RowHandle < 3) // 鍙緭鍑哄墠鍑犺閬垮厤澶鏃ュ織 + { + System.Diagnostics.Debug.WriteLine($"瀛楁鍊艰皟璇� - 瀛楁: {config.FieldName}, 瀹為檯鍊�: '{stringValue}', 绫诲瀷: {cellValue.GetType().Name}, 鏉′欢: {config.Condition}"); + } + + // 鍒ゆ柇鏉′欢鏄惁鍖归厤 + conditionMatched = IsConditionMatch(stringValue, config.Condition); + } + } + + if (conditionMatched) + { + e.Appearance.ForeColor = config.Color; + System.Diagnostics.Debug.WriteLine($"棰滆壊鍖归厤鎴愬姛 - 瀛楁/琛ㄨ揪寮�: {config.FieldName ?? config.Condition}, 鏉′欢: {config.Condition}"); + break; // 鍖归厤鍒扮涓�涓潯浠跺氨鍋滄 + } + } + } + } + + /// <summary> + /// 妫�鏌ユ槸鍚︿负璁$畻琛ㄨ揪寮忥紙鍖呭惈瀛楁杩愮畻锛� + /// </summary> + private static bool IsCalculationExpression(string condition) + { + if (string.IsNullOrEmpty(condition)) + return false; + + // 妫�鏌ユ槸鍚﹀寘鍚暟瀛﹁繍绠楃鍜屾瘮杈冭繍绠楃鐨勭粍鍚� + char[] mathOperators = { '+', '-', '*', '/' }; + string[] comparisonOperators = { ">=", "<=", ">", "<", "=", "!=" }; + + bool hasMathOperator = condition.IndexOfAny(mathOperators) >= 0; + bool hasComparisonOperator = comparisonOperators.Any(op => condition.Contains(op)); + + // 濡傛灉鍚屾椂鍖呭惈鏁板杩愮畻绗﹀拰姣旇緝杩愮畻绗︼紝灏辫涓烘槸璁$畻琛ㄨ揪寮� + return hasMathOperator && hasComparisonOperator; + } + + /// <summary> + /// 鍒ゆ柇鏉′欢鏄惁鍖归厤 + /// </summary> + private static bool IsConditionMatch(string value, string condition) + { + if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(condition)) + return false; + + condition = condition.Trim(); + value = value.Trim(); + + // 澶勭悊contains鏉′欢 + if (condition.StartsWith("contains", StringComparison.OrdinalIgnoreCase)) + { + string matchText = condition.Substring(8).Trim(); + + // 绉婚櫎鍓嶇紑澶勭悊锛堝"M:鍏嶆"涓殑"M:"锛� + string processedValue = value; + int colonIndex = processedValue.IndexOf(':'); + if (colonIndex >= 0 && colonIndex < processedValue.Length - 1) + { + processedValue = processedValue.Substring(colonIndex + 1).Trim(); + } + + return processedValue.IndexOf(matchText, StringComparison.OrdinalIgnoreCase) >= 0; + } + + // 澶勭悊绛変簬鏉′欢 + if (condition.StartsWith("=")) + { + string targetValue = condition.Substring(1).Trim(); + + // 鐗规畩澶勭悊bit绫诲瀷瀛楁锛圔oolean鍊硷級 + if (IsBooleanCondition(targetValue)) + { + return IsBooleanMatch(value, targetValue); + } + + return string.Equals(value, targetValue, StringComparison.OrdinalIgnoreCase); + } + + // 澶勭悊鏁板�兼瘮杈冩潯浠� + if (decimal.TryParse(value, out decimal numericValue)) + { + if (condition.StartsWith(">=")) + { + if (decimal.TryParse(condition.Substring(2).Trim(), out decimal target)) + return numericValue >= target; + } + else if (condition.StartsWith("<=")) + { + if (decimal.TryParse(condition.Substring(2).Trim(), out decimal target)) + return numericValue <= target; + } + else if (condition.StartsWith(">")) + { + if (decimal.TryParse(condition.Substring(1).Trim(), out decimal target)) + return numericValue > target; + } + else if (condition.StartsWith("<")) + { + if (decimal.TryParse(condition.Substring(1).Trim(), out decimal target)) + return numericValue < target; + } + else if (decimal.TryParse(condition, out decimal target)) + { + return numericValue == target; + } + } + + // 妫�鏌ユ槸鍚︽槸甯冨皵鍊兼潯浠� + if (IsBooleanCondition(condition)) + { + return IsBooleanMatch(value, condition); + } + + // 榛樿鎸夊瓧绗︿覆鐩哥瓑澶勭悊 + return string.Equals(value, condition, StringComparison.OrdinalIgnoreCase); + } + + /// <summary> + /// 鍒ゆ柇澶氬瓧娈佃繍绠楁潯浠舵槸鍚﹀尮閰嶏紙鏀寔瀛楁闂磋繍绠楋級 + /// </summary> + private static bool IsConditionMatchWithCalculation(GridView gridView, int rowHandle, string condition) + { + if (string.IsNullOrEmpty(condition)) + return false; + + condition = condition.Trim(); + + try + { + // 瑙f瀽骞惰绠楄〃杈惧紡 + decimal calculatedValue = EvaluateExpression(gridView, rowHandle, condition); + + // 濡傛灉琛ㄨ揪寮忚绠楁垚鍔燂紝杩斿洖true锛堣〃绀烘潯浠舵弧瓒筹級 + return true; + } + catch + { + // 濡傛灉璁$畻澶辫触锛岃繑鍥瀎alse + return false; + } + } + + /// <summary> + /// 璁$畻鍖呭惈瀛楁鍚嶇殑琛ㄨ揪寮� + /// 鏀寔鏍煎紡锛歠ieldA+fieldB>100, fieldA-fieldB<=50, fieldA*fieldB>=fieldC绛� + /// </summary> + private static decimal EvaluateExpression(GridView gridView, int rowHandle, string expression) + { + // 鎻愬彇姣旇緝杩愮畻绗﹀拰鐩爣鍊� + string[] operators = { ">=", "<=", ">", "<", "=", "!=" }; + string op = ""; + string leftExpression = ""; + string rightExpression = ""; + + foreach (var oper in operators) + { + if (expression.Contains(oper)) + { + string[] parts = expression.Split(new string[] { oper }, StringSplitOptions.None); + if (parts.Length == 2) + { + op = oper; + leftExpression = parts[0].Trim(); + rightExpression = parts[1].Trim(); + break; + } + } + } + + if (string.IsNullOrEmpty(op)) + throw new ArgumentException("鏃犳晥鐨勮〃杈惧紡鏍煎紡"); + + // 璁$畻宸︿晶琛ㄨ揪寮忕殑鍊� + decimal leftValue = CalculateFieldExpression(gridView, rowHandle, leftExpression); + + // 璁$畻鍙充晶琛ㄨ揪寮忕殑鍊硷紙鍙兘鏄暟瀛楁垨瀛楁琛ㄨ揪寮忥級 + decimal rightValue; + if (decimal.TryParse(rightExpression, out rightValue)) + { + // 鍙充晶鏄暟瀛� + } + else + { + // 鍙充晶鏄瓧娈佃〃杈惧紡 + rightValue = CalculateFieldExpression(gridView, rowHandle, rightExpression); + } + + // 鏍规嵁杩愮畻绗﹀垽鏂潯浠舵槸鍚︽弧瓒� + switch (op) + { + case ">=": + return leftValue >= rightValue ? 1 : 0; + case "<=": + return leftValue <= rightValue ? 1 : 0; + case ">": + return leftValue > rightValue ? 1 : 0; + case "<": + return leftValue < rightValue ? 1 : 0; + case "=": + return leftValue == rightValue ? 1 : 0; + case "!=": + return leftValue != rightValue ? 1 : 0; + default: + throw new ArgumentException($"涓嶆敮鎸佺殑杩愮畻绗�: {op}"); + } + } + + /// <summary> + /// 璁$畻鍖呭惈瀛楁杩愮畻鐨勮〃杈惧紡锛堝锛歠ieldA+fieldB-fieldC*2锛� + /// </summary> + private static decimal CalculateFieldExpression(GridView gridView, int rowHandle, string expression) + { + expression = expression.Trim(); + + // 绠�鍗曠殑琛ㄨ揪寮忚В鏋愬櫒 - 鎸夎繍绠椾紭鍏堢骇澶勭悊 + // 鍏堝鐞嗕箻闄わ紝鍐嶅鐞嗗姞鍑� + + // 鍒嗗壊鍔犲噺杩愮畻 + var addSubTerms = SplitExpression(expression, new[] { '+', '-' }); + decimal result = 0; + char lastOp = '+'; + + foreach (var term in addSubTerms) + { + string cleanTerm = term.Key.Trim(); + char op = term.Value; + + // 澶勭悊涔橀櫎杩愮畻 + decimal termValue = CalculateMultiplyDivide(gridView, rowHandle, cleanTerm); + + if (lastOp == '+') + result += termValue; + else if (lastOp == '-') + result -= termValue; + + lastOp = op; + } + + return result; + } + + /// <summary> + /// 澶勭悊涔橀櫎杩愮畻 + /// </summary> + private static decimal CalculateMultiplyDivide(GridView gridView, int rowHandle, string expression) + { + var mulDivTerms = SplitExpression(expression, new[] { '*', '/' }); + decimal result = 0; + char lastOp = '*'; + bool isFirst = true; + + foreach (var term in mulDivTerms) + { + string cleanTerm = term.Key.Trim(); + char op = term.Value; + + decimal termValue = GetFieldOrNumericValue(gridView, rowHandle, cleanTerm); + + if (isFirst) + { + result = termValue; + isFirst = false; + } + else if (lastOp == '*') + result *= termValue; + else if (lastOp == '/') + result /= termValue; + + lastOp = op; + } + + return result; + } + + /// <summary> + /// 鍒嗗壊琛ㄨ揪寮� + /// </summary> + private static List<KeyValuePair<string, char>> SplitExpression(string expression, char[] operators) + { + var result = new List<KeyValuePair<string, char>>(); + string currentTerm = ""; + + for (int i = 0; i < expression.Length; i++) + { + char c = expression[i]; + + if (operators.Contains(c)) + { + if (!string.IsNullOrEmpty(currentTerm)) + { + result.Add(new KeyValuePair<string, char>(currentTerm, i < expression.Length - 1 ? c : '\0')); + currentTerm = ""; + } + } + else + { + currentTerm += c; + } + } + + if (!string.IsNullOrEmpty(currentTerm)) + { + result.Add(new KeyValuePair<string, char>(currentTerm, '\0')); + } + + return result; + } + + /// <summary> + /// 鑾峰彇瀛楁鍊兼垨鏁板�� + /// </summary> + private static decimal GetFieldOrNumericValue(GridView gridView, int rowHandle, string valueExpression) + { + valueExpression = valueExpression.Trim(); + + // 灏濊瘯瑙f瀽涓烘暟瀛� + if (decimal.TryParse(valueExpression, out decimal numValue)) + { + return numValue; + } + + // 浣滀负瀛楁鍚嶅鐞� + try + { + object cellValue = gridView.GetRowCellValue(rowHandle, valueExpression); + if (cellValue != null && decimal.TryParse(cellValue.ToString(), out decimal fieldValue)) + { + return fieldValue; + } + } + catch + { + // 瀛楁涓嶅瓨鍦ㄦ垨鏃犳硶杞崲涓烘暟瀛� + } + + return 0; // 榛樿鍊� + } + + /// <summary> + /// 妫�鏌ユ槸鍚︽槸甯冨皵鍊兼潯浠� + /// </summary> + private static bool IsBooleanCondition(string condition) + { + string lowerCondition = condition.ToLower(); + return lowerCondition == "true" || lowerCondition == "false" || + lowerCondition == "1" || lowerCondition == "0"; + } + + /// <summary> + /// 甯冨皵鍊煎尮閰嶆鏌� + /// </summary> + private static bool IsBooleanMatch(string value, string condition) + { + // 鏍囧噯鍖栧竷灏斿�� + bool conditionBool = NormalizeBooleanValue(condition); + bool valueBool = NormalizeBooleanValue(value); + + return conditionBool == valueBool; + } + + /// <summary> + /// 鏍囧噯鍖栧竷灏斿�� + /// </summary> + private static bool NormalizeBooleanValue(string value) + { + if (string.IsNullOrEmpty(value)) + return false; + + string lowerValue = value.Trim().ToLower(); + + // 澶勭悊鍚勭鍙兘鐨則rue鍊� + if (lowerValue == "true" || lowerValue == "1" || lowerValue == "鏄�" || lowerValue == "宸插鏍�") + return true; + + // 澶勭悊鍚勭鍙兘鐨刦alse鍊� + if (lowerValue == "false" || lowerValue == "0" || lowerValue == "鍚�" || lowerValue == "鏈鏍�" || lowerValue == "") + return false; + + // 榛樿涓篺alse + return false; + } + + /// <summary> + /// 璁剧疆GridView澶嶉�夋鍒楃偣鍑绘椂鑷姩鍒锋柊鏉′欢姹囨�� + /// 2025-08-15 kyy 鏂板鍏敤鏂规硶 + /// </summary> + /// <param name="gridView">鐩爣GridView鎺т欢</param> + /// <param name="checkboxFieldName">澶嶉�夋瀛楁鍚嶏紙榛樿涓篶hkInt锛�</param> + /// <param name="delayMs">寤惰繜鍒锋柊鏃堕棿锛堟绉掞紝榛樿100ms锛�</param> + public static void SetupCheckboxClickRefresh(DevExpress.XtraGrid.Views.Grid.GridView gridView, string checkboxFieldName = "chkInt", int delayMs = 100) + { + if (gridView == null) return; + + // 娣诲姞榧犳爣鐐瑰嚮浜嬩欢锛屾娴嬪閫夋鍒楃偣鍑� + gridView.MouseDown += (s, e) => + { + var hitInfo = gridView.CalcHitInfo(e.Location); + if (hitInfo.InRowCell && hitInfo.Column?.FieldName == checkboxFieldName) + { + // 澶嶉�夋鍒楄鐐瑰嚮锛屽欢杩熷埛鏂版眹鎬荤‘淇濆�煎凡鏇存柊 + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = delayMs; + timer.Tick += (sender, args) => + { + timer.Stop(); + timer.Dispose(); + RefreshConditionalSummary(gridView); + }; + timer.Start(); + } + }; + } + + /// <summary> + /// 涓�閿缃瓽ridView鏉′欢姹囨�荤殑瀹屾暣鍔熻兘锛堝寘鍚潯浠舵眹鎬�+瀹炴椂鍒锋柊锛� + /// 2025-08-15 kyy 鏂板渚挎嵎鏂规硶 + /// </summary> + /// <param name="gridView">鐩爣GridView鎺т欢</param> + /// <param name="conditionFieldName">鏉′欢瀛楁鍚嶏紙濡俢hkInt锛�</param> + /// <param name="conditionValue">鏉′欢鍊硷紙濡倀rue琛ㄧず閫変腑锛�</param> + /// <param name="summaryColumns">闇�瑕佹眹鎬荤殑鍒楀悕鏁扮粍</param> + /// <param name="enableRealTimeRefresh">鏄惁鍚敤瀹炴椂鍒锋柊锛堥粯璁rue锛�</param> + /// <param name="refreshDelayMs">鍒锋柊寤惰繜鏃堕棿锛堟绉掞紝榛樿100ms锛�</param> + public static void SetupCompleteConditionalSummary(DevExpress.XtraGrid.Views.Grid.GridView gridView, + string conditionFieldName, object conditionValue, string[] summaryColumns, + bool enableRealTimeRefresh = true, int refreshDelayMs = 100) + { + if (gridView == null || summaryColumns == null || summaryColumns.Length == 0) return; + + // 1. 璁剧疆鏉′欢姹囨�� + SetupGridSummaryWithCondition(gridView, conditionFieldName, conditionValue, summaryColumns); + + if (!enableRealTimeRefresh) return; + + // 2. 璁剧疆瀹炴椂鍒锋柊浜嬩欢 + // 鍗曞厓鏍煎�煎彉鍖栦簨浠� + gridView.CellValueChanged += (s, e) => + { + if (e.Column.FieldName == conditionFieldName) + { + RefreshConditionalSummary(gridView); + } + }; + + // 鏁版嵁婧愬彉鍖栦簨浠� + gridView.DataSourceChanged += (s, e) => + { + RefreshConditionalSummary(gridView); + }; + + // 缂栬緫鍣ㄩ殣钘忎簨浠� + gridView.HiddenEditor += (s, e) => + { + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = 50; + timer.Tick += (sender, args) => + { + timer.Stop(); + timer.Dispose(); + RefreshConditionalSummary(gridView); + }; + timer.Start(); + }; + + // 3. 璁剧疆澶嶉�夋鐐瑰嚮鍒锋柊 + SetupCheckboxClickRefresh(gridView, conditionFieldName, refreshDelayMs); + } + + #endregion } @@ -2460,6 +3293,7 @@ return Text.ToString(); } + } /// <summary> diff --git a/DevApp/Gs.DevApp/UserControl/SelectCgMx.Designer.cs b/DevApp/Gs.DevApp/UserControl/SelectCgMx.Designer.cs index dde82b7..c21d7a5 100644 --- a/DevApp/Gs.DevApp/UserControl/SelectCgMx.Designer.cs +++ b/DevApp/Gs.DevApp/UserControl/SelectCgMx.Designer.cs @@ -190,7 +190,7 @@ this.gridColumn3.OptionsColumn.ReadOnly = true; this.gridColumn3.Visible = true; this.gridColumn3.VisibleIndex = 12; - this.gridColumn3.Width = 98; + this.gridColumn3.Width = 82; // // gv_supplierItemCode // @@ -229,7 +229,7 @@ this.gridColumn6.OptionsColumn.ReadOnly = true; this.gridColumn6.Visible = true; this.gridColumn6.VisibleIndex = 8; - this.gridColumn6.Width = 109; + this.gridColumn6.Width = 130; // // gridColumn9 // @@ -240,7 +240,7 @@ this.gridColumn9.OptionsColumn.ReadOnly = true; this.gridColumn9.Visible = true; this.gridColumn9.VisibleIndex = 9; - this.gridColumn9.Width = 39; + this.gridColumn9.Width = 32; // // gridColumn7 // @@ -255,7 +255,7 @@ this.gridColumn7.OptionsColumn.ReadOnly = true; this.gridColumn7.Visible = true; this.gridColumn7.VisibleIndex = 7; - this.gridColumn7.Width = 23; + this.gridColumn7.Width = 138; // // gv_purchaseUnit // @@ -269,7 +269,7 @@ this.gv_purchaseUnit.Tag = "query_a.PURCHASE_UNIT"; this.gv_purchaseUnit.Visible = true; this.gv_purchaseUnit.VisibleIndex = 14; - this.gv_purchaseUnit.Width = 181; + this.gv_purchaseUnit.Width = 154; // // gv_remarks // @@ -283,7 +283,7 @@ this.gv_remarks.Tag = "query_a.REMARKS"; this.gv_remarks.Visible = true; this.gv_remarks.VisibleIndex = 11; - this.gv_remarks.Width = 26; + this.gv_remarks.Width = 20; // // gridColumn5 // @@ -304,7 +304,7 @@ this.gridColumn10.Name = "gridColumn10"; this.gridColumn10.Visible = true; this.gridColumn10.VisibleIndex = 13; - this.gridColumn10.Width = 112; + this.gridColumn10.Width = 94; // // gridColumn2 // @@ -314,7 +314,7 @@ this.gridColumn2.Name = "gridColumn2"; this.gridColumn2.Visible = true; this.gridColumn2.VisibleIndex = 15; - this.gridColumn2.Width = 46; + this.gridColumn2.Width = 37; // // gridColumn4 // @@ -335,7 +335,7 @@ this.gridColumn1.Name = "gridColumn1"; this.gridColumn1.Visible = true; this.gridColumn1.VisibleIndex = 16; - this.gridColumn1.Width = 134; + this.gridColumn1.Width = 113; // // gridColumn8 // @@ -344,7 +344,7 @@ this.gridColumn8.Name = "gridColumn8"; this.gridColumn8.Visible = true; this.gridColumn8.VisibleIndex = 17; - this.gridColumn8.Width = 186; + this.gridColumn8.Width = 159; // // gv_demandDocumentId // @@ -362,7 +362,7 @@ this.gv_sourceDocumentId.Name = "gv_sourceDocumentId"; this.gv_sourceDocumentId.Visible = true; this.gv_sourceDocumentId.VisibleIndex = 18; - this.gv_sourceDocumentId.Width = 79; + this.gv_sourceDocumentId.Width = 91; // // gv_remainingReceivedQty // @@ -371,7 +371,7 @@ this.gv_remainingReceivedQty.Name = "gv_remainingReceivedQty"; this.gv_remainingReceivedQty.Visible = true; this.gv_remainingReceivedQty.VisibleIndex = 10; - this.gv_remainingReceivedQty.Width = 104; + this.gv_remainingReceivedQty.Width = 87; // // panelControl3 // diff --git a/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs b/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs index 31aed7b..e546142 100644 --- a/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs +++ b/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs @@ -31,7 +31,20 @@ this.gridView1.CustomDrawColumnHeader += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomDrawColumnHeader(s, e); }; // 涓篏ridView鐨勯紶鏍囨姮璧蜂簨浠舵坊鍔犲鐞嗘柟娉曪紝瀹炵幇鑷畾涔変氦浜� - this.gridView1.MouseUp += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain, gridView1); }; + this.gridView1.MouseUp += (s, e) => { + Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain, gridView1); + + // 鍏ㄩ��/鍙栨秷鍏ㄩ�夊悗绔嬪嵆鏇存柊姹囨�伙紝缂╃煭寤惰繜鏃堕棿 + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = 80; // 缂╃煭寤惰繜纭繚鎿嶄綔瀹屾垚鍚庣珛鍗冲埛鏂� + timer.Tick += (sender, args) => + { + timer.Stop(); + timer.Dispose(); + UtilityHelper.RefreshConditionalSummary(gridView1); // 浣跨敤鏂扮殑鍒锋柊鏂规硶 + }; + timer.Start(); + }; // 閰嶇疆澶嶉�夊垪鐨勬帓搴忓拰绛涢�夐�夐」锛岀鐢ㄦ帓搴忓拰绛涢�夊姛鑳� this.colChkInt.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; @@ -85,6 +98,15 @@ { getPageList(1); }; + + /// <summary> + /// 鏉′欢姹囨�伙細鍙閫変腑锛堟墦鍕撅級鐨勮杩涜姹囨�� + /// chkInt瀛楁涓簍rue鏃舵墠璁$畻purchaseQty鍜寃ssl鐨勫悎璁� + /// 浣跨敤涓�閿紡鏂规硶锛屽寘鍚潯浠舵眹鎬�+瀹炴椂鍒锋柊鍔熻兘 + /// </summary> + UtilityHelper.SetupCompleteConditionalSummary(gridView1, "chkInt", true, new string[] { "purchaseQty", "wssl" }); + + } /// <summary> -- Gitblit v1.9.3