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.RepairManage { public partial class RepairManageAudit : PageBase { #region 定义变量 /// /// 委托主键 /// public string CH_TrustID { get { return (string)ViewState["CH_TrustID"]; } set { ViewState["CH_TrustID"] = value; } } /// /// 查询视图集合 /// private static List trustItems = new List(); #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now); this.txtCH_AuditDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); BLL.UserService.InitUserDropDownList(this.drpCH_AuditMan, this.CurrUser.LoginProjectId, true);//审核人 this.drpCH_AuditMan.SelectedValue = this.CurrUser.UserId; this.InitTreeMenu(); } } #endregion #region 加载树装置-单位-工作区 /// /// 加载树 /// private void InitTreeMenu() { if (!string.IsNullOrEmpty(this.txtReportDate.Text.Trim())) { DateTime? startTime = Funs.GetNewDateTime(this.txtReportDate.Text.Trim()); DateTime? endTime = startTime.HasValue ? startTime.Value.AddMonths(1) : System.DateTime.Now; this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "单位-装置-月份"; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvControlItem.Nodes.Add(rootNode); List units = null; var unit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId); if (unit == null || unit.UnitType == BLL.Const.ProjectUnitType_1 || unit.UnitType == BLL.Const.ProjectUnitType_3 || unit.UnitType == BLL.Const.ProjectUnitType_5) { if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId)) { units = (from x in Funs.DB.Base_Unit join y in Funs.DB.ProjectData_WorkArea on x.UnitId equals y.UnitId where (x.UnitId == this.CurrUser.UnitId || y.SupervisorUnitId == this.CurrUser.UnitId) && y.ProjectId == this.CurrUser.LoginProjectId select x).Distinct().ToList(); } else { units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, "2"); } } else { units = (from x in Funs.DB.Base_Unit where x.UnitId == this.CurrUser.UnitId select x).ToList(); } List trustLists = new List(); ///委托单 if (!this.txtReportDate.Hidden) { trustLists = (from x in Funs.DB.CH_Trust where x.CH_TrustType == "2" && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustDate >= startTime && x.CH_TrustDate < endTime select x).ToList(); } else { trustLists = (from x in Funs.DB.CH_Trust where x.CH_TrustType == "2" && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustCode.Contains(this.txtSearchCode.Text.Trim()) select x).ToList(); } if (units != null) { foreach (var item in units) { TreeNode rootUnitNode = new TreeNode();//定义根节点 rootUnitNode.Text = item.UnitName; rootUnitNode.NodeID = item.UnitId; rootUnitNode.Expanded = true; rootUnitNode.ToolTip = "施工单位"; rootNode.Nodes.Add(rootUnitNode); var checkList = trustLists.Where(x => x.CH_TrustUnit == item.UnitId).ToList(); this.BindNodes(rootUnitNode, checkList); } } else { Alert.ShowInTop("请先增加施工单位!", MessageBoxIcon.Warning); return; } } else { Alert.ShowInTop("请选择委托月份!", MessageBoxIcon.Warning); return; } } private void updateTreeMenu( ) { var trustLists = (from x in Funs.DB.CH_Trust where x.CH_TrustType == "2" && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustCode.Contains(this.txtSearchCode.Text.Trim()) select x).ToList(); foreach (TreeNode item in this.tvControlItem.Nodes) { updateChildTreeMenu(item, trustLists); } } private void updateChildTreeMenu(TreeNode node, List trustLists) { bool hasRed = false; foreach (TreeNode item in node.Nodes) { if (string.IsNullOrEmpty(item.ToolTip)) { var t = trustLists.FirstOrDefault(x => x.CH_TrustID == item.NodeID); if (t != null && (!t.CH_AuditDate.HasValue || string.IsNullOrEmpty(t.CH_AuditMan))) { hasRed = true; item.Text = "" + item.Text + ""; item.ParentNode.Text = "" + item.ParentNode.Text + ""; item.ParentNode.ParentNode.Text = "" + item.ParentNode.ParentNode.Text + ""; } else { item.Text = item.Text.Replace("", "").Replace("", ""); //item.ParentNode.Text = item.ParentNode.Text.Replace("", "").Replace("", ""); //item.ParentNode.ParentNode.Text = item.ParentNode.ParentNode.Text.Replace("", "").Replace("", ""); } } else { updateChildTreeMenu(item, trustLists); } } if (!hasRed) { node.Text = node.Text.Replace("", "").Replace("", ""); bool hasRed1 = false; foreach (TreeNode item1 in node.ParentNode.Nodes) { if (item1.Text.Contains("font")) { hasRed1 = true; } } if (!hasRed1) { node.ParentNode.Text = node.ParentNode.Text.Replace("", "").Replace("", ""); } } } #endregion #region 绑定树节点 /// /// 绑定树节点 /// /// private void BindNodes(TreeNode node, List trustLists) { if (node.ToolTip == "施工单位") { var installId = (from x in trustLists select x.InstallationId).Distinct(); if (installId.Count() > 0) { var install = from x in Funs.DB.Project_Installation where installId.Contains(x.InstallationId) orderby x.InstallationCode select x; foreach (var q in install) { TreeNode newNode = new TreeNode(); newNode.Text = q.InstallationName; newNode.NodeID = q.InstallationId + "|" + node.NodeID; ; newNode.ToolTip = "装置"; newNode.Expanded = true; node.Nodes.Add(newNode); this.BindNodes(newNode, trustLists); } } } else if (node.ToolTip == "装置") { string installationId = Funs.GetStrListByStr(node.NodeID, '|')[0]; var pointListMonth = (from x in trustLists where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.NodeID select string.Format("{0:yyyy-MM}", x.CH_TrustDate)).Distinct(); foreach (var item in pointListMonth) { TreeNode newNode = new TreeNode(); newNode.Text = item; newNode.NodeID = item + "|" + node.NodeID; ; newNode.ToolTip = "月份"; node.Nodes.Add(newNode); this.BindNodes(newNode, trustLists); } } else if (node.ToolTip == "月份") { string installationId = Funs.GetStrListByStr(node.ParentNode.NodeID, '|')[0]; var days = (from x in trustLists where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.ParentNode.NodeID orderby x.CH_TrustDate descending select x.CH_TrustDate).Distinct(); foreach (var item in days) { TreeNode newNode = new TreeNode(); newNode.Text = string.Format("{0:yyyy-MM-dd}", item); newNode.NodeID = item.ToString() + "|" + node.NodeID; ; newNode.ToolTip = "日期"; node.Nodes.Add(newNode); this.BindNodes(newNode, trustLists); } } else if (node.ToolTip == "日期") { string installationId = Funs.GetStrListByStr(node.ParentNode.ParentNode.NodeID, '|')[0]; var dReports = from x in trustLists where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.ParentNode.ParentNode.NodeID && x.CH_TrustDate == Funs.GetNewDateTime(node.Text) orderby x.CH_TrustCode descending select x; foreach (var item in dReports) { TreeNode newNode = new TreeNode(); if (!string.IsNullOrEmpty(item.CH_TrustCode)) { newNode.Text = item.CH_TrustCode; } else { newNode.Text = "未知"; } if (!item.CH_AuditDate.HasValue || string.IsNullOrEmpty(item.CH_AuditMan)) { newNode.Text = "" + newNode.Text + ""; node.Text = "" + node.Text + ""; node.ParentNode.Text = "" + node.ParentNode.Text + ""; } newNode.NodeID = item.CH_TrustID; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } } } #endregion #region 查询Tree /// /// 按日期、单号查询 /// /// /// protected void ckFind_SelectedIndexChanged(object sender, EventArgs e) { if (this.ckFind.SelectedValue == "0") { this.txtReportDate.Hidden = false; this.txtSearchCode.Hidden = true; if (string.IsNullOrEmpty(this.txtReportDate.Text)) { this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now); } } else { this.txtReportDate.Hidden = true; this.txtSearchCode.Hidden = false; } this.InitTreeMenu(); } protected void Tree_TextChanged(object sender, EventArgs e) { this.InitTreeMenu(); } #endregion #region 点击树节点 /// /// 点击树节点 /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { trustItems = new List(); this.CH_TrustID = this.tvControlItem.SelectedNodeID; if (!string.IsNullOrEmpty(this.CH_TrustID)) { Model.CH_Trust trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID); if (trust != null) { this.txtCH_TrustCode.Text = trust.CH_TrustCode; if (!string.IsNullOrEmpty(trust.CH_TrustUnit)) { this.txtCH_TrustUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit); } if (!string.IsNullOrEmpty(trust.InstallationId)) { this.txtInstallationName.Text = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId).InstallationName; } this.txtCH_TrustDate.Text = trust.CH_TrustDate.HasValue ? string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate) : ""; this.txtCH_Press.Text = trust.CH_Press; if (!string.IsNullOrEmpty(trust.CH_NDTRate)) { var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(trust.CH_NDTRate); if (rate != null) { this.txtCH_NDTRate.Text = rate.DetectionRateCode + "-" + rate.DetectionRate + "%"; } } this.txtCH_WorkNo.Text = trust.CH_WorkNo; if (!string.IsNullOrEmpty(trust.CH_NDTMethod)) { this.txtCH_NDTMethod.Text = Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod).DetectionTypeName; } 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)) { if (trust.CH_AcceptGrade == "1") { this.txtCH_AcceptGrade.Text = "Ⅰ"; } else if (trust.CH_AcceptGrade == "2") { this.txtCH_AcceptGrade.Text = "Ⅱ"; } else if (trust.CH_AcceptGrade == "3") { this.txtCH_AcceptGrade.Text = "Ⅲ"; } else if (trust.CH_AcceptGrade == "4") { this.txtCH_AcceptGrade.Text = "Ⅳ"; } else if (trust.CH_AcceptGrade == "5") { this.txtCH_AcceptGrade.Text = "Ⅴ"; } } if (!string.IsNullOrEmpty(trust.CH_Tabler)) { this.txtCH_Tabler.Text =BLL.UserService.GetUserNameByUserId(trust.CH_Tabler); } if (!string.IsNullOrEmpty(trust.CH_SlopeType)) { this.txtCH_SlopeType.Text = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType).GrooveTypeName; } this.txtCH_NDTCriteria.Text = trust.CH_NDTCriteria; if (!string.IsNullOrEmpty(trust.CH_WeldMethod)) { this.txtCH_WeldMethod.Text = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod).WeldingMethodName; } this.txtCH_ServiceTemp.Text = trust.CH_ServiceTemp; if (!string.IsNullOrEmpty(trust.CH_CheckUnit)) { this.txtCH_CheckUnit.Text = BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit); } this.txtCH_RequestDate.Text = trust.CH_RequestDate.HasValue ? string.Format("{0:yyyy-MM-dd}", trust.CH_RequestDate) : ""; this.txtRemark.Text = trust.CH_Remark; if (!string.IsNullOrEmpty(trust.CH_AuditMan)) { this.drpCH_AuditMan.SelectedValue = trust.CH_AuditMan; } else { this.drpCH_AuditMan.SelectedValue = this.CurrUser.UserId; } this.txtCH_AuditDate.Text = trust.CH_AuditDate.HasValue ? string.Format("{0:yyyy-MM-dd}", trust.CH_AuditDate) : string.Format("{0:yyyy-MM-dd}", DateTime.Now); trustItems = BLL.TrustManageEditService.GetTrustItemViewByTrustId(this.CH_TrustID); if (trustItems.Count > 0) { this.Grid1.DataSource = trustItems; this.Grid1.DataBind(); } //隐藏和显示审核、取消审核按钮 if (!string.IsNullOrEmpty(trust.CH_AuditMan)&&trust.CH_AuditDate.HasValue) { this.btnAudit.Hidden = true; this.btnCancelAudit.Hidden = false; } else { this.btnAudit.Hidden = false; this.btnCancelAudit.Hidden = true; } } } else { this.CH_TrustID = string.Empty; } } #endregion #region Grid行绑定事件 /// /// Grid行绑定事件 /// /// /// protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { foreach (var item in trustItems) { if (item.JOT_JointStatus == "100" || item.JOT_JointStatus == "102") { if (item.JOT_ID == e.RowID) { CheckBoxField s = Grid1.FindColumn("JOT_JointStatus") as CheckBoxField; e.CellCssClasses[s.ColumnIndex] = "hidethis"; } } } } #endregion #region 审核 /// /// 审核 /// /// /// protected void btnAudit_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnAuditing)) { var updatetrust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID); if (updatetrust != null && !String.IsNullOrEmpty(this.CH_TrustID)) { Model.CH_Trust trust = new Model.CH_Trust(); trust.CH_TrustID = this.CH_TrustID; if (!String.IsNullOrEmpty(this.txtCH_AuditDate.Text) && this.drpCH_AuditMan.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_AuditMan.SelectedValue)) { trust.CH_AuditDate = Funs.GetNewDateTime(this.txtCH_AuditDate.Text); trust.CH_AuditMan = this.drpCH_AuditMan.SelectedValue; BLL.TrustManageEditService.AuditCH_Trust(trust); var trustItems = from x in Funs.DB.CH_TrustItem where x.CH_TrustID == this.CH_TrustID select x; foreach (var newitem in trustItems) { BLL.TrustManageEditService.UpdateJOT_TrustFlag(newitem.JOT_ID, "1"); ////更新焊口代号 var jotitem = BLL.PW_JointInfoService.GetJointInfoByJotID(newitem.JOT_ID); var chek = Funs.DB.CH_CheckItem.FirstOrDefault(x => x.JOT_ID == newitem.JOT_ID); if (chek == null) { BLL.RepairService.UpdateNewJointNo(newitem.JOT_ID, "K1"); } if (jotitem.JOT_JointStatus == "104") { BLL.RepairService.UpdateNewJointNo(jotitem.JOT_ID, "C"); } var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod); if (ndttype != null) { if (ndttype.DetectionTypeCode == "RT") { BLL.CheckManageService.UpdateCheckIsRepair(newitem.JOT_ID, this.CH_TrustID, true, "1"); } else { BLL.CheckManageService.UpdateCheckIsRepair(newitem.JOT_ID, this.CH_TrustID, true, "2"); } } } ShowNotify("审核完成!", MessageBoxIcon.Success); updateTreeMenu(); this.btnAudit.Hidden = true; this.btnCancelAudit.Hidden = false; } else { Alert.ShowInTop("请填写审核人和审核日期!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("请选择要审核的单据!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 取消审核 /// /// 取消审核 /// /// /// protected void btnCancelAudit_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnCancelAuditing)) { var trustItem = BLL.TrustManageEditService.GetCH_TrustItemByCH_TrustID(this.CH_TrustID); if (trustItem != null) { foreach (var item in trustItem) { var nd = from x in Funs.DB.CH_CheckItem where x.CH_TrustItemID == item.CH_TrustItemID select x; if (nd.Count() > 0) { Alert.ShowInTop("'此委托单已在检测不允许取消审核!", MessageBoxIcon.Warning); return; } } } var updatetrust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID); if (updatetrust != null && !String.IsNullOrEmpty(this.CH_TrustID)) { Model.CH_Trust trust = new Model.CH_Trust(); trust.CH_TrustID = this.CH_TrustID; trust.CH_AuditDate = null; trust.CH_AuditMan = null; this.btnCancelAudit.Hidden = true; this.btnAudit.Hidden = false; BLL.TrustManageEditService.AuditCH_Trust(trust); var trustItems = from x in Funs.DB.CH_TrustItem where x.CH_TrustID == this.CH_TrustID select x; foreach (var newitem in trustItems) { BLL.TrustManageEditService.UpdateJOT_TrustFlag(newitem.JOT_ID, "2"); ////更新焊口代号 var jotitem = BLL.PW_JointInfoService.GetJointInfoByJotID(newitem.JOT_ID); if (jotitem.JOT_JointStatus == "102" || jotitem.JOT_JointStatus == "104") { BLL.RepairService.UpdateCancelAuditJointNo(jotitem.JOT_ID); } } ShowNotify("取消审核完成!", MessageBoxIcon.Success); updateTreeMenu(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_RepairManageAuditMenuId, button); } #endregion #region 打印 /// /// 打印按钮 /// /// /// //protected void btnPrint_Click(object sender, EventArgs e) //{ // string reportId = this.tvControlItem.SelectedNode.NodeID; // var q = BLL.TrustManageEditService.GetCH_TrustByID(reportId); // if (q != null) // { // string varValue = string.Empty; // //var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId); // //var installationName = BLL.Project_InstallationService.GetInstallationByInstallationId(q.InstallationId).InstallationName; // //var unitName = BLL.UnitService.GetUnitNameByUnitId(q.UnitId); // //varValue = installationName + "|" + unitName + "|" + projectName + "|" + q.PW_PointDate.Value.ToString("yyyy-MM-dd") + "|" + q.PW_PointNo; // if (!string.IsNullOrEmpty(varValue)) // { // varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ",")); // } // if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == true) //3表示无损委托 // { // PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReportId, reportId, varValue, this.CurrUser.LoginProjectId))); // } // else if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == false) // { // PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport2Id, reportId, varValue, this.CurrUser.LoginProjectId))); // } // else if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == null) // { // var p = BLL.Project_SysSetService.GetSysSetBySetId("3", this.CurrUser.LoginProjectId); // if (p.SetValue == "3") // { // PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport3Id, reportId, varValue, this.CurrUser.LoginProjectId))); // } // else // 4表示为神化委托单 // { // PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport4Id, reportId, varValue, this.CurrUser.LoginProjectId))); // } // } // } // else // { // Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning); // return; // } //} protected void btnPrint_Click(object sender, EventArgs e) { if (printType.SelectedValue == "0") //焊接工作记录 { // 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 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) { dr["WorkAreaName"] = PworkArea.WorkAreaName; dr["WorkAreaCode"] = PworkArea.WorkAreaCode; } } dt.Rows.Add(dr); Dictionary keyValuePairs = new Dictionary(); 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("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath))); } } else { Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning); return; } } else if (printType.SelectedValue == "1") //焊接工作记录 { // 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 listStr = new List(); listStr.Add(new SqlParameter("@CH_TrustID", tvControlItem.SelectedNodeID)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); tb.TableName = "Data"; 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 keyValuePairs = new Dictionary(); 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.AddFastreportTable(tb); 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"] = "古雷中沙石化有限公司"; } if (File.Exists(rootPath + initTemplatePath)) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../TrustManage/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; } } else if (printType.SelectedValue == "2") { string strSql = @"select h.ISO_IsoNo, c.JOT_ID,c.JOT_JointNo CH_RepairLocation,Defects_Definition, (select count(*) from CH_CheckItem c where c.CHT_CheckResult!='合格'and a.JOT_ID =c.JOT_ID) BackNumber,DefectLength ,d.WED_Code as WED_Code1,e.WED_Code as WED_Code2,f.CHT_CheckDate from CH_TrustItem a left join CH_CheckItem b on a.JOT_ID = b.JOT_ID left join CH_Check f on f.CHT_CheckID = b.CHT_CheckID left join PW_JointInfo c on b.JOT_ID = c.JOT_ID left join BS_Welder d on d.WED_ID = c.JOT_CellWelder left join BS_Welder e on e.WED_ID = c.JOT_FloorWelder left join PW_JointInfo g on g.JOT_ID = a.JOT_ID left join PW_IsoInfo h on g.ISO_ID= h.ISO_ID where a.CH_TrustID = @TrustID and b.JOT_ID is not null "; List listStr = new List(); listStr.Add(new SqlParameter("@TrustID", tvControlItem.SelectedNodeID)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); if (tb != null) { tb.TableName = "Table1"; } Dictionary keyValuePairs = new Dictionary(); if (tb.Rows.Count > 0 && tb.Rows[0]["JOT_ID"] != null) { var joint = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == tb.Rows[0]["JOT_ID"].ToString()); keyValuePairs.Add("JOT_JointDesc", joint.JOT_JointDesc); var material = Funs.DB.Base_Material.FirstOrDefault(x => x.MaterialId == joint.MaterialId); keyValuePairs.Add("MaterialCode", material.MaterialCode); var weldingMethod = Funs.DB.Base_WeldingMethod.FirstOrDefault(x => x.WeldingMethodId == joint.WME_ID); keyValuePairs.Add("WeldingMethodName", weldingMethod.WeldingMethodName); var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_ID == joint.ISO_ID); if (iso != null) { keyValuePairs.Add("ISO_IsoNo", iso.ISO_IsoNo); keyValuePairs.Add("ISO_IsoNumber", iso.ISO_IsoNumber); } var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); if (workArea != null) { keyValuePairs.Add("WorkAreaName", workArea.WorkAreaName); keyValuePairs.Add("WorkAreaCode", workArea.WorkAreaCode); } var installation = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId); keyValuePairs.Add("InstallationName", installation.InstallationName); } var proejct = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); keyValuePairs.Add("ProjectName", proejct.ProjectName); BLL.Common.FastReportService.ResetData(); BLL.Common.FastReportService.AddFastreportTable(tb); BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs); // Session["Table"] = dt; // Session["CH_TrustID"] = reportId; string initTemplatePath = ""; string rootPath = Server.MapPath("~/"); initTemplatePath = "File\\Fastreport\\管道焊缝返修施工记录.frx"; if (File.Exists(rootPath + initTemplatePath)) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath))); } } else if (printType.SelectedValue == "3") { string strSql = @"select c.JOT_ID,c.JOT_JointNo CH_RepairLocation,Defects_Definition, (select count(*) from CH_CheckItem c where c.CHT_CheckResult!='合格'and a.JOT_ID =c.JOT_ID) BackNumber,DefectLength ,d.WED_Code as WED_Code1,e.WED_Code as WED_Code2,f.CHT_CheckDate from CH_TrustItem a left join CH_CheckItem b on a.JOT_ID = b.JOT_ID left join CH_Check f on f.CHT_CheckID = b.CHT_CheckID left join PW_JointInfo c on b.JOT_ID = c.JOT_ID left join BS_Welder d on d.WED_ID = c.JOT_CellWelder left join BS_Welder e on e.WED_ID = c.JOT_FloorWelder where a.CH_TrustID = @TrustID and b.JOT_ID is not null "; List listStr = new List(); listStr.Add(new SqlParameter("@TrustID", tvControlItem.SelectedNodeID)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); if (tb != null) { tb.TableName = "Table1"; } Dictionary keyValuePairs = new Dictionary(); if (tb.Rows.Count > 0 && tb.Rows[0]["JOT_ID"] != null) { var joint = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == tb.Rows[0]["JOT_ID"].ToString()); keyValuePairs.Add("JOT_JointDesc", joint.JOT_JointDesc); var material = Funs.DB.Base_Material.FirstOrDefault(x => x.MaterialId == joint.MaterialId); keyValuePairs.Add("MaterialCode", material.MaterialCode); var weldingMethod = Funs.DB.Base_WeldingMethod.FirstOrDefault(x => x.WeldingMethodId == joint.WME_ID); keyValuePairs.Add("WeldingMethodName", weldingMethod.WeldingMethodName); var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_ID == joint.ISO_ID); if (iso != null) { keyValuePairs.Add("ISO_IsoNo", iso.ISO_IsoNo); keyValuePairs.Add("ISO_IsoNumber", iso.ISO_IsoNumber); } var PworkArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); if (PworkArea != null) { keyValuePairs.Add("WorkAreaName", PworkArea.WorkAreaName); } } var proejct = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); keyValuePairs.Add("ProjectName", proejct.ProjectName); BLL.Common.FastReportService.ResetData(); BLL.Common.FastReportService.AddFastreportTable(tb); BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs); // Session["Table"] = dt; // Session["CH_TrustID"] = reportId; string initTemplatePath = ""; string rootPath = Server.MapPath("~/"); initTemplatePath = "File\\Fastreport\\设备焊缝返修施工记录.frx"; if (File.Exists(rootPath + initTemplatePath)) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath))); } } } #endregion } }