264 lines
11 KiB
C#
264 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using Newtonsoft.Json.Linq;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.HJGL.TestPackageManage
|
|
{
|
|
public partial class TestPackageManage : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
|
|
#region 绑定树节点
|
|
/// <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.Expanded = true;
|
|
rootProjectNode.EnableExpandEvent = true;
|
|
rootProjectNode.ToolTip = "施工号";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
|
|
TreeNode tn = new TreeNode();
|
|
tn.NodeID = "temp";
|
|
tn.Text = "正在加载...";
|
|
rootProjectNode.Nodes.Add(tn);
|
|
}
|
|
}
|
|
|
|
private void BindNodes(TreeNode node)
|
|
{
|
|
var iso = (from x in Funs.DB.HJGL_PW_IsoInfo
|
|
where x.ProjectId == node.NodeID
|
|
select x.PressureTestPackageNo).Distinct();
|
|
if (iso.Count() > 0)
|
|
{
|
|
foreach (var packageNo in iso)
|
|
{
|
|
if (!string.IsNullOrEmpty(packageNo))
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = packageNo + "(" + node.Text + ")";
|
|
newNode.NodeID = packageNo + "(" + node.Text + ")";
|
|
newNode.CommandName = packageNo;
|
|
newNode.EnableClickEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
DataTable data2 = null;
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid2()
|
|
{
|
|
string strSql = @"select pro.ProjectCode, ISO_ID,ISO_IsoNo,[dbo].[HJGL_Fun_GetBatchByIso](ISO_ID) as BatchCode,
|
|
(SELECT ISNULL(SUM(jot.JOT_Size),0) FROM dbo.HJGL_PW_JointInfo jot WHERE jot.ISO_ID=iso.ISO_ID) AS TotalSize,
|
|
(SELECT ISNULL(SUM(jot.JOT_Size),0) FROM dbo.HJGL_PW_JointInfo jot WHERE jot.ISO_ID=iso.ISO_ID
|
|
AND jot.DReportID IS NULL) AS NoSize
|
|
from dbo.HJGL_PW_IsoInfo iso
|
|
left join Base_Project pro on pro.ProjectId=iso.ProjectId
|
|
WHERE iso.ProjectId=@ProjectId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
|
|
{
|
|
strSql += " AND PressureTestPackageNo = @PressureTestPackageNo";
|
|
listStr.Add(new SqlParameter("@PressureTestPackageNo", tvControlItem.SelectedNode.CommandName));
|
|
listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNode.ParentNode.NodeID));
|
|
}
|
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
data2 = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
//Grid2.RecordCount = data2.Rows.Count;
|
|
//data2 = GetFilteredTable(Grid2.FilteredData, data2);
|
|
//var table = this.GetPagedDataTable(Grid2, data2);
|
|
var table = GetSortTable(Grid2, data2);
|
|
Grid2.DataSource = table;
|
|
Grid2.DataBind();
|
|
}
|
|
|
|
private void OutputSummaryData()
|
|
{
|
|
float totalSize = 0.0f;
|
|
float noSize = 0.0f;
|
|
foreach (DataRow row in data2.Rows)
|
|
{
|
|
totalSize += Convert.ToInt32(row["TotalSize"]);
|
|
noSize += Convert.ToInt32(row["NoSize"]);
|
|
}
|
|
|
|
JObject summary = new JObject();
|
|
summary.Add("ProjectCode", "合计:");
|
|
summary.Add("TotalSize", totalSize.ToString("F2"));
|
|
summary.Add("NoSize", noSize.ToString("F2"));
|
|
|
|
Grid2.SummaryData = summary;
|
|
|
|
}
|
|
|
|
|
|
private void BindGrid1()
|
|
{
|
|
string strSql = @"select project.ProjectCode, v.BatchId,batch.BatchCode,ty.JOTY_Name,rate.NDTR_Name,
|
|
batch.SubmitAskDate, batch.AskCompleteDate,
|
|
(case when (select Count(*) from dbo.HJGL_CH_TrustItem item
|
|
left join dbo.HJGL_BO_BatchDetail batchDetail on batchDetail.BatchDetailId=item.BatchDetailId
|
|
where item.States!='2' and batchDetail.BatchId=v.BatchId)>0 OR
|
|
(SELECT COUNT(*) FROM dbo.HJGL_BO_Batch b WHERE b.BatchId=v.BatchId AND b.BatchIsClosed=1)=0
|
|
THEN '否' else '是' end) as IsPass,
|
|
(select ReportFeedback from dbo.HJGL_BO_Batch d
|
|
where d.BatchId=v.BatchId) as ReportFeedback
|
|
from
|
|
(select distinct detail.BatchId from dbo.HJGL_BO_BatchDetail detail
|
|
left join dbo.HJGL_PW_IsoInfo iso on detail.ISO_ID=iso.ISO_ID
|
|
WHERE iso.PressureTestPackageNo=@PressureTestPackageNo
|
|
and iso.ProjectId=@ProjectId) as v
|
|
left join dbo.HJGL_BO_Batch batch on batch.BatchId=v.BatchId
|
|
LEFT JOIN dbo.HJGL_BS_JointType ty ON ty.JOTY_ID = batch.JOTY_ID
|
|
LEFT JOIN dbo.HJGL_BS_NDTRate rate ON rate.NDTR_ID = batch.NDTR_ID
|
|
left join dbo.Base_Project project on project.ProjectId=batch.ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
|
|
{
|
|
listStr.Add(new SqlParameter("@PressureTestPackageNo", tvControlItem.SelectedNode.CommandName));
|
|
listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNode.ParentNode.NodeID));
|
|
}
|
|
|
|
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);
|
|
var table = GetSortTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
data2 = null;
|
|
List<Model.HJGL_BO_Batch> batchLists = (from x in Funs.DB.HJGL_BO_Batch
|
|
where x.ProjectId == tvControlItem.SelectedNode.ParentNode.NodeID && !x.AskCompleteDate.HasValue
|
|
select x).ToList();
|
|
var batchdetails = from x in Funs.DB.HJGL_BO_BatchDetail
|
|
join y in Funs.DB.HJGL_BO_Batch on x.BatchId equals y.BatchId
|
|
where y.ProjectId == tvControlItem.SelectedNode.ParentNode.NodeID
|
|
select x;
|
|
var trustdetails = from x in Funs.DB.HJGL_CH_TrustItem
|
|
join y in Funs.DB.HJGL_BO_BatchDetail on x.BatchDetailId equals y.BatchDetailId
|
|
join z in Funs.DB.HJGL_BO_Batch on y.BatchId equals z.BatchId
|
|
where z.ProjectId == tvControlItem.SelectedNode.ParentNode.NodeID
|
|
select x;
|
|
foreach (var item in batchLists)
|
|
{
|
|
bool isCheck = true;
|
|
var batchdetail = from x in batchdetails where x.BatchId == item.BatchId select x.BatchDetailId;
|
|
var trust = BLL.HJGL_TrustManageEditService.GetTrustByBatchId(item.BatchId);
|
|
var ndtr = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(item.NDTR_ID);
|
|
var trustdetail = from x in trustdetails where batchdetail.Contains(x.BatchDetailId) orderby x.FeedbackDate descending select x;
|
|
if (trust == null && ndtr.NDTR_Rate.Value != 0)
|
|
{
|
|
isCheck = false;
|
|
}
|
|
else
|
|
{
|
|
if (trustdetail.Where(x => x.States != "2").Count() > 0)
|
|
{
|
|
isCheck = false;
|
|
}
|
|
}
|
|
//检测合格,更新要求完成日期
|
|
if (isCheck && item.BatchIsClosed == true)
|
|
{
|
|
DateTime date = DateTime.Now;
|
|
if (trustdetail.Count() > 0)
|
|
{
|
|
if (trustdetail.FirstOrDefault().FeedbackDate != null)
|
|
{
|
|
date = trustdetail.FirstOrDefault().FeedbackDate.Value;
|
|
}
|
|
}
|
|
item.AskCompleteDate = date;
|
|
BLL.HJGL_BO_BatchService.UpdateBatch(item);
|
|
}
|
|
}
|
|
BindGrid1();
|
|
BindGrid2();
|
|
OutputSummaryData();
|
|
}
|
|
|
|
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (e.Node.Nodes != null)
|
|
{
|
|
e.Node.Nodes.Clear();
|
|
}
|
|
this.BindNodes(e.Node);
|
|
}
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid1();
|
|
BindGrid2();
|
|
}
|
|
|
|
protected void Grid2_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
data2 = null;
|
|
BindGrid1();
|
|
BindGrid2();
|
|
OutputSummaryData();
|
|
}
|
|
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
BindGrid1();
|
|
BindGrid2();
|
|
}
|
|
}
|
|
} |