using BLL; using System; 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 RepairManageEdit : 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) { //施工单位、装置 //if (BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId) == null || BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId).UnitTypeId == BLL.Const.ProjectUnitType_1 || BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId).UnitTypeId == BLL.Const.ProjectUnitType_5) //{ // BLL.UnitService.InitUnitNameByUnitTypeDropDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true); // BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, true); //} //else //{ // BLL.UnitService.InitSubUnitNameDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true); // BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true); //} var pUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2); if (pUnit != null) { this.drpCH_TrustUnit.DataTextField = "UnitName"; this.drpCH_TrustUnit.DataValueField = "UnitId"; this.drpCH_TrustUnit.DataSource = pUnit; this.drpCH_TrustUnit.DataBind(); this.drpCH_TrustUnit.SelectedValue = this.CurrUser.UnitId; if (CurrUser.UnitId != Const.UnitId_TCC && CurrUser.UserId != Const.hfnbdId) { this.drpCH_TrustUnit.Enabled = false; } BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true); this.drpInstallationId.SelectedIndex = 0; } BLL.Base_DetectionRateService.InitDetectionRateDropDownList(this.drpCH_NDTRate, true);//探伤比例 BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpCH_NDTMethod, true);//检测方法 BLL.UserService.InitUserDropDownList(this.drpCH_TrustMan, this.CurrUser.LoginProjectId, true);//委托人 //合格等级 this.drpCH_AcceptGrade.DataTextField = "Text"; this.drpCH_AcceptGrade.DataValueField = "Value"; this.drpCH_AcceptGrade.DataSource = BLL.DropListService.HJGL_GetAcceptGradeList(); this.drpCH_AcceptGrade.DataBind(); Funs.FineUIPleaseSelect(this.drpCH_AcceptGrade); BLL.UserService.InitUserDropDownList(this.drpCH_Tabler, this.CurrUser.LoginProjectId, true);//制单人 BLL.Base_GrooveTypeService.InitGrooveTypeDropDownList(this.drpCH_SlopeType, true);//坡口类型 BLL.Base_WeldingMethodService.InitWeldingMethodDropDownList(this.drpCH_WeldMethod, true);//焊接方法 BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpCH_CheckUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_5, true);//检测单位 this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now); this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.drpCH_TrustMan.SelectedValue = this.CurrUser.UserId; this.drpCH_Tabler.SelectedValue = this.CurrUser.UserId; this.txtCH_NDTCriteria.Text = "NB/T47013-2015"; this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); 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; } } #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.drpCH_TrustUnit.SelectedValue = trust.CH_TrustUnit; } if (!string.IsNullOrEmpty(trust.InstallationId)) { BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true); this.drpInstallationId.SelectedValue = trust.InstallationId; } 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)) { this.drpCH_NDTRate.SelectedValue = trust.CH_NDTRate; } this.txtCH_WorkNo.Text = trust.CH_WorkNo; if (!string.IsNullOrEmpty(trust.CH_NDTMethod)) { this.drpCH_NDTMethod.SelectedValue = trust.CH_NDTMethod; } if (!string.IsNullOrEmpty(trust.CH_TrustMan)) { this.drpCH_TrustMan.SelectedValue = trust.CH_TrustMan; } this.txtCH_ItemName.Text = trust.CH_ItemName; if (!string.IsNullOrEmpty(trust.CH_AcceptGrade)) { this.drpCH_AcceptGrade.SelectedValue = trust.CH_AcceptGrade; } if (!string.IsNullOrEmpty(trust.CH_Tabler)) { this.drpCH_Tabler.SelectedValue = trust.CH_Tabler; } if (!string.IsNullOrEmpty(trust.CH_SlopeType)) { this.drpCH_SlopeType.SelectedValue = trust.CH_SlopeType; } this.txtCH_NDTCriteria.Text = trust.CH_NDTCriteria; if (!string.IsNullOrEmpty(trust.CH_WeldMethod)) { this.drpCH_WeldMethod.SelectedValue = trust.CH_WeldMethod; } this.txtCH_ServiceTemp.Text = trust.CH_ServiceTemp; if (!string.IsNullOrEmpty(trust.CH_CheckUnit)) { this.drpCH_CheckUnit.SelectedValue = 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; trustItems = BLL.TrustManageEditService.GetTrustItemViewByTrustId(this.CH_TrustID); this.Grid1.DataSource = trustItems; this.Grid1.DataBind(); } string url = AttachFileService.getFileUrl(this.CH_TrustID); if (!string.IsNullOrEmpty(url)) { lbIsUpload.Text = "已上传"; } else { lbIsUpload.Text = ""; } } else { this.CH_TrustID = string.Empty; } } #endregion #region 增加 /// /// 增加按钮 /// /// /// protected void btnAdd_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnAdd)) { this.CH_TrustID = string.Empty; this.txtCH_TrustCode.Text = string.Empty; //this.drpCH_TrustUnit.SelectedIndex = 0; this.drpInstallationId.SelectedIndex = 0; this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtCH_Press.Text = string.Empty; this.drpCH_NDTRate.SelectedIndex = 0; this.txtCH_WorkNo.Text = string.Empty; this.drpCH_NDTMethod.SelectedIndex = 0; this.drpCH_TrustMan.SelectedValue = this.CurrUser.UserId; this.txtCH_ItemName.Text = string.Empty; this.drpCH_AcceptGrade.SelectedIndex = 0; this.drpCH_Tabler.SelectedValue = this.CurrUser.UserId; this.drpCH_SlopeType.SelectedIndex = 0; this.txtCH_NDTCriteria.Text = "NB/T47013-2015"; this.drpCH_WeldMethod.SelectedIndex = 0; this.txtCH_ServiceTemp.Text = string.Empty; this.drpCH_CheckUnit.SelectedIndex = 0; this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtRemark.Text = string.Empty; trustItems.Clear(); trustItems = new List(); this.Grid1.DataSource = trustItems; this.Grid1.DataBind(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 查找管线焊口 /// /// 查找按钮 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { if (GetButtonPower(BLL.Const.BtnSave)) { if (this.drpCH_TrustUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue)) { Alert.ShowInTop("请选择委托单位!", MessageBoxIcon.Warning); return; } else if (this.drpInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallationId.SelectedValue)) { Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning); return; } else { string window = String.Format("ShowRepairSearch.aspx?unitId={0}&&installationId={1}&&ch_TrustID={2}", this.drpCH_TrustUnit.SelectedValue, this.drpInstallationId.SelectedValue, this.CH_TrustID, "编辑 - "); PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdJOTID.ClientID) + Window1.GetShowReference(window)); } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 删除返修委托单 /// /// 删除按钮 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnDelete)) { this.CH_TrustID = this.tvControlItem.SelectedNodeID; if (!string.IsNullOrEmpty(this.CH_TrustID)) { var trust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID); if (trust != null && !trust.CH_AuditDate.HasValue) { BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(CH_TrustID); BLL.TrustManageEditService.DeleteCH_TrustByCH_TrustID(CH_TrustID); if (trustItems.Count > 0) { foreach (var j in trustItems) { BLL.TrustManageEditService.UpdateJOT_TrustFlag(j.JOT_ID, "2"); var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod); if (ndttype.DetectionTypeCode == "RT") { BLL.CheckManageService.UpdateCheckIsRepair(j.JOT_ID, CH_TrustID, false, "1"); } else { BLL.CheckManageService.UpdateCheckIsRepair(j.JOT_ID, CH_TrustID, false, "2"); } } } trustItems.Clear(); this.CH_TrustID = null; this.Grid1.DataSource = null; this.Grid1.DataBind(); ShowNotify("删除成功!", MessageBoxIcon.Success); } else { Alert.ShowInTop("此委托单已审核不能删除", MessageBoxIcon.Warning); return; } } else { Alert.ShowInTop("请选择要删除的委托单!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnSave)) { if (trustItems.Count <= 0) { Alert.ShowInTop("委托单信息不能为空!", MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtCH_TrustCode.Text)) { Alert.ShowInTop("请选择委托单号!", MessageBoxIcon.Warning); return; } if (this.drpCH_NDTRate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue)) { Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning); return; } if (this.drpCH_NDTMethod.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue)) { Alert.ShowInTop("请选择检测方法!", MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtCH_TrustCode.Text)) { Alert.ShowInTop("请输入委托单号!", MessageBoxIcon.Warning); return; } if (this.drpCH_CheckUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue)) { Alert.ShowInTop("请选择检测单位!", MessageBoxIcon.Warning); return; } string isoId = null; //7表示无损委托单对应管线,True表示只对应一条管线 var sysSet = BLL.Project_SysSetService.GetSysSetBySetId("7", this.CurrUser.LoginProjectId); if (sysSet != null) { var isoNum = (from x in trustItems select x.ISO_IsoNo).Distinct(); if (isoNum.Count() > 1) { Alert.ShowInTop("一个委托单只对应一条管线!"); return; } else { isoId = BLL.PW_JointInfoService.GetJointInfoByJotID(trustItems.FirstOrDefault().JOT_ID).ISO_ID; } } Model.CH_Trust trust = new Model.CH_Trust(); trust.ProjectId = this.CurrUser.LoginProjectId; trust.CH_TrustCode = this.txtCH_TrustCode.Text.Trim(); if (this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue)) { trust.CH_TrustUnit = this.drpCH_TrustUnit.SelectedValue; } if (this.drpInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallationId.SelectedValue)) { trust.InstallationId = this.drpInstallationId.SelectedValue; } trust.CH_TrustDate = Funs.GetNewDateTime(this.txtCH_TrustDate.Text.Trim()); trust.CH_Press = this.txtCH_Press.Text.Trim(); if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue)) { trust.CH_NDTRate = this.drpCH_NDTRate.SelectedValue; } trust.CH_WorkNo = this.txtCH_WorkNo.Text.Trim(); if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue)) { trust.CH_NDTMethod = this.drpCH_NDTMethod.SelectedValue; } if (this.drpCH_TrustMan.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_TrustMan.SelectedValue)) { trust.CH_TrustMan = this.drpCH_TrustMan.SelectedValue; } trust.CH_ItemName = this.txtCH_ItemName.Text.Trim(); if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue)) { trust.CH_AcceptGrade = this.drpCH_AcceptGrade.SelectedValue; } if (this.drpCH_Tabler.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_Tabler.SelectedValue)) { trust.CH_Tabler = this.drpCH_Tabler.SelectedValue; } if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_SlopeType.SelectedValue)) { trust.CH_SlopeType = this.drpCH_SlopeType.SelectedValue; } trust.CH_NDTCriteria = this.txtCH_NDTCriteria.Text.Trim(); if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_WeldMethod.SelectedValue)) { trust.CH_WeldMethod = this.drpCH_WeldMethod.SelectedValue; } trust.CH_ServiceTemp = this.txtCH_ServiceTemp.Text.Trim(); if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue)) { trust.CH_CheckUnit = this.drpCH_CheckUnit.SelectedValue; } trust.CH_RequestDate = Funs.GetNewDateTime(this.txtCH_RequestDate.Text); trust.CH_Remark = this.txtRemark.Text.Trim(); trust.CH_TrustType = "2"; trust.ToIso_Id = isoId; var updatetrust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID); if (updatetrust != null && updatetrust.CH_AuditDate.HasValue) { Alert.ShowInTop("此条委托单已审核不能修改!", MessageBoxIcon.Warning); return; } if (updatetrust != null && !string.IsNullOrEmpty(CH_TrustID)) { trust.CH_TrustID = CH_TrustID; BLL.TrustManageEditService.UpdateCH_Trust(trust); BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(CH_TrustID); //BLL.LogService.AddLog(this.CurrUser.UserId, "修改委托单信息"); if (trustItems.Count > 0) { foreach (var j in trustItems) { BLL.TrustManageEditService.UpdateJOT_TrustFlag(j.JOT_ID, "2"); } } } else { trust.CH_TrustID = SQLHelper.GetNewID(typeof(Model.CH_Trust)); this.CH_TrustID = trust.CH_TrustID; BLL.TrustManageEditService.AddCH_Trust(trust); //BLL.LogService.AddLog(this.CurrUser.UserId, "添加委托单信息"); } foreach (var item in trustItems) { Model.CH_TrustItem newitem = new Model.CH_TrustItem(); newitem.CH_TrustID = this.CH_TrustID; newitem.JOT_ID = item.JOT_ID; JArray mergedData = Grid1.GetMergedData(); foreach (JObject mergedRow in mergedData) { string status = mergedRow.Value("status"); JObject values = mergedRow.Value("values"); string rowID = values.Value("JOT_ID").ToString(); if (rowID == item.JOT_ID) { item.CH_Remark = values.Value("CH_Remark"); newitem.CH_Remark = item.CH_Remark; } newitem.CH_RepairLocation = values.Value("CH_RepairLocation"); } BLL.TrustManageEditService.AddCH_TrustItem(newitem); //更新焊口委托情况 BLL.TrustManageEditService.UpdateJOT_TrustFlag(item.JOT_ID, "1"); ////更新焊口 是否扩透 切除口 var jotitem = BLL.PW_JointInfoService.GetJointInfoByJotID(item.JOT_ID); for (int i = 0; i < Grid1.Rows.Count; i++) { string id = Grid1.Rows[i].RowID; if (item.JOT_ID == id) { CheckBoxField jointStatus = (CheckBoxField)Grid1.FindColumn("JOT_JointStatus"); bool s = jointStatus.GetCheckedState(i); if (s) { jotitem.JOT_JointStatus = "104"; } else { jotitem.JOT_JointStatus = "101"; } } else { jotitem.JOT_JointStatus = "102"; } } //更新焊口加R BLL.PW_JointInfoService.UpdateJointPoint(jotitem); //BLL.RepairService.UpdateNewJointNo(item.JOT_ID, "R"); var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod); if (ndttype.DetectionTypeCode == "RT") { BLL.CheckManageService.UpdateCheckIsRepair(item.JOT_ID, this.CH_TrustID, true, "1"); } else { BLL.CheckManageService.UpdateCheckIsRepair(item.JOT_ID, this.CH_TrustID, true, "2"); } } trustItems.Clear(); ShowNotify("保存成功!", MessageBoxIcon.Success); InitTreeMenu(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 关闭弹出窗体 /// /// 关闭弹出窗体 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { trustItems = new List(); List infos = Funs.GetStrListByStr(hdJOTID.Text, ','); if (string.IsNullOrEmpty(CH_TrustID)) { foreach (var item in infos) { if (item.Contains(";")) { var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(item.Split(';')[0], this.CurrUser.LoginProjectId); if (info != null) { var checkItem = Funs.DB.CH_CheckItem.FirstOrDefault(x => x.CHT_CheckID == item.Split(';')[1] && x.JOT_ID == item.Split(';')[0]); if (checkItem.DefectLength.HasValue) info.CH_RepairLocation = checkItem.DefectLength.Value.ToString("0.##"); trustItems.Add(info); } } else { var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(item, this.CurrUser.LoginProjectId); if (info != null) { trustItems.Add(info); } } } } else { foreach (var jotid in infos) { if (jotid.Contains(";")) { var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(jotid.Split(';')[0], this.CurrUser.LoginProjectId); if (info != null) { var checkItem = Funs.DB.CH_CheckItem.FirstOrDefault(x => x.CHT_CheckID == jotid.Split(';')[1] && x.JOT_ID == jotid.Split(';')[0]); if (checkItem.DefectLength.HasValue) info.CH_RepairLocation = checkItem.DefectLength.Value.ToString("0.##"); trustItems.Add(info); } } else { var item = BLL.TrustManageEditService.GetCH_TrustItemByJOT_ID(jotid); if (item.Where(y => y.JOT_ID == jotid).Count() == 0) { var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(jotid, this.CurrUser.LoginProjectId); if (info != null) { trustItems.Add(info); } } } } } this.Grid1.DataSource = trustItems; this.Grid1.DataBind(); if (trustItems.Count > 0) { var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == trustItems[0].JOT_ID); var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == trustItems[0].ISO_IsoNo); var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue); if (iso.Is_Standard.HasValue && !iso.Is_Standard.Value) { this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId; this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId; this.drpCH_SlopeType.SelectedValue = join.JST_ID; this.drpCH_WeldMethod.SelectedValue = join.WME_ID; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue); if (trustUnit != null && workArea != null && NDTMethod != null) { try { if (this.CurrUser.LoginProjectId == "3c45e9f1-8d2a-497f-8304-c66a11622c14" ) { if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null) { var checkUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_CheckUnit.SelectedValue); //var install = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId); string code = "" + workArea.WorkAreaCode + "-" + trustUnit.UnitCode + "-" + checkUnit.UnitCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code); } } else if (this.CurrUser.LoginProjectId == "f04b138b-6194-4380-88b5-f8410d7039fa") { if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null) { var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); //var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var checkUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_CheckUnit.SelectedValue); //var install = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId);iso.ISO_IsoNo + "-" + string code = "SFP-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + checkUnit.UnitCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code); } } else { string code = "TCC-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K"; } } catch (Exception ee) { } } } else { this.drpCH_NDTRate.SelectedValue = join.DetectionRateId; this.drpCH_NDTMethod.SelectedValue = join.DetectionTypeId; this.drpCH_SlopeType.SelectedValue = join.JST_ID; this.drpCH_WeldMethod.SelectedValue = join.WME_ID; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue); if (trustUnit != null && workArea != null && NDTMethod != null) { try { string code = trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K"; } catch (Exception ee) { } } } } } #endregion #region 右键删除焊口 /// /// 右键删除焊口 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (this.GetButtonPower(BLL.Const.BtnDelete)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID); if (trust != null && trust.CH_AuditDate.HasValue) { Alert.ShowInTop("此委托单已审核不能删除!", MessageBoxIcon.Warning); return; } else { var item = trustItems.FirstOrDefault(x => x.JOT_ID == rowID); if (item != null) { BLL.TrustManageEditService.UpdateJOT_TrustFlag(rowID, "2"); trustItems.RemoveAt(rowIndex); } } } Grid1.DataSource = trustItems; Grid1.DataBind(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region DropDownList下拉选择事件 /// /// 合格等级下拉选择事件 /// /// /// protected void drpCH_AcceptGrade_SelectedIndexChanged(object sender, EventArgs e) { //if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue)) //{ // txtCH_NDTCriteria.Text = "NB/T47013-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; //} //else //{ // txtCH_NDTCriteria.Text = "NB/T47013-2015"; //} if (drpCH_NDTMethod.SelectedValue != null && drpCH_NDTMethod.SelectedValue != BLL.Const._Null) { var detectionType = Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(drpCH_NDTMethod.SelectedValue); string type = detectionType.DetectionTypeCode.Split('\\')[0]; switch (type) { case "RT": // RT采用标准--NB / T47013.2 - 2015 II级 //UT采用标准--NB / T47013.3 - 2015 I级 //MT采用标准--NB / T47013.4 - 2015 I级 //PT采用标准--NB / T47013.5 - 2015 I级 // TOFD采用标准--NB / T47013.10 - 2015 II级 //3D - TFM--NB / T47013.15 - 2021 II级 if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.2-2015/AB级" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.2-2015/AB级"; } break; case "UT": if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.3-2015/B级" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.3-2015/B级"; } break; case "MT": if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.4-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.4-2015"; } break; case "PT": if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.5-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.5-2015"; } break; case "TOFD": if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.10-2015/B级" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.10-2015/B级"; } break; case "3D-TFM": if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null) { txtCH_NDTCriteria.Text = "NB/T47013.15-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; } else { txtCH_NDTCriteria.Text = "NB/T47013.15-2015"; } break; case "PA": txtCH_NDTCriteria.Text = "NB/T47013.15-2021 B级" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")"; break; } } } /// /// 委托单位下拉选择事件 /// /// /// protected void drpCH_TrustUnit_SelectedIndexChanged(object sender, EventArgs e) { this.drpInstallationId.Items.Clear(); if (!string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue) && this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null) { //if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId)) //{ // BLL.Project_InstallationService.InitInstallationBySupervisorUnitIdListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, this.CurrUser.UnitId, true); // this.drpInstallationId.SelectedIndex = 0; //} //else //{ // BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true); // this.drpInstallationId.SelectedIndex = 0; //} BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true); this.drpInstallationId.SelectedIndex = 0; //加载委托单号 string prefixCode = string.Empty; var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_TCC); // var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue); // prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-"; //this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode); needChangeCode(sender, e); } else { Funs.FineUIPleaseSelect(this.drpInstallationId); } } /// /// 装置下拉选择事件 /// /// /// protected void drpInstallationId_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallationId.SelectedValue)) { //string prefixCode = string.Empty; //string areaCode = string.Empty; //var workarea = BLL.WorkAreaService.GetWorkAreaByProjectIdAndInstalltionIdAndUnitId(this.CurrUser.LoginProjectId, this.drpInstallationId.SelectedValue, this.drpCH_TrustUnit.SelectedValue); //if (workarea != null) //{ // areaCode = workarea.WorkAreaCode; //} //var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_TCC); //var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue); //prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-" + areaCode + "-"; //this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode); } } /// /// 检测方法下拉选择事件 /// /// /// protected void drpCH_NDTMethod_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue)) { //string prefixCode = string.Empty; //string areaCode = string.Empty; //string unitCode = string.Empty; //string ndttCode = string.Empty; //var workarea = BLL.WorkAreaService.GetWorkAreaByProjectIdAndInstalltionIdAndUnitId(this.CurrUser.LoginProjectId, this.drpInstallationId.SelectedValue, this.drpCH_TrustUnit.SelectedValue); //if (workarea != null) //{ // areaCode = workarea.WorkAreaCode; //} //var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_TCC); //var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue); //var ndtt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(this.drpCH_NDTMethod.SelectedValue); //if (ndtt != null) //{ // ndttCode = ndtt.DetectionTypeCode; //} // prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-" + areaCode + "-" + ndttCode + "-"; // this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode); } } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_RepairManageMenuId, button); } #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 protected void imgBtnFile_Click(object sender, EventArgs e) { 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) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}", 0, reportId, BLL.Const.HJGL_RepairManageMenuId))); } else { Alert.ShowInTop("请选择委托单!", MessageBoxIcon.Warning); return; } } #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)) { 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 listStr = new List(); 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) { 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 ( 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 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 != 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; } var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == tb.Rows[0]["ISO_IsoNo"].ToString()); if (iso != null) { dr["WorkAreaCode"] = iso.DeviceName; } } 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"] = "古雷中沙石化有限公司"; dt.Rows[0]["ProjectName"] = installation.InstallationName; } 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))); } } } //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 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(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 protected void needChangeCode(object sender, EventArgs e) { var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID); if (trust == null) { //trustItems = new List(); //List infos = Funs.GetStrListByStr(hdJOTID.Text, ','); //if (string.IsNullOrEmpty(CH_TrustID)) //{ // foreach (var item in infos) // { // var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(item, this.CurrUser.LoginProjectId); // if (info != null) // { // trustItems.Add(info); // } // } //} //else //{ // foreach (var jotid in infos) // { // var item = BLL.TrustManageEditService.GetCH_TrustItemByJOT_ID(jotid); // if (item.Where(y => y.JOT_ID == jotid).Count() == 0) // { // var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(jotid, this.CurrUser.LoginProjectId); // if (info != null) // { // trustItems.Add(info); // } // } // } //} if (trustItems.Count > 0) { var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == trustItems[0].JOT_ID); var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == trustItems[0].ISO_IsoNo); var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue); if (iso.Is_Standard.HasValue && !iso.Is_Standard.Value) { //this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId; //this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId; //this.drpCH_SlopeType.SelectedValue = join.JST_ID; //this.drpCH_WeldMethod.SelectedValue = join.WME_ID; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue); if (trustUnit != null && workArea != null && NDTMethod != null) { try { if (this.CurrUser.LoginProjectId == "3c45e9f1-8d2a-497f-8304-c66a11622c14" ) { if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null) { var checkUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_CheckUnit.SelectedValue); //var install = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId); string code = "" + workArea.WorkAreaCode + "-" + trustUnit.UnitCode + "-" + checkUnit.UnitCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code); } } else if (this.CurrUser.LoginProjectId == "f04b138b-6194-4380-88b5-f8410d7039fa") { if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null) { // var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); //var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var checkUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_CheckUnit.SelectedValue); //var install = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId);iso.ISO_IsoNo + "-" + string code = "SFP-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + checkUnit.UnitCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code); } } else { string code = "TCC-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K"; } } catch (Exception ee) { } } } else { //this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId; //this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId; //this.drpCH_SlopeType.SelectedValue = join.JST_ID; //this.drpCH_WeldMethod.SelectedValue = join.WME_ID; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue); if (trustUnit != null && workArea != null && NDTMethod != null) { try { string code = trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K"; if (this.CurrUser.LoginProjectId == "f04b138b-6194-4380-88b5-f8410d7039fa") { if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null) { // var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); //var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId); var checkUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_CheckUnit.SelectedValue); //var install = Funs.DB.Project_Installation.FirstOrDefault(x => x.InstallationId == workArea.InstallationId);iso.ISO_IsoNo + "-" + code = "SFP-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + checkUnit.UnitCode + "-" + NDTMethod.DetectionTypeCode + "-"; this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code); } } } catch (Exception ee) { } } } } } } public static string ConvertRepairLocation(object jotId) { if (jotId != null) { var RepairLocation = (from x in Funs.DB.CH_CheckItem where x.JOT_ID == jotId.ToString() orderby x.CHT_FilmDate descending select x.CHT_RepairLocation ).FirstOrDefault() ; if (RepairLocation != null) { return RepairLocation.ToString(); } } return null; } protected void drpCH_CheckUnit_SelectedIndexChanged(object sender, EventArgs e) { needChangeCode(sender, e); } protected void drpCH_NDTMethod_SelectedIndexChanged1(object sender, EventArgs e) { needChangeCode(sender, e); drpCH_AcceptGrade_SelectedIndexChanged(sender, e); } } }