using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; using BLL; using Newtonsoft.Json.Linq; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.HJGL.WeldingReport { public partial class WelderCheckStatistic : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); var pUnit = BLL.Base_UnitService.GetUnitsByProjectUnitType(this.CurrUser.LoginProjectId, BLL.Const.UnitType_4); ///单位 this.drpUnit.DataTextField = "UnitName"; this.drpUnit.DataValueField = "UnitId"; this.drpUnit.DataSource = pUnit; this.drpUnit.DataBind(); Funs.FineUIPleaseSelect(this.drpUnit); ///项目 this.drpProject.DataTextField = "ProjectCode"; this.drpProject.DataValueField = "ProjectId"; this.drpProject.DataSource = BLL.Base_ProjectService.GetProjectListByUserId(this.CurrUser.UserId, "1"); this.drpProject.DataBind(); Funs.FineUIPleaseSelect(this.drpProject); this.drpProject.SelectedValue = this.CurrUser.LoginProjectId; Funs.FineUIPleaseSelect(this.drpWloName); } } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { List listStr = new List(); if (this.drpUnit.SelectedValue != BLL.Const._Null) { listStr.Add(new SqlParameter("@unitcode", this.drpUnit.SelectedValue)); } else { listStr.Add(new SqlParameter("@unitcode", null)); } //if (this.drpWorkArea.SelectedValue != BLL.Const._Null) //{ // listStr.Add(new SqlParameter("@workareacode", this.drpWorkArea.SelectedValue)); //} //else //{ // listStr.Add(new SqlParameter("@workareacode", null)); //} if (this.drpWloName.SelectedValue != BLL.Const._Null) { listStr.Add(new SqlParameter("@WED_ID", this.drpWloName.SelectedValue)); } else { listStr.Add(new SqlParameter("@WED_ID", null)); } if (this.drpProject.SelectedValue != BLL.Const._Null) { listStr.Add(new SqlParameter("@projectId", this.drpProject.SelectedValue)); } else { listStr.Add(new SqlParameter("@projectId", null)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunProc("HJGL_sp_rpt_welderStatistics", parameter); this.Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { this.BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue); this.BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { this.BindGrid(); } #endregion #region 统计按钮事件 /// /// 统计 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { BindGrid(); } #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(); sb.Append(""); sb.Append(""); sb.Append(""); foreach (GridColumn column in grid.Columns) { sb.AppendFormat("", column.HeaderText); } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); 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("", html); } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } #endregion #region 下拉框联动事件 /// /// 项目下拉框变化事件 /// /// /// protected void drpProject_OnSelectedIndexChanged(object sender, EventArgs e) { this.drpUnit.Items.Clear(); ///单位 this.drpWloName.Items.Clear(); ///焊工 if (this.drpProject.SelectedValue != BLL.Const._Null) { var pUnit = BLL.Base_UnitService.GetUnitsByProjectUnitType(this.drpProject.SelectedValue, BLL.Const.UnitType_4); this.drpUnit.DataSource = pUnit; this.drpUnit.DataBind(); } Funs.FineUIPleaseSelect(this.drpUnit); this.drpUnit.SelectedValue = BLL.Const._Null; Funs.FineUIPleaseSelect(this.drpWloName); this.drpWloName.SelectedValue = BLL.Const._Null; } /// /// 单位下拉框变化事件 /// /// /// protected void drpUnit_OnSelectedIndexChanged(object sender, EventArgs e) { this.drpWloName.Items.Clear(); ///焊工 if (this.drpUnit.SelectedValue != BLL.Const._Null) { this.drpWloName.DataTextField = "Text"; this.drpWloName.DataValueField = "Value"; this.drpWloName.DataSource = BLL.HJGL_PersonManageService.GetProjectWelderCodeListByUnitId(this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue); this.drpWloName.DataBind(); } Funs.FineUIPleaseSelect(this.drpWloName); this.drpWloName.SelectedValue = BLL.Const._Null; } #endregion } }