BaoKai_202508-Wms-Jingwang..../WMS.Ctrl/DevExpressCustom/FrmGroupList.cs

113 lines
3.7 KiB
C#
Raw Permalink Normal View History

2025-08-24 09:35:55 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
namespace WMS.Ctrl
{
public partial class FrmGroupList : Form
{
#region
#endregion
#region
/// <summary>
/// 构造函数
/// </summary>
public FrmGroupList(DataTable myGroupDTable)
{
InitializeComponent();
LoadGroupList(myGroupDTable);
}
#endregion
#region
/// <summary>
/// 导出
/// </summary>
private void bExport_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
this.gridControl1.ShowExportDialog();
this.Cursor = Cursors.Default;
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
}
}
#endregion
#region
/// <summary>
/// 汇总明细(列表)
/// </summary>
private void LoadGroupList(DataTable myGroupDTable)
{
WaitDialogForm wdf = null;
try
{
this.Cursor = Cursors.WaitCursor;
wdf = new WaitDialogForm("......", "正在加载");
//绑定数据
this.gridView1.Columns.Clear();
this.gridControl1.DataSource = myGroupDTable;
//设置列属性
for (int col = 0; col < this.gridView1.Columns.Count; col++)
{
string caption = this.gridView1.Columns[col].GetTextCaption();
if (caption.StartsWith("*") == true)
{
this.gridView1.Columns[col].DisplayFormat.FormatType = FormatType.Numeric;
this.gridView1.Columns[col].DisplayFormat.FormatString = "n2";
this.gridView1.Columns[col].GroupFormat.FormatType = FormatType.Numeric;
this.gridView1.Columns[col].GroupFormat.FormatString = "n2";
this.gridView1.Columns[col].Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, caption, "{0:n2}")});
}
else if (caption == "#统计行数")
{
this.gridView1.Columns[col].DisplayFormat.FormatType = FormatType.Numeric;
this.gridView1.Columns[col].DisplayFormat.FormatString = "n0";
this.gridView1.Columns[col].GroupFormat.FormatType = FormatType.Numeric;
this.gridView1.Columns[col].GroupFormat.FormatString = "n0";
this.gridView1.Columns[col].Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, caption, "{0:n0}")});
}
}
if (this.gridView1.RowCount <= 100)
{
this.gridView1.BestFitColumns();
}
this.gridView1.RefreshData();
if (wdf != null) wdf.Close();
this.Cursor = Cursors.Default;
}
catch (Exception ex)
{
if (wdf != null) wdf.Close();
this.Cursor = Cursors.Default;
}
}
#endregion
}
}