using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BLL;
namespace FineUIPro.Web.HJGL.WeldingReport
{
public partial class InspectionBatchItem : PageBase
{
///
/// 批次
///
public string BatchId
{
get
{
return (string)ViewState["BatchId"];
}
set
{
ViewState["BatchId"] = value;
}
}
#region 加载页面
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BatchId = Request.Params["BatchId"];
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetProjectListByUserId(this.CurrUser.UserId, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
this.drpNdtType.DataTextField = "NDT_Code";
this.drpNdtType.DataValueField = "NDT_ID";
this.drpNdtType.DataSource = BLL.HJGL_TestingService.GetNDTTypeNameList();
this.drpNdtType.DataBind();
Funs.FineUIPleaseSelect(this.drpNdtType);
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
btnSelectColumn.OnClientClick = Window1.GetShowReference("InspectionBatchShowColumn.aspx");
//btnSelectExportColumns.OnClientClick = Window2.GetShowReference("InspectionBatchSelectExportColumn.aspx");
// 绑定表格
BindGrid();
}
else
{
if (GetRequestEventArgument() == "reloadGrid")
{
BindGrid();
}
}
}
///
/// 显示的列
///
///
private void GetShowColumn(string column)
{
if (!string.IsNullOrEmpty(column))
{
this.Grid1.Columns[1].Hidden = true;
this.Grid1.Columns[2].Hidden = true;
this.Grid1.Columns[3].Hidden = true;
this.Grid1.Columns[4].Hidden = true;
this.Grid1.Columns[5].Hidden = true;
this.Grid1.Columns[6].Hidden = true;
this.Grid1.Columns[7].Hidden = true;
this.Grid1.Columns[8].Hidden = true;
this.Grid1.Columns[9].Hidden = true;
this.Grid1.Columns[10].Hidden = true;
this.Grid1.Columns[11].Hidden = true;
this.Grid1.Columns[12].Hidden = true;
this.Grid1.Columns[13].Hidden = true;
this.Grid1.Columns[14].Hidden = true;
this.Grid1.Columns[15].Hidden = true;
this.Grid1.Columns[16].Hidden = true;
this.Grid1.Columns[17].Hidden = true;
this.Grid1.Columns[18].Hidden = true;
this.Grid1.Columns[19].Hidden = true;
this.Grid1.Columns[20].Hidden = true;
this.Grid1.Columns[21].Hidden = true;
this.Grid1.Columns[22].Hidden = true;
this.Grid1.Columns[23].Hidden = true;
this.Grid1.Columns[24].Hidden = true;
this.Grid1.Columns[25].Hidden = true;
this.Grid1.Columns[26].Hidden = true;
this.Grid1.Columns[27].Hidden = true;
this.Grid1.Columns[28].Hidden = true;
this.Grid1.Columns[29].Hidden = true;
this.Grid1.Columns[30].Hidden = true;
this.Grid1.Columns[31].Hidden = true;
this.Grid1.Columns[32].Hidden = true;
this.Grid1.Columns[33].Hidden = true;
List columns = column.Split(',').ToList();
foreach (var item in columns)
{
this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false;
}
}
}
///
/// 绑定数据
///
private void BindGrid()
{
string strSql = "select v.*,newid() as New_ID from (SELECT distinct * FROM HJGL_View_InspectionBatch WHERE 1=1";
List listStr = new List();
if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null")
{
strSql += " AND ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.drpProjectId.SelectedValue));
}
if (!string.IsNullOrEmpty(this.BatchId))
{
strSql += " AND BatchId =@BatchId";
listStr.Add(new SqlParameter("@BatchId", this.BatchId));
}
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
strSql += " AND ISO_IsoNo LIKE @IsoNo";
listStr.Add(new SqlParameter("@IsoNo", "%" + this.txtIsoNo.Text.Trim() + "%"));
}
if (this.drpNdtType.SelectedValue != Const._Null)
{
strSql += " AND CH_NDTMethod = @NdtType";
listStr.Add(new SqlParameter("@NdtType", this.drpNdtType.SelectedValue));
}
strSql += " ) v";
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
//显示列
Model.Sys_UserShowColumns c = BLL.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "3");
if (c != null)
{
this.GetShowColumn(c.Columns);
}
}
#endregion
#region 查询
///
/// 查询
///
///
///
protected void Text_TextChanged(object sender, EventArgs e)
{
BindGrid();
}
///
/// 查询
///
///
///
protected void TextBox_TextChanged(object sender, EventArgs e)
{
BindGrid();
}
#endregion
//#region 表头过滤
/////
///// 表头过滤
/////
/////
/////
//protected void Grid1_FilterChange(object sender, EventArgs e)
//{
// BindGrid();
//}
//#endregion
#region 分页
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
//Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region 关闭弹出窗口
///
/// 关闭弹出窗口刷新Grid
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region 导出
/// 导出按钮
///
///
///
protected void btnOut_Click(object sender, EventArgs e)
{
//int n = 0;
//foreach (GridRow dg in this.Grid1.Rows)
//{
// if (n > 0)
// {
// dg.CellAttributes[18].Add("style", "vnd.ms-excel.numberformat: @;");//第十一列的字段是[24928161122003E8]需要转换格式.
// }
// n++;
//}
Model.Sys_UserShowColumns c = BLL.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "3");
List columns = new List();
if (c != null)
{
string[] items = ("0," + c.Columns).Split(',');
columns = new List(items);
}
else
{
for (int i = 1; i <= Grid1.Columns.Count; i++)
{
columns.Add(i.ToString());
}
}
Response.ClearContent();
string filename = Funs.GetNewFileName();
//string style = @"