141 lines
4.4 KiB
C#
141 lines
4.4 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace FineUIPro.Web.DigData
|
|
{
|
|
public partial class HSEDataDW : 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);
|
|
ProjectService.InitProjectDropDownList(this.drpProject, false);
|
|
Funs.FineUIPleaseSelect(drpProject, "请选择项目");
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据Grid1
|
|
/// <summary>
|
|
/// 绑定数据Grid1
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
var getData = HSEDataDWService.getDataDWList(this.drpProject.SelectedValue,
|
|
Funs.GetNewDateTime(this.txtStartTime.Text), Funs.GetNewDateTime(this.txtEndTime.Text), this.Grid1);
|
|
Grid1.RecordCount = HSEDataDWService.count;
|
|
Grid1.DataSource = getData;
|
|
Grid1.DataBind();
|
|
this.OutputSummaryData(); ///取合计值
|
|
}
|
|
|
|
/// <summary>
|
|
/// 计算合计
|
|
/// </summary>
|
|
private void OutputSummaryData()
|
|
{
|
|
int aCount1 = 0, aCount2 = 0, aCount3 = 0;
|
|
for (int i = 0; i < Grid1.Rows.Count(); i++)
|
|
{
|
|
aCount1 += Funs.GetNewIntOrZero(Grid1.Rows[i].Values[3].ToString());
|
|
aCount2 += Funs.GetNewIntOrZero(Grid1.Rows[i].Values[4].ToString());
|
|
aCount3 += Funs.GetNewIntOrZero(Grid1.Rows[i].Values[5].ToString());
|
|
}
|
|
|
|
JObject summary = new JObject
|
|
{
|
|
{ "ProjectName", "合计" },
|
|
{ "Count1", aCount1.ToString() },
|
|
{ "Count2", aCount2.ToString() },
|
|
{ "Count3", aCount3.ToString() },
|
|
};
|
|
Grid1.SummaryData = summary;
|
|
}
|
|
|
|
|
|
/// <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)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.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 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
|
|
}
|
|
} |