2023-06-29

This commit is contained in:
2023-06-29 21:45:06 +08:00
parent 11313e97aa
commit 06572131a7
9 changed files with 1201 additions and 73 deletions
@@ -1,8 +1,10 @@
using BLL;
using FineUIPro.Web.HJGL.HotProcessHard;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
@@ -550,7 +552,7 @@ namespace FineUIPro.Web.HJGL.PointTrust
}
}
protected void btnPrint_Click(object sender, EventArgs e)
protected void btnPrint1_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnPrint))
{
@@ -589,6 +591,380 @@ namespace FineUIPro.Web.HJGL.PointTrust
return;
}
}
protected void btnPrint_Click(object sender, EventArgs e)
{
// string reportId = this.tvControlItem.SelectedNode.NodeID;
// var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
DataTable dt = new DataTable("Table1");
dt.Columns.Add("ProjectName", typeof(String));
dt.Columns.Add("CH_CheckUnit", typeof(String));
dt.Columns.Add("WorkAreaName", typeof(String));
dt.Columns.Add("CH_TrustUnit", typeof(String));
dt.Columns.Add("CH_TrustMan", typeof(String));
dt.Columns.Add("CH_TrustCode", typeof(String));
dt.Columns.Add("WorkAreaCode", typeof(String));
dt.Columns.Add("CH_NDTCriteria", typeof(String));
dt.Columns.Add("CH_WeldMethod", typeof(String));
dt.Columns.Add("CH_AcceptGrade", typeof(String));
dt.Columns.Add("CH_NDTMethod", typeof(String));
dt.Columns.Add("CH_SlopeType", typeof(String));
dt.Columns.Add("CH_NDTRate", typeof(String));
DataRow dr = dt.NewRow();
if (this.tvControlItem.SelectedNode == null)
{
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
return;
}
string reportId = this.tvControlItem.SelectedNode.NodeID;
// Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
// Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(reportId);
if (trust != null)
{
string varValue = string.Empty;
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
dr["ProjectName"] = projectName;
if (!string.IsNullOrEmpty(trust.NDEUnit))
{
dr["CH_CheckUnit"] = BLL.UnitService.GetUnitNameByUnitId(trust.NDEUnit).ToString();
}
if (!string.IsNullOrEmpty(trust.TrustBatchCode))
{
dr["CH_TrustCode"] = trust.TrustBatchCode;
}
/* if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
{
dr["CH_NDTCriteria"] = trust.CH_NDTCriteria;
}*/
if (!string.IsNullOrEmpty(trust.DetectionTypeCode))
{
dr["CH_NDTMethod"] = trust.DetectionTypeCode;
}
if (!string.IsNullOrEmpty(trust.DetectionRateId))
{
var list = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(trust.DetectionRateId);
if (list != null)
{
dr["CH_NDTRate"] = list.DetectionRateCode;
}
}
var PworkArea = Funs.DB.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == trust.UnitWorkId);
if (PworkArea != null)
{
//var cel = recordSheet.GetRow(3).CreateCell(1);
//cel.SetCellValue(PworkArea.WorkAreaCode);
//cel.CellStyle = styleCenter;
dr["WorkAreaName"] = PworkArea.UnitWorkName;
dr["WorkAreaCode"] = PworkArea.UnitWorkCode;
}
dt.Rows.Add(dr);
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("TrustBatchId", trust.TrustBatchId);
keyValuePairs.Add("totalUnit", "赛鼎工程有限公司");
var unitcheck = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
if (unitcheck != null && !string.IsNullOrEmpty(unitcheck.UnitId))
{
keyValuePairs.Add("supUnit", BLL.UnitService.GetUnitNameByUnitId(unitcheck.UnitId).ToString());
}
/* if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
{
keyValuePairs.Add("CheckUnit", BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
}
if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
{
keyValuePairs.Add("ConUnit", BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
}
*/
BLL.FastReportService.ResetData();
BLL.FastReportService.AddFastreportTable(dt);
BLL.FastReportService.AddFastreportParameter(keyValuePairs);
// Session["Table"] = dt;
// Session["CH_TrustID"] = reportId;
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单NoPic.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
//if (trust != null)
//{
// string varValue = string.Empty;
// var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
// var installation = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId);
// 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));
// recordSheet.GetRow(1).CreateCell(8).SetCellValue(projectName.ToString());
// recordSheet.GetRow(1).GetCell(8).CellStyle = styleCenter;
// //recordSheet.GetRow(1).CreateCell(8).SetCellValue(installation.InstallationName);
// //recordSheet.GetRow(1).GetCell(8).CellStyle = styleCenter;
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
// {
// // recordSheet.AddMergedRegion(new CellRangeAddress(2, 2, 1, 2));
// var cel = recordSheet.GetRow(3).CreateCell(1);
// cel.SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_TrustMan))
// {
// var cel = recordSheet.GetRow(3).CreateCell(5);
// cel.SetCellValue(BLL.UserService.GetUserNameByUserId(trust.CH_TrustMan));
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_TrustCode))
// {
// var cel = recordSheet.GetRow(3).CreateCell(7);
// cel.SetCellValue(trust.CH_TrustCode);
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
// {
// var cel = recordSheet.GetRow(4).CreateCell(7);
// cel.SetCellValue(trust.CH_NDTCriteria);
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
// {
// var type = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod);
// var cel = recordSheet.GetRow(5).CreateCell(5);
// if (type != null)
// {
// cel.SetCellValue(type.WeldingMethodName);
// }
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
// {
// var list = BLL.TrustManageEditService.GetAcceptGradeList();
// var grade = list.FirstOrDefault(x => x.Value == trust.CH_AcceptGrade);
// var cel = recordSheet.GetRow(5).CreateCell(7);
// if (grade != null)
// {
// cel.SetCellValue(grade.Text);
// }
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
// {
// var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
// var cel = recordSheet.GetRow(6).CreateCell(1);
// if (type != null)
// {
// cel.SetCellValue(type.DetectionTypeName);
// }
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_NDTRate))
// {
// var list = BLL.Base_DetectionRateService.GetNDTRateNameList();
// var rate = list.FirstOrDefault(x => x.Value == trust.CH_NDTRate);
// var cel = recordSheet.GetRow(6).CreateCell(7);
// if (rate != null)
// {
// cel.SetCellValue(rate.Text);
// }
// cel.CellStyle = styleCenter;
// }
// if (!string.IsNullOrEmpty(trust.CH_SlopeType))
// {
// var type = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType);
// var cel = recordSheet.GetRow(6).CreateCell(5);
// if (type != null)
// {
// cel.SetCellValue(type.GrooveTypeName);
// }
// cel.CellStyle = styleCenter;
// }
// string strSql = @"SELECT *
// FROM dbo.View_CH_TrustItem jot
// WHERE CH_TrustID=@CH_TrustID";
// List<SqlParameter> listStr = new List<SqlParameter>();
// listStr.Add(new SqlParameter("@CH_TrustID", tvControlItem.SelectedNodeID));
// SqlParameter[] parameter = listStr.ToArray();
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// if (tb.Rows.Count > 0 && tb.Rows[0]["WorkAreaId"] != null)
// {
// var PworkArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == tb.Rows[0]["WorkAreaId"].ToString());
// if (PworkArea != null)
// {
// //var cel = recordSheet.GetRow(3).CreateCell(1);
// //cel.SetCellValue(PworkArea.WorkAreaCode);
// //cel.CellStyle = styleCenter;
// recordSheet.GetRow(2).CreateCell(8).SetCellValue(PworkArea.WorkAreaName);
// recordSheet.GetRow(2).GetCell(8).CellStyle = styleCenter;
// recordSheet.GetRow(4).CreateCell(1).SetCellValue(PworkArea.WorkAreaCode);
// recordSheet.GetRow(4).GetCell(1).CellStyle = styleCenter;
// }
// }
// if (tb.Rows.Count > 16)
// {
// recordSheet.ShiftRows(9, 28, tb.Rows.Count - 16);
// for (int j = 0; j < tb.Rows.Count - 16; j++)
// {
// recordSheet.CopyRow(8 + j, 9 + j);
// }
// var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
// if (unit != null && !string.IsNullOrEmpty(unit.UnitId))
// {
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(0).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(unit.UnitId).ToString());
// }
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(2).SetCellValue("中国天辰工程有限公司");
// if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
// {
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(5).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
// }
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
// {
// recordSheet.GetRow(20 + tb.Rows.Count - 16).CreateCell(7).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
// }
// }
// else
// {
// var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
// if (unit != null && !string.IsNullOrEmpty(unit.UnitId))
// {
// recordSheet.GetRow(20).GetCell(0).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(unit.UnitId).ToString());
// }
// recordSheet.GetRow(20).GetCell(2).SetCellValue("中国天辰工程有限公司");
// if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
// {
// recordSheet.GetRow(20).GetCell(5).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
// }
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
// {
// recordSheet.GetRow(20).GetCell(7).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
// }
// }
// for (int i = 0; i < tb.Rows.Count; i++)
// {
// try
// {
// recordSheet.GetRow(8 + i).GetCell(0).SetCellValue("" + (i + 1));
// recordSheet.GetRow(8 + i).GetCell(1).SetCellValue(tb.Rows[i]["ISO_IsoNo"] != null ? tb.Rows[i]["ISO_IsoNo"].ToString() : "");
// recordSheet.GetRow(8 + i).GetCell(2).SetCellValue(tb.Rows[i]["ISO_IsoNumber"] != null ? tb.Rows[i]["ISO_IsoNumber"].ToString() : "");
// recordSheet.GetRow(8 + i).GetCell(3).SetCellValue(tb.Rows[i]["JOT_JointNo"] != null ? tb.Rows[i]["JOT_JointNo"].ToString() : "");
// //recordSheet.GetRow(7 + i).GetCell(4).SetCellValue(tb.Rows[i]["ISO_IsoNumber"] != null ? tb.Rows[i]["ISO_IsoNumber"].ToString() : "");
// recordSheet.GetRow(8 + i).GetCell(7).SetCellValue(tb.Rows[i]["STE_Name1"] != null ? tb.Rows[i]["STE_Name1"].ToString() : "");
// recordSheet.GetRow(8 + i).GetCell(6).SetCellValue(tb.Rows[i]["JOT_JointDesc"] != null ? tb.Rows[i]["JOT_JointDesc"].ToString() : "");
// string WED_Name = "";
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code1"].ToString()))
// WED_Name += tb.Rows[i]["WED_Code1"].ToString();
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code2"].ToString()) && WED_Name != tb.Rows[i]["WED_Code2"].ToString())
// WED_Name += " " + tb.Rows[i]["WED_Code2"].ToString();
// recordSheet.GetRow(8 + i).GetCell(5).SetCellValue(WED_Name);
// }
// 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
{
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
return;
}
}
#region
/// <summary>