11
This commit is contained in:
@@ -115,9 +115,7 @@
|
||||
EnableTextSelection="True" AllowColumnLocking="true">
|
||||
<Columns>
|
||||
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号" Width="60px" HeaderTextAlign="Center" TextAlign="Center"/>
|
||||
<f:RenderField Width="100px" HeaderText="管线号" ColumnID="pipe_no" DataField="pipe_no"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
|
||||
<f:RenderField Width="100px" HeaderText="图号" ColumnID="drawing_number" DataField="drawing_number"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
@@ -144,7 +142,7 @@
|
||||
</f:RegionPanel>
|
||||
</Items>
|
||||
</f:Tab>
|
||||
|
||||
|
||||
<f:Tab Title="管道材料表" BodyPadding="10px" Layout="Fit" runat="server">
|
||||
<Items>
|
||||
<f:RegionPanel ID="RegionPanel3" ShowBorder="false" runat="server" Margin="5px">
|
||||
@@ -189,10 +187,59 @@
|
||||
</f:Grid>
|
||||
</Items>
|
||||
</f:Region>
|
||||
|
||||
|
||||
|
||||
</Regions>
|
||||
</f:RegionPanel>
|
||||
</Items>
|
||||
</f:Tab>
|
||||
|
||||
|
||||
<f:Tab Title="材料汇总表" BodyPadding="10px" Layout="Fit" runat="server">
|
||||
<Items>
|
||||
<f:RegionPanel ID="RegionPanel4" ShowBorder="false" runat="server" Margin="5px">
|
||||
<Toolbars>
|
||||
<f:Toolbar ID="Toolbar5" Position="Top" runat="server" ToolbarAlign="Right">
|
||||
<Items>
|
||||
<f:Button ID="btnOut4" OnClick="btnOut4_Click" runat="server" Text="导出" Icon="TableGo"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
</Items>
|
||||
</f:Toolbar>
|
||||
</Toolbars>
|
||||
<Regions>
|
||||
<f:Region ID="Region5" ShowBorder="false" ShowHeader="false" Position="Center"
|
||||
AutoScroll="true" EnableAjax="true" MinHeight="100px"
|
||||
BoxConfigAlign="Stretch" BoxConfigPosition="Left" runat="server">
|
||||
<Items>
|
||||
<f:Grid ID="Grid4" ShowBorder="true" ShowHeader="false" Title="按类型、规格、描述汇总数量" EnableCollapse="true"
|
||||
runat="server" BoxFlex="1" DataKeyNames="id" EnableColumnLines="true" DataIDField="id"
|
||||
EnableTextSelection="True" AllowColumnLocking="true">
|
||||
<Columns>
|
||||
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号" Width="60px" HeaderTextAlign="Center" TextAlign="Center"/>
|
||||
<f:RenderField Width="100px" HeaderText="类型" ColumnID="category" DataField="category"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="100px" HeaderText="规格" ColumnID="spec" DataField="spec"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="100px" HeaderText="汇总数量" ColumnID="qty" DataField="qty"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="100px" HeaderText="描述" ColumnID="description" DataField="description" ExpandUnusedSpace="true"
|
||||
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
|
||||
</f:RenderField>
|
||||
</Columns>
|
||||
</f:Grid>
|
||||
</Items>
|
||||
</f:Region>
|
||||
|
||||
|
||||
</Regions>
|
||||
</f:RegionPanel>
|
||||
</Items>
|
||||
</f:Tab>
|
||||
</Tabs>
|
||||
</f:TabStrip>
|
||||
|
||||
|
||||
@@ -426,11 +426,139 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
Grid1.DataSource = dt;
|
||||
Grid1.DataBind();
|
||||
|
||||
Grid2.DataSource = dt;
|
||||
// Grid2: 按图号合并 — 图号、类型、规格、描述相同的,数量累加
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
DataTable dtGroupByDrawing = new DataTable();
|
||||
dtGroupByDrawing.Columns.Add("id");
|
||||
dtGroupByDrawing.Columns.Add("drawing_number");
|
||||
dtGroupByDrawing.Columns.Add("category");
|
||||
dtGroupByDrawing.Columns.Add("spec");
|
||||
dtGroupByDrawing.Columns.Add("qty");
|
||||
dtGroupByDrawing.Columns.Add("description");
|
||||
var groups2 = dt.AsEnumerable()
|
||||
.GroupBy(r => new
|
||||
{
|
||||
drawing_number = r.Field<string>("drawing_number") ?? "",
|
||||
category = r.Field<string>("category") ?? "",
|
||||
spec = r.Field<string>("spec") ?? "",
|
||||
description = r.Field<string>("description") ?? ""
|
||||
})
|
||||
.Select(g => new
|
||||
{
|
||||
g.Key.drawing_number,
|
||||
g.Key.category,
|
||||
g.Key.spec,
|
||||
g.Key.description,
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty")))
|
||||
});
|
||||
foreach (var g in groups2)
|
||||
{
|
||||
DataRow newRow = dtGroupByDrawing.NewRow();
|
||||
newRow["id"] = Guid.NewGuid().ToString();
|
||||
newRow["drawing_number"] = g.drawing_number;
|
||||
newRow["category"] = g.category;
|
||||
newRow["spec"] = g.spec;
|
||||
newRow["qty"] = g.qty;
|
||||
newRow["description"] = g.description;
|
||||
dtGroupByDrawing.Rows.Add(newRow);
|
||||
}
|
||||
Grid2.DataSource = dtGroupByDrawing;
|
||||
}
|
||||
else
|
||||
{
|
||||
Grid2.DataSource = null;
|
||||
}
|
||||
Grid2.DataBind();
|
||||
|
||||
Grid3.DataSource = dt;
|
||||
// Grid3: 按管线号合并 — 类型、规格、描述相同的,数量累加(不展示图号)
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
DataTable dtGroupByPipe = new DataTable();
|
||||
dtGroupByPipe.Columns.Add("id");
|
||||
dtGroupByPipe.Columns.Add("pipe_no");
|
||||
dtGroupByPipe.Columns.Add("category");
|
||||
dtGroupByPipe.Columns.Add("spec");
|
||||
dtGroupByPipe.Columns.Add("qty");
|
||||
dtGroupByPipe.Columns.Add("description");
|
||||
var groups3 = dt.AsEnumerable()
|
||||
.GroupBy(r => new
|
||||
{
|
||||
pipe_no = r.Field<string>("pipe_no") ?? "",
|
||||
category = r.Field<string>("category") ?? "",
|
||||
spec = r.Field<string>("spec") ?? "",
|
||||
description = r.Field<string>("description") ?? ""
|
||||
})
|
||||
.Select(g => new
|
||||
{
|
||||
g.Key.pipe_no,
|
||||
g.Key.category,
|
||||
g.Key.spec,
|
||||
g.Key.description,
|
||||
qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field<string>("qty")))
|
||||
});
|
||||
foreach (var g in groups3)
|
||||
{
|
||||
DataRow newRow = dtGroupByPipe.NewRow();
|
||||
newRow["id"] = Guid.NewGuid().ToString();
|
||||
newRow["pipe_no"] = g.pipe_no;
|
||||
newRow["category"] = g.category;
|
||||
newRow["spec"] = g.spec;
|
||||
newRow["qty"] = g.qty;
|
||||
newRow["description"] = g.description;
|
||||
dtGroupByPipe.Rows.Add(newRow);
|
||||
}
|
||||
Grid3.DataSource = dtGroupByPipe;
|
||||
}
|
||||
else
|
||||
{
|
||||
Grid3.DataSource = null;
|
||||
}
|
||||
Grid3.DataBind();
|
||||
|
||||
// 材料汇总表:按类型、规格、描述汇总数量
|
||||
|
||||
DataTable dtSummary = new DataTable();
|
||||
dtSummary.Columns.Add("id");
|
||||
dtSummary.Columns.Add("category");
|
||||
dtSummary.Columns.Add("spec");
|
||||
dtSummary.Columns.Add("qty");
|
||||
dtSummary.Columns.Add("description");
|
||||
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
var groups = dt.AsEnumerable()
|
||||
.GroupBy(r => new
|
||||
{
|
||||
cat = r["category"].ToString().Trim(),
|
||||
sp = r["spec"].ToString().Trim(),
|
||||
desc = r["description"].ToString().Trim()
|
||||
})
|
||||
.OrderBy(g => g.Key.cat)
|
||||
.ThenBy(g => g.Key.sp);
|
||||
|
||||
int idx = 1;
|
||||
foreach (var g in groups)
|
||||
{
|
||||
var row = dtSummary.NewRow();
|
||||
row["id"] = idx++;
|
||||
row["category"] = g.Key.cat;
|
||||
row["spec"] = g.Key.sp;
|
||||
row["description"] = g.Key.desc;
|
||||
|
||||
decimal totalQty = 0;
|
||||
foreach (var r in g)
|
||||
{
|
||||
if (decimal.TryParse(r["qty"].ToString(), out decimal qty))
|
||||
totalQty += qty;
|
||||
}
|
||||
row["qty"] = totalQty.ToString();
|
||||
dtSummary.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
Grid4.DataSource = dtSummary;
|
||||
Grid4.DataBind();
|
||||
}
|
||||
#region 双击事件
|
||||
/// <summary>
|
||||
@@ -471,6 +599,22 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
}
|
||||
|
||||
#region 导出按钮
|
||||
/// <summary>
|
||||
/// 从URL中获取文件名(不含扩展名)
|
||||
/// </summary>
|
||||
private string GetUrlFileName()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(URL))
|
||||
{
|
||||
try
|
||||
{
|
||||
return System.IO.Path.GetFileNameWithoutExtension(URL);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出材料表
|
||||
/// </summary>
|
||||
@@ -480,7 +624,8 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
{
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
string prefix = GetUrlFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
@@ -496,7 +641,8 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
{
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("图纸材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
string prefix = GetUrlFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "图纸材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
Response.Write(GetGridTableHtml(Grid2));
|
||||
@@ -512,13 +658,31 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
{
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("管道材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
string prefix = GetUrlFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "管道材料表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
Response.Write(GetGridTableHtml(Grid3));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出材料汇总表
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut4_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
string prefix = GetUrlFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(prefix + "材料汇总表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
Response.Write(GetGridTableHtml(Grid4));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出方法
|
||||
/// </summary>
|
||||
|
||||
+63
@@ -239,6 +239,69 @@ namespace FineUIPro.Web.HJGL.DataIn
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Grid Grid3;
|
||||
|
||||
/// <summary>
|
||||
/// RegionPanel4 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.RegionPanel RegionPanel4;
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar5 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Toolbar Toolbar5;
|
||||
|
||||
/// <summary>
|
||||
/// Button1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button Button1;
|
||||
|
||||
/// <summary>
|
||||
/// Region5 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Region Region5;
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar6 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Toolbar Toolbar6;
|
||||
|
||||
/// <summary>
|
||||
/// btnOut4 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnOut4;
|
||||
|
||||
/// <summary>
|
||||
/// Grid4 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Grid Grid4;
|
||||
|
||||
/// <summary>
|
||||
/// Window1 控件。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user