2022-09-05 16:36:31 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
namespace FineUIPro.Web.HJGL.TestPackage
{
public partial class SelectPipeline : PageBase
{
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
Model . Project_Sys_Set pressUnit = BLL . Project_SysSetService . GetSysSetBySetId ( "8" , this . CurrUser . LoginProjectId ) ;
if ( pressUnit ! = null & & pressUnit . SetValue = = "2" )
{
this . Grid1 . Columns [ 2 ] . HeaderText = "设计压力kpa(g)" ;
this . Grid1 . Columns [ 5 ] . HeaderText = "压力试验压力kpa(g)" ;
}
// 试验介质
Base_TestMediumService . InitMediumDropDownList ( this . drpTestMedium , "1" , true ) ;
// 管线等级
BLL . Base_PipingClassService . InitPipingClassDropDownList ( drpPipingClass , this . CurrUser . LoginProjectId , true , "请选择" ) ;
//管道介质
Base_MediumService . InitMediumCodeDropDownList ( this . drpMedium , this . CurrUser . LoginProjectId , true ) ;
//单位工程
UnitWorkService . InitAZUnitWorkDownList ( this . drpUnitWork , this . CurrUser . LoginProjectId , true ) ;
this . drpUnitWork . SelectedValue = Request . Params [ "UnitWorkId" ] ;
BindGrid ( ) ;
}
}
private void BindGrid ( )
{
var ptpPipelineList = from x in Funs . DB . PTP_PipelineList select x ;
string PTP_ID = Request . Params [ "PTP_ID" ] ;
string UnitWorkId = Request . Params [ "UnitWorkId" ] ;
string pipingClass = string . Empty ;
foreach ( var item in this . drpUnitWork . SelectedValueArray )
{
if ( item ! = null )
{
UnitWorkId + = item + "," ;
}
}
foreach ( var item in this . drpPipingClass . SelectedValueArray )
{
if ( item ! = BLL . Const . _Null )
{
pipingClass + = item + "," ;
}
}
string strSql = @"SELECT IsoInfo.ProjectId,IsoInfo.UnitWorkId,UnitWork.UnitWorkCode,IsoInfo.PipelineId,IsoInfo.PipelineCode,
IsoInfo.UnitId,IsoInfo.DesignPress,IsoInfo.DesignTemperature,IsoInfo.TestPressure,IsoInfo.TestMedium,testMedium.MediumName AS
TestMediumName,IsoInfo.SingleNumber,IsoInfo.PipingClassId,class.PipingClassCode
FROM dbo.HJGL_Pipeline AS IsoInfo
LEFT JOIN WBS_UnitWork AS UnitWork ON IsoInfo.UnitWorkId=UnitWork.UnitWorkId
LEFT JOIN dbo.Base_TestMedium AS testMedium ON testMedium.TestMediumId = IsoInfo.TestMedium
LEFT JOIN dbo.Base_PipingClass class ON class.PipingClassId = IsoInfo.PipingClassId
WHERE IsoInfo.ProjectId= @ProjectId and @UnitWorkId like '%'+IsoInfo.UnitWorkId+'%' " ;
if ( ! this . cbShow . Checked )
{
strSql + = " and (select count(*) from PTP_PipelineList 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 ( ! string . IsNullOrEmpty ( pipingClass ) )
{
strSql + = " AND @PipingClassId like '%'+ IsoInfo.PipingClassId +'%' " ;
listStr . Add ( new SqlParameter ( "@PipingClassId" , pipingClass ) ) ;
}
if ( this . drpMedium . SelectedValue ! = Const . _Null )
{
strSql + = " AND IsoInfo.MediumId = @MediumId" ;
listStr . Add ( new SqlParameter ( "@MediumId" , this . drpMedium . SelectedValue ) ) ;
}
if ( this . drpTestMedium . SelectedValue ! = Const . _Null )
{
strSql + = " AND IsoInfo.TestMedium = @TestMedium" ;
listStr . Add ( new SqlParameter ( "@TestMedium" , this . drpTestMedium . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( numTestPressure . Text ) & & ! string . IsNullOrEmpty ( numTo . Text ) )
{
strSql + = " AND cast(isnull(IsoInfo.TestPressure,0) as decimal(9,5)) >=@MinTestPressure AND cast(isnull(IsoInfo.TestPressure,0) as decimal(9,5)) <=@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 ( ) ;
for ( int i = 0 ; i < Grid1 . Rows . Count ; i + + )
{
var ptpPipeLine = ptpPipelineList . FirstOrDefault ( x = > x . PipelineId = = Grid1 . Rows [ i ] . DataKeys [ 0 ] . ToString ( ) ) ;
if ( ptpPipeLine ! = null )
{
Grid1 . Rows [ i ] . RowCssClass = "Yellow" ;
Grid1 . Rows [ i ] . RowSelectable = false ;
}
}
}
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
2026-10-08 15:03:00 +08:00
/// <summary>
/// 读取已选管线编号:优先取令牌对应的 Session 值(查询串过长会被前置代理拒绝),兼容旧的 Pipelines 参数
/// </summary>
private string GetSelectedPipelines ( )
{
string token = Request . Params [ "Token" ] ;
if ( ! string . IsNullOrEmpty ( token ) )
{
string key = "HJGL_SelectPipelinePipelines_" + token ;
string pipelines = Session [ key ] as string ;
Session . Remove ( key ) ;
return pipelines ? ? string . Empty ;
}
return Request . Params [ "Pipelines" ] ? ? string . Empty ;
}
2022-09-05 16:36:31 +08:00
protected void btnSave_Click ( object sender , EventArgs e )
{
if ( this . Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInParent ( "请至少选择一行" , MessageBoxIcon . Warning ) ;
return ;
}
2026-10-08 15:03:00 +08:00
string Pipeline = GetSelectedPipelines ( ) ;
2022-09-05 16:36:31 +08:00
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 )
{
drpMedium . SelectedIndex = 0 ;
drpPipingClass . SelectedIndex = 0 ;
drpTestMedium . SelectedIndex = 0 ;
numTestPressure . Text = "" ;
numTo . Text = "" ;
BindGrid ( ) ;
}
protected void ckbAllUnitWork_CheckedChanged ( object sender , CheckedEventArgs e )
{
BindGrid ( ) ;
}
}
}