ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/HJGL/WeldingManage/JointInfo.aspx.cs

1083 lines
50 KiB
C#
Raw Normal View History

2024-05-08 17:17:11 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
using System.Web;
using NPOI.XSSF.UserModel;
using NPOI.SS.Util;
using System.IO;
using NPOI.SS.UserModel;
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.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "2");
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;
List<string> columns = column.Split(',').ToList();
foreach (var item in columns)
{
this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false;
}
}
}
#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 joints = from x in Funs.DB.HJGL_PW_JointInfo where x.ProjectId == this.CurrUser.LoginProjectId select x;
var iso = from x in Funs.DB.HJGL_PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId select x;
if (!string.IsNullOrEmpty(this.txtIsono.Text))
{
iso = iso.Where(e => e.ISO_IsoNo.Contains(this.txtIsono.Text.Trim()));
}
iso = iso.OrderBy(x => x.ISO_IsoNo);
if (iso.Count() > 0)
{
foreach (var q in iso)
{
int jotCount = (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == q.ISO_ID select x).Count();
TreeNode newNode = new TreeNode();
newNode.NodeID = q.ISO_ID;
newNode.Text = q.ISO_IsoNo;
newNode.Text += "【" + jotCount.ToString() + "焊口】";
newNode.EnableClickEvent = true;
rootNode.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)
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID);
{
if (iso != null)
{
lbDesignPress.Text = iso.ISO_DesignPress.HasValue ? iso.ISO_DesignPress.Value.ToString("F2").Trim() : "";
lbDesignTemperature.Text = iso.ISO_DesignTemperature.HasValue ? iso.ISO_DesignTemperature.Value.ToString("F2").Trim() : "";
var ste = BLL.HJGL_MaterialService.GetSteelBySteID(iso.STE_ID);
if (ste != null)
{
lbMat.Text = ste.STE_Code.Trim();
}
var ser = BLL.HJGL_MediumService.GetServiceBySERID(iso.SER_ID);
if (ser != null)
{
lbSer.Text = ser.SER_Code.Trim();
}
}
}
}
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT JOT_ID,ProjectId,JOT_JointNo,Sort1,Sort2,Sort3,Sort4,Sort5
,JOT_DailyReportNo,JOT_WeldDate,ISO_ID,ISO_IsoNo,STE_Name1,STE_Name2,WED_Code1,WED_Name1,WED_Code2
,(CASE WHEN STE_Name1 IS NOT NULL AND STE_Name2 IS NOT NULL and STE_Name1!=STE_Name2 THEN STE_Name1 + '/' + STE_Name2
WHEN STE_Name1 IS NOT NULL THEN STE_Name1 ELSE ISNULL(STE_Name2,'') END) AS STE_Name --
,WED_Name2,WLO_Code,(CASE WHEN WLO_Code='F' THEN '' WHEN WLO_Code='S' THEN '' ELSE '' END) AS WLO_Name
,JOT_DoneDin,IS_Compute,Component1,Component2,WeldMat,JointStatus
,(CASE WHEN JointStatus='1' THEN '' WHEN JointStatus='2' THEN '' WHEN JointStatus='3' THEN '' ELSE '' END) AS JointStatusName
,JOT_Dia,JOT_Size,JOT_Sch,JOT_FactSch,JOT_JointDesc,WeldSilk,JOTY_Name,WME_Name
,JST_Name,(CASE WHEN IS_Proess= '1' THEN '是' ELSE '否' END) AS IS_Proess
,JOT_PrepareTemp,JOT_CellTemp,JOT_LastTemp,JOT_JointAttribute,BatchCode,PointDate
,ProessTypes,JOT_Remark,NDTR_Name,Is_hj,If_dk
,(CASE WHEN IsSpecial=1 THEN '是' ELSE '否' END) AS IsSpecialName
FROM HJGL_View_JointInfo WHERE ProjectId= @ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
if (rbIsHj.SelectedValue == "0")
{
strSql += " AND ISO_ID =@ISO_ID";
listStr.Add(new SqlParameter("@ISO_ID", this.tvControlItem.SelectedNodeID));
}
if (rbIsHj.SelectedValue == "1")
{
strSql += " AND ISO_ID =@ISO_ID AND Is_hj=1";
listStr.Add(new SqlParameter("@ISO_ID", this.tvControlItem.SelectedNodeID));
}
if (rbIsHj.SelectedValue == "2")
{
strSql += " AND ISO_ID =@ISO_ID AND Is_hj=0";
listStr.Add(new SqlParameter("@ISO_ID", this.tvControlItem.SelectedNodeID));
}
if (!string.IsNullOrEmpty(this.txtJOT_JointNo.Text.Trim()))
{
strSql += " AND JOT_JointNo LIKE @JOT_JointNo";
listStr.Add(new SqlParameter("@JOT_JointNo", "%" + this.txtJOT_JointNo.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
//this.Grid1.PageIndex = 0;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
if (!string.IsNullOrEmpty(this.hdPageMax.Text))
{
int newPageIndex = 0;
decimal c = Convert.ToDecimal(Math.Round(Convert.ToDecimal(Grid1.RecordCount) / Convert.ToDecimal(this.Grid1.PageSize), 2));
if (c.ToString().IndexOf(".") > 0 && c.ToString().Substring(c.ToString().IndexOf("."), c.ToString().Length - c.ToString().IndexOf(".")) != ".00")
{
string c1 = c.ToString().Substring(0, c.ToString().IndexOf("."));
newPageIndex = Convert.ToInt32(c1);
}
else
{
newPageIndex = Convert.ToInt32(c) - 1;
}
this.Grid1.PageIndex = newPageIndex;
var table2 = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table2;
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
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
// DataRowView row = e.DataItem as DataRowView;
string jotid = Grid1.DataKeys[e.RowIndex][0].ToString();
var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByJotId(jotid);
var hot = Funs.DB.HJGL_CH_HotProessTrustItem.FirstOrDefault(x => x.JOT_ID == jotid);
if (batchDetail != null)
{
var batch = BLL.HJGL_BO_BatchService.GetBatchById(batchDetail.BatchId);
WindowField joint = Grid1.FindColumn("JOT_JointNo") as WindowField;
if (batch.BatchIsClosed == true || hot != null)
{
e.CellCssClasses[joint.ColumnIndex] = "color";
}
}
}
#endregion
#region
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_JointInfoMenuId, BLL.Const.BtnModify))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoEdit.aspx?JOT_ID={0}", Grid1.SelectedRowID, "编辑 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 增加焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnAdd))
{
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID);
if (isoInfo != null)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoEdit.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
}
else
{
ShowNotify("请先选择管线!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 批量增加焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnBatchAdd_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnAdd))
{
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(tvControlItem.SelectedNodeID);
if (isoInfo != null)
{
this.hdPageMax.Text = "1";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("JointInfoBatchEdit.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
}
else
{
ShowNotify("请先选择管线!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 焊口信息编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_JointInfoMenuId, BLL.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
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
protected void btnMenuUpdate_Click(object sender, EventArgs e)
{
if (this.CurrUser.Account == Const.Gly)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(Grid1.SelectedRowID);
if (!string.IsNullOrEmpty(jot.DReportID))
{
PageContext.RegisterStartupScript(Window8.GetShowReference(String.Format("JointReportUpdate.aspx?JOT_ID={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("该焊口还未焊接!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("只有管理员才有更改的权限!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
bool isShow = true;
if (Grid1.SelectedRowIndexArray.Length > 1)
{
isShow = false;
}
bool isDelete = false;
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (judgementDelete(rowID, isShow))
{
isDelete = true;
BLL.HJGL_BO_BatchDetailService.DeleteBatchDetail(rowID); //删除批明细
BLL.HJGL_PW_JointInfoService.DeleteJointInfo(rowID);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊口信息");
}
}
if (isDelete)
{
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
}
this.BindGrid();
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 报表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
#region
//string isoId = this.tvControlItem.SelectedNodeID;
//var q = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId);
//if (q != null)
//{
// string varValue = string.Empty;
// var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
// if (project != null)
// {
// varValue = project.ProjectName + "|管道";
// }
// if (!string.IsNullOrEmpty(varValue))
// {
// //varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ","));
// varValue = HttpUtility.UrlEncodeUnicode(varValue);
// }
// PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_JointInfoReportId, isoId, varValue)));
//}
//else
//{
// ShowNotify("请选择管线!", MessageBoxIcon.Warning);
// return;
//}
#endregion
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
//导出文件
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string ReportFileName = filePath + "out.xlsx";
var project = Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
var isoList = from x in Funs.DB.HJGL_PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId select x;
if (isoList != null && isoList.Count() > 0)
{
int rowIndex = 0;
XSSFWorkbook hssfworkbook = new XSSFWorkbook();
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("焊接工作记录");
foreach (var item in isoList)
{
var listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@IsoId", item.ISO_ID));
listStr.Add(new SqlParameter("@Flag", "0"));
SqlParameter[] parameter = listStr.ToArray();
var tb = SQLHelper.GetDataTableRunProc("HJGL_spJointWorkRecordNew", parameter);
if (tb.Rows.Count > 0)
{
var workIndex = Math.Ceiling((float)tb.Rows.Count / 11);
for (int i = 1; i <= workIndex; i++)
{
var pageTb = GetPageToDataTable(tb, i, 11);
ICellStyle style = hssfworkbook.CreateCellStyle();
style.BorderBottom = BorderStyle.Thin;
style.BorderLeft = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
style.BorderTop = BorderStyle.Thin;
style.VerticalAlignment = VerticalAlignment.Center;
style.Alignment = HorizontalAlignment.Center;
IFont font = hssfworkbook.CreateFont();
font.FontHeightInPoints = 7;
style.SetFont(font);
style.WrapText = true;
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 18, style, 0, 12);
#region
CellRangeAddress region = new CellRangeAddress(rowIndex, rowIndex + 1, 0, 2);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(0).SetCellValue("SH/T 3503-J415-1");
region = new CellRangeAddress(rowIndex, rowIndex + 1, 3, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(3).SetCellValue("管道焊接工作记录" + (i > 1 ? "续" : "") + "");
region = new CellRangeAddress(rowIndex, rowIndex, 9, 10);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(9).SetCellValue("工程名称:");
region = new CellRangeAddress(rowIndex, rowIndex, 11, 12);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(11).SetCellValue(project.ProjectName);
region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 9, 10);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 1).GetCell(9).SetCellValue("单位工程名称:");
region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 11, 12);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("管道");
#endregion
#region
var dataTit = rowIndex + 2;
//合并单元格
for (int hb = dataTit; hb <= dataTit + 11; hb++)
{
region = new CellRangeAddress(hb, hb, 0, 1);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 8, 9);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 10, 11);
ws.AddMergedRegion(region);
}
//列头
ws.GetRow(dataTit).GetCell(0).SetCellValue("管道编号/单线号");
ws.GetRow(dataTit).GetCell(2).SetCellValue("焊口\n编号");
ws.GetRow(dataTit).GetCell(3).SetCellValue("焊工\n代号");
ws.GetRow(dataTit).GetCell(4).SetCellValue("规格\nmm");
ws.GetRow(dataTit).GetCell(5).SetCellValue("材质");
ws.GetRow(dataTit).GetCell(6).SetCellValue("焊接位置");
ws.GetRow(dataTit).GetCell(7).SetCellValue("焊接方法");
ws.GetRow(dataTit).GetCell(8).SetCellValue("焊材牌号");
ws.GetRow(dataTit).GetCell(10).SetCellValue("实际预热\n温度℃");
ws.GetRow(dataTit).GetCell(12).SetCellValue("焊接日期");
//数据
for (int j = 0; j < pageTb.Rows.Count; j++)
{
int dataIndex = rowIndex + j + 3;
ws.GetRow(dataIndex).GetCell(0).SetCellValue(pageTb.Rows[j]["ISO_IsoNo"].ToString());
ws.GetRow(dataIndex).GetCell(2).SetCellValue(pageTb.Rows[j]["JOT_JointNo"].ToString());
ws.GetRow(dataIndex).GetCell(3).SetCellValue(pageTb.Rows[j]["WED_Code"].ToString());
ws.GetRow(dataIndex).GetCell(4).SetCellValue(pageTb.Rows[j]["JOT_JointDesc"].ToString());
ws.GetRow(dataIndex).GetCell(5).SetCellValue(pageTb.Rows[j]["STE_Code"].ToString());
ws.GetRow(dataIndex).GetCell(6).SetCellValue(pageTb.Rows[j]["weldLocal"].ToString());
ws.GetRow(dataIndex).GetCell(7).SetCellValue(pageTb.Rows[j]["WME_Name"].ToString());
ws.GetRow(dataIndex).GetCell(8).SetCellValue(pageTb.Rows[j]["WMT_MatName"].ToString());
ws.GetRow(dataIndex).GetCell(10).SetCellValue(pageTb.Rows[j]["JOT_PrepareTemp"].ToString());
ws.GetRow(dataIndex).GetCell(12).SetCellValue(pageTb.Rows[j]["WeldDate"].ToString());
}
#endregion
#region
if (i == 1)
{
var tailIndex = rowIndex + 14;
region = new CellRangeAddress(tailIndex, tailIndex, 0, 3);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex).GetCell(0).CellStyle = style;
ws.GetRow(tailIndex).GetCell(1).CellStyle = style;
ws.GetRow(tailIndex).GetCell(2).CellStyle = style;
ws.GetRow(tailIndex).GetCell(3).CellStyle = style;
ws.GetRow(tailIndex).GetCell(0).SetCellValue("建设/监理单位");
ws.GetRow(tailIndex + 1).GetCell(0).SetCellValue("专业工程师:");
region = new CellRangeAddress(tailIndex + 4, tailIndex + 4, 1, 3);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 4).GetCell(0).SetCellValue("日期:");
region = new CellRangeAddress(tailIndex, tailIndex, 4, 7);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex).GetCell(4).CellStyle = style;
ws.GetRow(tailIndex).GetCell(5).CellStyle = style;
ws.GetRow(tailIndex).GetCell(6).CellStyle = style;
ws.GetRow(tailIndex).GetCell(7).CellStyle = style;
ws.GetRow(tailIndex).GetCell(4).SetCellValue("总承包单位");
ws.GetRow(tailIndex + 1).GetCell(4).SetCellValue("专业工程师:");
region = new CellRangeAddress(tailIndex + 4, tailIndex + 4, 5, 7);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 4).GetCell(4).SetCellValue("日期:");
region = new CellRangeAddress(tailIndex, tailIndex, 8, 12);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex).GetCell(8).CellStyle = style;
ws.GetRow(tailIndex).GetCell(9).CellStyle = style;
ws.GetRow(tailIndex).GetCell(10).CellStyle = style;
ws.GetRow(tailIndex).GetCell(11).CellStyle = style;
ws.GetRow(tailIndex).GetCell(12).CellStyle = style;
ws.GetRow(tailIndex).GetCell(8).SetCellValue("施工单位");
region = new CellRangeAddress(tailIndex + 1, tailIndex + 1, 8, 9);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 1).GetCell(8).SetCellValue("记录人:");
region = new CellRangeAddress(tailIndex + 2, tailIndex + 2, 8, 9);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 2).GetCell(8).SetCellValue("质量检查员:");
region = new CellRangeAddress(tailIndex + 3, tailIndex + 3, 8, 9);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 3).GetCell(8).SetCellValue("焊接责任工程师:");
region = new CellRangeAddress(tailIndex + 4, tailIndex + 4, 8, 9);
ws.AddMergedRegion(region);
region = new CellRangeAddress(tailIndex + 4, tailIndex + 4, 10, 12);
ws.AddMergedRegion(region);
ws.GetRow(tailIndex + 4).GetCell(8).SetCellValue("日期:");
#region 线
ICellStyle bottomStyle = hssfworkbook.CreateCellStyle();
bottomStyle.BorderBottom = BorderStyle.Thin;
bottomStyle.BorderLeft = BorderStyle.None;
bottomStyle.BorderRight = BorderStyle.None;
bottomStyle.BorderTop = BorderStyle.None;
bottomStyle.VerticalAlignment = VerticalAlignment.Center;
bottomStyle.Alignment = HorizontalAlignment.Left;
bottomStyle.SetFont(font);
bottomStyle.WrapText = true;
ws.GetRow(tailIndex + 4).GetCell(0).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(1).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(2).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(4).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(5).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(6).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(8).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(9).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(10).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(11).CellStyle = bottomStyle;
#endregion
#region 线
ICellStyle rightStyle = hssfworkbook.CreateCellStyle();
rightStyle.BorderBottom = BorderStyle.None;
rightStyle.BorderLeft = BorderStyle.None;
rightStyle.BorderRight = BorderStyle.Thin;
rightStyle.BorderTop = BorderStyle.None;
rightStyle.VerticalAlignment = VerticalAlignment.Center;
rightStyle.Alignment = HorizontalAlignment.Left;
rightStyle.SetFont(font);
rightStyle.WrapText = true;
ws.GetRow(tailIndex + 1).GetCell(3).CellStyle =
ws.GetRow(tailIndex + 2).GetCell(3).CellStyle =
ws.GetRow(tailIndex + 3).GetCell(3).CellStyle =
ws.GetRow(tailIndex + 1).GetCell(7).CellStyle =
ws.GetRow(tailIndex + 2).GetCell(7).CellStyle =
ws.GetRow(tailIndex + 3).GetCell(7).CellStyle =
ws.GetRow(tailIndex + 1).GetCell(12).CellStyle =
ws.GetRow(tailIndex + 2).GetCell(12).CellStyle =
ws.GetRow(tailIndex + 3).GetCell(12).CellStyle = rightStyle;
#endregion
#region 线
ICellStyle botrigStyle = hssfworkbook.CreateCellStyle();
botrigStyle.BorderBottom = BorderStyle.Thin;
botrigStyle.BorderLeft = BorderStyle.None;
botrigStyle.BorderRight = BorderStyle.Thin;
botrigStyle.BorderTop = BorderStyle.None;
botrigStyle.VerticalAlignment = VerticalAlignment.Center;
botrigStyle.Alignment = HorizontalAlignment.Left;
botrigStyle.SetFont(font);
botrigStyle.WrapText = true;
ws.GetRow(tailIndex + 4).GetCell(3).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(7).CellStyle =
ws.GetRow(tailIndex + 4).GetCell(12).CellStyle = botrigStyle;
#endregion
#region 线
ICellStyle leftStyle = hssfworkbook.CreateCellStyle();
leftStyle.BorderBottom = BorderStyle.None;
leftStyle.BorderLeft = BorderStyle.Thin;
leftStyle.BorderRight = BorderStyle.None;
leftStyle.BorderTop = BorderStyle.None;
leftStyle.VerticalAlignment = VerticalAlignment.Center;
leftStyle.Alignment = HorizontalAlignment.Left;
leftStyle.SetFont(font);
leftStyle.WrapText = true;
ws.GetRow(tailIndex + 1).GetCell(0).CellStyle =
ws.GetRow(tailIndex + 2).GetCell(0).CellStyle =
ws.GetRow(tailIndex + 3).GetCell(0).CellStyle = leftStyle;
#endregion
#region 线
ICellStyle botleftStyle = hssfworkbook.CreateCellStyle();
botleftStyle.BorderBottom = BorderStyle.Thin;
botleftStyle.BorderLeft = BorderStyle.Thin;
botleftStyle.BorderRight = BorderStyle.None;
botleftStyle.BorderTop = BorderStyle.None;
botleftStyle.VerticalAlignment = VerticalAlignment.Center;
botleftStyle.Alignment = HorizontalAlignment.Left;
botleftStyle.SetFont(font);
botleftStyle.WrapText = true;
ws.GetRow(tailIndex + 4).GetCell(0).CellStyle = botleftStyle;
#endregion
}
#endregion
rowIndex += 27;
}
}
}
ws.ForceFormulaRecalculation = true;
using (FileStream filess = File.OpenWrite(ReportFileName))
{
hssfworkbook.Write(filess);
}
FileInfo filet = new FileInfo(ReportFileName);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode("管道焊接记录.xlsx"));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", filet.Length.ToString());
// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.ContentType = "application/ms-excel";
// 把文件流发送到客户端
Response.WriteFile(filet.FullName);
// 停止页面的执行
Response.End();
}
}
/// <summary>
/// 打印焊接记录(新)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrintNew_Click(object sender, EventArgs e)
{
string isoId = this.tvControlItem.SelectedNodeID;
var q = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId);
if (q != null)
{
string varValue = string.Empty;
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
varValue = project.ProjectName + "|管道";
}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@IsoId", isoId));
listStr.Add(new SqlParameter("@Flag", "0"));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spJointWorkRecordNew", parameter);
string page = Funs.GetPagesCountByPageSize(11, 16, tb.Rows.Count).ToString();
varValue = varValue + "|" + page;
if (!string.IsNullOrEmpty(varValue))
{
varValue = HttpUtility.UrlEncodeUnicode(varValue);
}
if (tb.Rows.Count <= 11)
{
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_JointInfoNewReport1Id, isoId, varValue)));
}
else
{
PageContext.RegisterStartupScript(Window7.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_JointInfoNewReport2Id, isoId, varValue)));
PageContext.RegisterStartupScript(Window6.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_JointInfoNewReport1Id, isoId, varValue)));
}
}
else
{
ShowNotify("请选择管线!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 文档名
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnFileName_Click(object sender, EventArgs e)
{
string isoId = this.tvControlItem.SelectedNodeID;
var q = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId);
if (q != null)
{
if (q != null)
{
string code = string.Empty;
string projectCode = BLL.Base_ProjectService.GetProjectCode(q.ProjectId);
code = projectCode + "-" + q.ISO_IsoNo + "-焊接记录";
PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../CheckManage/FileCode.aspx?code={0}", HttpUtility.UrlEncodeUnicode(code), "编辑 - ")));
}
}
else
{
ShowNotify("请选择管线!", 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();
this.hdPageMax.Text = string.Empty;
}
protected void Window8_Close(object sender, WindowCloseEventArgs e)
{
this.BindGrid();
}
/// <summary>
/// 关闭弹出窗口4
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window4_Close(object sender, WindowCloseEventArgs e)
{
this.InitTreeMenu();//加载树
this.BindGrid();
//显示列
Model.Sys_UserShowColumns c = BLL.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "2");
if (c != null)
{
this.GetShowColumn(c.Columns);
}
}
/// <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.Funs.DB.HJGL_CH_HotProessTrustItem.FirstOrDefault(x => x.JOT_ID == id) != null
|| BLL.Funs.DB.HJGL_CH_HotProessResult.FirstOrDefault(x => x.JOT_ID == id) != null)
{
content = "该焊口已进行热处理委托,不能删除!";
}
var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByJotId(id);
if (batchDetail != null)
{
var batch = BLL.HJGL_BO_BatchService.GetBatchById(batchDetail.BatchId);
if (batch.BatchIsClosed == true)
{
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 btnOut_Click(object sender, EventArgs e)
{
var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(this.tvControlItem.SelectedNodeID);
if (iso != null)
{
var set = BLL.Project_SysSetService.GetSysSetBySetId("4", this.CurrUser.LoginProjectId);
if (set != null && set.IsAuto == true) ///是PDMS格式
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("JointInfoOut2.aspx?ISO_ID={0}", this.tvControlItem.SelectedNodeID, "导出 - ")));
}
else
{
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="bigType"></param>
/// <returns></returns>
protected string ConvertProessTypes(object ProessTypes)
{
string proessTypes = string.Empty;
if (ProessTypes != null)
{
proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString());
}
return proessTypes;
}
#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("JointInfoShowColumn.aspx", "显示列 - ")));
}
#endregion
#region
/// <summary>
/// 行和列
/// </summary>
/// <returns></returns>
private XSSFSheet ExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd)
{
for (int i = sRows; i <= eRows; i++)
{
ws.CreateRow(i);
ws.GetRow(i).HeightInPoints = i == sRows ? 30 : i == (sRows + 1) ? 27 : i == (sRows + 2) ? 28 : 21;
for (int j = cStart; j <= cEnd; j++)
{
ws.GetRow(i).CreateCell(j);
if (i < sRows + 14)
{
ws.GetRow(i).GetCell(j).CellStyle = style;
}
else
{
ICellStyle nstyle = hssfworkbook.CreateCellStyle();
nstyle.BorderBottom = BorderStyle.None;
nstyle.BorderLeft = BorderStyle.None;
nstyle.BorderRight = BorderStyle.None;
nstyle.BorderTop = BorderStyle.None;
nstyle.VerticalAlignment = VerticalAlignment.Center;
nstyle.Alignment = HorizontalAlignment.Left;
IFont font = hssfworkbook.CreateFont();
font.FontHeightInPoints = 7;
nstyle.SetFont(font);
nstyle.WrapText = true;
ws.GetRow(i).GetCell(j).CellStyle = nstyle;
}
}
}
return ws;
}
/// <summary>
/// 数据分页
/// </summary>
/// <param name="dt">数据源</param>
/// <param name="PageIndex">第几页</param>
/// <param name="PageSize">每页多少条</param>
/// <returns></returns>
private DataTable GetPageToDataTable(DataTable dt, int PageIndex, int PageSize)
{
if (PageIndex == 0)
return dt;//0页代表每页数据直接返回
if (dt == null)
{
DataTable table = new DataTable();
return table;
}
DataTable newdt = dt.Copy();
newdt.Clear();//copy dt的框架
int rowbegin = (PageIndex - 1) * PageSize;
int rowend = PageIndex * PageSize;//要展示的数据条数
if (rowbegin >= dt.Rows.Count)
return newdt;//源数据记录数小于等于要显示的记录直接返回dt
if (rowend > dt.Rows.Count)
rowend = dt.Rows.Count;
for (int i = rowbegin; i <= rowend - 1; i++)
{
DataRow newdr = newdt.NewRow();
DataRow dr = dt.Rows[i];
foreach (DataColumn column in dt.Columns)
{
newdr[column.ColumnName] = dr[column.ColumnName];
}
newdt.Rows.Add(newdr);
}
return newdt;
}
#endregion
}
}