| | |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.Data; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraGrid.Views.Grid; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | |
| | | // 初始化表单控件 |
| | | InitializeComponent(); |
| | | |
| | | /* #region 自动汇总beg |
| | | gridView1.Columns["purchaseQty"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom; |
| | | gridView1.Columns["yssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom; |
| | | gridView1.Columns["wssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom; |
| | | |
| | | gridView1.CustomSummaryCalculate += (sender, e) => |
| | | { |
| | | GridView view = sender as GridView; |
| | | if (e.SummaryProcess == CustomSummaryProcess.Start) |
| | | { |
| | | // 初始化汇总值 |
| | | e.TotalValue = 0m; |
| | | } |
| | | else if (e.SummaryProcess == CustomSummaryProcess.Calculate) |
| | | { |
| | | // 检查当前行的Status字段是否为1 |
| | | int status = Convert.ToInt32(view.GetListSourceRowCellValue(e.RowHandle, "chkInt")); |
| | | if (status == 1) |
| | | { |
| | | string _colCaption = e.Item.ToString(); |
| | | if (_colCaption.Contains("采购")) |
| | | { |
| | | decimal amount = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "purchaseQty")); |
| | | e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount; |
| | | } |
| | | else if (_colCaption.Contains("已收")) |
| | | { |
| | | decimal amount2 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "yssl")); |
| | | e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount2; |
| | | } |
| | | else if (_colCaption.Contains("未收")) |
| | | { |
| | | decimal amount3 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "wssl")); |
| | | e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount3; |
| | | } |
| | | } |
| | | } |
| | | else if (e.SummaryProcess == CustomSummaryProcess.Finalize) |
| | | { |
| | | // 设置最终汇总值 |
| | | e.TotalValue = e.TotalValue; |
| | | } |
| | | }; |
| | | |
| | | // 添加复选框变化事件,实时更新汇总 |
| | | gridView1.CellValueChanged += (s, e) => |
| | | { |
| | | if (e.Column.FieldName == "chkInt") |
| | | { |
| | | // 复选框值变化时强制刷新汇总 |
| | | gridView1.UpdateSummary(); |
| | | } |
| | | }; |
| | | #endregion |
| | | */ |
| | | |
| | | // 为GridView的列标题绘制事件添加处理方法,使用自定义绘制 |
| | | this.gridView1.CustomDrawColumnHeader += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomDrawColumnHeader(s, e); }; |
| | | |
| | | // 为GridView的鼠标抬起事件添加处理方法,实现自定义交互 |
| | | //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.gridView1.MouseUp += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain, gridView1); }; |
| | | // 配置复选列的排序和筛选选项,禁用排序和筛选功能 |
| | | this.colChkInt.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
| | | this.colChkInt.OptionsFilter.AllowAutoFilter = false; |
| | |
| | | { |
| | | getPageList(1); |
| | | }; |
| | | |
| | | /// <summary> |
| | | /// 条件汇总:只对选中(打勾)的行进行汇总 |
| | | /// chkInt字段为true时才计算purchaseQty和wssl的合计 |
| | | /// 使用一键式方法,包含条件汇总+实时刷新功能 |
| | | /// </summary> |
| | | //UtilityHelper.SetupCompleteConditionalSummary(gridView1, "chkInt", true, new string[] { "purchaseQty", "wssl" }); |
| | | |
| | | |
| | | } |
| | | |