406 lines
16 KiB
C#
406 lines
16 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.IO;
|
|
using FineUIPro.Web.common.BaseInfo;
|
|
using System.Collections;
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class WeldInspectionCheckRecord : PageBase
|
|
{
|
|
#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.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);
|
|
Funs.FineUIPleaseSelect(this.drpIsoId);
|
|
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
this.InitTreeMenu();//加载树
|
|
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
//this.BindGrid();
|
|
|
|
this.drpIsoId.Items.Clear();
|
|
this.drpIsoId.DataTextField = "ISO_IsoNo";
|
|
this.drpIsoId.DataValueField = "ISO_ID";
|
|
this.drpIsoId.DataSource = (from x in Funs.DB.HJGL_PW_IsoInfo where x.ProjectId == this.tvControlItem.SelectedNodeID select x).ToList();
|
|
this.drpIsoId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpIsoId);
|
|
this.drpIsoId.SelectedIndex = 0;
|
|
|
|
Funs.FineUIPleaseSelect(this.drpWeldingDate);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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 != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = item.ProjectName;
|
|
rootProjectNode.CommandName = "项目名称";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
this.BindGrid();
|
|
//this.Grid1.Items.Clear();
|
|
//this.Grid1.DataBind();
|
|
this.drpIsoId.Items.Clear();
|
|
this.drpIsoId.DataTextField = "ISO_IsoNo";
|
|
this.drpIsoId.DataValueField = "ISO_ID";
|
|
this.drpIsoId.DataSource = (from x in Funs.DB.HJGL_PW_IsoInfo where x.ProjectId == this.tvControlItem.SelectedNodeID select x).ToList();
|
|
this.drpIsoId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpIsoId);
|
|
this.drpIsoId.SelectedIndex = 0;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
|
|
private static DataTable tb = null;
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpIsoId.SelectedValue) && this.drpIsoId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@ISO_ID", this.drpIsoId.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@ISO_ID", null));
|
|
}
|
|
listStr.Add(new SqlParameter("@VICheckDate", null));
|
|
listStr.Add(new SqlParameter("@NDTR_ID", null));
|
|
if (!string.IsNullOrEmpty(this.drpJointType.SelectedValue) && this.drpJointType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@JOTY_Group", this.drpJointType.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@JOTY_Group", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpWeldingDate.SelectedValue) && this.drpWeldingDate.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldingDate", this.drpWeldingDate.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldingDate", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
tb = SQLHelper.GetDataTableRunProc("HJGL_sp_WeldInspectionCheckRecord", parameter);
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#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
|
|
#endregion
|
|
|
|
#region 查询
|
|
///<summary>
|
|
///查询
|
|
///</summary>
|
|
///<param name="sender"></param>
|
|
///<param name="e"></param>
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
string projectId = this.tvControlItem.SelectedNodeID;
|
|
if (projectId != null && !string.IsNullOrEmpty(projectId))
|
|
{
|
|
if (this.drpIsoId.SelectedValue==BLL.Const._Null&&string.IsNullOrEmpty(this.drpIsoId.SelectedValue))
|
|
{
|
|
Alert.ShowInTop("请选择管线", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(this.drpJointType.SelectedValue))
|
|
{
|
|
Alert.ShowInTop("请选择焊缝类型", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpIsoId.SelectedValue) && this.drpIsoId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@ISO_ID", this.drpIsoId.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@ISO_ID", null));
|
|
}
|
|
listStr.Add(new SqlParameter("@VICheckDate", null));
|
|
listStr.Add(new SqlParameter("@NDTR_ID", null));
|
|
if (!string.IsNullOrEmpty(this.drpJointType.SelectedValue) && this.drpJointType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@JOTY_Group", this.drpJointType.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@JOTY_Group", null));
|
|
}
|
|
if (this.drpWeldingDate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpWeldingDate.SelectedValue))
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldingDate", this.drpWeldingDate.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@WeldingDate", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunProc("HJGL_sp_WeldInspectionCheckRecord", parameter);
|
|
|
|
if (tb.Rows.Count > 0)
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("Number");
|
|
dt.Columns.Add("ISO_IsoNo");
|
|
dt.Columns.Add("JOT_JointNo");
|
|
dt.Columns.Add("WED_Code");
|
|
dt.Columns.Add("JOT_JointDesc");
|
|
dt.Columns.Add("STE_Code");
|
|
dt.Columns.Add("JOT_Location");
|
|
dt.Columns.Add("WME_Name");
|
|
dt.Columns.Add("WMT_MatName");
|
|
dt.Columns.Add("JOT_PrepareTemp");
|
|
dt.Columns.Add("PassVI");
|
|
dt.Columns.Add("NoPassVI");
|
|
dt.Columns.Add("Remark");
|
|
|
|
DataView dv = tb.DefaultView;//获取表视图
|
|
dv.Sort = "ISO_IsoNo,JOT_JointNo ASC";//按照ID倒序排序
|
|
tb = dv.ToTable();//转为表
|
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
|
int i = 0;
|
|
foreach (var row in rows)
|
|
{
|
|
var newRows = dt.NewRow();
|
|
newRows["Number"] = (i + 1).ToString();
|
|
newRows["ISO_IsoNo"] = row["ISO_IsoNo"].ToString();
|
|
newRows["JOT_JointNo"] = row["JOT_JointNo"].ToString();
|
|
newRows["WED_Code"] = row["WED_Code"].ToString();
|
|
newRows["JOT_JointDesc"] = row["JOT_JointDesc"].ToString();
|
|
newRows["STE_Code"] = row["STE_Code"].ToString();
|
|
newRows["JOT_Location"] = row["JOT_Location"].ToString();
|
|
newRows["WME_Name"] = row["WME_Name"].ToString();
|
|
newRows["WMT_MatName"] = row["WMT_MatName"].ToString();
|
|
newRows["JOT_PrepareTemp"] = row["JOT_PrepareTemp"].ToString();
|
|
newRows["PassVI"] = row["PassVI"].ToString();
|
|
newRows["NoPassVI"] = row["NoPassVI"].ToString();
|
|
newRows["Remark"] = row["Remark"].ToString();
|
|
dt.Rows.Add(newRows);
|
|
i++;
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
|
|
keyValuePairs.Add("InspectionCount", tb.Rows.Count.ToString());
|
|
string nderName = string.Empty;
|
|
string ndtrId = tb.Rows[0]["NDTR_ID"].ToString();
|
|
if (!string.IsNullOrEmpty(ndtrId))
|
|
{
|
|
var rate = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(ndtrId);
|
|
if (rate != null)
|
|
{
|
|
nderName = rate.NDTR_Name;
|
|
}
|
|
}
|
|
keyValuePairs.Add("NDTRName", nderName);
|
|
if (this.drpJointType.SelectedValue == "1")
|
|
{
|
|
keyValuePairs.Add("NDTType", "RT");
|
|
}
|
|
else
|
|
{
|
|
keyValuePairs.Add("NDTType", "PT");
|
|
}
|
|
if (this.drpWeldingDate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpWeldingDate.SelectedValue))
|
|
{
|
|
string weldingDate = string.Format("{0:yyyy年MM月dd日}", Convert.ToDateTime(this.drpWeldingDate.SelectedValue));
|
|
keyValuePairs.Add("WeldingDate", weldingDate);
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
initTemplatePath = "File\\Fastreport\\JGZL\\管道焊接接头报检检查记录.frx";
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("没有可打印的数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void drpIsoId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.drpIsoId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpIsoId.SelectedValue))
|
|
{
|
|
BindGrid();
|
|
|
|
this.drpWeldingDate.Items.Clear();
|
|
List<string> lists = new List<string>();
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|
{
|
|
lists.Add(string.Format("{0:yyyy-MM-dd}", tb.Rows[i]["JOT_WeldDate"]));
|
|
}
|
|
lists = lists.Distinct().OrderBy(x => x).ToList();
|
|
|
|
this.drpWeldingDate.DataTextField = "Text";
|
|
this.drpWeldingDate.DataValueField = "Value";
|
|
this.drpWeldingDate.DataSource = lists;
|
|
this.drpWeldingDate.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpWeldingDate);
|
|
this.drpWeldingDate.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
protected void drpWeldingDate_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
} |