This commit is contained in:
佘春生 2024-06-21 16:37:50 +08:00
parent 09caeb9eed
commit f404b44aeb
7 changed files with 446 additions and 82 deletions

View File

@ -162,7 +162,7 @@
</site>
<site name="WebApi" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\湛江巴斯夫\Basf_TCC7\HJGL\WebApi" />
<virtualDirectory path="/" physicalPath="E:\MyProject\ZJ_BSF\Basf_TCC7\HJGL\WebApi" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:3862:localhost" />
@ -250,7 +250,7 @@
</site>
<site name="FineUIPro.Web(10)" id="13">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\湛江巴斯夫\Basf_TCC7\HJGL\FineUIPro.Web" />
<virtualDirectory path="/" physicalPath="E:\MyProject\ZJ_BSF\Basf_TCC7\HJGL\FineUIPro.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:13960:localhost" />

Binary file not shown.

View File

@ -9,7 +9,7 @@
<section name="FineUIPro" type="FineUIPro.ConfigSection, FineUIPro" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="HJGLDBConnectionString" connectionString="Data Source=.;Initial Catalog=HJGLDB_ZJBSF;uid=sa;pwd=Sh@nghai9;"/>
<add name="HJGLDBConnectionString" connectionString="Data Source=.\sql2016;Initial Catalog=HJGLDB_ZJBSF;uid=sa;pwd=1111;"/>
<!--<add name="HJGLDBConnectionString" connectionString="Data Source=.;Initial Catalog=HJGLDB;Integrated Security=True"
providerName="System.Data.SqlClient" />-->
</connectionStrings>

View File

@ -120,9 +120,6 @@
</f:TextBox>
<f:ToolbarFill ID="ToolbarFill2" runat="server">
</f:ToolbarFill>
<f:Button ID="btnExport" Text="打印" ToolTip="导出" EnableAjax="false" DisableControlBeforePostBack="false" Icon="ApplicationGet" runat="server"
OnClick="btnExport_Click">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
@ -150,10 +147,11 @@
HeaderTextAlign="Center" TextAlign="Left" Width="120px">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,QualityNo %>" ColumnID="QualityNo" DataField="QualityNo"
FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
FieldType="String" TextAlign="Left" Width="150px">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,Acceptance %>" ColumnID="Acceptance"
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px">
</f:RenderField>
</Columns>

View File

@ -1,13 +1,17 @@
using BLL;
using System;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using BLL;
using Model;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
namespace FineUIPro.Web.WeldingProcess.PMI
{
public partial class PMIDelegation : PageBase
@ -65,7 +69,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
this.tvControlItem.Nodes.Add(rootNode);
List<Model.PMI_Delegation> trustLists = new List<Model.PMI_Delegation>(); ///PMI委托单
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()))
{
trustLists = (from x in Funs.DB.PMI_Delegation where x.ProjectId == CurrUser.LoginProjectId && x.DelegationNo.Contains(this.txtSearchNo.Text.Trim()) orderby x.DelegationNo select x).ToList();
@ -140,7 +144,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
var result = Funs.DB.PMI_Delegation.FirstOrDefault(t=>t.Id==this.tvControlItem.SelectedNodeID);
var result = Funs.DB.PMI_Delegation.FirstOrDefault(t => t.Id == this.tvControlItem.SelectedNodeID);
if (result != null)
{
this.PMIDelegationId = result.Id;
@ -184,7 +188,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
/// </summary>
private void PageInfoLoad()
{
var trust =Funs.DB.PMI_Delegation.FirstOrDefault(t=>t.Id==this.PMIDelegationId);
var trust = Funs.DB.PMI_Delegation.FirstOrDefault(t => t.Id == this.PMIDelegationId);
if (trust != null)
{
this.txtDelegationNo.Text = trust.DelegationNo;
@ -279,7 +283,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PMIDelegationMenuId, Const.BtnAdd))
{
this.SetTextTemp();
string window = String.Format("PMIDelegationEdit.aspx?PMIDelegationId={0}", string.Empty, "新增 - ") ;
string window = String.Format("PMIDelegationEdit.aspx?PMIDelegationId={0}", string.Empty, "新增 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(this.hdPMIDelegationId.ClientID)
+ Window2.GetShowReference(window));
}
@ -299,7 +303,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessTrustMenuId, Const.BtnSave))
{
var trustManage = Funs.DB.PMI_Delegation.FirstOrDefault (t=>t.Id==this.PMIDelegationId);
var trustManage = Funs.DB.PMI_Delegation.FirstOrDefault(t => t.Id == this.PMIDelegationId);
if (trustManage != null)
{
string openUrl = String.Format("PMIDelegationEdit.aspx?PMIDelegationId={0}", this.PMIDelegationId, "编辑 - ");
@ -328,9 +332,9 @@ namespace FineUIPro.Web.WeldingProcess.PMI
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PMIDelegationMenuId, Const.BtnDelete))
{
var trustManage =Funs.DB.PMI_Delegation.FirstOrDefault (t=>t.Id==this.PMIDelegationId);
var trustManage = Funs.DB.PMI_Delegation.FirstOrDefault(t => t.Id == this.PMIDelegationId);
if (trustManage != null)
{
{
//删除主表数据
Funs.DB.PMI_Delegation.DeleteOnSubmit(trustManage);
//删除 明细表
@ -367,7 +371,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
{
this.InitTreeMenu();
this.BindGrid();
}
#region
@ -383,51 +387,435 @@ namespace FineUIPro.Web.WeldingProcess.PMI
#endregion
#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.DailyReportCompleteMenuId, button);
}
#endregion
/// <summary>
/// 打印
/// </summary>
protected void btnExport_Click(object sender, EventArgs e)
{
Alert.ShowInTop("待开发!", MessageBoxIcon.Warning);
return;
//if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_BatchTrustMenuId, Const.BtnOut))
//{
if (string.IsNullOrWhiteSpace(this.tvControlItem.SelectedNodeID))
{
Alert.ShowInTop("请选择委托单!", MessageBoxIcon.Warning);
return;
}
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";
int rowIndex = 0;
XSSFWorkbook hssfworkbook = new XSSFWorkbook();
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("无损检测委托单(PMI)");
// if (string.IsNullOrWhiteSpace(this.tvControlItem.SelectedNodeID))
// {
// Alert.ShowInTop("请选择委托单!", MessageBoxIcon.Warning);
// return;
// }
// string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
// //导出文件
// string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
// if (!Directory.Exists(filePath))
// {
// Directory.CreateDirectory(filePath);
// }
// string ReportFileName = filePath + "out1.xlsx";
// int rowIndex = 0;
// XSSFWorkbook hssfworkbook = new XSSFWorkbook();
// XSSFSheet ws = new XSSFSheet();
// string trustBatchId = this.tvControlItem.SelectedNodeID;
//}
//else
//{
// ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
//}
#region
ws.SetColumnWidth(0, 6 * 256);
ws.SetColumnWidth(1, 4 * 256);
ws.SetColumnWidth(2, 6 * 256);
ws.SetColumnWidth(3, 6 * 256);
ws.SetColumnWidth(4, 6 * 256);
ws.SetColumnWidth(5, 6 * 256);
ws.SetColumnWidth(6, 9 * 256);
ws.SetColumnWidth(7, 9 * 256);
ws.SetColumnWidth(8, 5 * 256);
ws.SetColumnWidth(9, 5 * 256);
ws.SetColumnWidth(10, 5 * 256);
ws.SetColumnWidth(11, 8 * 256);
ws.SetColumnWidth(12, 9 * 256);
ws.SetColumnWidth(13, 11 * 256);
#endregion
string pmiId = this.tvControlItem.SelectedNodeID;
//头部
var pmititle = Funs.DB.PMI_Delegation.FirstOrDefault(x => x.Id == pmiId);
//列表
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", pmititle != null ? pmititle.ProjectId : this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@PMIID", this.PMIDelegationId));
SqlParameter[] parameter = listStr.ToArray();
var tb = SQLHelper.GetDataTableRunText("SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID", parameter);
//模拟多页数据sql
//var tb = SQLHelper.GetDataTableRunText("SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID", parameter);
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
var styleButton = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
var styleTop = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
var styleNone = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
if (tb.Rows.Count > 0 && pmititle != null)
{
var tbNum = tb.Rows.Count;
var pageNum =
tbNum < 15 ? 1
: Math.Ceiling((float)(tbNum - 14) / 14) + 1;
//循环页
for (int i = 1; i <= pageNum; i++)
{
#region
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 12, style, 0, 13, 1);
//行0
CellRangeAddress region = new CellRangeAddress(rowIndex, rowIndex + 3, 0, 3);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(0).SetCellValue("NDE-002");
ws.GetRow(rowIndex).GetCell(0).CellStyle = style;
ws.GetRow(rowIndex).GetCell(1).CellStyle = style;
ws.GetRow(rowIndex).GetCell(2).CellStyle = style;
ws.GetRow(rowIndex).GetCell(3).CellStyle = style;
region = new CellRangeAddress(rowIndex, rowIndex + 3, 4, 10);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(4).SetCellValue("无损检测委托单\r\nPMI");
ws.GetRow(rowIndex).GetCell(4).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 16, true, true);
ws.GetRow(rowIndex).GetCell(5).CellStyle = style;
ws.GetRow(rowIndex).GetCell(6).CellStyle = style;
ws.GetRow(rowIndex).GetCell(7).CellStyle = style;
ws.GetRow(rowIndex).GetCell(8).CellStyle = style;
ws.GetRow(rowIndex).GetCell(9).CellStyle = style;
ws.GetRow(rowIndex).GetCell(10).CellStyle = style;
region = new CellRangeAddress(rowIndex, rowIndex, 11, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex).GetCell(11).SetCellValue("工程名称:巴斯夫(广东)一体化项目专用化学品二区");
ws.GetRow(rowIndex).GetCell(11).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
ws.GetRow(rowIndex).GetCell(12).CellStyle = styleButton;
ws.GetRow(rowIndex).GetCell(13).CellStyle = styleButton;
//行1
region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 11, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("BASF (Guangdong) Integrated Project Citral Cluster");
ws.GetRow(rowIndex + 1).GetCell(11).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
ws.GetRow(rowIndex + 1).GetCell(12).CellStyle = styleNone;
ws.GetRow(rowIndex + 1).GetCell(13).CellStyle = styleNone;
//行2
region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 11, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("单元名称:");
ws.GetRow(rowIndex + 2).GetCell(11).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
ws.GetRow(rowIndex + 2).GetCell(12).CellStyle = styleNone;
ws.GetRow(rowIndex + 2).GetCell(13).CellStyle = styleNone;
//行3
region = new CellRangeAddress(rowIndex + 3, rowIndex + 3, 11, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 3).GetCell(11).SetCellValue("Unit Name:");
ws.GetRow(rowIndex + 3).GetCell(11).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
ws.GetRow(rowIndex + 3).GetCell(12).CellStyle = styleTop;
ws.GetRow(rowIndex + 3).GetCell(13).CellStyle = styleTop;
//行4
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("委托单位");
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 4).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 4).GetCell(7).SetCellValue("委托编号");
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 4).GetCell(9).SetCellValue("");
//行5
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 5).GetCell(0).SetCellValue("检测单位");
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 5).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 5).GetCell(7).SetCellValue("检测方法");
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 5).GetCell(9).SetCellValue("");
//行6
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 6).GetCell(0).SetCellValue("检件名称");
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 6).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 6).GetCell(7).SetCellValue("表面状态");
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 6).GetCell(9).SetCellValue("");
//行7
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 7).GetCell(0).SetCellValue("检测标准");
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 7).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 7).GetCell(7).SetCellValue("检测比例");
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 7).GetCell(9).SetCellValue("");
//行8
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 8).GetCell(0).SetCellValue("转动口/固定口");
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 8).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 8).GetCell(7).SetCellValue("委托日期");
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 8).GetCell(9).SetCellValue("");
//行9
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 9).GetCell(0).SetCellValue("焊接方法");
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 9).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 9).GetCell(7).SetCellValue("压力管道分级");
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 9).GetCell(9).SetCellValue("");
//行10
region = new CellRangeAddress(rowIndex + 10, rowIndex + 10, 0, 1);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 10).GetCell(0).SetCellValue("检测时机");
region = new CellRangeAddress(rowIndex + 10, rowIndex + 10, 2, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 10).GetCell(2).SetCellValue("");
region = new CellRangeAddress(rowIndex + 10, rowIndex + 10, 7, 8);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 10).GetCell(7).SetCellValue("被检产品标准");
region = new CellRangeAddress(rowIndex + 10, rowIndex + 10, 9, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 10).GetCell(9).SetCellValue("");
//行12
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 0, 2);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(0).SetCellValue("检件编号/管线号");
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 3, 4);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(3).SetCellValue("");
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 5, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(5).SetCellValue("焊口总数");
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 7, 9);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(7).SetCellValue("");
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 10, 11);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(10).SetCellValue("抽检数量");
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 12, 13);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 11).GetCell(12).SetCellValue("");
//行13
ws.GetRow(rowIndex + 12).GetCell(0).SetCellValue("检测\r\n部位");
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 1, 3);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 12).GetCell(1).SetCellValue("检件编号/管线号");
ws.GetRow(rowIndex + 12).GetCell(4).SetCellValue("焊口号");
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 5, 6);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 12).GetCell(5).SetCellValue("焊工代号");
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 7, 10);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 12).GetCell(7).SetCellValue("检件材质");
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 11, 12);
ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 12).GetCell(11).SetCellValue("检件规格(mm)");
ws.GetRow(rowIndex + 12).GetCell(13).SetCellValue("备注");
#endregion
#region
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 13, rowIndex + 26, style, 0, 13, 2);
var dataTit = rowIndex + 13;
var tIndex = 12 + 14;
var dStart = 0;
var dEnd = 0;
if (i == 1)
{
dStart = 0;
dEnd = 14;
}
else
{
dStart = i == 2 ? 14 : ((i - 2) * 14) + 14;
dEnd = ((i - 1) * 14) + 14;
}
//合并单元格
for (int hb = dataTit; hb <= rowIndex + tIndex; hb++)
{
region = new CellRangeAddress(hb, hb, 1, 3);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 5, 6);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 7, 10);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 11, 12);
ws.AddMergedRegion(region);
}
//获取当前页数据
var pageTb = GetPageToTable(tb, dStart, dEnd);
for (int j = 0; j < pageTb.Rows.Count; j++)
{
int dataIndex = dataTit + j;
//检测部位
ws.GetRow(dataIndex).GetCell(0).SetCellValue("");
//检件编号/管线号
ws.GetRow(dataIndex).GetCell(1).SetCellValue("数据待绑定");
//焊口号
ws.GetRow(dataIndex).GetCell(4).SetCellValue("");
//焊工代号
ws.GetRow(dataIndex).GetCell(5).SetCellValue("");
//检件材质
ws.GetRow(dataIndex).GetCell(7).SetCellValue("");
//检件规格(mm)
ws.GetRow(dataIndex).GetCell(11).SetCellValue("");
//备注
ws.GetRow(dataIndex).GetCell(13).SetCellValue("");
}
if (dataTit + pageTb.Rows.Count < 26)
{
ws.GetRow(dataTit + pageTb.Rows.Count).GetCell(0).SetCellValue("以下空白");
}
rowIndex += tIndex;
#endregion
#region
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 9, style, 0, 13, 3);
//合并单元格
for (int hb = rowIndex + 1; hb <= rowIndex + 9; hb++)
{
for (int c = 0; c <= 13; c++)
{
if (hb >= rowIndex + 2 && hb <= rowIndex + 3)
{
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Left, 10.5, true, false);
}
if (hb >= rowIndex + 4 && hb <= rowIndex + 8)
{
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Right, 10.5, true, false);
}
if (hb == rowIndex + 9)
{
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, false);
}
}
region = new CellRangeAddress(hb, hb, 0, 2);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 3, 5);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 6, 7);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 8, 11);
ws.AddMergedRegion(region);
region = new CellRangeAddress(hb, hb, 12, 13);
ws.AddMergedRegion(region);
}
//尾部行1
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("施工单位");
ws.GetRow(rowIndex + 1).GetCell(3).SetCellValue("监理单位");
ws.GetRow(rowIndex + 1).GetCell(6).SetCellValue("管理公司");
ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("建设单位");
ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("检测单位");
//尾部行2
ws.GetRow(rowIndex + 2).GetCell(0).SetCellValue("");
ws.GetRow(rowIndex + 2).GetCell(3).SetCellValue("");
ws.GetRow(rowIndex + 2).GetCell(6).SetCellValue("");
ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("");
ws.GetRow(rowIndex + 2).GetCell(12).SetCellValue("");
//尾部行3
ws.GetRow(rowIndex + 3).GetCell(0).SetCellValue("质量检测员:");
ws.GetRow(rowIndex + 3).GetCell(3).SetCellValue("专业工程师:");
ws.GetRow(rowIndex + 3).GetCell(6).SetCellValue("专业/质量工程师:");
ws.GetRow(rowIndex + 3).GetCell(8).SetCellValue("业主代表:");
ws.GetRow(rowIndex + 3).GetCell(12).SetCellValue("接收人:");
//尾部行6
ws.GetRow(rowIndex + 6).GetCell(0).SetCellValue("专业工程师:");
//尾部行8
ws.GetRow(rowIndex + 8).GetCell(0).SetCellValue(" 年 月 日");
ws.GetRow(rowIndex + 8).GetCell(3).SetCellValue(" 年 月 日");
ws.GetRow(rowIndex + 8).GetCell(6).SetCellValue(" 年 月 日");
ws.GetRow(rowIndex + 8).GetCell(8).SetCellValue(" 年 月 日");
ws.GetRow(rowIndex + 8).GetCell(12).SetCellValue(" 年 月 日");
#endregion
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 10, rowIndex + 10, style, 0, 13, 3, true);
rowIndex += 11;
}
}
ws.SetMargin(MarginType.LeftMargin, 0.3);
ws.SetMargin(MarginType.RightMargin, 0.2);
ws.SetMargin(MarginType.BottomMargin, 0.4);
ws.PrintSetup.Landscape = false;
ws.PrintSetup.PaperSize = 9;
ws.ForceFormulaRecalculation = true;
using (FileStream filess = System.IO.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("无损检测委托单(PMI).xlsx"));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", filet.Length.ToString());
// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.ContentType = "application/ms-excel";
// 把文件流发送到客户端
Response.WriteFile(filet.FullName);
// 停止页面的执行
Response.End();
}
#region
/// <summary>
/// 获取某一列的所有值
/// </summary>
/// <typeparam name="T">列数据类型</typeparam>
/// <param name="dtSource">数据表</param>
/// <param name="filedName">列名</param>
/// <returns></returns>
public static List<T> GetColumnValues<T>(DataTable dtSource, string filedName)
{
return (from r in dtSource.AsEnumerable() select r.Field<T>(filedName)).ToList<T>();
}
/// <summary>
/// 无损检测委托单行和列
/// </summary>
@ -481,7 +869,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
}
/// <summary>
/// 材料及配件检测委托单行和列
/// 行和列
/// </summary>
/// <returns></returns>
private XSSFSheet ClExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, bool istitle = false, bool isnobk = false)
@ -508,7 +896,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
ws.GetRow(i).CreateCell(j);
if (isnobk)
{
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, NPOI.SS.UserModel.BorderStyle.None, NPOI.SS.UserModel.BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
}
else
{
@ -553,18 +941,5 @@ namespace FineUIPro.Web.WeldingProcess.PMI
#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.DailyReportCompleteMenuId, button);
}
#endregion
}
}

View File

@ -266,15 +266,6 @@ namespace FineUIPro.Web.WeldingProcess.PMI
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill2;
/// <summary>
/// btnExport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnExport;
/// <summary>
/// ToolbarSeparator1 控件。
/// </summary>