113 lines
3.7 KiB
C#
113 lines
3.7 KiB
C#
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
|
|
|
|
}
|
|
}
|