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;
namespace FineUIPro.Web.HJGL.PointTrust
{
public partial class TrustBatch : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtTrustDateMonth.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
//BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpNDEUnit, false, this.CurrUser.LoginProjectId, BLL.Const.UnitType_4, "请选择");
this.InitTreeMenu();//加载树
}
}
#region 加载树
///
/// 加载树
///
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode1 = new TreeNode();
rootNode1.NodeID = "1";
rootNode1.Text = "建筑工程";
rootNode1.CommandName = "建筑工程";
rootNode1.Selectable = false;
this.tvControlItem.Nodes.Add(rootNode1);
TreeNode rootNode2 = new TreeNode();
rootNode2.NodeID = "2";
rootNode2.Text = "安装工程";
rootNode2.CommandName = "安装工程";
rootNode2.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode2);
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// 获取当前用户所在单位
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
select x).ToList();
List unitWork1 = null;
List unitWork2 = null;
// 当前为施工单位,只能操作本单位的数据
if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
{
unitWork1 = (from x in unitWorkList
where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
select x).ToList();
unitWork2 = (from x in unitWorkList
where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
select x).ToList();
}
else
{
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
}
if (unitWork1.Count() > 0)
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
tn1.Text = q.UnitWorkName;
tn1.ToolTip = "施工单位:" + u.UnitName;
tn1.CommandName = "单位工程";
tn1.EnableExpandEvent = true;
rootNode1.Nodes.Add(tn1);
BindNodes(tn1);
}
}
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
tn2.Text = q.UnitWorkName;
tn2.ToolTip = "施工单位:" + u.UnitName;
tn2.EnableExpandEvent = true;
tn2.CommandName = "单位工程";
rootNode2.Nodes.Add(tn2);
BindNodes(tn2);
}
}
}
///
/// 绑定树节点
///
///
private void BindNodes(TreeNode node)
{
var p = from x in Funs.DB.HJGL_Batch_PointBatch
where x.UnitWorkId == node.NodeID
&& x.StartDate < Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01")
select x;
if (p.Count() > 0)
{
TreeNode newNode = new TreeNode();
newNode.Text = "探伤类型";
newNode.NodeID = "探伤类型";
node.Nodes.Add(newNode);
}
}
#endregion
#region 绑定树节点
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
e.Node.Nodes.Clear();
if (e.Node.CommandName == "单位工程")
{
var detectionTypes = from x in Funs.DB.Base_DetectionType
orderby x.DetectionTypeCode
select new { x.DetectionTypeId, x.DetectionTypeCode, x.DetectionTypeName };
foreach (var item in detectionTypes)
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.UnitWorkId == e.Node.NodeID
&& x.DetectionTypeId == item.DetectionTypeId
select x;
TreeNode newNode = new TreeNode();
if (pointManages.Count() > 0)
{
newNode.Text = item.DetectionTypeCode;
newNode.NodeID = item.DetectionTypeId + "|" + e.Node.NodeID;
newNode.EnableExpandEvent = true;
newNode.ToolTip = item.DetectionTypeName;
newNode.CommandName = "探伤类型";
e.Node.Nodes.Add(newNode);
}
TreeNode tn1 = new TreeNode
{
Text = "检测比例",
NodeID = "检测比例",
};
newNode.Nodes.Add(tn1);
}
}
if (e.Node.CommandName == "探伤类型")
{
var detectionRates = from x in Funs.DB.Base_DetectionRate
orderby x.DetectionRateCode
select new { x.DetectionRateId, x.DetectionRateCode, x.DetectionRateValue };
foreach (var item in detectionRates)
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.UnitWorkId == e.Node.ParentNode.NodeID
&& x.DetectionTypeId == e.Node.NodeID.Split('|')[0]
&& x.DetectionRateId == item.DetectionRateId
&& x.StartDate < Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01")
select x;
if (item.DetectionRateValue > 0) //探伤比例为0的批不显示
{
TreeNode newNode = new TreeNode();
if (pointManages.Count() > 0)
{
newNode.Text = item.DetectionRateValue.ToString() + "%";
newNode.NodeID = item.DetectionRateId + "|" + e.Node.NodeID;
newNode.EnableExpandEvent = true;
newNode.ToolTip = item.DetectionRateCode;
newNode.CommandName = "检测比例";
e.Node.Nodes.Add(newNode);
}
TreeNode tn1 = new TreeNode
{
Text = "检测批",
NodeID = "检测批",
};
newNode.Nodes.Add(tn1);
}
}
}
if (e.Node.CommandName == "检测比例")
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.DetectionRateId == e.NodeID.Split('|')[0]
&& x.DetectionTypeId == e.Node.ParentNode.NodeID.Split('|')[0]
&& x.UnitWorkId == e.Node.ParentNode.ParentNode.NodeID
&& x.StartDate < Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01")
select x;
if (!string.IsNullOrEmpty(this.txtWelderCode.Text))
{
pointManages = pointManages.Where(x => x.WelderCode.Contains(this.txtWelderCode.Text.Trim()));
}
foreach (var item in pointManages)
{
TreeNode newNode = new TreeNode
{
NodeID = item.PointBatchId,
ToolTip = "批",
EnableClickEvent = true,
};
string code = "DK-" + item.PointBatchCode.Substring(item.PointBatchCode.Length - 4);
// 未委托批次红色显示
if (BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(item.PointBatchId) == null)
{
newNode.Text = "" + code + "";
newNode.ToolTip = "未委托";
}
else
{
newNode.Text = code;
}
e.Node.Nodes.Add(newNode);
}
}
}
#endregion
#region 点击TreeView
///
/// 点击TreeView
///
///
///
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
PageInfo();
this.BindGrid();
}
#endregion
private void PageInfo()
{
this.txtTrustBatchCode.Text = string.Empty;
this.txtTrustDate.Text = string.Empty;
this.txtDetectionTypeCode.Text = string.Empty;
this.lbNDEUnit.Text = string.Empty;
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
if (trust != null)
{
if (batch.IsClosed == true)
{
lbIsTrust.Text = "无需委托";
}
else
{
this.txtTrustBatchCode.Text = trust.TrustBatchCode;
if (trust.TrustDate != null)
{
this.txtTrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.TrustDate);
}
this.txtDetectionTypeCode.Text = trust.DetectionTypeCode;
lbIsTrust.Text = "已委托";
if (trust.IsAudit == true)
{
lbIsAudit.Text = "已审核";
}
else
{
lbIsAudit.Text = "未审核";
}
if (!string.IsNullOrEmpty(trust.NDEUnit))
{
var unit = BLL.UnitService.GetUnitByUnitId(trust.NDEUnit);
if (unit != null)
{
lbNDEUnit.Text = unit.UnitName;
}
}
}
}
else
{
if (batch != null)
{
lbIsTrust.Text = "未委托";
}
}
}
///
/// 生成委托单
///
///
///
protected void btnPointAudit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnGenerate))
{
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointAudit.aspx", "委托 - ")));
Model.HJGL_Batch_PointBatch pointBatch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
if (pointBatch != null)
{
if (pointBatch.IsClosed == true)
{
ShowNotify("该检验批无需委托!", MessageBoxIcon.Warning);
return;
}
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
if (trust != null)
{
ShowNotify("该检验批已生成委托!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointTrust.aspx?PointBatchId=" + this.tvControlItem.SelectedNodeID, "委托 - ")));
}
else
{
ShowNotify("请选择检验批!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#region 数据绑定
///
/// 数据绑定
///
private void BindGrid()
{
if (this.tvControlItem.SelectedNode != null)
{
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
if (trust == null) //为生成委托
{
string strSql = @"SELECT * FROM dbo.View_GenerateTrustItem d WHERE PointBatchId=@PointBatchId ";
List listStr = new List
{
};
listStr.Add(new SqlParameter("@PointBatchId", this.tvControlItem.SelectedNodeID));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 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();
}
else
{
string strSql = @"SELECT * FROM dbo.View_Batch_BatchTrustItem d WHERE TrustBatchId=@TrustBatchId ";
List listStr = new List
{
};
listStr.Add(new SqlParameter("@TrustBatchId", trust.TrustBatchId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 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 页索引改变事件
///
/// 页索引改变事件
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
#endregion
#region 排序
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region 分页选择下拉改变事件
///
/// 分页选择下拉改变事件
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#endregion
#endregion
#region 关闭弹出窗口及刷新页面
///
/// 关闭弹出窗口
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.InitTreeMenu();//加载树
this.BindGrid();
}
///
/// 查询
///
///
///
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
///
/// 查询
///
///
///
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
protected void btnAudit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnAuditing))
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
string trustBatchId = this.tvControlItem.SelectedNodeID;
BLL.Batch_BatchTrustService.UpdateBatchTrustAudit(trustBatchId, true);
PageInfo();
ShowNotify("该委托单已审核!", MessageBoxIcon.Success);
}
else
{
ShowNotify("请选择要审核委托单!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
protected void btnDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnDelete))
{
Model.SGGLDB db = Funs.DB;
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
string trustBatchId = this.tvControlItem.SelectedNodeID;
string trustBatchCode = this.tvControlItem.SelectedNode.Text;
var trust = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
if (trust.IsAudit == true)
{
ShowNotify("该委托单已审核,不能删除!", MessageBoxIcon.Warning);
return;
}
else
{
var batchItem = from y in db.HJGL_Batch_BatchTrustItem where y.TrustBatchId == trustBatchId select y;
foreach (var item in batchItem)
{
Model.HJGL_Batch_PointBatchItem pointBatchItem = null;
if (item.PointBatchItemId != null)
{
pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == item.PointBatchItemId);
}
else
{
pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.RepairRecordId == item.RepairRecordId);
}
if (pointBatchItem != null)
{
pointBatchItem.IsBuildTrust = null;
}
}
db.HJGL_Batch_BatchTrustItem.DeleteAllOnSubmit(batchItem);
db.HJGL_Batch_BatchTrust.DeleteOnSubmit(trust);
db.SubmitChanges();
this.InitTreeMenu();
this.BindGrid();
ShowNotify("已删除委托单:" + trustBatchCode, MessageBoxIcon.Success);
}
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
protected void btnPrint1_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnPrint))
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
string varValue = string.Empty;
string pointBatchId = this.tvControlItem.SelectedNodeID;
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(pointBatchId);
if (trust != null)
{
varValue = trust.TrustBatchCode + "|" + trust.TrustDate.Value.Date + "|";
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
varValue = varValue + project.ProjectName + "|" + project.ProjectCode + "|";
}
//varValue = varValue + trust.InstallationName + "|" + trust.InstallationCode;
if (!string.IsNullOrEmpty(varValue))
{
varValue = HttpUtility.UrlEncodeUnicode(varValue);
}
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.CheckTrustReport, trust.TrustBatchId, varValue)));
}
else
{
ShowNotify("尚未生成委托,无法打印!", MessageBoxIcon.Warning);
return;
}
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
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 keyValuePairs = new Dictionary();
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 listStr = new List();
// 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 判断是否可删除
///
/// 判断是否可以删除
///
///
private bool judgementDelete(string id, bool isShow)
{
string content = string.Empty;
//if (BLL.HJGL_HotProessManageEditService.GetHotProessByJotId(id) > 0)
//{
// content = "热处理已经使用了该焊口,不能删除!";
//}
//if (BLL.Funs.DB.HJGL_CH_TrustItem.FirstOrDefault(x => x.TrustBatchItemId == id) != null)
//{
// content = "无损委托已经使用了该焊口,不能删除!";
//}
//if (BLL.Funs.DB.HJGL_CH_CheckItem.FirstOrDefault(x => x.TrustBatchItemId == id) != null)
//{
// content = "检测单已经使用了该焊口,不能删除!";
//}
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content, MessageBoxIcon.Error);
}
return false;
}
}
#endregion
}
}