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 WelderDynamicStatistics : PageBase
{
#region 加载
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnitId, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
}
}
#endregion
#region 绑定BindGrid
///
///
///
private DataTable tb = null;
///
/// 绑定数据
///
private void BindGrid()
{
List listStr = new List
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId)
};
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@unitId", this.drpUnitId.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@unitId", null));
}
SqlParameter[] parameter = listStr.ToArray();
tb = SQLHelper.GetDataTableRunProc("sp_rpt_WelderDynamicStatistics", parameter);
this.Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
///
/// 改变索引事件
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
///
/// 分页下拉选择事件
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
#region 计算合计
///
/// 计算合计
///
protected void OutputSummaryData()
{
if (tb != null)
{
int total_count = 0;//报考总人数
int PD_wait_exam_count = 0;//管道(人数)待考试
int PD_qualified_duty_count = 0;////管道(人数)合格在岗
int PD_qualified_leave_count = 0;////管道(人数)合格离岗
int FE_wait_exam_count = 0;//设备(人数)待考试
int FE_qualified_duty_count = 0;////设备(人数)合格在岗
int FE_qualified_leave_count = 0;////设备(人数)合格离岗
int JG_wait_exam_count = 0;//钢结构(人数)待考试
int JG_qualified_duty_count = 0;////钢结构(人数)合格在岗
int JG_qualified_leave_count = 0;////钢结构(人数)合格离岗
int TJ_wait_exam_count = 0;//土建(人数)待考试
int TJ_qualified_duty_count = 0;////土建(人数)合格在岗
int TJ_qualified_leave_count = 0;////土建(人数)合格离岗
foreach (DataRow row in tb.Rows)
{
total_count += Funs.GetNewIntOrZero(row["total_count"].ToString());
PD_wait_exam_count += Funs.GetNewIntOrZero(row["PD_wait_exam_count"].ToString());
PD_qualified_duty_count += Funs.GetNewIntOrZero(row["PD_qualified_duty_count"].ToString());
PD_qualified_leave_count += Funs.GetNewIntOrZero(row["PD_qualified_leave_count"].ToString());
FE_wait_exam_count += Funs.GetNewIntOrZero(row["FE_wait_exam_count"].ToString());
FE_qualified_duty_count += Funs.GetNewIntOrZero(row["FE_qualified_duty_count"].ToString());
FE_qualified_leave_count += Funs.GetNewIntOrZero(row["FE_qualified_leave_count"].ToString());
JG_wait_exam_count += Funs.GetNewIntOrZero(row["JG_wait_exam_count"].ToString());
JG_qualified_duty_count += Funs.GetNewIntOrZero(row["JG_qualified_duty_count"].ToString());
JG_qualified_leave_count += Funs.GetNewIntOrZero(row["JG_qualified_leave_count"].ToString());
TJ_wait_exam_count += Funs.GetNewIntOrZero(row["TJ_wait_exam_count"].ToString());
TJ_qualified_duty_count += Funs.GetNewIntOrZero(row["TJ_qualified_duty_count"].ToString());
TJ_qualified_leave_count += Funs.GetNewIntOrZero(row["TJ_qualified_leave_count"].ToString());
}
JObject summary = new JObject
{
{ "UnitName", "合计:" },
{ "total_count", total_count },
{"PD_wait_exam_count",PD_wait_exam_count },
{"PD_qualified_duty_count",PD_qualified_duty_count },
{"PD_qualified_leave_count",PD_qualified_leave_count },
{"FE_wait_exam_count",FE_wait_exam_count },
{"FE_qualified_duty_count",FE_qualified_duty_count },
{"FE_qualified_leave_count",FE_qualified_leave_count },
{"JG_wait_exam_count",JG_wait_exam_count },
{"JG_qualified_duty_count",JG_qualified_duty_count },
{"JG_qualified_leave_count",JG_qualified_leave_count },
{"TJ_wait_exam_count",TJ_wait_exam_count },
{"TJ_qualified_duty_count",TJ_qualified_duty_count },
{"TJ_qualified_leave_count",TJ_qualified_leave_count },
};
Grid1.SummaryData = summary;
}
}
#endregion
#region 统计按钮事件
///
/// 统计
///
///
///
protected void BtnAnalyse_Click(object sender, EventArgs e)
{
BindGrid();
OutputSummaryData();
}
#endregion
#region 导出按钮
/// 导出按钮
///
///
///
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();
}
///
/// 导出方法
///
///
///
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
grid.PageSize = this.Grid1.RecordCount;
BindGrid();
MultiHeaderTable mht = new MultiHeaderTable();
mht.ResolveMultiHeaderTable(Grid1.Columns);
sb.Append("");
sb.Append("");
foreach (List
");
return sb.ToString();
}
#endregion
}
}