420 lines
16 KiB
C#
420 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
{
|
|
public partial class TestingReportPrompt : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 管线ID
|
|
/// </summary>
|
|
private string ISO_ID
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ISO_ID"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ISO_ID"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
this.drpNDT.DataTextField = "NDT_Code";
|
|
this.drpNDT.DataValueField = "NDT_ID";
|
|
this.drpNDT.DataSource = BLL.HJGL_TestingService.GetNDTTypeNameList();
|
|
this.drpNDT.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpNDT);
|
|
|
|
this.drpCompleteReport.DataTextField = "Text";
|
|
this.drpCompleteReport.DataValueField = "Value";
|
|
this.drpCompleteReport.DataSource = BLL.DropListService.IsTrueOrFalseDrpList();
|
|
this.drpCompleteReport.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpCompleteReport);
|
|
|
|
this.InitTreeMenu();//加载树
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "施工号-批次号-管线号";
|
|
rootNode.ToolTip = "施工号";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.ToolTip = "施工号";
|
|
rootProjectNode.EnableExpandEvent = true;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
|
|
TreeNode tn = new TreeNode();
|
|
tn.NodeID = "temp";
|
|
tn.Text = "正在加载...";
|
|
rootProjectNode.Nodes.Add(tn);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定树节点
|
|
/// <summary>
|
|
/// 绑定树节点
|
|
/// </summary>
|
|
/// <param name="rootProjectNode"></param>
|
|
/// <param name="trustLists"></param>
|
|
private void BindNodes(TreeNode node, List<Model.HJGL_View_BatchTree> batchLists)
|
|
{
|
|
if (node.ToolTip == "施工号")
|
|
{
|
|
var batchList = from x in batchLists
|
|
group x by new { x.BatchId, x.BatchCode,x.ReportFeedback } into g
|
|
select new { g.Key};
|
|
foreach (var item in batchList)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
if (item.Key.ReportFeedback != null)
|
|
{
|
|
newNode.Text = "<font color='#009966'>" + item.Key.BatchCode + "</font>";
|
|
}
|
|
else
|
|
{
|
|
newNode.Text = item.Key.BatchCode;
|
|
|
|
}
|
|
newNode.NodeID = item.Key.BatchId;
|
|
newNode.ToolTip = "批次号";
|
|
newNode.EnableClickEvent = true;
|
|
newNode.EnableExpandEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
|
|
TreeNode tn1 = new TreeNode();
|
|
tn1.NodeID = "temp";
|
|
tn1.Text = "正在加载...";
|
|
newNode.Nodes.Add(tn1);
|
|
//this.BindNodes(newNode, batchLists);
|
|
}
|
|
}
|
|
else if (node.ToolTip == "批次号")
|
|
{
|
|
var batchs = from x in batchLists where x.BatchId == node.NodeID select x;
|
|
var batchList = from x in batchs
|
|
group x by new { x.ISO_ID, x.Iso_IsoNo } into g
|
|
select new { g.Key };
|
|
foreach (var item in batchList)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
|
|
newNode.Text = item.Key.Iso_IsoNo;
|
|
newNode.NodeID = node.NodeID + "|" + item.Key.ISO_ID;
|
|
newNode.EnableClickEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region TreeView点击事件
|
|
/// <summary>
|
|
/// TreeView点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.ISO_ID = tvControlItem.SelectedNodeID;
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (e.Node.Nodes != null)
|
|
{
|
|
e.Node.Nodes.Clear();
|
|
}
|
|
|
|
string projectId = string.Empty;
|
|
if (e.Node.ToolTip == "施工号")
|
|
{
|
|
projectId = e.NodeID;
|
|
}
|
|
if (e.Node.ToolTip == "批次号")
|
|
{
|
|
projectId = e.Node.ParentNode.NodeID;
|
|
}
|
|
|
|
List<Model.HJGL_View_BatchTree> batchLists = new List<Model.HJGL_View_BatchTree>();
|
|
if (this.drpNDT.SelectedValue != BLL.Const._Null)
|
|
{
|
|
batchLists = (from x in Funs.DB.HJGL_View_BatchTree
|
|
where x.ProjectId == projectId
|
|
&& x.NDT.Contains(this.drpNDT.SelectedValue)
|
|
select x).ToList();
|
|
}
|
|
else
|
|
{
|
|
batchLists = (from x in Funs.DB.HJGL_View_BatchTree
|
|
where x.ProjectId == projectId
|
|
select x).ToList();
|
|
}
|
|
|
|
this.BindNodes(e.Node, batchLists);
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT BatchDetail.BatchDetailId, BatchDetail.BatchId, BatchDetail.ISO_ID,
|
|
BatchDetail.JOT_ID, BatchDetail.NDT,
|
|
NDTName = STUFF((SELECT ',' + NDT_Code FROM HJGL_BS_NDTType AS B WHERE PATINDEX('%,' + RTRIM(B.NDT_ID) + ',%', ',' + BatchDetail.NDT + ',') > 0 ORDER BY PATINDEX('%,' + RTRIM(BatchDetail.NDT) + ',%', ',' + BatchDetail.NDT + ',') FOR XML PATH('')), 1, 1,''),
|
|
Batch.BatchCode, Batch.SubmitAskDate, Batch.AskCompleteDate, Batch.ReportFeedback,
|
|
Project.ProjectCode,IsoInfo.Iso_IsoNo,JointInfo.JOT_JointNo,
|
|
JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5
|
|
FROM dbo.HJGL_BO_BatchDetail AS BatchDetail
|
|
LEFT JOIN dbo.HJGL_BO_Batch AS Batch ON Batch.BatchId = BatchDetail.BatchId
|
|
LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = BatchDetail.JOT_ID
|
|
LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = BatchDetail.ISO_ID
|
|
LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId = Batch.ProjectId
|
|
WHERE 1 = 1 and(select count(*) from HJGL_CH_TrustItem ti where ti.BatchDetailId = BatchDetail.BatchDetailId) > 0";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
if (tvControlItem.SelectedNodeID != string.Empty)
|
|
{
|
|
if (tvControlItem.SelectedNodeID.Split('|').Count() > 1)
|
|
{
|
|
var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID.Split('|')[1]);
|
|
if (iso != null)
|
|
{
|
|
strSql += " AND IsoInfo.ISO_ID = @ISO_ID";
|
|
listStr.Add(new SqlParameter("@ISO_ID", tvControlItem.SelectedNodeID.Split('|')[1]));
|
|
|
|
strSql += " AND BatchDetail.BatchId = @BatchId";
|
|
listStr.Add(new SqlParameter("@BatchId", tvControlItem.SelectedNode.ParentNode.NodeID));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var project = BLL.Base_ProjectService.GetProjectByProjectId(tvControlItem.SelectedNodeID);
|
|
var batch = BLL.HJGL_BO_BatchService.GetBatchById(tvControlItem.SelectedNodeID);
|
|
if (project != null)
|
|
{
|
|
strSql += " AND Batch.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNodeID));
|
|
}
|
|
if (batch != null)
|
|
{
|
|
strSql += " AND BatchDetail.BatchId = @BatchId";
|
|
listStr.Add(new SqlParameter("@BatchId", tvControlItem.SelectedNodeID));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND Batch.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
}
|
|
|
|
if (this.drpNDT.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND BatchDetail.NDT = @NDT";
|
|
listStr.Add(new SqlParameter("@NDT", this.drpNDT.SelectedValue));
|
|
}
|
|
if (this.drpCompleteReport.SelectedValue != BLL.Const._Null)
|
|
{
|
|
if (this.drpCompleteReport.SelectedValue == BLL.Const._True)
|
|
{
|
|
strSql += " AND Batch.ReportFeedback is not null";
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND Batch.ReportFeedback is null";
|
|
}
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpNDT_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void drpCompleteReport_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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();
|
|
}
|
|
#endregion
|
|
|
|
protected void Window1_Close(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;
|
|
//this.Grid1.PageSize = this.;
|
|
this.Grid1.PageSize = 10000;
|
|
//BindBatch();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
#pragma warning disable CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
#pragma warning restore CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
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;\">");
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber" && (row.FindControl("labNumber") as AspNet.Label) != null)
|
|
{
|
|
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "SubmitAskDate" || column.ColumnID == "AskCompleteDate" || column.ColumnID == "ReportFeedback")
|
|
{
|
|
var date = Funs.GetNewDateTime(html);
|
|
if (date != null)
|
|
{
|
|
html = string.Format("{0:yyyy-MM-dd}", date);
|
|
}
|
|
else
|
|
{
|
|
html = string.Empty;
|
|
}
|
|
}
|
|
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
} |