131 lines
4.4 KiB
C#
131 lines
4.4 KiB
C#
|
|
using BLL;
|
|||
|
|
using Newtonsoft.Json.Linq;
|
|||
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace FineUIPro.Web.DigData
|
|||
|
|
{
|
|||
|
|
public partial class TrainRecordAnalysis : PageBase
|
|||
|
|
{
|
|||
|
|
#region 加载
|
|||
|
|
/// <summary>
|
|||
|
|
/// 加载页面
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
ProjectService.InitProjectDropDownList(this.drpProject, false);
|
|||
|
|
Funs.FineUIPleaseSelect(drpProject, "请选择项目");
|
|||
|
|
TrainTypeService.InitTrainTypeDropDownList(this.drpTrainType, false);
|
|||
|
|
Funs.FineUIPleaseSelect(drpTrainType, "请选择培训类型");
|
|||
|
|
// 绑定表格
|
|||
|
|
this.BindGrid();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 绑定数据Grid1
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定数据Grid1
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindGrid()
|
|||
|
|
{
|
|||
|
|
var getData = ProblemAnalysisService.getTrainRecordData(this.rblType.SelectedValue, this.drpProject.SelectedValue, this.drpTrainType.SelectedValue,
|
|||
|
|
Funs.GetNewDateTime(this.txtStartTime.Text), Funs.GetNewDateTime(this.txtEndTime.Text));
|
|||
|
|
DataTable tb = this.LINQToDataTable(getData);
|
|||
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
|
Grid1.DataSource = table;
|
|||
|
|
Grid1.DataBind();
|
|||
|
|
this.OutputSummaryData(tb); ///取合计值
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 计算合计
|
|||
|
|
/// </summary>
|
|||
|
|
private void OutputSummaryData(DataTable tb)
|
|||
|
|
{
|
|||
|
|
int allCount = 0, okCount = 0, unCount = 0, aumberV = 0;
|
|||
|
|
string rate = "0%";
|
|||
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
aumberV += Funs.GetNewIntOrZero(tb.Rows[i]["NumberV"].ToString());
|
|||
|
|
allCount += Funs.GetNewIntOrZero(tb.Rows[i]["AllCount"].ToString());
|
|||
|
|
okCount += Funs.GetNewIntOrZero(tb.Rows[i]["OkCount"].ToString());
|
|||
|
|
unCount += Funs.GetNewIntOrZero(tb.Rows[i]["UnCount"].ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (allCount > 0)
|
|||
|
|
{
|
|||
|
|
rate = Math.Round(okCount * 1.0 / allCount * 100, 1).ToString() + "%";
|
|||
|
|
}
|
|||
|
|
JObject summary = new JObject
|
|||
|
|
{
|
|||
|
|
{ "Name", "合计" },
|
|||
|
|
{ "NumberV", aumberV.ToString() },
|
|||
|
|
{ "AllCount", allCount.ToString() },
|
|||
|
|
{ "OkCount", okCount.ToString() },
|
|||
|
|
{ "UnCount", unCount.ToString() },
|
|||
|
|
{ "Rate", rate}
|
|||
|
|
};
|
|||
|
|
Grid1.SummaryData = summary;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排序
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|||
|
|
{
|
|||
|
|
BindGrid();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 查询
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.BindGrid();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void btSearch_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.BindGrid();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#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("HSE教育培训" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|||
|
|
Response.ContentType = "application/excel";
|
|||
|
|
Response.ContentEncoding = Encoding.UTF8;
|
|||
|
|
this.Grid1.PageSize = this.Grid1.RecordCount;
|
|||
|
|
this.BindGrid();
|
|||
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|||
|
|
Response.End();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|