CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/HJGL/PurgingCleaning/SelectPipeline.aspx.cs

149 lines
6.4 KiB
C#
Raw Normal View History

2021-04-30 10:28:37 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.HJGL.PurgingCleaning
{
public partial class SelectPipeline : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 管线等级
BLL.Base_PipingClassService.InitPipingClassDropDownList(drpPipingClass, this.CurrUser.LoginProjectId, true, "请选择");
BindGrid();
}
}
private void BindGrid()
{
string UnitWorkId = Request.Params["UnitWorkId"];
string strSql = @"SELECT IsoInfo.ProjectId,IsoInfo.UnitWorkId,UnitWork.UnitWorkCode,IsoInfo.PipelineId,IsoInfo.PipelineCode,
IsoInfo.UnitId,IsoInfo.TestPressure,IsoInfo.TestMedium,
bs.MediumName,testMedium.MediumName AS TestMediumName,IsoInfo.SingleNumber,
IsoInfo.PipingClassId,
(case when IsoInfo.PCtype='1' then pur.MediumName when IsoInfo.PCtype is null then null end) PurgingMediumName,
(case when IsoInfo.PCtype='2' then pur.MediumName when IsoInfo.PCtype is null then null end) CleaningMediumName
FROM dbo.HJGL_Pipeline AS IsoInfo
LEFT JOIN WBS_UnitWork AS UnitWork ON IsoInfo.UnitWorkId=UnitWork.UnitWorkId
LEFT JOIN dbo.Base_Medium AS bs ON bs.MediumId = IsoInfo.MediumId
LEFT JOIN dbo.Base_TestMedium AS testMedium ON testMedium.TestMediumId = IsoInfo.TestMedium
LEFT JOIN dbo.Base_TestMedium AS pur ON pur.TestMediumId = PCMedium
LEFT JOIN dbo.Base_TestMedium AS cle ON cle.TestMediumId = PCMedium
LEFT JOIN dbo.PTP_PipelineList AS IsoList ON IsoList.PipelineId = IsoInfo.PipelineId
LEFT JOIN PTP_TestPackage As Test ON Test.PTP_ID =IsoList.PTP_ID
WHERE IsoInfo.ProjectId= @ProjectId And Test.FinishDef is not null
AND UnitWork.UnitWorkId= @UnitWorkId and (select count(*) from HJGL_PC_Pipeline p where p.PipelineId=IsoInfo.PipelineId)=0";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@UnitWorkId", UnitWorkId));
if (this.drpPipingClass.SelectedValue != Const._Null)
{
strSql += " AND IsoInfo.PipingClassId = @PipingClassId";
listStr.Add(new SqlParameter("@PipingClassId", this.drpPipingClass.SelectedValue));
}
if (!string.IsNullOrEmpty(numTestPressure.Text) && !string.IsNullOrEmpty(numTo.Text))
{
strSql += " AND IsoInfo.TestPressure >=@MinTestPressure AND IsoInfo.TestPressure <=@MaxTestPressure";
listStr.Add(new SqlParameter("@MinTestPressure", Convert.ToDecimal(numTestPressure.Text)));
listStr.Add(new SqlParameter("@MaxTestPressure", Convert.ToDecimal(numTo.Text)));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
// tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
protected void btnFind_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#region
#region
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
this.BindGrid();
}
#endregion
#endregion
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInParent("请至少选择一行", MessageBoxIcon.Warning);
return;
}
string Pipeline = Request.Params["Pipelines"];
string Pipelines = string.Empty;
if (!string.IsNullOrEmpty(Pipeline))
{
Pipelines += Pipeline + ",";
}
int[] selections = Grid1.SelectedRowIndexArray;
foreach (int rowIndex in selections)
{
if (!Pipeline.Contains(Grid1.DataKeys[rowIndex][0].ToString()))
{
Pipelines += Grid1.DataKeys[rowIndex][0].ToString() + ",";
}
}
if (Pipelines != string.Empty)
{
Pipelines = Pipelines.Substring(0, Pipelines.Length - 1);
}
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(Pipelines) + ActiveWindow.GetHidePostBackReference());
}
protected void btnRset_Click(object sender, EventArgs e)
{
drpPipingClass.SelectedIndex = 0;
numTestPressure.Text = "";
numTo.Text = "";
BindGrid();
}
}
}