2023-06-27 10:14:53 +08:00
using BLL ;
using Model ;
using Newtonsoft.Json.Linq ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.IO ;
using System.Linq ;
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
namespace FineUIPro.Web.TestRun.BeforeTestRun
{
public partial class SysPipingDeviceImport : PageBase
{
/// <summary>
/// 点击树状主键
/// </summary>
public string TreePreRunId { get { return ( string ) ViewState [ "TreePreRunId" ] ; } set { ViewState [ "TreePreRunId" ] = value ; } }
/// <summary>
/// 子系统主键
/// </summary>
public string SsubSystemId { get { return ( string ) ViewState [ "SsubSystemId" ] ; } set { ViewState [ "SsubSystemId" ] = value ; } }
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
this . InitTreeMenu ( ) ; //加载树
TabStrip1 . ActiveTabIndex = 0 ;
}
}
#region 加 载 树
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu ( )
{
this . tvControlItem . Nodes . Clear ( ) ;
TreeNode rootNode = new TreeNode ( ) ;
rootNode . Text = "系统划分" ;
rootNode . NodeID = "0" ;
rootNode . Expanded = true ;
rootNode . ToolTip = "" ;
rootNode . EnableClickEvent = true ;
this . tvControlItem . Nodes . Add ( rootNode ) ;
var allPreRunLs = Funs . DB . PreRun_SysDevice . Where ( p = > p . ProjectId = = this . CurrUser . LoginProjectId ) . ToList ( ) ;
2023-08-29 09:45:18 +08:00
var onePreRunLs = allPreRunLs . Where ( p = > p . PreRunLevel = = 1 ) . OrderBy ( x = > x . Sort ) ;
2023-06-27 10:14:53 +08:00
foreach ( var item in onePreRunLs )
{
TreeNode rootUnitNode = new TreeNode ( ) ; //定义根节点
rootUnitNode . NodeID = item . PreRunId ;
rootUnitNode . Text = item . PreRunName ;
rootUnitNode . ToolTip = item . PreRunName ;
rootUnitNode . CommandName = "" ;
rootUnitNode . EnableClickEvent = true ;
rootUnitNode . EnableExpandEvent = true ;
rootNode . Nodes . Add ( rootUnitNode ) ;
rootUnitNode . Expanded = true ;
var otherPreRunls = allPreRunLs . Where ( p = > p . PreRunLevel ! = 1 ) . ToList ( ) ;
this . BindNodes ( rootUnitNode , otherPreRunls , item . PreRunId ) ;
}
}
/// <summary>
/// 绑定树节点
/// </summary>
private void BindNodes ( TreeNode node , List < PreRun_SysDevice > list , string parentId )
{
2023-08-29 09:45:18 +08:00
var itemList = list . Where ( p = > p . ParentId = = parentId ) . OrderBy ( x = > x . Sort ) . ToList ( ) ;
2023-06-27 10:14:53 +08:00
if ( itemList . Count > 0 )
{
foreach ( var item in itemList )
{
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = item . PreRunName ;
newNode . NodeID = item . PreRunId ;
newNode . ToolTip = item . PreRunName ;
newNode . CommandName = "" ;
newNode . EnableClickEvent = true ;
node . Nodes . Add ( newNode ) ;
BindNodes ( newNode , list , item . PreRunId ) ;
}
}
}
/// <summary>
/// 数加载
/// </summary>
protected void tvControlItem_NodeExpand ( object sender , TreeNodeEventArgs e )
{
if ( e . Node . Nodes ! = null )
{
e . Node . Nodes . Clear ( ) ;
}
var allPreRunLs = Funs . DB . PreRun_SysDevice . Where ( p = > p . ProjectId = = this . CurrUser . LoginProjectId ) . ToList ( ) ;
this . BindNodes ( e . Node , allPreRunLs , e . NodeID ) ;
}
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand ( object sender , TreeCommandEventArgs e )
{
this . TreePreRunId = tvControlItem . SelectedNodeID ;
this . PageBase ( ) ;
}
/// <summary>
/// 数据显示
/// </summary>
public void PageBase ( )
{
zxtsc . Hidden = true ;
zxtsxt . Hidden = true ;
zz . Hidden = true ;
gx . Hidden = true ;
sxt . Hidden = true ;
sszxt . Hidden = true ;
var model = Funs . DB . PreRun_SysDevice . FirstOrDefault ( p = > p . PreRunId = = this . TreePreRunId ) ;
if ( model ! = null )
{
var ids = new List < string > ( ) ;
if ( ! string . IsNullOrWhiteSpace ( model . InstallationId ) ) ids . Add ( model . InstallationId ) ;
if ( ! string . IsNullOrWhiteSpace ( model . ProcessesId ) ) ids . Add ( model . ProcessesId ) ;
if ( ! string . IsNullOrWhiteSpace ( model . SystemId ) ) ids . Add ( model . SystemId ) ;
if ( ! string . IsNullOrWhiteSpace ( model . SubsystemId ) ) ids . Add ( model . SubsystemId ) ;
var list = Funs . DB . PreRun_SysDevice . Where ( p = > ids . Contains ( p . PreRunId ) ) . ToList ( ) ;
if ( list . Count ( p = > p . PreRunLevel = = 1 ) > 0 )
{
zz . Hidden = false ;
lblzzbm . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 1 ) . PreRunCode ;
lblzzmc . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 1 ) . PreRunName ;
}
if ( list . Count ( p = > p . PreRunLevel = = 2 ) > 0 )
{
gx . Hidden = false ;
lblgxmc . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 2 ) . PreRunName ;
lblgxbm . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 2 ) . PreRunCode ;
}
if ( list . Count ( p = > p . PreRunLevel = = 3 ) > 0 )
{
sxt . Hidden = false ;
lblsxtmc . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 3 ) . PreRunName ;
lblsxtbm . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 3 ) . PreRunCode ;
}
if ( list . Count ( p = > p . PreRunLevel = = 4 ) > 0 )
{
sszxt . Hidden = false ;
lblszxtmc . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 4 ) . PreRunName ;
lblszxtbm . Text = list . FirstOrDefault ( p = > p . PreRunLevel = = 4 ) . PreRunCode ;
}
//判断是否为S系统
if ( model . PreRunLevel = = 3 )
{
zxtsc . Hidden = false ;
ZxtgdBrid ( ) ;
}
//判断是否为SS系统
if ( model . PreRunLevel = = 4 )
{
hidSystemId . Text = model . SystemId ;
zxtsxt . Hidden = false ;
SubPropertyBrid ( ) ;
}
}
}
#endregion
#region S系统管道一览表导入
/// <summary>
/// 绑定管道号
/// </summary>
public void ZxtgdBrid ( )
{
string strSql = @"select * from PreRun_PropertySysPiping where ProjectId=@ProjectId and SystemId=@SystemId " ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@SystemId" , this . tvControlItem . SelectedNodeID ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
GridZxtgd . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( GridZxtgd , tb ) ;
GridZxtgd . DataSource = table ;
GridZxtgd . DataBind ( ) ;
TabStrip1 . ActiveTabIndex = 0 ;
}
/// <summary>
/// 行按钮事件
/// </summary>
protected void GridZxtgd_RowCommand ( object sender , GridCommandEventArgs e )
{
if ( e . CommandName = = "Delete" )
{
string rowID = e . RowID ;
var model = Funs . DB . PreRun_PropertySysPiping . FirstOrDefault ( p = > p . PropertyId = = rowID ) ;
Funs . DB . PreRun_PropertySysPiping . DeleteOnSubmit ( model ) ;
Funs . DB . SubmitChanges ( ) ;
ZxtgdBrid ( ) ;
ShowNotify ( "删除成功!" ) ;
}
}
/// <summary>
/// 分页
/// </summary>
protected void GridZxtgd_PageIndexChange ( object sender , GridPageEventArgs e )
{
GridZxtgd . PageIndex = e . NewPageIndex ;
ZxtgdBrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
protected void GridZxtgd_Sort ( object sender , GridSortEventArgs e )
{
GridZxtgd . SortDirection = e . SortDirection ;
GridZxtgd . SortField = e . SortField ;
ZxtgdBrid ( ) ;
}
/// <summary>
/// 分页下拉框事件
/// </summary>
protected void ddlZxtgdPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
GridZxtgd . PageSize = Convert . ToInt32 ( ddlZxtgdPageSize . SelectedValue ) ;
ZxtgdBrid ( ) ;
}
/// <summary>
/// 导入管道一览表
/// </summary>
protected void btnZxtgdImport_Click ( object sender , EventArgs e )
{
try
{
if ( this . fileData . HasFile = = false )
{
ShowNotify ( "请选择excel文件!" , MessageBoxIcon . Warning ) ;
return ;
}
string IsXls = Path . GetExtension ( this . fileData . FileName ) . ToString ( ) . Trim ( ) . ToLower ( ) ;
if ( IsXls ! = ".xls" & & IsXls ! = ".xlsx" )
{
ShowNotify ( "excel文件类型错误!" , MessageBoxIcon . Warning ) ;
return ;
}
string rootPath = Server . MapPath ( "~/" ) ;
string initFullPath = rootPath + Const . ExcelUrl ;
if ( ! Directory . Exists ( initFullPath ) )
{
Directory . CreateDirectory ( initFullPath ) ;
}
//指定上传文件名称
string fileUrl = BLL . Funs . GetNewFileName ( ) + IsXls ;
//上传文件路径
string filePath = initFullPath + fileUrl ;
//文件上传服务器
this . fileData . PostedFile . SaveAs ( filePath ) ;
//文件上传服务器后的名称
string fileName = rootPath + Const . ExcelUrl + fileUrl ;
//读取Excel
DataSet ds = NPOIHelper . ExcelToDataSet ( fileName , out string message , false ) ;
if ( ds = = null )
{
ShowNotify ( "模板错误,请从系统下载正确的模板!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( ! string . IsNullOrWhiteSpace ( message ) )
{
ShowNotify ( message , MessageBoxIcon . Warning ) ;
return ;
}
if ( ds . Tables [ 0 ] . Rows . Count > 3 )
{
var fileVerify = PropertyVerifyFile ( ds ) ;
if ( ! fileVerify )
{
ShowNotify ( "请获取正确模板!" , MessageBoxIcon . Warning ) ;
return ;
}
var columVerify = HasRepeatData ( ds . Tables [ 0 ] , new string [ ] { "A" } ) ;
if ( columVerify )
{
2023-07-28 11:14:32 +08:00
ShowNotify ( "模板中存在管道号相同或管道号为空的数据!" , MessageBoxIcon . Warning ) ;
2023-06-27 10:14:53 +08:00
return ;
}
var pipingCodes = GetColumnValues < string > ( ds . Tables [ 0 ] , "A" ) ;
var removeCodes = new List < string > ( ) { "管道号" , "管道说明" , "" } ;
pipingCodes . RemoveAll ( a = > removeCodes . Contains ( a ) ) ;
var existPropertys = Funs . DB . PreRun_PropertySysPiping . Where ( a = > pipingCodes . Contains ( a . PipingCode ) & & a . SystemId = = tvControlItem . SelectedNodeID & & a . ProjectId = = this . CurrUser . LoginProjectId ) . ToList ( ) ;
if ( existPropertys . Count > 0 )
{
2023-08-29 09:45:18 +08:00
//删除已经存在的信息
Funs . DB . PreRun_PropertySysPiping . DeleteAllOnSubmit ( existPropertys ) ;
Funs . DB . SubmitChanges ( ) ;
//ShowNotify($"管道号({string.Join(",", existPropertys.ConvertAll(s => s.PipingCode))})已存在!", MessageBoxIcon.Warning);
//return;
2023-06-27 10:14:53 +08:00
}
List < PreRun_PropertySysPiping > list = new List < PreRun_PropertySysPiping > ( ) ;
//数据导入
for ( int i = 3 ; i < ds . Tables [ 0 ] . Rows . Count ; i + + )
{
2023-07-28 11:14:32 +08:00
if ( string . IsNullOrWhiteSpace ( ds . Tables [ 0 ] . Rows [ i ] [ 0 ] . ToString ( ) ) )
{
ShowNotify ( $"第{i}行管道号为空" , MessageBoxIcon . Warning ) ;
return ;
}
2023-06-27 10:14:53 +08:00
PreRun_PropertySysPiping model = new PreRun_PropertySysPiping ( ) ;
model . PropertyId = Guid . NewGuid ( ) . ToString ( ) ;
model . SystemId = tvControlItem . SelectedNodeID ;
model . ProjectId = this . CurrUser . LoginProjectId ;
model . PipingCode = ds . Tables [ 0 ] . Rows [ i ] [ 0 ] . ToString ( ) ;
2023-07-28 11:14:32 +08:00
model . Diameter = ds . Tables [ 0 ] . Rows [ i ] [ 7 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 7 ] . ToString ( ) : string . Empty ;
model . MaterialLevel = ds . Tables [ 0 ] . Rows [ i ] [ 9 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 9 ] . ToString ( ) : string . Empty ;
model . AdiabatType = ds . Tables [ 0 ] . Rows [ i ] [ 14 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 14 ] . ToString ( ) : string . Empty ;
model . AdiabatThickness = ds . Tables [ 0 ] . Rows [ i ] [ 17 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 17 ] . ToString ( ) : string . Empty ;
model . MediumState = ds . Tables [ 0 ] . Rows [ i ] [ 19 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 19 ] . ToString ( ) : string . Empty ;
model . DrawingNo = ds . Tables [ 0 ] . Rows [ i ] [ 21 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 21 ] . ToString ( ) : string . Empty ;
model . PipingStart = ds . Tables [ 0 ] . Rows [ i ] [ 28 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 28 ] . ToString ( ) : string . Empty ;
model . PipingEnd = ds . Tables [ 0 ] . Rows [ i ] [ 34 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 34 ] . ToString ( ) : string . Empty ;
model . PipingLevel = ds . Tables [ 0 ] . Rows [ i ] [ 40 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 40 ] . ToString ( ) : string . Empty ;
model . NormalTemperature = ds . Tables [ 0 ] . Rows [ i ] [ 42 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 42 ] . ToString ( ) : string . Empty ;
model . NormalPressure = ds . Tables [ 0 ] . Rows [ i ] [ 44 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 44 ] . ToString ( ) : string . Empty ;
model . DesignTemperature = ds . Tables [ 0 ] . Rows [ i ] [ 46 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 46 ] . ToString ( ) : string . Empty ;
model . DesignPressure = ds . Tables [ 0 ] . Rows [ i ] [ 48 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 48 ] . ToString ( ) : string . Empty ;
model . PaintLevel = ds . Tables [ 0 ] . Rows [ i ] [ 50 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 50 ] . ToString ( ) : string . Empty ;
model . Remark = ds . Tables [ 0 ] . Rows [ i ] [ 53 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 53 ] . ToString ( ) : string . Empty ;
2023-06-27 10:14:53 +08:00
model . AddUser = this . CurrUser . UserId ;
model . AddTime = DateTime . Now ;
model . Sort = i - 2 ;
list . Add ( model ) ;
}
Funs . DB . PreRun_PropertySysPiping . InsertAllOnSubmit ( list ) ;
Funs . DB . SubmitChanges ( ) ;
}
else
{
ShowNotify ( "文件无数据!" , MessageBoxIcon . Warning ) ;
}
ZxtgdBrid ( ) ;
2023-08-29 09:45:18 +08:00
ShowNotify ( "导入成功!" , MessageBoxIcon . Success ) ;
2023-06-27 10:14:53 +08:00
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Warning ) ;
}
}
/// <summary>
/// 管道一览表保存
/// </summary>
protected void btnZxtgdSave_Click ( object sender , EventArgs e )
{
try
{
JArray mergedData = GridZxtgd . GetMergedData ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int i = mergedRow . Value < int > ( "index" ) ;
var propertyId = this . GridZxtgd . Rows [ i ] . DataKeys [ 0 ] . ToString ( ) ;
PreRun_PropertySysPiping model = Funs . DB . PreRun_PropertySysPiping . FirstOrDefault ( x = > x . PropertyId = = propertyId ) ;
if ( model = = null ) continue ;
model . PipingCode = values . Value < string > ( "PipingCode" ) ;
model . Diameter = values . Value < string > ( "Diameter" ) ;
model . MaterialLevel = values . Value < string > ( "MaterialLevel" ) ;
model . AdiabatType = values . Value < string > ( "AdiabatType" ) ;
model . AdiabatThickness = values . Value < string > ( "AdiabatThickness" ) ;
model . MediumState = values . Value < string > ( "MediumState" ) ;
model . DrawingNo = values . Value < string > ( "DrawingNo" ) ;
model . PipingStart = values . Value < string > ( "PipingStart" ) ;
model . PipingEnd = values . Value < string > ( "PipingEnd" ) ;
model . PipingLevel = values . Value < string > ( "PipingLevel" ) ;
model . NormalTemperature = values . Value < string > ( "NormalTemperature" ) ;
model . NormalPressure = values . Value < string > ( "NormalPressure" ) ;
model . DesignTemperature = values . Value < string > ( "DesignTemperature" ) ;
model . DesignPressure = values . Value < string > ( "DesignPressure" ) ;
model . PaintLevel = values . Value < string > ( "PaintLevel" ) ;
model . Remark = values . Value < string > ( "Remark" ) ;
Funs . DB . SubmitChanges ( ) ;
}
ZxtgdBrid ( ) ;
ShowNotify ( "修改成功!" ) ;
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Error ) ;
}
}
/// <summary>
/// 管道模板下载
/// </summary>
protected void btnGdDownLoad_Click ( object sender , EventArgs e )
{
PageContext . RegisterStartupScript ( Confirm . GetShowReference ( "是否确认下载模板?" , String . Empty , MessageBoxIcon . Question , PageManager1 . GetCustomEventReference ( false , "Confirmgd_OK" ) , PageManager1 . GetCustomEventReference ( "Confirm_Cancel" ) ) ) ;
}
#endregion
#region S系统工艺设备一览表导入
/// <summary>
/// 绑定工艺设备
/// </summary>
public void ZxtgyBrid ( )
{
string strSql = @"select * from PreRun_TechnologySysPiping where ProjectId=@ProjectId and SystemId=@SystemId " ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@SystemId" , this . tvControlItem . SelectedNodeID ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
GridZxtgy . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( GridZxtgy , tb ) ;
GridZxtgy . DataSource = table ;
GridZxtgy . DataBind ( ) ;
TabStrip1 . ActiveTabIndex = 1 ;
}
/// <summary>
/// 分页
/// </summary>
protected void GridZxtgy_PageIndexChange ( object sender , GridPageEventArgs e )
{
GridZxtgy . PageIndex = e . NewPageIndex ;
ZxtgyBrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
protected void GridZxtgy_Sort ( object sender , GridSortEventArgs e )
{
GridZxtgy . SortDirection = e . SortDirection ;
GridZxtgy . SortField = e . SortField ;
ZxtgyBrid ( ) ;
}
/// <summary>
/// 行点击事件
/// </summary>
protected void GridZxtgy_RowCommand ( object sender , GridCommandEventArgs e )
{
if ( e . CommandName = = "Delete" )
{
string rowID = e . RowID ;
var model = Funs . DB . PreRun_TechnologySysPiping . FirstOrDefault ( p = > p . TechnologyId = = rowID ) ;
Funs . DB . PreRun_TechnologySysPiping . DeleteOnSubmit ( model ) ;
Funs . DB . SubmitChanges ( ) ;
ZxtgyBrid ( ) ;
ShowNotify ( "删除成功!" ) ;
}
}
/// <summary>
/// 分页下拉框事件
/// </summary>
protected void ddlZxtgyPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
GridZxtgy . PageSize = Convert . ToInt32 ( ddlZxtgyPageSize . SelectedValue ) ;
ZxtgyBrid ( ) ;
}
/// <summary>
/// 工艺设备导入
/// </summary>
protected void btnZxtgyImport_Click ( object sender , EventArgs e )
{
try
{
if ( this . filegyData . HasFile = = false )
{
ShowNotify ( "请选择excel文件!" , MessageBoxIcon . Warning ) ;
return ;
}
string IsXls = Path . GetExtension ( this . filegyData . FileName ) . ToString ( ) . Trim ( ) . ToLower ( ) ;
if ( IsXls ! = ".xls" & & IsXls ! = ".xlsx" )
{
ShowNotify ( "excel文件类型错误!" , MessageBoxIcon . Warning ) ;
return ;
}
string rootPath = Server . MapPath ( "~/" ) ;
string initFullPath = rootPath + Const . ExcelUrl ;
if ( ! Directory . Exists ( initFullPath ) )
{
Directory . CreateDirectory ( initFullPath ) ;
}
//指定上传文件名称
string fileUrl = BLL . Funs . GetNewFileName ( ) + IsXls ;
//上传文件路径
string filePath = initFullPath + fileUrl ;
//文件上传服务器
this . filegyData . PostedFile . SaveAs ( filePath ) ;
//文件上传服务器后的名称
string fileName = rootPath + Const . ExcelUrl + fileUrl ;
//读取Excel
DataSet ds = NPOIHelper . ExcelToDataSet ( fileName , out string message , false ) ;
if ( ds = = null )
{
ShowNotify ( "模板错误,请从系统下载正确的模板!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( ! string . IsNullOrWhiteSpace ( message ) )
{
ShowNotify ( message , MessageBoxIcon . Warning ) ;
return ;
}
if ( ds . Tables [ 0 ] . Rows . Count > 2 )
{
var fileVerify = TechnologyVerifyFile ( ds ) ;
if ( ! fileVerify )
{
ShowNotify ( "请获取正确模板!" , MessageBoxIcon . Warning ) ;
return ;
}
2023-07-28 11:14:32 +08:00
var tagNumbers = GetColumnValues < string > ( ds . Tables [ 0 ] , "D" ) ;
2023-06-27 10:14:53 +08:00
var removeNumbers = new List < string > ( ) { "设备位号" , "" } ;
tagNumbers . RemoveAll ( a = > removeNumbers . Contains ( a ) ) ;
var existTechnologys = Funs . DB . PreRun_TechnologySysPiping . Where ( a = > tagNumbers . Contains ( a . TagNumber ) & & a . SystemId = = tvControlItem . SelectedNodeID & & a . ProjectId = = this . CurrUser . LoginProjectId ) . ToList ( ) ;
if ( existTechnologys . Count > 0 )
{
2023-08-29 09:45:18 +08:00
//删除已经存在的信息
Funs . DB . PreRun_TechnologySysPiping . DeleteAllOnSubmit ( existTechnologys ) ;
Funs . DB . SubmitChanges ( ) ;
//ShowNotify($"设备位号({string.Join(",", existTechnologys.ConvertAll(s => s.TagNumber))})已存在!", MessageBoxIcon.Warning);
//return;
2023-06-27 10:14:53 +08:00
}
2023-07-28 11:14:32 +08:00
string nameSpecificationStr = string . Empty ;
string materialStr = string . Empty ;
PreRun_TechnologySysPiping model = new PreRun_TechnologySysPiping ( ) ;
2023-06-27 10:14:53 +08:00
List < PreRun_TechnologySysPiping > list = new List < PreRun_TechnologySysPiping > ( ) ;
//数据导入
for ( int i = 2 ; i < ds . Tables [ 0 ] . Rows . Count ; i + + )
{
2023-07-28 11:14:32 +08:00
if ( string . IsNullOrWhiteSpace ( ds . Tables [ 0 ] . Rows [ i ] [ 3 ] . ToString ( ) ) )
{
if ( model = = null )
{
ShowNotify ( $"{i}行数据存在错误!" , MessageBoxIcon . Warning ) ;
return ;
}
else
{
if ( ! string . IsNullOrWhiteSpace ( ds . Tables [ 0 ] . Rows [ i ] [ 8 ] . ToString ( ) ) )
{
nameSpecificationStr + = "\n" + ds . Tables [ 0 ] . Rows [ i ] [ 8 ] . ToString ( ) ;
}
if ( ! string . IsNullOrWhiteSpace ( ds . Tables [ 0 ] . Rows [ i ] [ 32 ] . ToString ( ) ) )
{
materialStr + = "\n" + ds . Tables [ 0 ] . Rows [ i ] [ 32 ] . ToString ( ) ;
}
}
}
else
{
if ( model ! = null & & list . Count ( x = > x . TagNumber = = model . TagNumber ) > 0 )
{
list . Where ( x = > x . TagNumber = = model . TagNumber ) . ToList ( ) . ForEach ( p = >
{
p . Materials = materialStr ;
p . NameSpecifications = nameSpecificationStr ;
} ) ;
}
model = new PreRun_TechnologySysPiping ( ) ;
model . TechnologyId = Guid . NewGuid ( ) . ToString ( ) ;
model . SystemId = tvControlItem . SelectedNodeID ;
model . ProjectId = this . CurrUser . LoginProjectId ;
model . TagNumber = ds . Tables [ 0 ] . Rows [ i ] [ 3 ] . ToString ( ) ;
model . NameSpecifications = ds . Tables [ 0 ] . Rows [ i ] [ 8 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 8 ] . ToString ( ) : string . Empty ;
model . DrawingNo = ds . Tables [ 0 ] . Rows [ i ] [ 24 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 24 ] . ToString ( ) : string . Empty ;
model . Materials = ds . Tables [ 0 ] . Rows [ i ] [ 32 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 32 ] . ToString ( ) : string . Empty ;
model . NumOperate = ds . Tables [ 0 ] . Rows [ i ] [ 41 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 41 ] . ToString ( ) : string . Empty ;
model . NumStandby = ds . Tables [ 0 ] . Rows [ i ] [ 43 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 43 ] . ToString ( ) : string . Empty ;
model . WeightSingle = ds . Tables [ 0 ] . Rows [ i ] [ 45 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 45 ] . ToString ( ) : string . Empty ;
model . WeightTotal = ds . Tables [ 0 ] . Rows [ i ] [ 48 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 48 ] . ToString ( ) : string . Empty ;
model . Remark = ds . Tables [ 0 ] . Rows [ i ] [ 51 ] ! = null ? ds . Tables [ 0 ] . Rows [ i ] [ 51 ] . ToString ( ) : string . Empty ;
model . AddUser = this . CurrUser . UserId ;
model . AddTime = DateTime . Now ;
model . Sort = i - 1 ;
materialStr = model . Materials ;
nameSpecificationStr = model . NameSpecifications ;
list . Add ( model ) ;
}
//最后一条数据累加
if ( i = = ds . Tables [ 0 ] . Rows . Count - 1 )
{
if ( model ! = null & & list . Count ( x = > x . TagNumber = = model . TagNumber ) > 0 )
{
list . Where ( x = > x . TagNumber = = model . TagNumber ) . ToList ( ) . ForEach ( p = >
{
p . Materials = materialStr ;
p . NameSpecifications = nameSpecificationStr ;
} ) ;
}
}
2023-06-27 10:14:53 +08:00
}
2023-07-28 11:14:32 +08:00
if ( list . GroupBy ( x = > x . TagNumber ) . Count ( ) ! = list . Count )
{
ShowNotify ( "模板中存在设备位号相同的数据!" , MessageBoxIcon . Warning ) ;
return ;
}
2023-06-27 10:14:53 +08:00
Funs . DB . PreRun_TechnologySysPiping . InsertAllOnSubmit ( list ) ;
Funs . DB . SubmitChanges ( ) ;
}
else
{
ShowNotify ( "文件无数据!" , MessageBoxIcon . Warning ) ;
}
ZxtgyBrid ( ) ;
2023-08-29 09:45:18 +08:00
ShowNotify ( "导入成功!" , MessageBoxIcon . Success ) ;
2023-06-27 10:14:53 +08:00
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Warning ) ;
}
}
/// <summary>
/// 工艺设备保存
/// </summary>
protected void btnZxtgySave_Click ( object sender , EventArgs e )
{
try
{
JArray mergedData = GridZxtgy . GetMergedData ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int i = mergedRow . Value < int > ( "index" ) ;
var technologyId = this . GridZxtgy . Rows [ i ] . DataKeys [ 0 ] . ToString ( ) ;
PreRun_TechnologySysPiping model = Funs . DB . PreRun_TechnologySysPiping . FirstOrDefault ( x = > x . TechnologyId = = technologyId ) ;
if ( model = = null ) continue ;
model . TagNumber = values . Value < string > ( "TagNumber" ) ;
model . NameSpecifications = values . Value < string > ( "NameSpecifications" ) ;
model . DrawingNo = values . Value < string > ( "DrawingNo" ) ;
model . Materials = values . Value < string > ( "Materials" ) ;
model . NumOperate = values . Value < string > ( "NumOperate" ) ;
model . NumStandby = values . Value < string > ( "NumStandby" ) ;
model . WeightSingle = values . Value < string > ( "WeightSingle" ) ;
model . WeightTotal = values . Value < string > ( "WeightTotal" ) ;
model . Remark = values . Value < string > ( "Remark" ) ;
Funs . DB . SubmitChanges ( ) ;
}
ZxtgyBrid ( ) ;
ShowNotify ( "修改成功!" ) ;
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Error ) ;
}
}
/// <summary>
/// 工艺设备模板下载
/// </summary>
protected void btnGysbDownLoad_Click ( object sender , EventArgs e )
{
PageContext . RegisterStartupScript ( Confirm . GetShowReference ( "是否确认下载模板?" , String . Empty , MessageBoxIcon . Question , PageManager1 . GetCustomEventReference ( false , "Confirmgy_OK" ) , PageManager1 . GetCustomEventReference ( "Confirm_Cancel" ) ) ) ;
}
#endregion
#region SS子系统管道一览表选择
/// <summary>
/// 绑定
/// </summary>
public void SubPropertyBrid ( List < string > selectPropertys = null )
{
var datatb = new DataTable ( ) ;
var addTb = new DataTable ( ) ;
string strSql = @"select a.PropertyId,a.SystemId,a.ProjectId,a.PipingCode,a.Diameter,a.MaterialLevel,a.AdiabatType,a.AdiabatThickness,a.MediumState,a.DrawingNo,a.PipingStart,a.PipingEnd,a.PipingLevel,a.NormalTemperature,a.NormalPressure,a.DesignTemperature,a.DesignPressure,a.PaintLevel,a.Remark,a.AddUser,a.AddTime,a.Sort from PreRun_PropertySysPiping as a inner join PreRun_SubPropertySelect as b on a.PropertyId=b.PropertyId where 1=1 and a.ProjectId=@ProjectId and b.SubSystemId=@SubSystemId " ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@SubSystemId" , this . tvControlItem . SelectedNodeID ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
if ( selectPropertys ! = null & & selectPropertys . Count > 0 )
{
var existPropertyIds = GetColumnValues < string > ( tb , "PropertyId" ) ;
if ( existPropertyIds . Count > 0 ) selectPropertys . RemoveAll ( a = > existPropertyIds . Contains ( a ) ) ;
if ( selectPropertys . Count > 0 )
{
var addtbRowSql = $"select a.PropertyId,a.SystemId,a.ProjectId,a.PipingCode,a.Diameter,a.MaterialLevel,a.AdiabatType,a.AdiabatThickness,a.MediumState,a.DrawingNo,a.PipingStart,a.PipingEnd,a.PipingLevel,a.NormalTemperature,a.NormalPressure,a.DesignTemperature,a.DesignPressure,a.PaintLevel,a.Remark,a.AddUser,a.AddTime,a.Sort from PreRun_PropertySysPiping as a where 1=1 and a.PropertyId in ('{string.Join(" ',' ", selectPropertys)}')" ;
addTb = SQLHelper . GetDataTableRunText ( addtbRowSql ) ;
}
}
if ( addTb . Rows . Count > 0 ) datatb . Load ( addTb . CreateDataReader ( ) ) ;
if ( tb . Rows . Count > 0 ) datatb . Load ( tb . CreateDataReader ( ) ) ;
if ( datatb . Rows . Count > 0 )
{
var pids = GetColumnValues < string > ( datatb , "PropertyId" ) ;
if ( pids . Count > 0 ) hidSelectProperty . Text = string . Join ( "," , pids ) ;
}
else
{
hidSelectProperty . Text = string . Empty ;
}
gvSsxtgdxz . RecordCount = datatb . Rows . Count ;
var table = this . GetPagedDataTable ( GridZxtgd , datatb ) ;
gvSsxtgdxz . DataSource = table ;
gvSsxtgdxz . DataBind ( ) ;
TabStrip2 . ActiveTabIndex = 0 ;
}
/// <summary>
/// 分页
/// </summary>
protected void gvSsxtgdxz_PageIndexChange ( object sender , GridPageEventArgs e )
{
gvSsxtgdxz . PageIndex = e . NewPageIndex ;
SubPropertyBrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
protected void gvSsxtgdxz_Sort ( object sender , GridSortEventArgs e )
{
gvSsxtgdxz . SortDirection = e . SortDirection ;
gvSsxtgdxz . SortField = e . SortField ;
SubPropertyBrid ( ) ;
}
/// <summary>
/// 行按钮事件
/// </summary>
protected void gvSsxtgdxz_RowCommand ( object sender , GridCommandEventArgs e )
{
if ( e . CommandName = = "Delete" )
{
var ids = new List < string > ( ) ;
string rowID = e . RowID ;
var model = Funs . DB . PreRun_SubPropertySelect . FirstOrDefault ( p = > p . SubPropertyId = = rowID ) ;
if ( model ! = null )
{
Funs . DB . PreRun_SubPropertySelect . DeleteOnSubmit ( model ) ;
Funs . DB . SubmitChanges ( ) ;
}
if ( ! string . IsNullOrWhiteSpace ( hidSelectTechnology . Text ) )
{
ids = hidSelectProperty . Text . Split ( ',' ) . ToList ( ) ;
ids . RemoveAll ( a = > a = = rowID ) ;
}
SubPropertyBrid ( ids ) ;
ShowNotify ( "删除成功!" ) ;
}
}
/// <summary>
/// 分页下拉框事件
/// </summary>
protected void ddlSubPropertyPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
gvSsxtgdxz . PageSize = Convert . ToInt32 ( ddlSubPropertyPageSize . SelectedValue ) ;
SubPropertyBrid ( ) ;
}
/// <summary>
/// 选择
/// </summary>
protected void btnSelect_Click ( object sender , EventArgs e )
{
string window = $"SelectProperty.aspx?SubSystemId={this.tvControlItem.SelectedNodeID}&SystemId={hidSystemId.Text}&SelectPropertyIds={hidSelectProperty.Text}" ;
PageContext . RegisterStartupScript ( Window1 . GetSaveStateReference ( this . hidSelectProperty . ClientID ) + Window1 . GetShowReference ( window ) ) ;
}
/// <summary>
/// 关闭
/// </summary>
protected void Window1_Close ( object sender , WindowCloseEventArgs e )
{
var list = hidSelectProperty . Text . Split ( ',' ) . ToList ( ) ;
SubPropertyBrid ( list ) ;
}
/// <summary>
/// 保存
/// </summary>
protected void btnSelectSave_Click ( object sender , EventArgs e )
{
try
{
JArray mergedData = gvSsxtgdxz . GetMergedData ( ) ;
List < PreRun_SubPropertySelect > list = new List < PreRun_SubPropertySelect > ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int i = mergedRow . Value < int > ( "index" ) ;
var deleteSubs = Funs . DB . PreRun_SubPropertySelect . Where ( x = > x . SubSystemId = = this . tvControlItem . SelectedNodeID ) ;
Funs . DB . PreRun_SubPropertySelect . DeleteAllOnSubmit ( deleteSubs ) ;
var model = new PreRun_SubPropertySelect ( ) ;
model . SubPropertyId = Guid . NewGuid ( ) . ToString ( ) ;
model . ProjectId = this . CurrUser . LoginProjectId ;
model . SubSystemId = this . tvControlItem . SelectedNodeID ;
model . PropertyId = gvSsxtgdxz . DataKeys [ i ] [ 0 ] . ToString ( ) ;
model . AddUser = this . CurrUser . UserId ;
model . AddTime = DateTime . Now ;
model . Sort = i ;
list . Add ( model ) ;
}
if ( list . Count > 0 )
{
Funs . DB . PreRun_SubPropertySelect . InsertAllOnSubmit ( list ) ;
Funs . DB . SubmitChanges ( ) ;
}
SubPropertyBrid ( ) ;
ShowNotify ( "保存成功!" ) ;
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Error ) ;
}
}
#endregion
#region SS系统工艺设备一览表选择
/// <summary>
/// 绑定数据
/// </summary>
public void SubTechnologyBrid ( List < string > selectTechnologys = null )
{
var datatb = new DataTable ( ) ;
var addTb = new DataTable ( ) ;
string strSql = @"select a.TechnologyId,a.SystemId,a.ProjectId,a.TagNumber,a.NameSpecifications,a.DrawingNo,a.Materials,a.NumOperate,a.NumStandby,a.WeightSingle,a.WeightTotal,a.Remark,a.AddUser,a.AddTime,a.Sort from PreRun_TechnologySysPiping as a inner join PreRun_SubTechnologySelect as b on a.TechnologyId=b.TechnologyId where 1=1 and a.ProjectId=@ProjectId and b.SubSystemId=@SubSystemId " ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@SubSystemId" , this . tvControlItem . SelectedNodeID ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
if ( selectTechnologys ! = null & & selectTechnologys . Count > 0 )
{
var existTechnologyIds = GetColumnValues < string > ( tb , "TechnologyId" ) ;
if ( existTechnologyIds . Count > 0 ) selectTechnologys . RemoveAll ( a = > existTechnologyIds . Contains ( a ) ) ;
if ( selectTechnologys . Count > 0 )
{
var addtbRowSql = $"select a.TechnologyId,a.SystemId,a.ProjectId,a.TagNumber,a.NameSpecifications,a.DrawingNo,a.Materials,a.NumOperate,a.NumStandby,a.WeightSingle,a.WeightTotal,a.Remark,a.AddUser,a.AddTime,a.Sort from PreRun_TechnologySysPiping as a where 1=1 and a.TechnologyId in ('{string.Join(" ',' ", selectTechnologys)}')" ;
addTb = SQLHelper . GetDataTableRunText ( addtbRowSql ) ;
}
}
if ( addTb . Rows . Count > 0 ) datatb . Load ( addTb . CreateDataReader ( ) ) ;
if ( tb . Rows . Count > 0 ) datatb . Load ( tb . CreateDataReader ( ) ) ;
if ( datatb . Rows . Count > 0 )
{
var tids = GetColumnValues < string > ( datatb , "TechnologyId" ) ;
if ( tids . Count > 0 ) hidSelectTechnology . Text = string . Join ( "," , tids ) ;
}
else
{
hidSelectTechnology . Text = string . Empty ;
}
gvSsxtgyxz . RecordCount = datatb . Rows . Count ;
var table = this . GetPagedDataTable ( gvSsxtgyxz , datatb ) ;
gvSsxtgyxz . DataSource = table ;
gvSsxtgyxz . DataBind ( ) ;
TabStrip2 . ActiveTabIndex = 1 ;
}
/// <summary>
/// 分页
/// </summary>
protected void gvSsxtgyxz_PageIndexChange ( object sender , GridPageEventArgs e )
{
gvSsxtgyxz . PageIndex = e . NewPageIndex ;
SubTechnologyBrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
protected void gvSsxtgyxz_Sort ( object sender , GridSortEventArgs e )
{
gvSsxtgyxz . SortDirection = e . SortDirection ;
gvSsxtgyxz . SortField = e . SortField ;
SubTechnologyBrid ( ) ;
}
/// <summary>
/// 行事件
/// </summary>
protected void gvSsxtgyxz_RowCommand ( object sender , GridCommandEventArgs e )
{
if ( e . CommandName = = "Delete" )
{
var ids = new List < string > ( ) ;
string rowID = e . RowID ;
var model = Funs . DB . PreRun_SubTechnologySelect . FirstOrDefault ( p = > p . TechnologyId = = rowID ) ;
if ( model ! = null )
{
Funs . DB . PreRun_SubTechnologySelect . DeleteOnSubmit ( model ) ;
Funs . DB . SubmitChanges ( ) ;
}
if ( ! string . IsNullOrWhiteSpace ( hidSelectTechnology . Text ) )
{
ids = hidSelectTechnology . Text . Split ( ',' ) . ToList ( ) ;
ids . RemoveAll ( a = > a = = rowID ) ;
}
SubTechnologyBrid ( ids ) ;
ShowNotify ( "删除成功!" ) ;
}
}
/// <summary>
/// 分页下拉框事件
/// </summary>
protected void ddlSubTechnologyPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
gvSsxtgyxz . PageSize = Convert . ToInt32 ( ddlSubTechnologyPageSize . SelectedValue ) ;
SubTechnologyBrid ( ) ;
}
/// <summary>
/// 关闭
/// </summary>
protected void Window2_Close ( object sender , WindowCloseEventArgs e )
{
2023-09-21 17:47:26 +08:00
var list = hidSystemId . Text . Split ( ',' ) . ToList ( ) ;
2023-06-27 10:14:53 +08:00
SubTechnologyBrid ( list ) ;
}
/// <summary>
/// 选择
/// </summary>
protected void btngySelect_Click ( object sender , EventArgs e )
{
string window = $"SelectTechnology.aspx?SubSystemId={this.tvControlItem.SelectedNodeID}&SystemId={hidSystemId.Text}&SelectTechnologyIds={hidSelectTechnology.Text}" ;
2023-09-21 17:47:26 +08:00
PageContext . RegisterStartupScript ( Window2 . GetSaveStateReference ( this . hidSystemId . ClientID ) + Window2 . GetShowReference ( window ) ) ;
2023-06-27 10:14:53 +08:00
}
/// <summary>
/// 保存
/// </summary>
protected void btngySelectSave_Click ( object sender , EventArgs e )
{
try
{
JArray mergedData = gvSsxtgyxz . GetMergedData ( ) ;
List < PreRun_SubTechnologySelect > list = new List < PreRun_SubTechnologySelect > ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int i = mergedRow . Value < int > ( "index" ) ;
var deleteSubs = Funs . DB . PreRun_SubTechnologySelect . Where ( x = > x . SubSystemId = = this . tvControlItem . SelectedNodeID ) ;
Funs . DB . PreRun_SubTechnologySelect . DeleteAllOnSubmit ( deleteSubs ) ;
var model = new PreRun_SubTechnologySelect ( ) ;
model . SubTechnologyId = Guid . NewGuid ( ) . ToString ( ) ;
model . ProjectId = this . CurrUser . LoginProjectId ;
model . SubSystemId = this . tvControlItem . SelectedNodeID ;
model . TechnologyId = gvSsxtgyxz . DataKeys [ i ] [ 0 ] . ToString ( ) ;
model . AddUser = this . CurrUser . UserId ;
model . AddTime = DateTime . Now ;
model . Sort = i ;
list . Add ( model ) ;
}
if ( list . Count > 0 )
{
Funs . DB . PreRun_SubTechnologySelect . InsertAllOnSubmit ( list ) ;
Funs . DB . SubmitChanges ( ) ;
}
SubTechnologyBrid ( ) ;
ShowNotify ( "保存成功!" ) ;
}
catch ( Exception ex )
{
ShowNotify ( ex . Message , MessageBoxIcon . Error ) ;
}
}
#endregion
#region 私 有 方 法
/// <summary>
/// 验证管道模板是否正确
/// </summary>
/// <param name="ds"></param>
/// <returns></returns>
private bool PropertyVerifyFile ( DataSet ds )
{
var result = true ;
if ( ds . Tables [ 0 ] . Rows [ 1 ] [ 0 ] . ToString ( ) ! = "管道号" ) result = false ;
2023-07-28 11:14:32 +08:00
if ( ds . Tables [ 0 ] . Rows [ 1 ] [ 7 ] . ToString ( ) ! = "公称" ) result = false ;
if ( ds . Tables [ 0 ] . Rows [ 1 ] [ 9 ] . ToString ( ) ! = "管道材料等级" ) result = false ;
if ( ds . Tables [ 0 ] . Rows [ 1 ] [ 14 ] . ToString ( ) ! = "绝热伴热" ) result = false ;
2023-06-27 10:14:53 +08:00
return result ;
}
/// <summary>
/// 验证管道模板是否正确
/// </summary>
/// <param name="ds"></param>
/// <returns></returns>
private bool TechnologyVerifyFile ( DataSet ds )
{
var result = true ;
2023-07-28 11:14:32 +08:00
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ 3 ] . ToString ( ) ! = "设备位号" ) result = false ;
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ 8 ] . ToString ( ) ! = "设备名称和规格" ) result = false ;
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ 24 ] . ToString ( ) ! = "图号或型号" ) result = false ;
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ 32 ] . ToString ( ) ! = "制造材料" ) result = false ;
2023-06-27 10:14:53 +08:00
return result ;
}
/// <summary>
/// 验证datatable某列是否存在重复
/// </summary>
/// <returns></returns>
public bool HasRepeatData ( DataTable dt , string [ ] colName )
{
bool flag = false ;
DataView myDataView = new DataView ( dt ) ;
if ( myDataView . ToTable ( true , colName ) . Rows . Count < dt . Rows . Count )
{
flag = true ;
}
return flag ;
}
/// <summary>
/// 获取某一列的所有值
/// </summary>
/// <typeparam name="T">列数据类型</typeparam>
/// <param name="dtSource">数据表</param>
/// <param name="filedName">列名</param>
/// <returns></returns>
public static List < T > GetColumnValues < T > ( DataTable dtSource , string filedName )
{
return ( from r in dtSource . AsEnumerable ( ) select r . Field < T > ( filedName ) ) . ToList < T > ( ) ;
}
/// <summary>
/// 导入管道和工艺tab选择
/// </summary>
protected void TabStrip1_TabIndexChanged ( object sender , EventArgs e )
{
if ( TabStrip1 . ActiveTabIndex = = 0 )
{
//管道一览表
ZxtgdBrid ( ) ;
}
else if ( TabStrip1 . ActiveTabIndex = = 1 )
{
//工艺设备一览表
ZxtgyBrid ( ) ;
}
}
/// <summary>
/// 选择管道和工艺tab选择
/// </summary>
protected void TabStrip2_TabIndexChanged ( object sender , EventArgs e )
{
if ( TabStrip2 . ActiveTabIndex = = 0 )
{
//管道
SubPropertyBrid ( ) ;
}
else if ( TabStrip2 . ActiveTabIndex = = 1 )
{
//工艺设备
SubTechnologyBrid ( ) ;
}
}
/// <summary>
/// 下载导入模板
/// </summary>
protected void PageManager1_CustomEvent ( object sender , CustomEventArgs e )
{
if ( e . EventArgument = = "Confirmgd_OK" | | e . EventArgument = = "Confirmgy_OK" )
{
string constUrl = string . Empty ;
if ( e . EventArgument = = "Confirmgd_OK" )
{
constUrl = Const . PropertyUrl ;
}
else if ( e . EventArgument = = "Confirmgy_OK" )
{
constUrl = Const . TechnologyUrl ;
}
string rootPath = Server . MapPath ( "~/" ) ;
string uploadfilepath = rootPath + constUrl ;
string filePath = constUrl ;
string fileName = Path . GetFileName ( filePath ) ;
FileInfo info = new FileInfo ( uploadfilepath ) ;
long fileSize = info . Length ;
Response . ClearContent ( ) ;
Response . AddHeader ( "Content-Disposition" , "attachment;filename=" + System . Web . HttpUtility . UrlEncode ( fileName , System . Text . Encoding . UTF8 ) ) ;
Response . ContentType = "excel/plain" ;
Response . ContentEncoding = System . Text . Encoding . UTF8 ;
Response . AddHeader ( "Content-Length" , fileSize . ToString ( ) . Trim ( ) ) ;
Response . TransmitFile ( uploadfilepath , 0 , fileSize ) ;
Response . End ( ) ;
}
}
#endregion
}
}