xinjiang/SGGL/FineUIPro.Web/HJGL/WeldingManage/JointInfo.aspx.cs

1675 lines
91 KiB
C#
Raw Normal View History

2024-11-19 09:45:27 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Newtonsoft.Json.Linq;
using System.IO;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using System.Runtime.Serialization;
using FineUIPro.Web.ProjectData;
namespace FineUIPro.Web.HJGL.WeldingManage
{
public partial class JointInfo : 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.InitTreeMenu();//加载树
//显示列
Model.Sys_UserShowColumns c = BLL.UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "Joint");
if (c != null)
{
this.GetShowColumn(c.Columns);
}
}
}
#endregion
#region --
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "装置-单位-工作区";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
////装置
var pInstallation = (from x in Funs.DB.Project_Installation where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
////区域
var pWorkArea = (from x in Funs.DB.ProjectData_WorkArea where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
////单位
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
var workAreaIdList = (from x in BLL.Funs.DB.PW_IsoInfo
where x.ProjectId == this.CurrUser.LoginProjectId && x.ISO_IsoNo.Contains(this.txtIsono.Text.Trim())
orderby x.ISO_IsoNo
select x.WorkAreaId).Distinct().ToList();
pWorkArea = pWorkArea.Where(x => workAreaIdList.Contains(x.WorkAreaId)).OrderBy(x => x.WorkAreaCode).ToList();
pInstallation = (from x in pInstallation
join y in pWorkArea on x.InstallationId equals y.InstallationId
select x).Distinct().ToList();
pUnits = (from x in pUnits
join y in pWorkArea on x.UnitId equals y.UnitId
select x).Distinct().ToList();
this.BindNodes(rootNode, pInstallation, pWorkArea, pUnits);
}
#endregion
#region
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.Project_Installation> pInstallation, List<Model.ProjectData_WorkArea> pWorkArea, List<Model.Project_ProjectUnit> pUnits)
{
if (string.IsNullOrEmpty(node.ToolTip))
{
List<Model.Project_Installation> installations = pInstallation;
var pUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
if (pUnit != null && pUnit.UnitType != Const.ProjectUnitType_1 && pUnit.UnitType != Const.ProjectUnitType_5)
{
installations = (from x in pInstallation
join y in pWorkArea on x.InstallationId equals y.InstallationId
where y.UnitId == this.CurrUser.UnitId
orderby x.InstallationId
select x).Distinct().ToList();
}
foreach (var q in installations)
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.InstallationId;
newNode.Text = q.InstallationName;
newNode.ToolTip = "装置";
newNode.Expanded = true;
node.Nodes.Add(newNode);
this.BindNodes(newNode, pInstallation, pWorkArea, pUnits);
}
}
else if (node.ToolTip == "装置")
{
List<Model.Project_ProjectUnit> units = null;
var pUnitDepth = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
if (pUnitDepth == null || pUnitDepth.UnitType == Const.ProjectUnitType_1 || pUnitDepth.UnitType == Const.ProjectUnitType_5)
{
units = (from x in pUnits
join y in pWorkArea on x.UnitId equals y.UnitId
where y.InstallationId == node.NodeID && x.UnitType == Const.ProjectUnitType_2
select x).ToList();
}
else
{
units = (from x in pUnits
join y in pWorkArea on x.UnitId equals y.UnitId
where y.InstallationId == node.NodeID && x.UnitType == Const.ProjectUnitType_2 && x.UnitId == this.CurrUser.UnitId
select x).ToList();
}
units = units.OrderBy(x => x.InTime).Distinct().ToList();
foreach (var q in units)
{
var unit = BLL.UnitService.GetUnitByUnitId(q.UnitId);
if (unit != null)
{
TreeNode newNode = new TreeNode();
newNode.Text = unit.UnitName;
newNode.NodeID = q.UnitId + "|" + node.NodeID;
newNode.ToolTip = "单位";
node.Nodes.Add(newNode);
this.BindNodes(newNode, pInstallation, pWorkArea, pUnits);
}
}
}
else if (node.ToolTip == "单位")
{
var workAreas = (from x in pWorkArea
where x.InstallationId == node.ParentNode.NodeID && x.UnitId == node.NodeID.Split('|')[0]
select x);
workAreas = workAreas.OrderByDescending(x => x.WorkAreaCode);
foreach (var q in workAreas)
{
int a = (from x in BLL.Funs.DB.PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == node.NodeID.Split('|')[0] && x.WorkAreaId == q.WorkAreaId && x.Is_Standard== true select x).Count();
TreeNode newNode1 = new TreeNode();
newNode1.Text = q.WorkAreaCode + "【" + a.ToString() + "非标管线】";
newNode1.NodeID = q.WorkAreaId+ "_NoStandard";
newNode1.EnableExpandEvent = true;
newNode1.ToolTip = "区域非标管线";
node.Nodes.Add(newNode1);
int b = (from x in BLL.Funs.DB.PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == node.NodeID.Split('|')[0] && x.WorkAreaId == q.WorkAreaId && x.Is_Standard != true select x).Count();
TreeNode newNode2 = new TreeNode();
newNode2.Text = q.WorkAreaCode + "【" + b.ToString() + "标准管线】";
newNode2.NodeID = q.WorkAreaId+ "_Standard";
newNode2.EnableExpandEvent = true;
newNode2.ToolTip = "区域标准管线";
node.Nodes.Add(newNode2);
this.BindNodes(newNode1, pInstallation, pWorkArea, pUnits);
this.BindNodes(newNode2, pInstallation, pWorkArea, pUnits);
}
}
else if (node.ToolTip == "区域非标管线")
{
TreeNode newNode = new TreeNode();
newNode.Text = "非标管线";
newNode.NodeID = "非标管线";
node.Nodes.Add(newNode);
}
else if (node.ToolTip == "区域标准管线")
{
TreeNode newNode = new TreeNode();
newNode.Text = "标准管线";
newNode.NodeID = "标准管线";
node.Nodes.Add(newNode);
}
}
#endregion
#region
/// <summary>
/// 树展开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
if (e.Node.ToolTip == "区域非标管线")
{
e.Node.Nodes.Clear();
List<Model.PW_IsoInfo> isoInfo = new List<Model.PW_IsoInfo>();
isoInfo = (from x in BLL.Funs.DB.PW_IsoInfo
where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkAreaId == e.Node.NodeID.Split('_')[0] && x.Is_Standard==true
&& x.ISO_IsoNo.Contains(this.txtIsono.Text.Trim())
orderby x.ISO_IsoNo
select x).ToList();
foreach (var item in isoInfo)
{
var jotCount = (from x in Funs.DB.PW_JointInfo where x.ISO_ID == item.ISO_ID select x).Count();
TreeNode newNode = new TreeNode();
if (!String.IsNullOrEmpty(item.ISO_Sheet))
{
newNode.Text = item.ISO_IsoNo + "(" + item.ISO_Sheet + ")";
}
else
{
newNode.Text = item.ISO_IsoNo;
}
newNode.Text += "【" + jotCount.ToString() + "焊口】";
newNode.ToolTip = "管线(页数)【焊口数】";
newNode.NodeID = item.ISO_ID;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
}
}
else if (e.Node.ToolTip == "区域标准管线")
{
e.Node.Nodes.Clear();
List<Model.PW_IsoInfo> isoInfo = new List<Model.PW_IsoInfo>();
isoInfo = (from x in BLL.Funs.DB.PW_IsoInfo
where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkAreaId == e.Node.NodeID.Split('_')[0] && x.Is_Standard == false
&& x.ISO_IsoNo.Contains(this.txtIsono.Text.Trim())
orderby x.ISO_IsoNo
select x).ToList();
foreach (var item in isoInfo)
{
var jotCount = (from x in Funs.DB.PW_JointInfo where x.ISO_ID == item.ISO_ID select x).Count();
TreeNode newNode = new TreeNode();
if (!String.IsNullOrEmpty(item.ISO_Sheet))
{
newNode.Text = item.ISO_IsoNo + "(" + item.ISO_Sheet + ")";
}
else
{
newNode.Text = item.ISO_IsoNo;
}
newNode.Text += "【" + jotCount.ToString() + "焊口】";
newNode.ToolTip = "管线(页数)【焊口数】";
newNode.NodeID = item.ISO_ID;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
}
}
}
#endregion
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
var p = Funs.DB.PW_IsoInfo.Where(x => x.ISO_ID == this.tvControlItem.SelectedNodeID).FirstOrDefault();
if (p != null&& p.Is_Standard.HasValue)
{
if (p.Is_Standard.Value)
{
this.Grid1.FindColumn("DetectionRateValue").Hidden = false;
this.Grid1.FindColumn("DetectionTypeName").Hidden = false;
this.Grid1.FindColumn("WallBoard").Hidden = false;
}
else
{
this.Grid1.FindColumn("DetectionRateValue").Hidden = true;
this.Grid1.FindColumn("DetectionTypeName").Hidden = true;
this.Grid1.FindColumn("WallBoard").Hidden = true;
}
}
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT jointInfo.JOT_ID,
jointInfo.ProjectId,
jointInfo.JOT_JointNo,
jointInfo.is_hj,
jointInfo.JointStatusName,
jointInfo.JOT_TrustFlagName,
jointInfo.JOT_CheckFlagName,
jointInfo.ISO_ID,
jointInfo.ISO_IsoNo,
jointInfo.WorkAreaId,
jointInfo.WorkAreaCode,
jointInfo.JOT_WeldDate,
jointInfo.JOT_DailyReportNo,
jointInfo.STE_Name1,
jointInfo.STE_Name2,
jointInfo.Component1,
jointInfo.Component2,
jointInfo.WED_Code1,
jointInfo.WED_Name1,
jointInfo.WED_Code2,
jointInfo.WED_Name2,
jointInfo.JOT_JointDesc,
jointInfo.JOT_Dia,
jointInfo.JOT_Size,
jointInfo.JOT_Sch,
jointInfo.JOT_FactSch,
jointInfo.GrooveTypeName,
jointInfo.JOTY_ID,
jointInfo.WeldTypeName,
jointInfo.WME_ID,
jointInfo.WeldingMethodName,
jointInfo.WeldSilk,
jointInfo.WeldMat,
jointInfo.WLO_Code,
jointInfo.WeldingLocationName,
jointInfo.JOT_DoneDin,
jointInfo.JOT_PrepareTemp,
jointInfo.JOT_JointAttribute,
jointInfo.JOT_CellTemp,
jointInfo.JOT_LastTemp,
jointInfo.JOT_HeartNo1,
jointInfo.JOT_HeartNo2,
jointInfo.PointDate,
jointInfo.PointNo,
jointInfo.CH_TrustCode,
jointInfo.CH_TrustDate,
jointInfo.JOT_FaceCheckResult,
jointInfo.JOT_FaceCheckDate,
jointInfo.JOT_FaceChecker,
detectionRate.DetectionRateValue,
jointInfo.IS_Proess,
jointInfo.JOT_BelongPipe,
jointInfo.JOT_Electricity,
detectionType.DetectionTypeName,
jointInfo.JOT_Voltage,
jointInfo.JOT_ProessDate,
jointInfo.JOT_HotRpt,
jointInfo.Extend_Length,
(select top 1 CHT_CheckDate from CH_Check c left join CH_CheckItem ci on ci.CHT_CheckID=c.CHT_CheckID where ci.JOT_ID=jointInfo.JOT_ID order by CHT_CheckDate desc) as CHT_CheckDate,
(select top 1 CHT_CheckCode from CH_Check c left join CH_CheckItem ci on ci.CHT_CheckID=c.CHT_CheckID where ci.JOT_ID=jointInfo.JOT_ID order by CHT_CheckDate desc) as CHT_CheckCode,
jointInfo.JOT_Remark"
+ @" from View_JointInfo as jointInfo "
+ @" LEFT JOIN Base_DetectionRate AS detectionRate ON detectionRate.DetectionRateId = jointInfo.DetectionRateId"
+ @" LEFT JOIN Base_DetectionType AS detectionType ON detectionType.DetectionTypeId = jointInfo.DetectionTypeId"
+ @" WHERE jointInfo.ProjectId= @projectId AND jointInfo.ISO_ID=@isoId";
List<SqlParameter> listStr = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
};
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql += " AND jointInfo.JOT_JointNo LIKE @JOT_JointNo";
listStr.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.dpIsHj.SelectedValue))
{
strSql += " AND jointInfo.is_hj = @is_hj";
listStr.Add(new SqlParameter("@is_hj", this.dpIsHj.SelectedValue));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
tb.Columns.Add("index",typeof(System.Int16));
foreach(DataRow row in tb.Rows)
{
try
{
row["index"] = int.Parse(System.Text.RegularExpressions.Regex.Replace(row["JOT_JointNo"].ToString(), @"[^0-9]+", ""));
}
catch (Exception e)
{
row["index"] = 0;
}
}
// 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
#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>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
if (GetButtonPower(Const.BtnModify))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoEdit.aspx?JOT_ID={0}", Grid1.SelectedRowID, "编辑 - ")));
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 增加焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnAdd))
{
var isoInfo = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID);
if (isoInfo != null)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoEdit.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
}
else
{
Alert.ShowInTop("请先选择管线!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 批量增加焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnBatchAdd_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnAdd))
{
var isoInfo = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID);
if (isoInfo != null)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("JointInfoBatchEdit.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
}
else
{
Alert.ShowInTop("请先选择管线!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 焊口信息编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnModify))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoEdit.aspx?JOT_ID={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (GetButtonPower(Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
bool isShow = true;
if (Grid1.SelectedRowIndexArray.Length > 1)
{
isShow = false;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (this.CurrUser.UserId == Const.sysglyId || this.CurrUser.UserId == Const.hfnbdId)
{
var HotHardItems = Funs.DB.HotHardItem.Where(x => x.JOT_ID == rowID).ToList();
Funs.DB.HotHardItem.DeleteAllOnSubmit(HotHardItems);
var CH_TrustItems = BLL.Funs.DB.CH_TrustItem.Where(x => x.JOT_ID == rowID).ToList();
Funs.DB.CH_TrustItem.DeleteAllOnSubmit(CH_TrustItems);
var CH_CheckItems = BLL.Funs.DB.CH_CheckItem.Where(x => x.JOT_ID == rowID).ToList();
Funs.DB.CH_CheckItem.DeleteAllOnSubmit(CH_CheckItems);
Funs.DB.SubmitChanges();
}
else if (judgementDelete(rowID, isShow))
{
BLL.PW_JointInfoService.DeleteJointInfo(rowID);
//BLL.Sys_LogService.AddLog(BLL.Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊口信息");
}
}
//ShowNotify("删除成功!", MessageBoxIcon.Success);
this.BindGrid();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 报表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
string isoId = this.tvControlItem.SelectedNodeID;
var q = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId);
if (q != null)
{
if (printType.SelectedValue == "0") //焊接工作记录
{
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ISO_IsoNo", q.ISO_IsoNo);
var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
var install = BLL.Project_InstallationService.GetInstallationByInstallationId(workArea.InstallationId);
keyValuePairs.Add("InstallationName", install.InstallationName);
keyValuePairs.Add("WorkAreaName", workArea.WorkAreaName);
// keyValuePairs.Add("ProjectName", ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId));
keyValuePairs.Add("ProjectName", install.InstallationName);
BLL.Common.FastReportService.ResetData();
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
string strSql = @"SELECT '' WED_Name,'' JOT_WeldDate_Month,''JOT_WeldDate_Day,jointInfo.JOT_ID,
jointInfo.ProjectId,
jointInfo.JOT_JointNo,
jointInfo.is_hj,
jointInfo.JointStatusName,
jointInfo.JOT_TrustFlagName,
jointInfo.JOT_CheckFlagName,
jointInfo.ISO_ID,
jointInfo.ISO_IsoNo,
jointInfo.ISO_IsoNumber,
jointInfo.WorkAreaId,
jointInfo.WorkAreaCode,
jointInfo.JOT_WeldDate,
jointInfo.JOT_DailyReportNo,
jointInfo.STE_Name1,
jointInfo.STE_Name2,
jointInfo.Component1,
jointInfo.Component2,
jointInfo.WED_Code1,
jointInfo.WED_Name1,
jointInfo.WED_Code2,
jointInfo.WED_Name2,
jointInfo.JOT_JointDesc,
jointInfo.JOT_Dia,
jointInfo.JOT_Size,
jointInfo.JOT_Sch,
jointInfo.JOT_FactSch,
jointInfo.GrooveTypeName,
jointInfo.JOTY_ID,
jointInfo.WeldTypeName,
jointInfo.WME_ID,
jointInfo.WeldingMethodName,
jointInfo.WeldSilk,
jointInfo.WeldMat,
jointInfo.WLO_Code,
jointInfo.WeldingLocationName,
jointInfo.JOT_DoneDin,
jointInfo.JOT_PrepareTemp,
jointInfo.JOT_JointAttribute,
jointInfo.JOT_CellTemp,
jointInfo.JOT_LastTemp,
jointInfo.JOT_HeartNo1,
jointInfo.JOT_HeartNo2,
jointInfo.PointDate,
jointInfo.PointNo,
jointInfo.CH_TrustCode,
jointInfo.CH_TrustDate,
jointInfo.JOT_FaceCheckResult,
jointInfo.JOT_FaceCheckDate,
jointInfo.JOT_FaceChecker,
jointInfo.IS_Proess,
jointInfo.JOT_BelongPipe,
jointInfo.JOT_Electricity,
jointInfo.JOT_Voltage,
jointInfo.JOT_ProessDate,
jointInfo.JOT_HotRpt,
jointInfo.JOT_Remark,jointInfo.JOT_Location"
+ @" from View_JointInfo as jointInfo "
+ @" WHERE jointInfo.ProjectId= @projectId AND jointInfo.ISO_ID=@isoId ";
List<SqlParameter> listStr = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
};
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql += " AND jointInfo.JOT_JointNo LIKE @JOT_JointNo";
listStr.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.dpIsHj.SelectedValue))
{
strSql += " AND jointInfo.is_hj = @is_hj";
listStr.Add(new SqlParameter("@is_hj", this.dpIsHj.SelectedValue));
}
strSql += " order by JOT_JointNo ";
SqlParameter[] parameter5 = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter5);
tb.Columns.Add("index", typeof(System.Int16));
foreach (DataRow row in tb.Rows)
{
try
{
row["index"] = int.Parse(System.Text.RegularExpressions.Regex.Replace(row["JOT_JointNo"].ToString(), @"[^0-9]+", ""));
}
catch (Exception ex)
{
row["index"] = 0;
}
}
DataView dv = tb.DefaultView;//获取表视图
dv.Sort = "index,JOT_JointNo ASC";//按照ID倒序排序
tb = dv.ToTable();//转为表
if (tb != null)
{
tb.TableName = "Table1";
for (int i = 0; i < tb.Rows.Count; i++)
{
string WED_Name = "";
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name1"].ToString()))
WED_Name += tb.Rows[i]["WED_Name1"].ToString();
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name2"].ToString()))
WED_Name += " " + tb.Rows[i]["WED_Name1"].ToString();
tb.Rows[i]["WED_Name"] = WED_Name;
if (!string.IsNullOrEmpty(tb.Rows[i]["JOT_WeldDate"].ToString()))
{
DateTimeFormat dateTimeFormat = new DateTimeFormat("yyyy-MM-DD HH:mm:ss.000");
DateTime dateTime = DateTime.Parse(tb.Rows[i]["JOT_WeldDate"].ToString());
tb.Rows[i]["JOT_WeldDate_Month"] = dateTime.Month + "";
tb.Rows[i]["JOT_WeldDate_Day"] = dateTime.Day + "";
}
if (!string.IsNullOrEmpty(tb.Rows[i]["WeldSilk"].ToString()) && !string.IsNullOrEmpty(tb.Rows[i]["WeldMat"].ToString()))
{
tb.Rows[i]["WeldMat"] = tb.Rows[i]["WeldSilk"].ToString() + "+" + tb.Rows[i]["WeldMat"].ToString();
}
else if (!string.IsNullOrEmpty(tb.Rows[i]["WeldSilk"].ToString()))
{
tb.Rows[i]["WeldMat"] = tb.Rows[i]["WeldSilk"].ToString();
}
}
}
BLL.Common.FastReportService.AddFastreportTable(tb);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊接工作记录.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
// string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
// //模板文件
// string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/焊接管道记录.xlsx";
// //导出文件
// string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
// if (!Directory.Exists(filePath))
// {
// Directory.CreateDirectory(filePath);
// }
// string ReportFileName = filePath + "out.xlsx";
// FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
// XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
// XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("管道焊接工作记录");
// recordSheet.GetRow(0).GetCell(0).SetCellValue(q.ISO_IsoNo);
// var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
// var install = BLL.Project_InstallationService.GetInstallationByInstallationId(workArea.InstallationId);
// recordSheet.GetRow(0).GetCell(10).SetCellValue(install.InstallationName);
// recordSheet.GetRow(2).GetCell(10).SetCellValue(workArea.WorkAreaName);
// string strSql = @"SELECT jointInfo.JOT_ID,
// jointInfo.ProjectId,
// jointInfo.JOT_JointNo,
// jointInfo.is_hj,
// jointInfo.JointStatusName,
// jointInfo.JOT_TrustFlagName,
// jointInfo.JOT_CheckFlagName,
// jointInfo.ISO_ID,
// jointInfo.ISO_IsoNo,
// jointInfo.ISO_IsoNumber,
// jointInfo.WorkAreaId,
// jointInfo.WorkAreaCode,
// jointInfo.JOT_WeldDate,
// jointInfo.JOT_DailyReportNo,
// jointInfo.STE_Name1,
// jointInfo.STE_Name2,
// jointInfo.Component1,
// jointInfo.Component2,
// jointInfo.WED_Code1,
// jointInfo.WED_Name1,
// jointInfo.WED_Code2,
// jointInfo.WED_Name2,
// jointInfo.JOT_JointDesc,
// jointInfo.JOT_Dia,
// jointInfo.JOT_Size,
// jointInfo.JOT_Sch,
// jointInfo.JOT_FactSch,
// jointInfo.GrooveTypeName,
// jointInfo.JOTY_ID,
// jointInfo.WeldTypeName,
// jointInfo.WME_ID,
// jointInfo.WeldingMethodName,
// jointInfo.WeldSilk,
// jointInfo.WeldMat,
// jointInfo.WLO_Code,
// jointInfo.WeldingLocationName,
// jointInfo.JOT_DoneDin,
// jointInfo.JOT_PrepareTemp,
// jointInfo.JOT_JointAttribute,
// jointInfo.JOT_CellTemp,
// jointInfo.JOT_LastTemp,
// jointInfo.JOT_HeartNo1,
// jointInfo.JOT_HeartNo2,
// jointInfo.PointDate,
// jointInfo.PointNo,
// jointInfo.CH_TrustCode,
// jointInfo.CH_TrustDate,
// jointInfo.JOT_FaceCheckResult,
// jointInfo.JOT_FaceCheckDate,
// jointInfo.JOT_FaceChecker,
// jointInfo.IS_Proess,
// jointInfo.JOT_BelongPipe,
// jointInfo.JOT_Electricity,
// jointInfo.JOT_Voltage,
// jointInfo.JOT_ProessDate,
// jointInfo.JOT_HotRpt,
// jointInfo.JOT_Remark,jointInfo.JOT_Location"
// + @" from View_JointInfo as jointInfo "
// + @" WHERE jointInfo.ProjectId= @projectId AND jointInfo.ISO_ID=@isoId order by JOT_JointNo ";
// List<SqlParameter> listStr = new List<SqlParameter>
//{
// new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
// new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
//};
// SqlParameter[] parameter = listStr.ToArray();
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// //if (tb.Rows.Count > 27)
// //{
// // // for (int i = 0; i < (tb.Rows.Count - 24) % 30; i++)
// // for (int j = 0; j < tb.Rows.Count - 27; j++)
// // {
// // recordSheet.GetRow(6).CopyRowTo(7 + j);
// // }
// //}
// if (tb.Rows.Count > 12)
// {
// recordSheet.ShiftRows(7, 34, tb.Rows.Count - 12);
// for (int j = 0; j < tb.Rows.Count - 12; j++)
// {
// recordSheet.CopyRow(6 + j, 7 + j);
// }
// }
// for (int i = 0; i < tb.Rows.Count; i++)
// {
// try
// {
// string WED_Name = "";
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name1"].ToString()))
// WED_Name += tb.Rows[i]["WED_Name1"].ToString();
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name2"].ToString()))
// WED_Name += " " + tb.Rows[i]["WED_Name1"].ToString();
// recordSheet.GetRow(5 + i).GetCell(0).SetCellValue(WED_Name);
// recordSheet.GetRow(5 + i).GetCell(1).SetCellValue(tb.Rows[i]["ISO_IsoNo"].ToString());
// recordSheet.GetRow(5 + i).GetCell(2).SetCellValue(tb.Rows[i]["JOT_JointNo"].ToString());
// recordSheet.GetRow(5 + i).GetCell(3).SetCellValue(tb.Rows[i]["JOT_JointDesc"].ToString());
// recordSheet.GetRow(5 + i).GetCell(4).SetCellValue(tb.Rows[i]["STE_Name1"].ToString());
// recordSheet.GetRow(5 + i).GetCell(5).SetCellValue(tb.Rows[i]["ISO_IsoNumber"].ToString());
// recordSheet.GetRow(5 + i).GetCell(6).SetCellValue(tb.Rows[i]["JOT_HotRpt"].ToString());
// recordSheet.GetRow(5 + i).GetCell(7).SetCellValue(tb.Rows[i]["WeldingMethodName"].ToString());
// recordSheet.GetRow(5 + i).GetCell(8).SetCellValue(tb.Rows[i]["JOT_Location"].ToString());
// if (!string.IsNullOrEmpty(tb.Rows[i]["JOT_WeldDate"].ToString()))
// {
// DateTimeFormat dateTimeFormat = new DateTimeFormat("yyyy-MM-DD HH:mm:ss.000");
// DateTime dateTime = DateTime.Parse(tb.Rows[i]["JOT_WeldDate"].ToString());
// recordSheet.GetRow(5 + i).GetCell(10).SetCellValue(dateTime.Month);
// recordSheet.GetRow(5 + i).GetCell(11).SetCellValue(dateTime.Day);
// }
// }
// catch (Exception)
// {
// }
// }
// using (FileStream filess = File.OpenWrite(ReportFileName))
// {
// hssfworkbook.Write(filess);
// }
// //PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
// FileInfo filet = new FileInfo(ReportFileName);
// Response.Clear();
// Response.Charset = "GB2312";
// Response.ContentEncoding = System.Text.Encoding.UTF8;
// // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
// Response.AddHeader("Content-Disposition", "attachment; filename=管道焊接工作记录_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
// // 添加头信息,指定文件大小,让浏览器能够显示下载进度
// Response.AddHeader("Content-Length", filet.Length.ToString());
// // 指定返回的是一个不能被客户端读取的流,必须被下载
// Response.ContentType = "application/ms-excel";
// // 把文件流发送到客户端
// Response.WriteFile(filet.FullName);
// // 停止页面的执行
// Response.End();
}
else if (printType.SelectedValue == "1")// 焊接工艺评定
{
//string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
////模板文件
//string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/管道焊接工艺检查记录.xlsx";
////导出文件
//string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
//if (!Directory.Exists(filePath))
//{
// Directory.CreateDirectory(filePath);
//}
//string ReportFileName = filePath + "out.xlsx";
//FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
//XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
//XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("管道焊接工艺检查记录");
var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
var install = BLL.Project_InstallationService.GetInstallationByInstallationId(workArea.InstallationId);
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ISO_IsoNo", q.ISO_IsoNo);
keyValuePairs.Add("install", install.InstallationName);
keyValuePairs.Add("workarea", workArea.WorkAreaName);
BLL.Common.FastReportService.ResetData();
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
string strSql = @"SELECT '' WED_Code,jointInfo.JOT_ID,
jointInfo.ProjectId,
jointInfo.JOT_JointNo,
jointInfo.is_hj,
jointInfo.JointStatusName,
jointInfo.JOT_TrustFlagName,
jointInfo.JOT_CheckFlagName,
jointInfo.ISO_ID,
jointInfo.ISO_IsoNo,
jointInfo.ISO_IsoNumber,
jointInfo.WorkAreaId,
jointInfo.WorkAreaCode,
jointInfo.JOT_WeldDate,
jointInfo.JOT_DailyReportNo,
jointInfo.STE_Name1,
jointInfo.STE_Name2,
jointInfo.Component1,
jointInfo.Component2,
jointInfo.WED_Code1,
jointInfo.WED_Name1,
jointInfo.WED_Code2,
jointInfo.WED_Name2,
jointInfo.JOT_JointDesc,
jointInfo.JOT_Dia,
jointInfo.JOT_Size,
jointInfo.JOT_Sch,
jointInfo.JOT_FactSch,
jointInfo.GrooveTypeName,
jointInfo.JOTY_ID,
jointInfo.WeldTypeName,
jointInfo.WME_ID,
jointInfo.WeldingMethodName,
jointInfo.WeldSilk,
jointInfo.WeldMat,
jointInfo.WLO_Code,
jointInfo.WeldingLocationName,
jointInfo.JOT_DoneDin,
jointInfo.JOT_PrepareTemp,
jointInfo.JOT_JointAttribute,
jointInfo.JOT_CellTemp,
jointInfo.JOT_LastTemp,
jointInfo.JOT_HeartNo1,
jointInfo.JOT_HeartNo2,
jointInfo.PointDate,
jointInfo.PointNo,
jointInfo.CH_TrustCode,
jointInfo.CH_TrustDate,
jointInfo.JOT_FaceCheckResult,
jointInfo.JOT_FaceCheckDate,
jointInfo.JOT_FaceChecker,
jointInfo.IS_Proess,
jointInfo.JOT_BelongPipe,
jointInfo.JOT_Electricity,
jointInfo.JOT_Voltage,
jointInfo.JOT_ProessDate,
jointInfo.JOT_HotRpt,
jointInfo.JOT_Remark,jointInfo.JOT_Location"
+ @" from View_JointInfo as jointInfo "
+ @" WHERE jointInfo.ProjectId= @projectId AND jointInfo.ISO_ID=@isoId ";
List<SqlParameter> listStr = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
};
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql += " AND jointInfo.JOT_JointNo LIKE @JOT_JointNo";
listStr.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.dpIsHj.SelectedValue))
{
strSql += " AND jointInfo.is_hj = @is_hj";
listStr.Add(new SqlParameter("@is_hj", this.dpIsHj.SelectedValue));
}
strSql += " order by JOT_JointNo ";
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
//if (tb.Rows.Count > 27)
//{
// // for (int i = 0; i < (tb.Rows.Count - 24) % 30; i++)
// for (int j = 0; j < tb.Rows.Count - 27; j++)
// {
// recordSheet.GetRow(6).CopyRowTo(7 + j);
// }
//}
//if (tb.Rows.Count > 12)
//{
// recordSheet.ShiftRows(7, 34, tb.Rows.Count - 12);
// for (int j = 0; j < tb.Rows.Count - 12; j++)
// {
// recordSheet.CopyRow(6 + j, 7 + j);
// }
//}
for (int i = 0; i < tb.Rows.Count; i++)
{
try
{
string WED_Code = "";
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code1"].ToString()))
WED_Code += tb.Rows[i]["WED_Code1"].ToString();
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code2"].ToString()))
WED_Code += " " + tb.Rows[i]["WED_Code2"].ToString();
tb.Rows[i]["WED_Code"] = WED_Code;
//recordSheet.GetRow(5 + i).GetCell(0).SetCellValue(tb.Rows[i]["ISO_IsoNo"].ToString());
//recordSheet.GetRow(5 + i).GetCell(1).SetCellValue("");
//recordSheet.GetRow(5 + i).GetCell(2).SetCellValue(tb.Rows[i]["JOT_JointNo"].ToString());
//recordSheet.GetRow(5 + i).GetCell(4).SetCellValue(WED_Code);
//recordSheet.GetRow(5 + i).GetCell(5).SetCellValue("");
//recordSheet.GetRow(5 + i).GetCell(6).SetCellValue("");
//recordSheet.GetRow(5 + i).GetCell(7).SetCellValue("");
//recordSheet.GetRow(5 + i).GetCell(8).SetCellValue(tb.Rows[i]["WeldingMethodName"].ToString());
//recordSheet.GetRow(5 + i).GetCell(9).SetCellValue(tb.Rows[i]["JOT_Electricity"].ToString());
//recordSheet.GetRow(5 + i).GetCell(10).SetCellValue(tb.Rows[i]["JOT_Voltage"].ToString());
//recordSheet.GetRow(5 + i).GetCell(11).SetCellValue("");
//recordSheet.GetRow(5 + i).GetCell(13).SetCellValue(tb.Rows[i]["JOT_PrepareTemp"].ToString());
//recordSheet.GetRow(5 + i).GetCell(14).SetCellValue(tb.Rows[i]["JOT_CellTemp"].ToString());
//recordSheet.GetRow(5 + i).GetCell(15).SetCellValue(tb.Rows[i]["JOT_LastTemp"].ToString());
//if (!string.IsNullOrEmpty(tb.Rows[i]["JOT_FaceCheckDate"].ToString()))
//{
// DateTimeFormat dateTimeFormat = new DateTimeFormat("yyyy-MM-DD HH:mm:ss.000");
// DateTime dateTime = DateTime.Parse(tb.Rows[i]["JOT_FaceCheckDate"].ToString());
// recordSheet.GetRow(5 + i).GetCell(16).SetCellValue(dateTime.ToShortDateString());
//}
}
catch (Exception)
{
}
}
tb.TableName = "Table1";
BLL.Common.FastReportService.AddFastreportTable(tb);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊接工艺检查记录.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
//using (FileStream filess = File.OpenWrite(ReportFileName))
//{
// hssfworkbook.Write(filess);
//}
////PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
//FileInfo filet = new FileInfo(ReportFileName);
//Response.Clear();
//Response.Charset = "GB2312";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
//// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
//Response.AddHeader("Content-Disposition", "attachment; filename=管道焊接工艺检查记录_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
//// 添加头信息,指定文件大小,让浏览器能够显示下载进度
//Response.AddHeader("Content-Length", filet.Length.ToString());
//// 指定返回的是一个不能被客户端读取的流,必须被下载
//Response.ContentType = "application/ms-excel";
//// 把文件流发送到客户端
//Response.WriteFile(filet.FullName);
//// 停止页面的执行
//Response.End();
}
}
else if (printType.SelectedValue == "2")// 焊接工艺评定
{
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ISO_IsoNo", q.ISO_IsoNo);
var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
var install = BLL.Project_InstallationService.GetInstallationByInstallationId(workArea.InstallationId);
var project = BLL.ProjectService.GetProjectByProjectId(q.ProjectId);
keyValuePairs.Add("ProjecctName", project.ProjectName);//工程名称
keyValuePairs.Add("InstallationName", install.InstallationName);
keyValuePairs.Add("WorkAreaName", workArea.WorkAreaName);//单位工程名称
keyValuePairs.Add("ISOName", q.ISO_IsoNumber);//设备名称
keyValuePairs.Add("ISO_Specification", q.ISO_Specification);//设备规格
var material = Base_MaterialService.GetMaterialByMaterialId(q.MaterialId);
keyValuePairs.Add("MaterialCode", material.MaterialCode);//设备材质
String strSql1 = @"SELECT '' WED_Code, jointInfo.JOT_JointNo,--焊缝位置/焊缝编号
'' WED_Name,--
jointInfo.JOT_JointDesc,--mm
jointInfo.JOT_PrepareTemp, --
jointInfo.JOT_Electricity, -- A
jointInfo.JOT_Voltage, -- V
jointInfo.JOT_ID,
jointInfo.ProjectId,
jointInfo.JOT_WeldDate, --
jointInfo.WeldingMethodName,
jointInfo.WeldSilk,
WED_Name1,WED_Name2,WED_Code1,WED_Code2
from View_JointInfo as jointInfo WHERE jointInfo.ProjectId= @projectId AND jointInfo.ISO_ID=@isoId ";
List<SqlParameter> listStr1 = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
};
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql1 += " AND jointInfo.JOT_JointNo LIKE @JOT_JointNo";
listStr1.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.dpIsHj.SelectedValue))
{
strSql1 += " AND jointInfo.is_hj = @is_hj";
listStr1.Add(new SqlParameter("@is_hj", this.dpIsHj.SelectedValue));
}
strSql1 += " order by JOT_JointNo ";
SqlParameter[] parameter1 = listStr1.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql1, parameter1);
if (tb.Rows.Count > 0)
{
keyValuePairs.Add("WeldingMethodName", tb.Rows[0]["WeldingMethodName"].ToString());//焊接方法
keyValuePairs.Add("WeldSilk", tb.Rows[0]["WeldSilk"].ToString());//焊接材料
}
for (int i = 0; i < tb.Rows.Count; i++)
{
try
{
string WED_Name = "";
string WED_Code = "";
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name1"].ToString()))
{
WED_Name += tb.Rows[i]["WED_Name1"].ToString();
WED_Code += tb.Rows[i]["WED_Code1"].ToString();
}
if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Name2"].ToString()))
{
WED_Name += "," + tb.Rows[i]["WED_Name2"].ToString();
WED_Code += "," + tb.Rows[i]["WED_Code2"].ToString();
}
tb.Rows[i]["WED_Name"] = WED_Name;
tb.Rows[i]["WED_Code"] = WED_Code;
}
catch (Exception)
{
}
}
BLL.Common.FastReportService.ResetData();
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
tb.TableName = "Table1";
BLL.Common.FastReportService.AddFastreportTable(tb);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\设备焊接工作记录.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
else if (printType.SelectedValue == "3")
{
string varValue = string.Empty;
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
var workarea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
var installationName = BLL.Project_InstallationService.GetInstallationByInstallationId(workarea.InstallationId).InstallationName;
var unitName = BLL.UnitService.GetUnitNameByUnitId(q.UnitId);
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
//模板文件
string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/管道焊接接头报检检查记录.xlsx";
//导出文件
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string ReportFileName = filePath + "out.xlsx";
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
ICellStyle styleCenter = hssfworkbook.CreateCellStyle();
styleCenter.VerticalAlignment = VerticalAlignment.Center;
styleCenter.Alignment = HorizontalAlignment.Center;
styleCenter.BorderLeft = BorderStyle.Thin;
styleCenter.BorderTop = BorderStyle.Thin;
styleCenter.BorderRight = BorderStyle.Thin;
styleCenter.BorderBottom = BorderStyle.Thin;
styleCenter.WrapText = true;
IFont font = styleCenter.GetFont(hssfworkbook);
// font.Color = 10;//颜色
font.FontHeightInPoints = 10;//字体高度与excel中的字号一致
styleCenter.SetFont(font);
XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("管道焊接接头报检检查记录");
// recordSheet.AddMergedRegion(new CellRangeAddress(0, 0, 8, 9));
var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
//recordSheet.GetRow(0).CreateCell(14).SetCellValue(projectName.ToString());
recordSheet.GetRow(0).CreateCell(14).SetCellValue(installationName);
recordSheet.GetRow(0).GetCell(14).CellStyle = styleCenter;
recordSheet.GetRow(2).CreateCell(14).SetCellValue(workarea.WorkAreaName);
recordSheet.GetRow(2).GetCell(14).CellStyle = styleCenter;
recordSheet.GetRow(2).CreateCell(1).SetCellValue(unitName);
recordSheet.GetRow(2).GetCell(1).CellStyle = styleCenter;
recordSheet.GetRow(3).GetCell(8).CellStyle = styleCenter;
//recordSheet.GetRow(2).CreateCell(7).SetCellValue(q.CHT_CheckCode);
recordSheet.GetRow(2).GetCell(7).CellStyle = styleCenter;
int i = 0;
List<Model.View_JointInfo> items = Funs.DB.View_JointInfo.Where(x => x.ISO_ID == q.ISO_ID).ToList();
var ndtt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(items[0].DetectionTypeId);
if (ndtt != null)
{
recordSheet.GetRow(3).CreateCell(8).SetCellValue(ndtt.DetectionTypeCode);
}
recordSheet.GetRow(3).CreateCell(14).SetCellValue(items.Count + "个");
recordSheet.GetRow(3).GetCell(14).CellStyle = styleCenter;
if (items.Count > 11)
{
recordSheet.ShiftRows(17, 19, items.Count - 11);
for (int j = 0; j < items.Count - 11; j++)
{
recordSheet.CopyRow(16 + j, 17 + j);
}
recordSheet.GetRow(items.Count + 7).Height = recordSheet.GetRow(items.Count + 5).Height;
recordSheet.GetRow(items.Count + 6).Height = recordSheet.GetRow(items.Count + 5).Height;
}
foreach (var t in items)
{
if (q != null)
{
var dDetectionRate = Funs.DB.Base_DetectionRate.FirstOrDefault(x => x.DetectionRateId == q.DetectionRateId);
if (dDetectionRate != null)
{
recordSheet.GetRow(3).CreateCell(18).SetCellValue(dDetectionRate.DetectionRateValue + "%");
recordSheet.GetRow(3).GetCell(18).CellStyle = styleCenter;
}
}
recordSheet.GetRow(i + 6).CreateCell(0).SetCellValue((i + 1) + "");
recordSheet.GetRow(i + 6).GetCell(0).CellStyle = styleCenter;
recordSheet.GetRow(i + 6).CreateCell(1).SetCellValue(q.ISO_IsoNo);
recordSheet.GetRow(i + 6).GetCell(1).CellStyle = styleCenter;
recordSheet.GetRow(i + 6).CreateCell(3).SetCellValue(t.JOT_JointNo);
recordSheet.GetRow(i + 6).GetCell(3).CellStyle = styleCenter;
string welderCode = t.WED_Code1;
if (!string.IsNullOrEmpty(t.WED_Code2))
{
if (!string.IsNullOrEmpty(welderCode))
{
if (welderCode != t.WED_Code2)
{
welderCode += "," + t.WED_Code2;
}
}
else
{
welderCode = t.WED_Code2;
}
}
recordSheet.GetRow(i + 6).CreateCell(4).SetCellValue(welderCode);
recordSheet.GetRow(i + 6).GetCell(4).CellStyle = styleCenter;
#region
recordSheet.GetRow(i + 6).CreateCell(6).SetCellValue(t.JOT_JointDesc);
recordSheet.GetRow(i + 6).GetCell(6).CellStyle = styleCenter;
recordSheet.GetRow(i + 6).CreateCell(7).SetCellValue(t.STE_Name1);
recordSheet.GetRow(i + 6).GetCell(7).CellStyle = styleCenter;
recordSheet.GetRow(i + 6).CreateCell(10).SetCellValue(t.JOT_Location);
recordSheet.GetRow(i + 6).GetCell(10).CellStyle = styleCenter;
recordSheet.GetRow(i + 6).CreateCell(11).SetCellValue(t.WeldingMethodName);
recordSheet.GetRow(i + 6).GetCell(11).CellStyle = styleCenter;
string weldMat = "";
if (!string.IsNullOrEmpty(t.JOT_WeldSilk))
{
var consumables = Funs.DB.Base_Consumables.FirstOrDefault(x => x.ConsumablesId == t.JOT_WeldSilk);
if (consumables != null)
{
weldMat = consumables.ConsumablesName;
}
}
if (!string.IsNullOrEmpty(t.JOT_WeldMat))
{
var consumables = Funs.DB.Base_Consumables.FirstOrDefault(x => x.ConsumablesId == t.JOT_WeldMat);
if (consumables != null)
{
if (!string.IsNullOrEmpty(weldMat))
{
weldMat += "," + consumables.ConsumablesName;
}
else
{
weldMat = consumables.ConsumablesName;
}
}
}
recordSheet.GetRow(i + 6).CreateCell(12).SetCellValue(weldMat);
recordSheet.GetRow(i + 6).GetCell(12).CellStyle = styleCenter;
if (t.JOT_PrepareTemp.HasValue)
{
recordSheet.GetRow(i + 6).CreateCell(14).SetCellValue(t.JOT_PrepareTemp.Value.ToString("##.#"));
recordSheet.GetRow(i + 6).GetCell(14).CellStyle = styleCenter;
}
recordSheet.GetRow(i + 6).CreateCell(16).SetCellValue("合格");
recordSheet.GetRow(i + 6).GetCell(16).CellStyle = styleCenter;
#endregion
// checkItems.Add(checkItem);
i++;
}
using (FileStream filess = File.OpenWrite(ReportFileName))
{
hssfworkbook.Write(filess);
}
//PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
FileInfo filet = new FileInfo(ReportFileName);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response.AddHeader("Content-Disposition", "attachment; filename=管道焊接接头报检检查记录_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", filet.Length.ToString());
// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.ContentType = "application/ms-excel";
// 把文件流发送到客户端
Response.WriteFile(filet.FullName);
// 停止页面的执行
Response.End();
}
else if (printType.SelectedValue == "4")
{
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(q.WorkAreaId);
var install = BLL.Project_InstallationService.GetInstallationByInstallationId(workArea.InstallationId);
var project = BLL.ProjectService.GetProjectByProjectId(q.ProjectId);
keyValuePairs.Add("ProjecctName", project.ProjectName);//工程名称
keyValuePairs.Add("WorkAreaName", workArea.WorkAreaName);//单位工程名称
String strSql1 = @" select iso.ISO_IsoNo,jot.JOT_JointNo,PointCount,RequiredT,ActualT,RequestTime,ActualTime,ProessDate,RecordChartNo ,m.MaterialCode,JOT_JointDesc
from PW_JointInfo jot left join PW_IsoInfo iso on jot.ISO_ID=iso.ISO_ID
left join HJGL_HotProess_Report hot on jot.JOT_ID = hot.WeldJointId
left join Base_Material m on jot.MaterialId=m.MaterialId WHERE hot.WeldJointId is not null and jot.ProjectId= @projectId AND jot.ISO_ID=@isoId ";
List<SqlParameter> listStr1 = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
};
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql1 += " AND jot.JOT_JointNo LIKE @JOT_JointNo";
listStr1.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.dpIsHj.SelectedValue))
{
strSql1 += " AND jot.is_hj = @is_hj";
listStr1.Add(new SqlParameter("@is_hj", this.dpIsHj.SelectedValue));
}
strSql1 += " order by JOT_JointNo ";
SqlParameter[] parameter1 = listStr1.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql1, parameter1);
BLL.Common.FastReportService.ResetData();
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
tb.TableName = "Table1";
BLL.Common.FastReportService.AddFastreportTable(tb);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊接接头热处理报告.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
}
else
{
Alert.ShowInTop("请选择管线!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs 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();
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete(string id, bool isShow)
{
string content = string.Empty;
if (BLL.HotProessManageEditService.GetHotProessByJOTID(id).Count() > 0)
{
content = "热处理已经使用了该焊口,不能删除!";
}
if (BLL.Funs.DB.CH_TrustItem.FirstOrDefault(x => x.JOT_ID == id) != null)
{
content = "无损委托已经使用了该焊口,不能删除!";
}
if (BLL.Funs.DB.CH_CheckItem.FirstOrDefault(x => x.JOT_ID == id) != null)
{
content = "检测单已经使用了该焊口,不能删除!";
}
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content, MessageBoxIcon.Error);
}
return false;
}
}
#endregion
#region
/// <summary>
/// 导出焊口初始信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut2_Click(object sender, EventArgs e)
{
var iso = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(this.tvControlItem.SelectedNodeID);
if (iso != null)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("JointInfoOut.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "导出 - ")));
}
else
{
Alert.ShowInTop("请先选择一条管线!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 选择显示列
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelectColumn_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("JointShowColumn.aspx", "显示列 - ")));
}
#endregion
#region
protected void Window4_Close(object sender, WindowCloseEventArgs e)
{
this.BindGrid();
//显示列
Model.Sys_UserShowColumns c = BLL.UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "Joint");
if (c != null)
{
this.GetShowColumn(c.Columns);
}
}
/// <summary>
/// 显示的列
/// </summary>
/// <param name="column"></param>
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;
this.Grid1.Columns[34].Hidden = true;
this.Grid1.Columns[35].Hidden = true;
this.Grid1.Columns[36].Hidden = true;
this.Grid1.Columns[37].Hidden = true;
this.Grid1.Columns[38].Hidden = true;
this.Grid1.Columns[39].Hidden = true;
this.Grid1.Columns[40].Hidden = true;
this.Grid1.Columns[41].Hidden = true;
this.Grid1.Columns[42].Hidden = true;
this.Grid1.Columns[43].Hidden = true;
this.Grid1.Columns[44].Hidden = true;
this.Grid1.Columns[45].Hidden = true;
this.Grid1.Columns[46].Hidden = true;
this.Grid1.Columns[47].Hidden = true;
List<string> columns = column.Split(',').ToList();
foreach (var item in columns)
{
this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private bool GetButtonPower(string button)
{
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_JointInfoMenuId, button);
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtJOT_JointNo_TextChanged(object sender, EventArgs e)
{
BindGrid();
}
#endregion
protected void dpIsHj_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
}
}