using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using BLL; using Newtonsoft.Json.Linq; using System.Web; namespace FineUIPro.Web.HJGL.WeldingManage { public partial class PipelineManage : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); this.drpOut.DataTextField = "Text"; this.drpOut.DataValueField = "Value"; this.drpOut.DataSource = BLL.DropListService.HJGL_Pipe_OutListItem(); this.drpOut.DataBind(); Funs.FineUIPleaseSelect(this.drpOut); BindGrid(); } } #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { string strSql = @"SELECT ProjectId,ISO_ID,STE_ID,SER_ID,SERName,ISO_IsoNo,ISO_TotalDin ,ISO_Insulator,STECode,ISO_Executive,ISO_Specification,ISO_JointQty,IDName ,ISO_DesignPress,ISO_DesignTemperature,ISO_TestPress,ISO_TestTemperature ,ISO_Remark,MaterialStandardId,PressureTestPackageNo,OperatingPressure ,OperatingTemperature,PipeLineClass,PipeLineLength,LeakageTest ,TestCategoryNum,MaterialStandardCode FROM HJGL_View_IsoInfo WHERE ProjectId= @ProjectId"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); if (!string.IsNullOrEmpty(this.txtISO_IsoNo.Text.Trim())) { strSql += " AND ISO_IsoNo LIKE @ISO_IsoNo"; listStr.Add(new SqlParameter("@ISO_IsoNo", "%" + this.txtISO_IsoNo.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); this.OutputSummaryData(); ///取合计值 Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 计算合计 /// /// 计算合计 /// //private void OutputSummaryData(DataTable tb) //{ // decimal count2 = 0;//总达因数 // int count3 = 0;//总焊口数 // for (int i = 0; i < tb.Rows.Count; i++) // { // count2 += Funs.GetNewDecimalOrZero(tb.Rows[i]["ISO_TotalDin"].ToString()); // count3 += Funs.GetNewIntOrZero(tb.Rows[i]["ISO_JointQty"].ToString()); // } // JObject summary = new JObject(); // summary.Add("ISO_IsoNo", "合计:"); // summary.Add("ISO_TotalDin", count2); // summary.Add("ISO_JointQty", count3); // Grid1.SummaryData = summary; //} private void OutputSummaryData() { string sqlStr1 = @"SELECT COUNT(JOT_ID) FROM dbo.HJGL_PW_JointInfo WHERE ProjectId=@ProjectId"; string sqlStr2 = @"SELECT SUM(ISNULL(JOT_Size,0)) FROM dbo.HJGL_PW_JointInfo WHERE ProjectId=@ProjectId"; SqlParameter[] parameter1 = new SqlParameter[] { new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId) }; SqlParameter[] parameter2 = new SqlParameter[] { new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId) }; DataTable dt1 = SQLHelper.GetDataTableRunText(sqlStr1, parameter1); DataTable dt2 = SQLHelper.GetDataTableRunText(sqlStr2, parameter2); JObject summary = new JObject(); summary.Add("ISO_IsoNo", "合计:"); summary.Add("ISO_JointQty", dt1.Rows[0][0].ToString()); summary.Add("ISO_TotalDin", dt2.Rows[0][0].ToString()); Grid1.SummaryData = summary; } #endregion #region 分页排序 #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; 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.UserId, BLL.Const.HJGL_PipelineManageMenuId, BLL.Const.BtnModify)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PipelineManageEdit.aspx?ISO_ID={0}", Grid1.SelectedRowID, "编辑 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 增加管线信息 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PipelineManageMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PipelineManageEdit.aspx", "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 管线信息编辑 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_PipelineManageMenuId, BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PipelineManageEdit.aspx?ISO_ID={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 删除按钮 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PipelineManageMenuId, 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.HJGL_PW_IsoInfoService.DeleteIsoInfo(rowID); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除管线信息"); Alert.ShowInTop("删除成功!", MessageBoxIcon.Success); } } this.BindGrid(); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 关闭弹出窗口及刷新页面 /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); } /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; string jotInfo = string.Empty; var q = from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == id && x.DReportID != null select x; if (q.Count() > 0) { foreach (var item in q) { jotInfo += "焊口号:" + item.JOT_JointNo; var dr = Funs.DB.HJGL_BO_WeldReportMain.FirstOrDefault(x => x.DReportID == item.DReportID); if (dr != null) { jotInfo += ";焊接日报号:" + dr.JOT_DailyReportNo; } } content = "该管线已焊焊口!" + jotInfo; } 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) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PipelineManageMenuId, Const.BtnOut)) { if (this.drpOut.SelectedValue != BLL.Const._Null) { if (this.drpOut.SelectedValue == "1") { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PipelineManageOut.aspx", this.drpOut.SelectedValue, "编辑 - "))); } else if (this.drpOut.SelectedValue == "2") { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PipelineManageOut2.aspx", this.drpOut.SelectedValue, "编辑 - "))); } } else { Alert.ShowInTop("请选择要导出的表", MessageBoxIcon.Information); return; } } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region Grid1行点击事件 /// /// Grid1行点击事件 /// /// /// protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "print") { string isoId = this.Grid1.SelectedRow.RowID; var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId); if (isoInfo != null) { string varValue = string.Empty; string unitName = string.Empty; string projectName = string.Empty; string isoNo = string.Empty; var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); if (project != null) { projectName = project.ProjectName; } if (!string.IsNullOrEmpty(isoInfo.BSU_ID)) { var unit = BLL.Base_UnitService.GetUnit(isoInfo.BSU_ID); if (unit != null) { unitName = unit.UnitName; } } isoNo = isoInfo.ISO_IsoNo; //varValue = unitName + "|" + projectName + "|" + isoNo; string v1 = "NULL"; string v2 = "NULL"; string v3 = "NULL"; string v4 = "NULL"; string v5 = "NULL"; string v6 = "NULL"; string v7 = "NULL"; string v8 = "NULL"; string v9 = "NULL"; string v10 = "NULL"; string v11 = "NULL"; string v12 = "NULL"; string v13 = "NULL"; string v14 = "NULL"; string v15 = "NULL"; string v16 = "NULL"; string ptCount1 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "2" && y.ISO_ID == isoId && c.NDT_Code == "PT" select x).Distinct().Count().ToString(); string mtCount1 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "2" && y.ISO_ID == isoId && c.NDT_Code == "MT" select x).Distinct().Count().ToString(); if (ptCount1 != "0") { v1 = "PT"; v2 = ptCount1; if (mtCount1 != "0") { v3 = "MT"; v4 = mtCount1; } } else { if (mtCount1 != "0") { v1 = "MT"; v2 = mtCount1; } } string ptCount2 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "3" && y.ISO_ID == isoId && c.NDT_Code == "PT" select x).Distinct().Count().ToString(); string mtCount2 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "3" && y.ISO_ID == isoId && c.NDT_Code == "MT" select x).Distinct().Count().ToString(); if (ptCount2 != "0") { v5 = "PT"; v6 = ptCount2; if (mtCount1 != "0") { v7 = "MT"; v8 = mtCount2; } } else { if (mtCount2 != "0") { v5 = "MT"; v6 = mtCount2; } } string rtCount3 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "RT" select x).Distinct().Count().ToString(); string utCount3 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "UT" select x).Distinct().Count().ToString(); string pautCount3 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "PAUT" select x).Distinct().Count().ToString(); if (rtCount3 != "0") { v9 = "RT"; v10 = rtCount3; if (utCount3 != "0") { v11 = "UT"; v12 = utCount3; } else { if (pautCount3 != "0") { v11 = "PAUT"; v12 = pautCount3; } } } else { if (utCount3 != "0") { v9 = "UT"; v10 = utCount3; } else { if (pautCount3 != "0") { v9 = "PAUT"; v10 = pautCount3; } } } string rtCount4 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "RT" && y.JOT_JointAttribute == "固定" select x).Distinct().Count().ToString(); string utCount4 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "UT" && y.JOT_JointAttribute == "固定" select x).Distinct().Count().ToString(); string pautCount4 = (from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join a in Funs.DB.HJGL_BS_JointType on y.JOTY_ID equals a.JOTY_ID join b in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals b.CH_TrustID join c in Funs.DB.HJGL_BS_NDTType on b.CH_NDTMethod equals c.NDT_ID where a.JOTY_Group == "1" && y.ISO_ID == isoId && c.NDT_Code == "PAUT" && y.JOT_JointAttribute == "固定" select x).Distinct().Count().ToString(); if (rtCount4 != "0") { v13 = "RT"; v14 = rtCount4; if (utCount4 != "0") { v15 = "UT"; v16 = utCount4; } else { if (pautCount4 != "0") { v15 = "PAUT"; v16 = pautCount4; } } } else { if (utCount4 != "0") { v13 = "UT"; v14 = utCount4; } else { if (pautCount4 != "0") { v13 = "PAUT"; v14 = pautCount4; } } } List listStr = new List(); listStr.Add(new SqlParameter("@iso_id", isoId)); listStr.Add(new SqlParameter("@Flag", "0")); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_rpt_PipelineAttach", parameter); int totalPage = Funs.GetPagesCountByPageSize(23, 32, tb.Rows.Count); varValue = v1 + "|" + v2 + "|" + v3 + "|" + v4 + "|" + v5 + "|" + v6 + "|" + v7 + "|" + v8 + "|" + v9 + "|" + v10 + "|" + v11 + "|" + v12 + "|" + v13 + "|" + v14 + "|" + v15 + "|" + v16 + "|" + totalPage.ToString(); if (tb.Rows.Count <= 23) { PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_PipelineAttachReportId, isoId, varValue))); } else { PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_PipelineAttach2ReportId, isoId, varValue))); PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_PipelineAttachReportId, isoId, varValue))); } } } if (e.CommandName == "fileName")//文档名 { string isoId = this.Grid1.SelectedRow.RowID; var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId); if (isoInfo != null) { string code = string.Empty; string projectCode = BLL.Base_ProjectService.GetProjectCode(isoInfo.ProjectId); code = projectCode + "-" + isoInfo.ISO_IsoNo + "-附页"; PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../CheckManage/FileCode.aspx?code={0}", HttpUtility.UrlEncodeUnicode(code), "编辑 - "))); } } } #endregion } }