using BLL; using Newtonsoft.Json.Linq; using System; using System.Linq; using System.Text; namespace FineUIPro.Web.DigData { public partial class HSEDataDW : PageBase { #region 加载 /// /// 加载页面 /// /// /// 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 /// /// 绑定数据Grid1 /// 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(); ///取合计值 } /// /// 计算合计 /// 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; } /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { this.BindGrid(); } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion /// /// 查询 /// /// /// protected void btSearch_Click(object sender, EventArgs e) { this.BindGrid(); } #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("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 } }