ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/HJGL/WeldingReport/RTTestingResult.aspx.cs

310 lines
12 KiB
C#
Raw Normal View History

2024-05-08 17:17:11 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Data;
using BLL;
namespace FineUIPro.Web.HJGL.WeldingReport
{
public partial class RTTestingResult : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
//this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
this.InitTreeMenu();//加载树
this.txtReportDate.Text = DateTime.Now.Date.ToString();
}
}
#endregion
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
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");
if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null")
{
projects = projects.Where(x => x.ProjectId == this.drpProjectId.SelectedValue).ToList();
}
foreach (var item in projects)
{
TreeNode rootProjectNode = new TreeNode();//定义根节点
rootProjectNode.Text = item.ProjectCode;
rootProjectNode.NodeID = item.ProjectId;
rootProjectNode.ToolTip = item.ProjectName;
rootProjectNode.EnableExpandEvent = true;
rootProjectNode.CommandName = "施工号";
rootNode.Nodes.Add(rootProjectNode);
TreeNode tn = new TreeNode();
tn.NodeID = "temp";
tn.Text = "正在加载...";
//List<Model.HJGL_BO_Batch> batchLists = (from x in Funs.DB.HJGL_BO_Batch
// where x.ProjectId == item.ProjectId
// && (from y in Funs.DB.HJGL_BO_BatchDetail where x.BatchId==y.BatchId select y).Count()>0
// select x).ToList();
//this.BindNodes(rootProjectNode, batchLists);
rootProjectNode.Nodes.Add(tn);
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.HJGL_BO_Batch> batchLists)
{
if (node.CommandName == "施工号")
{
var pointListMonth = (from x in batchLists orderby x.BatchCode descending select x).Distinct();
foreach (var item in pointListMonth)
{
TreeNode newNode = new TreeNode();
if (item.IsPrintRTTestingResult == true)
{
newNode.Text = "<font color='#009966'>" + string.Format("{0:yyyy-MM-dd}", item.BatchStartDate) + " " + item.BatchCode + "</font>";
}
else
{
newNode.Text = string.Format("{0:yyyy-MM-dd}", item.BatchStartDate) + " " + item.BatchCode;
}
newNode.NodeID = item.BatchId;
newNode.ToolTip = "日期-批编号";
newNode.CommandName = "批编号";
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.PageLoadInfo();
this.BindGrid();
}
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
{
if (e.Node.Nodes != null)
{
e.Node.Nodes.Clear();
}
string node = e.NodeID;
List<Model.HJGL_BO_Batch> batchLists = (from x in Funs.DB.HJGL_BO_Batch
where x.ProjectId == e.NodeID
&& (from y in Funs.DB.HJGL_BO_BatchDetail where x.BatchId == y.BatchId select y).Count() > 0
select x).ToList();
this.BindNodes(e.Node, batchLists);
}
#endregion
#region
/// <summary>
/// 文本赋值
/// </summary>
private void PageLoadInfo()
{
string batchId = this.tvControlItem.SelectedNodeID;
Model.HJGL_CH_Trust trust = BLL.HJGL_TrustManageEditService.GetTrustByBatchId(batchId);
var batchItem = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(batchId);
if (trust != null)
{
this.lblTrustUnit.Text = "镇海石化建安工程有限公司";
if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
{
var unit = BLL.Base_UnitService.GetUnit(trust.CH_TrustUnit);
if (unit != null)
{
this.lblTrustUnit.Text = unit.UnitName;
}
}
this.lblCH_NDTCriteria.Text = trust.CH_NDTCriteria;
if (batchItem.Count()>0)
{
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchItem.First().JOT_ID);
Model.HJGL_PW_IsoInfo isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(jot.ISO_ID);
if (isoInfo != null)
{
if (!string.IsNullOrEmpty(isoInfo.BSU_ID))
{
Model.Base_Unit unit = BLL.Base_UnitService.GetUnit(isoInfo.BSU_ID);
if (unit != null)
{
this.lblConstructionUnit.Text = unit.UnitName;
}
}
}
}
}
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(batchId))
{
listStr.Add(new SqlParameter("@BatchId", batchId));
}
else
{
listStr.Add(new SqlParameter("@BatchId", null));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("spRT_CheckRepairResult", parameter);
for (int i = 0; i < tb.Rows.Count; i++)
{
this.lblOneRepairWeldCount.Text = tb.Rows[i]["JotNumR1"].ToString();
this.lblTwoRepairWeldCount.Text = tb.Rows[i]["JotNumR2"].ToString();
this.lblThreeRepairWeldCount.Text = tb.Rows[i]["JotNumR3"].ToString();
this.lblOneRepairSliceCount.Text = tb.Rows[i]["FilmNumR1"].ToString();
this.lblTwoRepairSliceCount.Text = tb.Rows[i]["FilmNumR2"].ToString();
this.lblThreeRepairSliceCount.Text = tb.Rows[i]["FilmNumR3"].ToString();
}
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
listStr.Add(new SqlParameter("@BatchId", this.tvControlItem.SelectedNodeID));
}
else
{
listStr.Add(new SqlParameter("@BatchId", null));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("spRT_CheckResult", parameter);
DataTable dtNew = tb.Clone();
for (int i = 0; i < tb.Rows.Count; i++)
{
if (tb.Rows[i][10].ToString() != "以下空白")
{
dtNew.ImportRow(tb.Rows[i]);
}
}
this.Grid1.RecordCount = dtNew.Rows.Count;
dtNew = GetFilteredTable(Grid1.FilteredData, dtNew);
var table = this.GetPagedDataTable(Grid1, dtNew);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
string BatchId = string.Empty;
string projectName = string.Empty;
string trustUnit = string.Empty;
string ndtCriteria = string.Empty;
string constructionUnit = string.Empty;
string varValue = string.Empty;
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
BatchId = this.tvControlItem.SelectedNodeID;
var batch = BLL.HJGL_BO_BatchService.GetBatchById(BatchId);
if (batch != null)
{
batch.IsPrintRTTestingResult = true;
BLL.HJGL_BO_BatchService.UpdateBatch(batch);
if (!string.IsNullOrEmpty(batch.ProjectId))
{
var project = BLL.Base_ProjectService.GetProjectByProjectId(batch.ProjectId);
if (project != null)
{
projectName = project.ProjectName;
}
}
if (!string.IsNullOrEmpty(lblTrustUnit.Text.Trim()))
{
trustUnit = lblTrustUnit.Text.Trim();
}
if (!string.IsNullOrEmpty(lblCH_NDTCriteria.Text.Trim()))
{
ndtCriteria = lblCH_NDTCriteria.Text.Trim();
}
if (!string.IsNullOrEmpty(lblConstructionUnit.Text.Trim()))
{
constructionUnit = lblConstructionUnit.Text.Trim();
}
}
}
else
{
Alert.ShowInTop("请选择批编号!", MessageBoxIcon.Warning);
return;
}
varValue = projectName + "|" + trustUnit + "|" + ndtCriteria + "|" + constructionUnit + "|" + txtReportDate.Text;
varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ","));
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", Const.HJGL_RTTestingResultReportId, BatchId, varValue)));
}
#endregion
}
}