288 lines
11 KiB
C#
288 lines
11 KiB
C#
using BLL;
|
|
using FineUIPro.Web.Controls;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingReport
|
|
{
|
|
public partial class ArriveStatic : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
//BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定BindGrid
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private DataTable tb = null;
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string sql = @"select WorkAreaId+'|'+ISO_ID id,
|
|
(select WorkAreaCode from ProjectData_WorkArea where WorkAreaId=CL_PMaterialS.WorkAreaId) as WorkAreaCode
|
|
,Pipeline
|
|
,sum(ppquantity)/sum(quantity) as dhl --到货率
|
|
,(select count(*) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID ) as hks --总焊口数
|
|
,(select count(*) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID and (DReportID is not null and DReportID<>'')) as yhs --已焊数
|
|
,isnull((select count(*) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID and (DReportID is null or DReportID='')),0) as whs --未焊数
|
|
,(select sum(JOT_Size) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID) as dys --总达因数
|
|
,(select sum(JOT_Size) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID and (DReportID is not null and DReportID<>'')) as ydy --完成达因数
|
|
,isnull((select sum(JOT_Size) from PW_JointInfo where ISO_ID=CL_PMaterialS.ISO_ID and (DReportID is null or DReportID='')),0) as wdy --完成达因数
|
|
,sum(quantity) as zquantity
|
|
,sum(ppquantity) as zppquantity
|
|
,ProjectId
|
|
,ISO_ID
|
|
from CL_PMaterialS
|
|
group by ISO_ID
|
|
,Pipeline
|
|
,ProjectId
|
|
,WorkAreaId
|
|
having ProjectId='" + this.CurrUser.LoginProjectId + "' order by WorkAreaId,Pipeline";
|
|
//List<SqlParameter> listStr = new List<SqlParameter>
|
|
//{
|
|
// new SqlParameter("@projectId", this.CurrUser.LoginProjectId)
|
|
//};
|
|
|
|
//SqlParameter[] parameter = listStr.ToArray();
|
|
tb = SQLHelper.GetDataTableRunText(sql, null);
|
|
if (tb != null)
|
|
{
|
|
tb.Columns.Add("dhlregion");
|
|
foreach (DataRow row in tb.Rows)
|
|
{
|
|
double dhl = 0;
|
|
double.TryParse(row["dhl"].ToString(), out dhl);
|
|
if (dhl >= 1.0)
|
|
row["dhlregion"] = "100%";
|
|
else if (dhl >= 0.9)
|
|
row["dhlregion"] = "90%-100%";
|
|
else if (dhl >= 0.8)
|
|
row["dhlregion"] = "80%-90%";
|
|
else if (dhl >= 0.7)
|
|
row["dhlregion"] = "70%-80%";
|
|
else if (dhl >= 0.6)
|
|
row["dhlregion"] = "60%-70%";
|
|
else if (dhl >= 0.5)
|
|
row["dhlregion"] = "50%-60%";
|
|
else if (dhl >= 0.4)
|
|
row["dhlregion"] = "40%-50%";
|
|
else if (dhl >= 0.3)
|
|
row["dhlregion"] = "30%-40%";
|
|
else if (dhl >= 0.2)
|
|
row["dhlregion"] = "20%-30%";
|
|
else if (dhl >= 0.1)
|
|
row["dhlregion"] = "10%-20%";
|
|
else
|
|
row["dhlregion"] = "0%-10%";
|
|
|
|
}
|
|
}
|
|
FilteredTable filteredTable = new FilteredTable();
|
|
filteredTable.FilterDataRowItem = FilterDataRowItemImplement;
|
|
|
|
tb = filteredTable.GetFilteredTable(Grid1.FilteredData, tb);
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, JToken fillteredObj, string column)
|
|
{
|
|
bool valid = false;
|
|
|
|
// if (column == "Name")
|
|
{
|
|
string sourceValue = sourceObj.ToString();
|
|
string fillteredValue = fillteredObj.Value<string>();
|
|
if (fillteredOperator == "equal")
|
|
{
|
|
if (sourceValue == fillteredValue)
|
|
{
|
|
valid = true;
|
|
}
|
|
}
|
|
else if (fillteredOperator == "contain")
|
|
{
|
|
if (sourceValue.Contains(fillteredValue))
|
|
{
|
|
valid = true;
|
|
}
|
|
}
|
|
else if (fillteredOperator == "start")
|
|
{
|
|
if (sourceValue.StartsWith(fillteredValue))
|
|
{
|
|
valid = true;
|
|
}
|
|
}
|
|
else if (fillteredOperator == "end")
|
|
{
|
|
if (sourceValue.EndsWith(fillteredValue))
|
|
{
|
|
valid = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return valid;
|
|
}
|
|
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
|
|
}
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 统计按钮事件
|
|
/// <summary>
|
|
/// 统计
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ArriveDetail.aspx?ISO_ID={0}", Grid1.SelectedRowID.Split('|')[1], "编辑 - ")));
|
|
|
|
|
|
}
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("探伤综合报告" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
grid.PageSize = this.Grid1.RecordCount;
|
|
BindGrid();
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber")
|
|
{
|
|
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
|
}
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
var sumary = grid.SummaryData;
|
|
if (sumary != null)
|
|
{
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
try
|
|
{
|
|
if (sumary.ContainsKey(column.ColumnID))
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", sumary.GetValue(column.ColumnID).ToString());
|
|
}
|
|
else
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", "");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", "");
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |