using BLL; using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Text; using System.Web; namespace FineUIPro.Web.HJGL.WeldingManage { public partial class JotTwoDesign : PageBase { public int pageSize = 20; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); Funs.FineUIPleaseSelect(DropTwoJointType, "请选择"); //BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, true); this.InitTreeMenu();//加载树 } } protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } #region 加载树装置-单位-工作区 /// /// 加载树 /// private void InitTreeMenu() { this.tvControlItem.Nodes.Clear(); TreeNode rootNode1 = new TreeNode(); rootNode1.NodeID = "1"; rootNode1.Text = "建筑工程"; rootNode1.CommandName = "建筑工程"; rootNode1.Selectable = false; this.tvControlItem.Nodes.Add(rootNode1); TreeNode rootNode2 = new TreeNode(); rootNode2.NodeID = "2"; rootNode2.Text = "安装工程"; rootNode2.CommandName = "安装工程"; rootNode2.Expanded = true; this.tvControlItem.Nodes.Add(rootNode2); var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); // 获取当前用户所在单位 var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId); var unitWorkList = (from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null select x).ToList(); List unitWork1 = null; List unitWork2 = null; //// 当前为施工单位,只能操作本单位的数据 //if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2) //{ // unitWork1 = (from x in unitWorkList // where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1" // select x).ToList(); // unitWork2 = (from x in unitWorkList // where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2" // select x).ToList(); //} //else //{ unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList(); unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList(); //} if (unitWork1.Count() > 0) { foreach (var q in unitWork1) { int a = 0; if (cbAllPipeline.Checked) { a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) select x).Count(); } else { a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) && (from y in Funs.DB.HJGL_WeldJoint where y.PipelineId == x.PipelineId && y.IsTwoJoint == true select y).Count() > 0 select x).Count(); } var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId); TreeNode tn1 = new TreeNode(); tn1.NodeID = q.UnitWorkId; tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线"; tn1.ToolTip = "施工单位:" + unitNamesUnitIds; tn1.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize); tn1.EnableClickEvent = true; tn1.EnableExpandEvent = true; rootNode1.Nodes.Add(tn1); if (a > 0) { // BindNodes(tn1); TreeNode newNode = new TreeNode(); newNode.Text = "加载管线..."; newNode.NodeID = "加载管线..."; tn1.Nodes.Add(newNode); } } } if (unitWork2.Count() > 0) { foreach (var q in unitWork2) { int a = 0; if (cbAllPipeline.Checked) { a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) select x).Count(); } else { a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) && (from y in Funs.DB.HJGL_WeldJoint where y.PipelineId == x.PipelineId && y.IsTwoJoint == true select y).Count() > 0 select x).Count(); } var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId); TreeNode tn2 = new TreeNode(); tn2.NodeID = q.UnitWorkId; tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线"; if (q.UnitWorkId == this.hdUnitWorkId.Text) { tn2.Expanded = true; } tn2.ToolTip = "施工单位:" + unitNamesUnitIds; tn2.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize); tn2.EnableClickEvent = true; tn2.EnableExpandEvent = true; rootNode2.Nodes.Add(tn2); if (a > 0) { // BindNodes(tn1); TreeNode newNode = new TreeNode(); newNode.Text = "加载管线..."; newNode.NodeID = "加载管线..."; tn2.Nodes.Add(newNode); } } } } #endregion private void BindNodes(TreeNode node) { List pipeline = new List(); pipeline = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == node.NodeID && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) orderby x.PipelineCode select x).ToList(); if (cbAllPipeline.Checked) { pipeline = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == node.NodeID && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) orderby x.PipelineCode select x).ToList(); } else { pipeline = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == node.NodeID && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) && (from y in Funs.DB.HJGL_WeldJoint where y.PipelineId == x.PipelineId && y.IsTwoJoint == true select y).Count() > 0 orderby x.PipelineCode select x).ToList(); } var hJGL_WeldJoints = (from x in Funs.DB.HJGL_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); int pageindex = int.Parse(node.CommandName.Split('|')[0]); int pageCount = int.Parse(node.CommandName.Split('|')[1]); if (pageindex <= pageCount) { pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList(); foreach (var item in pipeline) { //var jotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == item.PipelineId && x.IsTwoJoint == true select x).Count(); //var weldJotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == item.PipelineId && x.IsTwoJoint == true && x.WeldingDailyId != null select x).Count(); //TreeNode newNode = new TreeNode(); //if (jotCount > weldJotCount) //{ // newNode.Text = "" + item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】" + ""; //} //else //{ // newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】"; //} var jotCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId && x.IsTwoJoint == true select x).Count(); var AuditCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId && x.IsTwoJoint == true && x.AuditDate != null select x).Count(); TreeNode newNode = new TreeNode(); //if (jotCount == AuditCount) //全部审核 //{ // newNode.Text = "" + item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】" + ""; //} //else if (AuditCount == 0) //全部未审核 //{ // newNode.Text = "" + item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】" + ""; //} //else //部分审核 //{ // newNode.Text = "" + item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】" + ""; //} newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】"; newNode.ToolTip = "管线号【焊口数】"; newNode.NodeID = item.PipelineId; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } if (pageindex < pageCount) { TreeNode newNode = new TreeNode(); newNode.Text = "加载"; newNode.NodeID = SQLHelper.GetNewID(); newNode.CommandName = "加载"; newNode.Icon = Icon.ArrowDown; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } } } #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); this.hdUnitWorkId.Text = string.Empty; if (e.CommandName == "加载") { string CommandName = e.Node.ParentNode.CommandName; e.Node.ParentNode.CommandName = (int.Parse(CommandName.Split('|')[0]) + 1) + "|" + int.Parse(CommandName.Split('|')[1]); TreeNode treeNode = e.Node.ParentNode; treeNode.Nodes.Remove(e.Node); BindNodes(e.Node.ParentNode); } else { if (pipeline != null) { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID; this.BindGrid(); } else { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNodeID; NoAuditBindGrid(); } } } protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e) { if (e.Node.Nodes[0].NodeID == "加载管线...") { e.Node.Nodes.Clear(); BindNodes(e.Node); } } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { string strSql = @"SELECT WeldJointId,WeldJointCode,PipelineId,PipelineCode,JointAttribute,TwoJointType, ComponentsCode1,ComponentsCode2,IsWelding,IsHotProessStr,Material1Code,Material2Code, WeldTypeCode,Specification,HeartNo1,HeartNo2,isnull(Size,0) as Size,isnull(Dia,0) as Dia,isnull(Thickness,0) as Thickness,GrooveTypeCode, WeldingMethodCode,WeldingWireCode,WeldingRodCode,WeldingDate,WeldingDailyCode, BackingWelderCode,CoverWelderCode,MediumCode ,PreTemperature,JointArea,WPQCode,Remark, (CASE WHEN AuditDate IS NOT NULL THEN '已审核' ELSE '未审核' END) AS IsAudit, subMan.PersonName AS SubmitMan,auditMan.PersonName AS AuditMan,AuditDate,auditMan2.PersonName AS AuditMan2,AuditDate2 FROM View_HJGL_WeldJoint LEFT JOIN dbo.Person_Persons auditMan ON auditMan.PersonId=View_HJGL_WeldJoint.AuditMan LEFT JOIN dbo.Person_Persons auditMan2 ON auditMan2.PersonId=View_HJGL_WeldJoint.AuditMan2 LEFT JOIN dbo.Person_Persons subMan ON subMan.PersonId=View_HJGL_WeldJoint.SubmitMan WHERE IsTwoJoint = 1"; List listStr = new List { }; strSql += " AND PipelineId =@PipelineId"; listStr.Add(new SqlParameter("@PipelineId", this.tvControlItem.SelectedNodeID)); if (!string.IsNullOrEmpty(this.txtWeldJointCode.Text.Trim())) { strSql += " AND WeldJointCode LIKE @WeldJointCode"; listStr.Add(new SqlParameter("@WeldJointCode", "%" + this.txtWeldJointCode.Text.Trim() + "%")); } if (DropTwoJointType.SelectedValue != BLL.Const._Null) { strSql += " AND TwoJointType = @TwoJointType"; listStr.Add(new SqlParameter("@TwoJointType", DropTwoJointType.SelectedValue)); } if (rbIsAudit.SelectedValue != "2") { if (rbIsAudit.SelectedValue == "0") { strSql += " and AuditDate is null"; } else { strSql += " and AuditDate is not null"; } } if (!string.IsNullOrEmpty(this.txtAuditDate.Text.Trim())) { strSql += " AND CONVERT(VARCHAR(20),AuditDate,23) =@AuditDate"; listStr.Add(new SqlParameter("@AuditDate", this.txtAuditDate.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); decimal? d = 0; var SizeSum = tb.AsEnumerable().Select(x => x.Field("Size") ?? d).Sum(); lbSize.Text = SizeSum.ToString(); // 2.获取当前分页数据 Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } private void NoAuditBindGrid() { string strSql = @"SELECT WeldJointId,WeldJointCode,PipelineId,PipelineCode,JointAttribute,TwoJointType, ComponentsCode1,ComponentsCode2,IsWelding,IsHotProessStr,Material1Code,Material2Code, WeldTypeCode,Specification,HeartNo1,HeartNo2,isnull(Size,0) as Size,isnull(Dia,0) as Dia,isnull(Thickness,0) as Thickness,GrooveTypeCode, WeldingMethodCode,WeldingWireCode,WeldingRodCode,WeldingDate,WeldingDailyCode, BackingWelderCode,CoverWelderCode,MediumCode ,PreTemperature,JointArea,WPQCode,Remark, (CASE WHEN AuditDate IS NOT NULL THEN '已审核' ELSE '未审核' END) AS IsAudit, subMan.PersonName AS SubmitMan,auditMan.PersonName AS AuditMan,AuditDate FROM View_HJGL_WeldJoint LEFT JOIN dbo.Person_Persons auditMan ON auditMan.PersonId=View_HJGL_WeldJoint.AuditMan LEFT JOIN dbo.Person_Persons subMan ON subMan.PersonId=View_HJGL_WeldJoint.SubmitMan WHERE IsTwoJoint = 1"; List listStr = new List { }; strSql += " AND UnitWorkId =@UnitWorkId"; listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNodeID)); if (!string.IsNullOrEmpty(this.txtWeldJointCode.Text.Trim())) { strSql += " AND WeldJointCode LIKE @WeldJointCode"; listStr.Add(new SqlParameter("@WeldJointCode", "%" + this.txtWeldJointCode.Text.Trim() + "%")); } if (DropTwoJointType.SelectedValue != BLL.Const._Null) { strSql += " AND TwoJointType = @TwoJointType"; listStr.Add(new SqlParameter("@TwoJointType", DropTwoJointType.SelectedValue)); } if (rbIsAudit.SelectedValue != "2") { if (rbIsAudit.SelectedValue == "0") { strSql += " and AuditDate is null"; } else { strSql += " and AuditDate is not null"; } } if (!string.IsNullOrEmpty(this.txtAuditDate.Text.Trim())) { strSql += " AND CONVERT(VARCHAR(20),AuditDate,23) =@AuditDate"; listStr.Add(new SqlParameter("@AuditDate", this.txtAuditDate.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); var SizeSum = tb.AsEnumerable().Select(x => x.Field("Size")).Sum(); lbSize.Text = SizeSum.ToString(); // 2.获取当前分页数据 Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 分页排序 #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); this.hdUnitWorkId.Text = string.Empty; if (pipeline != null) { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID; this.BindGrid(); } else { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNodeID; NoAuditBindGrid(); } } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #endregion #region 焊口信息 维护事件 /// /// Grid双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnModify)) { if (BLL.WeldTaskService.GetWeldTaskByWeldJointId(Grid1.SelectedRowID) != null) //已下任务单,不可修改数据 { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointView.aspx?WeldJointId={0}", Grid1.SelectedRowID, "编辑 - "))); } else { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointEdit.aspx?WeldJointId={0}", Grid1.SelectedRowID, "编辑 - "))); } } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 增加焊口信息 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_JotTwoDesignMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointEdit.aspx?PipelineId={0}&&IsTwoJoint=1", this.tvControlItem.SelectedNodeID, "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 批量增加焊口信息 /// /// /// protected void btnBatchAdd_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_JotTwoDesignMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointBatchEdit.aspx?PipelineId={0}&&IsTwoJoint=1", this.tvControlItem.SelectedNodeID, "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 自动录入 /// /// /// protected void btnAutoInput_Click(object sender, EventArgs e) { //if (this.drpUnit.SelectedValue == BLL.Const._Null) //{ // ShowNotify("请选择工艺规程编制单位!", MessageBoxIcon.Warning); // return; //} //if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) //{ // var jotList = from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == tvControlItem.SelectedNodeID && x.WPQId == null && x.IsTwoJoint == true select x; // if (jotList.Count() > 0) // { // foreach (var jot in jotList) // { // List wpqList = BLL.WPQListServiceService.GetMatchWPQ(jot, this.CurrUser.LoginProjectId, drpUnit.SelectedValue); // if (wpqList != null) // { // Model.HJGL_WeldJoint newJot = WeldJointService.GetWeldJointByWeldJointId(jot.WeldJointId); // Model.WPQ_WPQList wps = new Model.WPQ_WPQList(); // var a = wpqList.FirstOrDefault(x => x.WeldingMethodId == "feb1234c-a538-476f-99ac-7b3ab15997c1"); //优先匹配GTAW+SMAW的焊评 // if (a == null) // { // wps = BLL.WPQListServiceService.GetWPQById(wpqList.First().WPQId); // } // else // { // wps = BLL.WPQListServiceService.GetWPQById(a.WPQId); // } // newJot.WPQId = wps.WPQId; // newJot.WeldJointId = jot.WeldJointId; // newJot.WeldingRod = wps.WeldingRod; // newJot.WeldingWire = wps.WeldingWire; // newJot.WeldingMethodId = wps.WeldingMethodId; // newJot.GrooveTypeId = wps.GrooveType; // newJot.PreTemperature = wps.PreTemperature; // newJot.IsHotProess = wps.IsHotProess; // newJot.MatchableWPQ = string.Join(",", wpqList.Select(x => x.WPQCode)); // BLL.WeldJointService.UpdateConWeldJoint(newJot); // } // } // } // BindGrid(); // ShowNotify("该管线焊口已完成自动录入!", MessageBoxIcon.Success); //} } /// /// 焊口信息编辑 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } if (BLL.WeldTaskService.GetWeldTaskByWeldJointId(Grid1.SelectedRowID) != null) //已下任务单,不可修改数据 { Alert.ShowInTop("该焊口已生成焊接任务单,不能编辑!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointEdit.aspx?WeldJointId={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void btnAudit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnAuditing)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } string[] weldJointIdList = Grid1.SelectedRowIDArray; foreach (string jot in weldJointIdList) { BLL.WeldJointService.UpdateJointAudit(jot, CurrUser.PersonId, DateTime.Now); } if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) { var jotList = from x in Funs.DB.HJGL_WeldJoint where weldJointIdList.Contains(x.WeldJointId) && x.WPQId == null && x.IsTwoJoint == true select x; if (jotList.Count() > 0) { foreach (var jot in jotList) { string unitId = string.Empty; Model.Person_Persons person = BLL.Person_PersonsService.GetPerson_PersonsById(jot.SubmitMan); if (person != null) { unitId = person.UnitId; } List wpqList = BLL.WPQListServiceService.GetMatchWPQ(jot, this.CurrUser.LoginProjectId, unitId); if (wpqList != null) { Model.HJGL_WeldJoint newJot = WeldJointService.GetWeldJointByWeldJointId(jot.WeldJointId); Model.WPQ_WPQList wps = new Model.WPQ_WPQList(); var a = wpqList.FirstOrDefault(x => x.WeldingMethodId == "feb1234c-a538-476f-99ac-7b3ab15997c1"); //优先匹配GTAW+SMAW的焊评 if (a == null) { wps = BLL.WPQListServiceService.GetWPQById(wpqList.First().WPQId); } else { wps = BLL.WPQListServiceService.GetWPQById(a.WPQId); } newJot.WPQId = wps.WPQId; newJot.WeldJointId = jot.WeldJointId; newJot.WeldingRod = wps.WeldingRod; newJot.WeldingWire = wps.WeldingWire; newJot.WeldingMethodId = wps.WeldingMethodId; newJot.GrooveTypeId = wps.GrooveType; newJot.PreTemperature = wps.PreTemperature; newJot.IsHotProess = wps.IsHotProess; newJot.MatchableWPQ = string.Join(",", wpqList.Select(x => x.WPQCode)); BLL.WeldJointService.UpdateConWeldJoint(newJot); } } } //BindGrid(); //ShowNotify("该管线焊口已完成自动录入!", MessageBoxIcon.Success); } ShowNotify("所选口审核成功!", MessageBoxIcon.Success); BindGrid(); //string weldJointIdList = string.Join("|", Grid1.SelectedRowIDArray); //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TwoJointAudit.aspx?WeldJointIdList={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void btnAudit2_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnAuditing)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } string[] weldJointIdList = Grid1.SelectedRowIDArray; foreach (string jot in weldJointIdList) { BLL.WeldJointService.UpdateJointAudit2(jot, CurrUser.PersonId, DateTime.Now); } ShowNotify("所选口审核成功!", MessageBoxIcon.Success); BindGrid(); //string weldJointIdList = string.Join("|", Grid1.SelectedRowIDArray); //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TwoJointAudit.aspx?WeldJointIdList={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void btnCancelAudit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnAuditing)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } string[] weldJointIdList = Grid1.SelectedRowIDArray; foreach (string jot in weldJointIdList) { BLL.WeldJointService.UpdateJointAudit(jot, null, null); } ShowNotify("已取消所选口的审核!", MessageBoxIcon.Success); BindGrid(); //string weldJointIdList = string.Join("|", Grid1.SelectedRowIDArray); //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TwoJointAudit.aspx?WeldJointIdList={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void btnCancelAudit2_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnAuditing)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } string[] weldJointIdList = Grid1.SelectedRowIDArray; foreach (string jot in weldJointIdList) { BLL.WeldJointService.UpdateJointAudit2(jot, null, null); } ShowNotify("已取消所选口的审核!", MessageBoxIcon.Success); BindGrid(); //string weldJointIdList = string.Join("|", Grid1.SelectedRowIDArray); //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TwoJointAudit.aspx?WeldJointIdList={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 焊口信息插入 /// /// /// protected void btnMenuInsert_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_JotTwoDesignMenuId, BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointEdit.aspx?WeldJointId={0}&Type=add", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 焊口信息查看 /// /// /// protected void btnView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldJointView.aspx?WeldJointId={0}", Grid1.SelectedRowID, "维护 - "))); } /// /// 删除按钮 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_JotTwoDesignMenuId, Const.BtnDelete)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } bool isShow = true; if (Grid1.SelectedRowIndexArray.Length > 1) { isShow = false; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); if (judgementDelete(rowID, isShow)) { BLL.WeldJointService.DeleteWeldJointById(rowID); ShowNotify("删除成功!", MessageBoxIcon.Success); //BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldJointMenuId, Const.BtnDelete, rowID); } } this.InitTreeMenu();//加载树 this.BindGrid(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 报表打印 /// /// 报表打印 /// /// /// protected void btnPrint_Click(object sender, EventArgs e) { string pipelineId = this.tvControlItem.SelectedNodeID; var q = BLL.PipelineService.GetPipelineByPipelineId(pipelineId); if (q != null) { var jotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == pipelineId select x).Count(); var weldJotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == pipelineId && x.WeldingDailyId != null select x).Count(); if (jotCount == weldJotCount) { string varValue = string.Empty; var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); if (project != null) { varValue = project.ProjectName; var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(q.UnitWorkId); if (unitWork != null) { varValue = varValue + "|" + unitWork.UnitWorkName; } } List listStr = new List(); listStr.Add(new SqlParameter("@IsoId", pipelineId)); listStr.Add(new SqlParameter("@Flag", "0")); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spJointWorkRecordNew", parameter); string page = Funs.GetPagesCountByPageSize(11, 16, tb.Rows.Count).ToString(); varValue = varValue + "|" + page; if (!string.IsNullOrEmpty(varValue)) { varValue = HttpUtility.UrlEncodeUnicode(varValue); } if (tb.Rows.Count <= 11) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport1Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); } else { PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport2Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport1Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); } } else { ShowNotify("请选择焊接完成管线!", MessageBoxIcon.Warning); return; } } else { ShowNotify("请选择管线!", MessageBoxIcon.Warning); return; } } #endregion #region 关闭弹出窗口及刷新页面 /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { //this.InitTreeMenu();//加载树 this.BindGrid(); } /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } protected void btnTreeFind_Click(object sender, EventArgs e) { this.InitTreeMenu(); this.BindGrid(); } #endregion #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; if (BLL.WeldTaskService.GetWeldTaskByWeldJointId(id) != null) { content = "该焊口已生成焊接任务单,不能删除!"; } //if (!string.IsNullOrEmpty(BLL.WeldJointService.GetWeldJointByWeldJointId(id).WeldingDailyId)) //{ // content = "该焊口已焊接,不能删除!"; //} //if (BLL.Funs.DB.HJGL_HotProess_TrustItem.FirstOrDefault(x => x.WeldJointId == id) != null) //{ // content = "热处理已经使用了该焊口,不能删除!"; //} if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content, MessageBoxIcon.Error); } return false; } } #endregion #region 导出焊口信息 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { string rootPath = Server.MapPath("~/"); string initTemplatePath = string.Empty; string uploadfilepath = string.Empty; string newUrl = string.Empty; string filePath = string.Empty; initTemplatePath = Const.JotTwoDesignTemplateUrl; uploadfilepath = rootPath + initTemplatePath; string constructionLogId = this.tvControlItem.SelectedNodeID; Model.SGGLDB db = Funs.DB; var workEfficiencys = from x in db.ZHGL_ConstructionLogWorkEfficiency where x.ConstructionLogId == constructionLogId select x; var persons = from x in db.ZHGL_ConstructionLogPerson where x.ConstructionLogId == constructionLogId select x; var machines = from x in db.ZHGL_ConstructionLogMachine where x.ConstructionLogId == constructionLogId select x; if (this.Grid1.Rows.Count > 0) { newUrl = uploadfilepath.Replace(".xlsx", "(" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + ")" + ".xlsx"); File.Copy(uploadfilepath, newUrl); // 第一步:读取文件流 NPOI.SS.UserModel.IWorkbook workbook; using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) { workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); } // 创建单元格样式 NPOI.SS.UserModel.ICellStyle cellStyle0 = workbook.CreateCellStyle(); cellStyle0.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle0.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle0.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle0.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle0.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cellStyle0.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyle0.WrapText = true; var font = workbook.CreateFont(); font.FontHeightInPoints = 11; font.IsBold = false; cellStyle0.SetFont(font); // 第二步:创建新数据行 NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); int rowCount = 2; for (int i = 0; i < this.Grid1.Rows.Count; i++) { NPOI.SS.UserModel.IRow row1 = sheet.CreateRow(rowCount); NPOI.SS.UserModel.ICell cell; cell = row1.CreateCell(0); cell.CellStyle = cellStyle0; cell.SetCellValue((i + 1).ToString()); cell = row1.CreateCell(1); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[2].ToString()); cell = row1.CreateCell(2); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[3].ToString()); cell = row1.CreateCell(3); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[4].ToString()); cell = row1.CreateCell(4); cell.CellStyle = cellStyle0; string date1 = this.Grid1.Rows[i].Values[5].ToString(); if (!string.IsNullOrEmpty(date1)) { date1 = string.Format("{0:yyyy-MM-dd}", Funs.GetNewDateTime(date1)); } cell.SetCellValue(date1); cell = row1.CreateCell(5); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[6].ToString()); cell = row1.CreateCell(6); cell.CellStyle = cellStyle0; string date2 = this.Grid1.Rows[i].Values[7].ToString(); if (!string.IsNullOrEmpty(date2)) { date2 = string.Format("{0:yyyy-MM-dd}", Funs.GetNewDateTime(date2)); } cell.SetCellValue(date2); cell = row1.CreateCell(7); cell.CellStyle = cellStyle0; string weldJointCode = string.Empty; var weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(this.Grid1.Rows[i].RowID); if (weldJoint != null) { weldJointCode = weldJoint.WeldJointCode; } cell.SetCellValue(weldJointCode); cell = row1.CreateCell(8); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[10].ToString()); cell = row1.CreateCell(9); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[11].ToString()); cell = row1.CreateCell(10); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[12].ToString()); cell = row1.CreateCell(11); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[13].ToString()); cell = row1.CreateCell(12); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[14].ToString()); cell = row1.CreateCell(13); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[15].ToString()); cell = row1.CreateCell(14); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[16].ToString()); cell = row1.CreateCell(15); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[17].ToString()); cell = row1.CreateCell(16); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[18].ToString()); cell = row1.CreateCell(17); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[20].ToString()); cell = row1.CreateCell(18); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[21].ToString()); cell = row1.CreateCell(19); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[22].ToString()); cell = row1.CreateCell(20); cell.CellStyle = cellStyle0; cell.SetCellValue(this.Grid1.Rows[i].Values[27].ToString()); rowCount++; } // 第三步:写入文件流 using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) { workbook.Write(stream); workbook.Close(); } string fileName = Path.GetFileName(newUrl); FileInfo info = new FileInfo(newUrl); long fileSize = info.Length; Response.Clear(); Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.AddHeader("Content-Length", fileSize.ToString()); Response.TransmitFile(newUrl, 0, fileSize); Response.Flush(); Response.Close(); File.Delete(newUrl); } else { ShowNotify("无数据可导出!", MessageBoxIcon.Warning); } } /// /// 导出焊口初始信息 /// /// /// protected void btnOut2_Click(object sender, EventArgs e) { //var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); //if (iso != null) //{ // Response.ClearContent(); // string filename = Funs.GetNewFileName(); // Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(Resources.Lan.WeldingJointInfo + filename, System.Text.Encoding.UTF8) + ".xls"); // Response.ContentType = "application/excel"; // Response.ContentEncoding = System.Text.Encoding.UTF8; // this.Grid1.PageSize = 100000; // this.BindGrid(); // Response.Write(GetGridTableHtml(Grid1)); // Response.End(); //} //else //{ // Alert.ShowInTop("请选择"PipelinetFirst, MessageBoxIcon.Warning); //} } #endregion #region 选择要显示列 /// /// 选择显示列 /// /// /// protected void btnSelectColumn_Click(object sender, EventArgs e) { //((FineUIPro.GroupField)this.Grid1.Columns[1]).Columns[0]; PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("JointShowColumn.aspx", "显示列 - "))); } #endregion #region 显示列 protected void Window4_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); //显示列 Model.Sys_UserShowColumns c = BLL.UserShowColumnsService.GetColumnsByUserId(this.CurrUser.PersonId, "Joint"); if (c != null) { this.GetShowColumn(c.Columns); } } /// /// 显示的列 /// /// private void GetShowColumn(string column) { if (!string.IsNullOrEmpty(column)) { //this.Grid1.Columns[1].Hidden = true; //((FineUIPro.GroupField)this.Grid1.Columns[1]).Columns[0].Hidden = true; //((FineUIPro.GroupField)this.Grid1.Columns[1]).Columns[1].Hidden = true; //((FineUIPro.GroupField)this.Grid1.Columns[1]).Columns[2].Hidden = true; //((FineUIPro.GroupField)this.Grid1.Columns[1]).Columns[3].Hidden = true; this.Grid1.Columns[2].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[0].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[1].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[2].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[3].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[4].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[5].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[6].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[7].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[2]).Columns[8].Hidden = true; this.Grid1.Columns[3].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[0].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[1].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[2].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[3].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[4].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[5].Hidden = true; ((FineUIPro.GroupField)this.Grid1.Columns[3]).Columns[6].Hidden = true; this.Grid1.Columns[4].Hidden = true; List columns = column.Split(',').ToList(); foreach (var item in columns) { if (!string.IsNullOrEmpty(item)) { if (item.Length == 1) { this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false; } else { int c1 = Convert.ToInt32(item.Substring(0, 1)); int c2 = Convert.ToInt32(item.Substring(1, 1)); this.Grid1.Columns[c1].Hidden = false; ((FineUIPro.GroupField)this.Grid1.Columns[c1]).Columns[c2].Hidden = false; } } } } } #endregion protected void rbIsAudit_SelectedIndexChanged(object sender, EventArgs e) { Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); this.hdUnitWorkId.Text = string.Empty; if (pipeline != null) { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID; this.BindGrid(); } else { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNodeID; NoAuditBindGrid(); } } protected void txtAuditDate_TextChanged(object sender, EventArgs e) { Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); this.hdUnitWorkId.Text = string.Empty; if (pipeline != null) { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID; this.BindGrid(); } else { this.hdUnitWorkId.Text = this.tvControlItem.SelectedNodeID; NoAuditBindGrid(); } } } }