1736 lines
82 KiB
C#
1736 lines
82 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.IO;
|
||
using NPOI.XSSF.UserModel;
|
||
using NPOI.SS.UserModel;
|
||
using System.Runtime.Serialization;
|
||
using NPOI.SS.Util;
|
||
using NPOI.HSSF.UserModel;
|
||
|
||
namespace FineUIPro.Web.HJGL.TrustManage
|
||
{
|
||
public partial class TrustManageEdit : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 委托主键
|
||
/// </summary>
|
||
public string CH_TrustID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["CH_TrustID"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["CH_TrustID"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点口单主键
|
||
/// </summary>
|
||
public string PW_PointID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["PW_PointID"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["PW_PointID"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.txtMonth.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
|
||
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
||
btnNew.OnClientClick = Window1.GetShowReference("TrustManageEditAdd.aspx") + "return false;";
|
||
this.InitTreeMenu();//加载树
|
||
}
|
||
}
|
||
|
||
#region 加载树装置-单位
|
||
/// <summary>
|
||
/// 加载树
|
||
/// </summary>
|
||
private void InitTreeMenu()
|
||
{
|
||
if (!string.IsNullOrEmpty(this.txtMonth.Text.Trim()))
|
||
{
|
||
this.tvControlItem.Nodes.Clear();
|
||
|
||
List<Model.Base_Unit> units = null;
|
||
var getUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
|
||
if (getUnit != null && getUnit.UnitType == BLL.Const.ProjectUnitType_2)
|
||
{
|
||
units = (from x in Funs.DB.Base_Unit where x.UnitId == this.CurrUser.UnitId select x).ToList();
|
||
}
|
||
else
|
||
{
|
||
units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
|
||
}
|
||
|
||
if (units != null)
|
||
{
|
||
foreach (var unit in units)
|
||
{
|
||
TreeNode rootNode = new TreeNode();//定义根节点
|
||
rootNode.Text = unit.UnitName;
|
||
rootNode.NodeID = unit.UnitId;
|
||
rootNode.Expanded = true;
|
||
rootNode.CommandName = "Unit";
|
||
this.tvControlItem.Nodes.Add(rootNode);
|
||
var instaRe = (from x in Funs.DB.CH_Trust
|
||
join y in Funs.DB.Project_Installation
|
||
on x.InstallationId equals y.InstallationId
|
||
where x.CH_TrustUnit == unit.UnitId && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustType == "1"
|
||
select y).Distinct();
|
||
foreach (var ins in instaRe)
|
||
{
|
||
TreeNode newNode = new TreeNode();
|
||
newNode.Text = ins.InstallationName;
|
||
newNode.NodeID = unit.UnitId + "|" + ins.InstallationId;
|
||
newNode.EnableExpandEvent = true;
|
||
newNode.CommandName = "Installation";
|
||
rootNode.Nodes.Add(newNode);
|
||
TreeNode emptyNode = new TreeNode();
|
||
emptyNode.Text = "";
|
||
emptyNode.NodeID = "";
|
||
newNode.Nodes.Add(emptyNode);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请先增加施工单位!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择月份!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
|
||
#region 展开树
|
||
/// <summary>
|
||
/// 展开树
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
|
||
{
|
||
e.Node.Nodes.Clear();
|
||
if (e.Node.CommandName == "Installation") //展开装置
|
||
{
|
||
TreeNode newNode = new TreeNode();
|
||
newNode.Text = this.txtMonth.Text.Trim();
|
||
newNode.NodeID = e.Node.NodeID + "|" + this.txtMonth.Text.Trim();
|
||
newNode.EnableExpandEvent = true;
|
||
newNode.CommandName = "Month";
|
||
e.Node.Nodes.Add(newNode);
|
||
TreeNode emptyNode = new TreeNode();
|
||
emptyNode.Text = "";
|
||
emptyNode.NodeID = "";
|
||
newNode.Nodes.Add(emptyNode);
|
||
}
|
||
else if (e.Node.CommandName == "Month") //展开月份
|
||
{
|
||
DateTime startDate = Funs.GetNewDateTimeOrNow(e.Node.NodeID.Split('|')[2] + "-01");
|
||
DateTime endDate = Funs.GetNewDateTimeOrNow(e.Node.NodeID.Split('|')[2] + "-01").AddMonths(1);
|
||
var days = (from x in Funs.DB.CH_Trust
|
||
where x.InstallationId == e.Node.ParentNode.NodeID.Split('|')[1]
|
||
&& x.CH_TrustUnit == e.Node.ParentNode.ParentNode.NodeID
|
||
&& x.CH_TrustDate >= startDate && x.CH_TrustDate < endDate && x.CH_TrustType == "1"
|
||
orderby x.CH_TrustDate
|
||
select x.CH_TrustDate).Distinct();
|
||
foreach (var day in days)
|
||
{
|
||
TreeNode newNode = new TreeNode();
|
||
newNode.Text = string.Format("{0:yyyy-MM-dd}", day);
|
||
newNode.NodeID = e.Node.NodeID + "|" + day.ToString();
|
||
newNode.EnableExpandEvent = true;
|
||
newNode.CommandName = "Day";
|
||
e.Node.Nodes.Add(newNode);
|
||
TreeNode emptyNode = new TreeNode();
|
||
emptyNode.Text = "";
|
||
emptyNode.NodeID = "";
|
||
newNode.Nodes.Add(emptyNode);
|
||
}
|
||
}
|
||
else if (e.Node.CommandName == "Day") //展开日期
|
||
{
|
||
var trusts = from x in Funs.DB.CH_Trust
|
||
where x.InstallationId.ToString() == e.Node.ParentNode.ParentNode.NodeID.Split('|')[1]
|
||
&& x.CH_TrustUnit == e.Node.ParentNode.ParentNode.ParentNode.NodeID
|
||
&& x.CH_TrustDate == Convert.ToDateTime(e.Node.NodeID.Split('|')[3]) && x.CH_TrustType=="1"
|
||
orderby x.CH_TrustCode
|
||
select x;
|
||
foreach (var trust in trusts)
|
||
{
|
||
TreeNode newNode = new TreeNode();
|
||
if (trust.CH_AuditDate.HasValue)
|
||
{
|
||
newNode.Text = trust.CH_TrustCode;
|
||
}
|
||
else
|
||
{
|
||
newNode.Text = "<font color='#FF0000'>" + trust.CH_TrustCode + "</font>";
|
||
}
|
||
|
||
newNode.NodeID = trust.CH_TrustID;
|
||
newNode.EnableClickEvent = true;
|
||
newNode.CommandName = "Trust";
|
||
e.Node.Nodes.Add(newNode);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
|
||
#endregion
|
||
|
||
|
||
#region 点击TreeView
|
||
/// <summary>
|
||
/// 点击TreeView
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
|
||
{
|
||
this.BindGrid();
|
||
CH_TrustID = this.tvControlItem.SelectedNodeID;
|
||
Model.CH_Trust trust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID);
|
||
if (trust != null)
|
||
{
|
||
this.txtCH_TrustCode.Text = trust.CH_TrustCode;
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
|
||
{
|
||
this.txtCH_TrustUnit.Text = BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit);
|
||
}
|
||
Model.Project_Installation ins = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId);
|
||
if (ins != null)
|
||
{
|
||
this.txtInstallation.Text = ins.InstallationName;
|
||
}
|
||
if (trust.CH_TrustDate != null)
|
||
{
|
||
this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate);
|
||
}
|
||
this.txtCH_Press.Text = trust.CH_Press;
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTRate))
|
||
{
|
||
var list = BLL.Base_DetectionRateService.GetNDTRateNameList();
|
||
var rate = list.FirstOrDefault(x => x.Value == trust.CH_NDTRate);
|
||
if (rate != null)
|
||
{
|
||
this.txtCH_NDTRate.Text = rate.Text;
|
||
}
|
||
}
|
||
this.txtCH_TrustType.Text = "委托";
|
||
this.txtCH_WorkNo.Text = trust.CH_WorkNo;
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
|
||
{
|
||
var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
|
||
if (type != null)
|
||
{
|
||
this.txtCH_NDTMethod.Text = type.DetectionTypeName;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
this.txtCH_NDTMethod.Text = "";
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustMan))
|
||
{
|
||
this.txtCH_TrustMan.Text = BLL.UserService.GetUserNameByUserId(trust.CH_TrustMan);
|
||
}
|
||
this.txtCH_ItemName.Text = trust.CH_ItemName;
|
||
if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
|
||
{
|
||
var list = BLL.TrustManageEditService.GetAcceptGradeList();
|
||
var grade = list.FirstOrDefault(x => x.Value == trust.CH_AcceptGrade);
|
||
if (grade != null)
|
||
{
|
||
this.txtCH_AcceptGrade.Text = grade.Text;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_Tabler))
|
||
{
|
||
this.txtCH_Tabler.Text = BLL.UserService.GetUserNameByUserId(trust.CH_Tabler);
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_SlopeType))
|
||
{
|
||
var type = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType);
|
||
if (type != null)
|
||
{
|
||
this.txtCH_SlopeType.Text = type.GrooveTypeName;
|
||
}
|
||
}
|
||
this.txtCH_NDTCriteria.Text = trust.CH_NDTCriteria;
|
||
if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
|
||
{
|
||
var type = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod);
|
||
if (type != null)
|
||
{
|
||
this.txtCH_WeldMethod.Text = type.WeldingMethodName;
|
||
}
|
||
}
|
||
this.txtCH_ServiceTemp.Text = trust.CH_ServiceTemp;
|
||
if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
{
|
||
this.txtCH_CheckUnit.Text = BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit);
|
||
}
|
||
if (trust.CH_RequestDate != null)
|
||
{
|
||
this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_RequestDate);
|
||
}
|
||
this.txtCH_Remark.Text = trust.CH_Remark;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnQuery_Click(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 数据绑定
|
||
/// <summary>
|
||
/// 数据绑定
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
if (this.tvControlItem.SelectedNode != null)
|
||
{
|
||
|
||
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);
|
||
|
||
// 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
|
||
{
|
||
Grid1.DataSource = null;
|
||
Grid1.DataBind();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 分页排序
|
||
#region 页索引改变事件
|
||
/// <summary>
|
||
/// 页索引改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 排序
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页选择下拉改变事件
|
||
/// <summary>
|
||
/// 分页选择下拉改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
#region 无损委托 维护事件
|
||
/// <summary>
|
||
/// 无损委托编辑
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnEdit_Click(object sender, EventArgs e)
|
||
{
|
||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.TrustManageEditMenuId, BLL.Const.BtnModify))
|
||
{
|
||
var trust = BLL.TrustManageEditService.GetCH_TrustByID(tvControlItem.SelectedNodeID);
|
||
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID) && trust != null)
|
||
{
|
||
if (trust.CH_AuditDate.HasValue)
|
||
{
|
||
Alert.ShowInTop("此委托单已审核不能编辑!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TrustManageEditAdd.aspx?CH_TrustID={0}", tvControlItem.SelectedNodeID, "维护 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("请选择要编辑的委托单!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TrustManageEditMenuId, Const.BtnDelete))
|
||
{
|
||
var trust = BLL.TrustManageEditService.GetCH_TrustByID(tvControlItem.SelectedNodeID);
|
||
if (trust == null)
|
||
{
|
||
Alert.ShowInTop("请选择要删除的委托单", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
var check = BLL.CheckManageService.GetCheckByTrustId(tvControlItem.SelectedNodeID);
|
||
if (trust != null && !trust.CH_AuditDate.HasValue && check == 0)
|
||
{
|
||
var trustItems = BLL.TrustManageEditService.GetView_CH_TrustItemByCH_TrustID(tvControlItem.SelectedNodeID);
|
||
foreach (var item in trustItems)
|
||
{
|
||
BLL.TrustManageEditService.UpdateJOT_TrustFlag(item.JOT_ID, "2");
|
||
}
|
||
|
||
BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(tvControlItem.SelectedNodeID);
|
||
BLL.TrustManageEditService.DeleteCH_TrustByCH_TrustID(tvControlItem.SelectedNodeID);
|
||
trustItems.Clear();
|
||
BLL.LogService.AddSys_Log(this.CurrUser, trust.CH_TrustCode, tvControlItem.SelectedNodeID, BLL.Const.TrustManageEditMenuId, "删除无损委托");
|
||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||
this.InitTreeMenu();
|
||
this.BindGrid();
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("此委托单已审核不能删除!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 关闭弹出窗口及刷新页面
|
||
/// <summary>
|
||
/// 关闭弹出窗口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
this.InitTreeMenu();//加载树
|
||
this.BindGrid();
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Tree_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.InitTreeMenu();
|
||
this.BindGrid();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 打印
|
||
/// <summary>
|
||
/// 打印按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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));
|
||
dt.Columns.Add("CH_TrustDate", typeof(String));
|
||
|
||
|
||
|
||
DataRow dr = dt.NewRow();
|
||
if (this.tvControlItem.SelectedNode == null)
|
||
{
|
||
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string reportId = this.tvControlItem.SelectedNode.NodeID;
|
||
var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
|
||
if (trust != null)
|
||
{
|
||
string varValue = string.Empty;
|
||
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
|
||
var installation = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId);
|
||
|
||
dr["ProjectName"] = projectName;
|
||
if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
{
|
||
dr["CH_CheckUnit"] = BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString();
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustMan))
|
||
{
|
||
var users = from u in Funs.DB.Sys_User
|
||
join pu in Funs.DB.Project_ProjectUser on u.UserId equals pu.UserId
|
||
where pu.ProjectId == this.CurrUser.LoginProjectId && pu.UnitId == trust.CH_CheckUnit
|
||
select u.UserName;
|
||
if (users != null && users.Count() > 0)
|
||
{
|
||
//dr["CH_TrustMan"] = BLL.UserService.GetUserNameByUserId(trust.CH_TrustMan);
|
||
dr["CH_TrustMan"] = string.Join(",", users);
|
||
}
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustCode))
|
||
{
|
||
dr["CH_TrustCode"] = trust.CH_TrustCode;
|
||
|
||
}
|
||
if (trust.CH_TrustDate.HasValue)
|
||
{
|
||
dr["CH_TrustDate"] = trust.CH_TrustDate.Value.ToString("yyyy年MM月dd日");
|
||
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
|
||
{
|
||
dr["CH_NDTCriteria"] = trust.CH_NDTCriteria;
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
|
||
{
|
||
var type = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod);
|
||
|
||
if (type != null)
|
||
{
|
||
dr["CH_WeldMethod"] = type.WeldingMethodName;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
|
||
{
|
||
|
||
var list = BLL.TrustManageEditService.GetAcceptGradeList();
|
||
var grade = list.FirstOrDefault(x => x.Value == trust.CH_AcceptGrade);
|
||
if (grade != null)
|
||
{
|
||
dr["CH_AcceptGrade"] = grade.Text;
|
||
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
|
||
{
|
||
var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
|
||
|
||
if (type != null)
|
||
{
|
||
dr["CH_NDTMethod"] = type.DetectionTypeName;
|
||
|
||
}
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTRate))
|
||
{
|
||
var list = BLL.Base_DetectionRateService.GetNDTRateNameList();
|
||
var rate = list.FirstOrDefault(x => x.Value == trust.CH_NDTRate);
|
||
if (rate != null)
|
||
{
|
||
dr["CH_NDTRate"] = rate.Text;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_SlopeType))
|
||
{
|
||
var type = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType);
|
||
if (type != null)
|
||
{
|
||
dr["CH_SlopeType"] = type.GrooveTypeName;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
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 != null)
|
||
{
|
||
foreach (DataRow row in tb.Rows)
|
||
{
|
||
string code = row["WED_Code1"].ToString();
|
||
if (!string.IsNullOrEmpty(row["WED_Code2"].ToString()))
|
||
{
|
||
if (code != row["WED_Code2"].ToString())
|
||
{
|
||
code += "," + row["WED_Code2"].ToString();
|
||
}
|
||
}
|
||
row["WED_Code2"] = code;
|
||
|
||
}
|
||
}
|
||
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;
|
||
dr["WorkAreaName"] = PworkArea.WorkAreaName;
|
||
dr["WorkAreaCode"] = PworkArea.WorkAreaCode;
|
||
|
||
|
||
}
|
||
}
|
||
dt.Rows.Add(dr);
|
||
|
||
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||
keyValuePairs.Add("CH_TrustID", reportId);
|
||
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());
|
||
|
||
}
|
||
|
||
if (trust.CH_TrustDate.HasValue)
|
||
{
|
||
keyValuePairs.Add("CH_TrustDate",trust.CH_TrustDate.Value.ToString("yyyy年MM月dd日"));
|
||
|
||
}
|
||
BLL.Common.FastReportService.ResetData();
|
||
BLL.Common.FastReportService.AddFastreportTable(dt);
|
||
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
||
|
||
// Session["Table"] = dt;
|
||
// Session["CH_TrustID"] = reportId;
|
||
string initTemplatePath = "";
|
||
string rootPath = Server.MapPath("~/");
|
||
var sysSet = Funs.DB.Project_Sys_Set.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.SetId == "3").FirstOrDefault();
|
||
if (sysSet != null && sysSet.IsAuto .HasValue && sysSet.IsAuto .Value)
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单NoPic.frx";
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单.frx";
|
||
}
|
||
if (this.CurrUser.LoginProjectId== "3c45e9f1-8d2a-497f-8304-c66a11622c14" )
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单裕龙.frx";
|
||
keyValuePairs["totalUnit"] = "山东裕龙石化有限公司(煤制氢项目部)";
|
||
}else if (this.CurrUser.LoginProjectId == "f04b138b-6194-4380-88b5-f8410d7039fa")
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单中沙.frx";
|
||
keyValuePairs["totalUnit"] = "古雷中沙石化有限公司";
|
||
dt.Rows[0]["ProjectName"] = installation.InstallationName;
|
||
|
||
}
|
||
|
||
if (File.Exists(rootPath + initTemplatePath))
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("./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;
|
||
}
|
||
}
|
||
protected void btnPrint1_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));
|
||
dt.Columns.Add("CH_TrustDate", typeof(String));
|
||
|
||
|
||
|
||
DataRow dr = dt.NewRow();
|
||
if (this.tvControlItem.SelectedNode == null)
|
||
{
|
||
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string reportId = this.tvControlItem.SelectedNode.NodeID;
|
||
var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
|
||
if (trust != null)
|
||
{
|
||
string varValue = string.Empty;
|
||
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
|
||
var installation = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId);
|
||
|
||
dr["ProjectName"] = projectName;
|
||
if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
{
|
||
dr["CH_CheckUnit"] = BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString();
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustMan))
|
||
{
|
||
dr["CH_TrustMan"] = BLL.UserService.GetUserNameByUserId(trust.CH_TrustMan);
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustCode))
|
||
{
|
||
dr["CH_TrustCode"] = trust.CH_TrustCode;
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
|
||
{
|
||
dr["CH_NDTCriteria"] = trust.CH_NDTCriteria;
|
||
}
|
||
if (trust.CH_TrustDate.HasValue)
|
||
{
|
||
dr["CH_TrustDate"] = trust.CH_TrustDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
|
||
{
|
||
var type = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod);
|
||
|
||
if (type != null)
|
||
{
|
||
dr["CH_WeldMethod"] = type.WeldingMethodName;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
|
||
{
|
||
|
||
var list = BLL.TrustManageEditService.GetAcceptGradeList();
|
||
var grade = list.FirstOrDefault(x => x.Value == trust.CH_AcceptGrade);
|
||
if (grade != null)
|
||
{
|
||
dr["CH_AcceptGrade"] = grade.Text;
|
||
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
|
||
{
|
||
var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
|
||
|
||
if (type != null)
|
||
{
|
||
dr["CH_NDTMethod"] = type.DetectionTypeName;
|
||
|
||
}
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_NDTRate))
|
||
{
|
||
var list = BLL.Base_DetectionRateService.GetNDTRateNameList();
|
||
var rate = list.FirstOrDefault(x => x.Value == trust.CH_NDTRate);
|
||
if (rate != null)
|
||
{
|
||
dr["CH_NDTRate"] = rate.Text;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(trust.CH_SlopeType))
|
||
{
|
||
var type = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType);
|
||
if (type != null)
|
||
{
|
||
dr["CH_SlopeType"] = type.GrooveTypeName;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
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 != null)
|
||
{
|
||
foreach (DataRow row in tb.Rows)
|
||
{
|
||
string code = row["WED_Code1"].ToString();
|
||
if (!string.IsNullOrEmpty(row["WED_Code2"].ToString()))
|
||
{
|
||
if (code != row["WED_Code2"].ToString())
|
||
{
|
||
code += "," + row["WED_Code2"].ToString();
|
||
}
|
||
}
|
||
row["WED_Code2"] = code;
|
||
|
||
}
|
||
}
|
||
|
||
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;
|
||
dr["WorkAreaName"] = PworkArea.WorkAreaName;
|
||
dr["WorkAreaCode"] = PworkArea.WorkAreaCode;
|
||
|
||
|
||
}
|
||
}
|
||
dt.Rows.Add(dr);
|
||
|
||
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||
keyValuePairs.Add("CH_TrustID", reportId);
|
||
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());
|
||
|
||
}
|
||
if (trust.CH_TrustDate.HasValue)
|
||
{
|
||
keyValuePairs.Add("CH_TrustDate", trust.CH_TrustDate.Value.ToString("yyyy年MM月dd日"));
|
||
|
||
}
|
||
|
||
BLL.Common.FastReportService.ResetData();
|
||
BLL.Common.FastReportService.AddFastreportTable(dt);
|
||
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
||
|
||
// Session["Table"] = dt;
|
||
// Session["CH_TrustID"] = reportId;
|
||
string initTemplatePath = "";
|
||
string rootPath = Server.MapPath("~/");
|
||
var sysSet = Funs.DB.Project_Sys_Set.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.SetId == "3").FirstOrDefault();
|
||
if (sysSet != null && sysSet.IsAuto.HasValue && sysSet.IsAuto.Value)
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\设备焊口检测委托单NoPic.frx";
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\设备焊口检测委托单.frx";
|
||
}
|
||
if (this.CurrUser.LoginProjectId == "3c45e9f1-8d2a-497f-8304-c66a11622c14" )
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\设备焊口检测委托单裕龙.frx";
|
||
keyValuePairs["totalUnit"] = "山东裕龙石化有限公司(煤制氢项目部)";
|
||
|
||
}else if (this.CurrUser.LoginProjectId == "f04b138b-6194-4380-88b5-f8410d7039fa")
|
||
{
|
||
initTemplatePath = "File\\Fastreport\\设备焊口检测委托单中沙.frx";
|
||
keyValuePairs["totalUnit"] = "古雷中沙石化有限公司";
|
||
dt.Rows[0]["ProjectName"] = installation.InstallationName;
|
||
|
||
}
|
||
if (File.Exists(rootPath + initTemplatePath))
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("./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;
|
||
}
|
||
}
|
||
|
||
|
||
//protected void btnPrint1_Click(object sender, EventArgs e)
|
||
//{
|
||
// string reportId = this.tvControlItem.SelectedNode.NodeID;
|
||
// var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
|
||
// 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(2).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;
|
||
// }
|
||
//}
|
||
|
||
|
||
#endregion
|
||
}
|
||
} |