239 lines
8.2 KiB
C#
239 lines
8.2 KiB
C#
using BLL;
|
|
using FineUIPro.Web.Controls;
|
|
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 PointTrustCheckTaskList : 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);
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnitId, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
|
|
Funs.FineUIPleaseSelect(this.drpWorkAreaId);
|
|
BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpNDTType, true);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定BindGrid
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private DataTable tb = null;
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
List<SqlParameter> listStr = new List<SqlParameter>
|
|
{
|
|
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));
|
|
}
|
|
if (this.drpWorkAreaId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@workAreaId", this.drpWorkAreaId.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@workAreaId", null));
|
|
}
|
|
if (this.drpNDTType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@ndtMethod", this.drpNDTType.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@ndtMethod", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
|
{
|
|
listStr.Add(new SqlParameter("@startDate",Funs.GetNewDateTime(this.txtStartDate.Text)));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@startDate", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndDate.Text))
|
|
{
|
|
listStr.Add(new SqlParameter("@endDate", Funs.GetNewDateTime(this.txtEndDate.Text)));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@endDate", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
tb = SQLHelper.GetDataTableRunProc("sp_rpt_PointTrustCheckTaskList", parameter);
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(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 BtnAnalyse_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#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("现场点口、委托检测任务单" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
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("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
|
|
foreach (List<object[]> rows in mht.MultiTable)
|
|
{
|
|
sb.Append("<tr>");
|
|
foreach (object[] cell in rows)
|
|
{
|
|
int rowspan = Convert.ToInt32(cell[0]);
|
|
int colspan = Convert.ToInt32(cell[1]);
|
|
GridColumn column = cell[2] as GridColumn;
|
|
if (!column.Hidden)
|
|
{
|
|
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
|
|
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
|
|
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
|
|
colspan != 1 ? " style=\"text-align:center;\"" : "",
|
|
column.HeaderText);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
int j = 0;
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
sb.Append("<tr>");
|
|
int i = 0;
|
|
foreach (GridColumn column in mht.Columns)
|
|
{
|
|
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
|
|
if (column.ColumnID == "tfNumber")
|
|
{
|
|
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
|
}
|
|
|
|
sb.AppendFormat("<td style=\"text-align:center;\">{0}</td>", html);
|
|
i++;
|
|
}
|
|
j++;
|
|
sb.Append("</tr>");
|
|
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region DropDownList 下拉选择
|
|
/// <summary>
|
|
/// 根据单位加载区域
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpWorkAreaId.Items.Clear();
|
|
if (this.drpUnitId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnitId.SelectedValue))
|
|
{
|
|
BLL.WorkAreaService.InitWorkAreaProjectUnitDropDownList(this.drpWorkAreaId, this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, true);
|
|
this.drpWorkAreaId.SelectedIndex = 0;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |