2024-05-08 17:17:11 +08:00
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.HotProessManage
{
public partial class HotProessManageEdit : PageBase
{
#region 加 载 页 面
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
this . ddlPageSize . SelectedValue = this . Grid1 . PageSize . ToString ( ) ;
this . drpIsoNo . SelectedValue = BLL . Const . _Null ;
this . drpProjectId . DataTextField = "ProjectCode" ;
this . drpProjectId . DataValueField = "ProjectId" ;
this . drpProjectId . DataSource = BLL . Base_ProjectService . GetOnProjectListByUserId ( this . CurrUser . UserId , "1" ) ;
this . drpProjectId . DataBind ( ) ;
Funs . FineUIPleaseSelect ( this . drpProjectId ) ;
this . drpProjectId . SelectedValue = this . CurrUser . LoginProjectId ;
this . InitTreeMenu ( ) ; //加载树
this . tvControlItem . SelectedNodeID = this . CurrUser . LoginProjectId ;
this . drpIsoNo . DataTextField = "ISO_IsoNo" ;
this . drpIsoNo . DataValueField = "ISO_ID" ;
this . drpIsoNo . DataSource = from x in Funs . DB . HJGL_PW_IsoInfo where x . ProjectId = = this . CurrUser . LoginProjectId select x ;
this . drpIsoNo . DataBind ( ) ;
Funs . FineUIPleaseSelect ( this . drpIsoNo ) ;
BindGrid ( ) ;
this . txtUnit . Text = "管道" ;
this . txtProessMethod . Text = "电加热" ;
this . txtProessEquipment . Text = "智能温控仪" ;
}
}
#endregion
#region 加 载 树
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu ( )
{
this . tvControlItem . Nodes . Clear ( ) ;
TreeNode rootNode = new TreeNode ( ) ;
rootNode . Text = "项目" ;
rootNode . NodeID = "0" ;
rootNode . Expanded = true ;
rootNode . EnableClickEvent = true ;
this . tvControlItem . Nodes . Add ( rootNode ) ;
List < Model . Base_Project > projects = BLL . Base_ProjectService . GetOnProjectListByUserId ( this . CurrUser . UserId , "1" ) ;
if ( this . drpProjectId . SelectedValueArray . Length > 1 | | ( this . drpProjectId . SelectedValueArray . Length = = 1 & & this . drpProjectId . SelectedValue ! = "null" ) )
{
projects = projects . Where ( x = > this . drpProjectId . SelectedValueArray . Contains ( x . ProjectId ) ) . ToList ( ) ;
}
foreach ( var item in projects )
{
TreeNode rootUnitNode = new TreeNode ( ) ; //定义根节点
rootUnitNode . Text = item . ProjectCode ;
rootUnitNode . NodeID = item . ProjectId ;
rootUnitNode . Expanded = true ;
rootUnitNode . ToolTip = item . ProjectName ;
rootUnitNode . CommandName = "项目名称" ;
rootUnitNode . EnableClickEvent = true ;
rootNode . Nodes . Add ( rootUnitNode ) ;
}
}
#endregion
#region 点 击 TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand ( object sender , TreeCommandEventArgs e )
{
string projectId = tvControlItem . SelectedNodeID ;
this . drpIsoNo . Items . Clear ( ) ;
this . drpIsoNo . DataSource = from x in Funs . DB . HJGL_PW_IsoInfo where x . ProjectId = = projectId select x ;
this . drpIsoNo . DataBind ( ) ;
Funs . FineUIPleaseSelect ( this . drpIsoNo ) ;
this . drpIsoNo . SelectedValue = BLL . Const . _Null ;
this . BindGrid ( ) ;
}
#endregion
#region 数 据 绑 定
protected void drpProjectId_SelectedIndexChanged ( object sender , EventArgs e )
{
this . InitTreeMenu ( ) ;
}
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid ( )
{
this . PageInfoLoad ( ) ; ///页面输入提交信息
this . txtHotProessNo . Text = string . Empty ;
string strSql = string . Empty ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
string projectIds = BLL . Base_ProjectService . GetStrOnProjectIds ( this . CurrUser . UserId , "1" ) ;
if ( this . tvControlItem . SelectedNode . CommandName = = "项目名称" )
{
strSql = @ "SELECT JointInfo.ProjectId,JointInfo.JOT_ID,Project.ProjectCode,HotProessItem.PrintDate,
( CASE WHEN v . RepairMark IS NOT NULL THEN ( JointInfo . JOT_JointNo + v . RepairMark )
ELSE JointInfo . JOT_JointNo END ) + isnull ( ( select Top 1 HardRepairMark from dbo . HJGL_CH_HotProessTrustItem a where a . JOT_ID = HotProessItem . JOT_ID and a . HotProessTrustId = HotProessItem . HotProessTrustId and a . ProessTypes = HotProessItem . ProessTypes ) , ' ' ) AS JOT_JointNo , IsoInfo . ISO_IsoNo , IsoInfo . ISO_ID ,
( CASE WHEN Steel . STE_Code IS NOT NULL AND Steel2 . STE_Code IS NOT NULL and Steel . STE_Code ! = Steel2 . STE_Code
THEN Steel . STE_Code + '/' + Steel2 . STE_Code
WHEN Steel . STE_Code IS NOT NULL THEN Steel . STE_Code
ELSE ISNULL ( Steel2 . STE_Code , ' ' ) END ) AS STE_Code ,
HotProessItem . PointCount , HotProessItem . RequiredT , HotProessItem . ActualT ,
HotProessItem . RequestTime , HotProessItem . ActualTime , HotProessItem . RecordChartNo ,
HotProessItem . HotProessDate , HotProessItem . HotProessTrustId ,
( SELECT ( case when HotHardCode is null then HardTestReportCode else HotHardCode end ) as HardTestReportCode FROM dbo . HJGL_CH_HardTestReport
2024-07-18 14:49:08 +08:00
WHERE HardTestReportId = t . HardTestReportId )
2024-05-08 17:17:11 +08:00
AS HardnessReportNo ,
HotProessItem . HotProessItemId , HotProessItem . SortIndex , HotProessItem . ProessTypes , JointInfo . JOT_JointDesc , isnull ( HotProessItem . Remark , ' ' ) as Remark
FROM dbo . HJGL_HotProessItem AS HotProessItem
LEFT JOIN dbo . HJGL_PW_JointInfo AS JointInfo ON JointInfo . JOT_ID = HotProessItem . JOT_ID
LEFT JOIN dbo . HJGL_PW_IsoInfo AS IsoInfo ON JointInfo . ISO_ID = IsoInfo . ISO_ID
left join Base_Project as Project on Project . ProjectId = IsoInfo . ProjectId
LEFT JOIN dbo . Project_WorkArea AS WorkArea ON IsoInfo . BAW_ID = WorkArea . WorkAreaId
LEFT JOIN dbo . HJGL_BS_Steel AS Steel ON JointInfo . STE_ID = Steel . STE_ID
LEFT JOIN dbo . HJGL_BS_Steel AS Steel2 ON JointInfo . STE_ID2 = Steel2 . STE_ID
left join ( select record . RepairMark , record . JOT_ID , h . HotProessItemId from dbo . HJGL_CH_HotProessTrustItem AS TrustItem
left join dbo . HJGL_CH_RepairItemRecord AS record ON record . RepairItemRecordId = TrustItem . TrustItemID
left join dbo . HJGL_HotProessItem h on h . JOT_ID = TrustItem . JOT_ID
where h . JOT_ID = TrustItem . JOT_ID and h . HotProessTrustId = TrustItem . HotProessTrustId and h . ProessTypes = TrustItem . ProessTypes ) v
on v . JOT_ID = HotProessItem . JOT_ID and v . HotProessItemId = HotProessItem . HotProessItemId
2024-07-18 14:49:08 +08:00
left join ( SELECT distinct re . HardTestReportId , item . JOT_ID , item . HotProessTrustId FROM dbo . HJGL_CH_HardTestReportItem item
left join dbo . HJGL_CH_HardTestReport re on item . HardTestReportId = re . HardTestReportId
WHERE ( re . FileType = 'R' or re . FileType is null ) ) t on t . JOT_ID = HotProessItem . JOT_ID and t . HotProessTrustId = HotProessItem . HotProessTrustId
2024-05-08 17:17:11 +08:00
WHERE JointInfo . ProjectId = @ProjectId ";
listStr . Add ( new SqlParameter ( "@ProjectId" , this . tvControlItem . SelectedNodeID ) ) ;
if ( this . drpIsoNo . SelectedValue ! = BLL . Const . _Null )
{
strSql + = @" AND IsoInfo.ISO_ID = @ISO_ID" ;
listStr . Add ( new SqlParameter ( "@ISO_ID" , this . drpIsoNo . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtSearchNo . Text . Trim ( ) ) )
{
strSql + = @" AND HotProessItem.RecordChartNo like @RecordChartNo" ;
listStr . Add ( new SqlParameter ( "@RecordChartNo" , "%" + this . txtSearchNo . Text . Trim ( ) + "%" ) ) ;
}
if ( this . rblIsPrint . SelectedValue = = "0" )
{
strSql + = @" AND HotProessItem.PrintDate is null" ;
}
else
{
strSql + = @" AND HotProessItem.PrintDate is not null" ;
}
var hotProessItems = from x in Funs . DB . View_HotProessItem where x . ProjectId = = this . tvControlItem . SelectedNodeID & & x . PrintDate ! = null & & x . IsPrint = = null select x ;
foreach ( var item in hotProessItems )
{
Model . HJGL_HotProessItem hItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( item . HotProessItemId ) ;
if ( hItem ! = null )
{
hItem . IsPrint = true ;
Funs . DB . SubmitChanges ( ) ;
}
}
}
else
{
strSql = @ "SELECT JointInfo.ProjectId,JointInfo.JOT_ID,Project.ProjectCode,HotProessItem.PrintDate,
( CASE WHEN v . RepairMark IS NOT NULL THEN ( JointInfo . JOT_JointNo + v . RepairMark )
ELSE JointInfo . JOT_JointNo END ) + isnull ( ( select Top 1 HardRepairMark from dbo . HJGL_CH_HotProessTrustItem a where a . JOT_ID = HotProessItem . JOT_ID and a . HotProessTrustId = HotProessItem . HotProessTrustId and a . ProessTypes = HotProessItem . ProessTypes ) , ' ' ) AS JOT_JointNo , IsoInfo . ISO_IsoNo , IsoInfo . ISO_ID ,
( CASE WHEN Steel . STE_Code IS NOT NULL AND Steel2 . STE_Code IS NOT NULL and Steel . STE_Code ! = Steel2 . STE_Code
THEN Steel . STE_Code + '/' + Steel2 . STE_Code
WHEN Steel . STE_Code IS NOT NULL THEN Steel . STE_Code
ELSE ISNULL ( Steel2 . STE_Code , ' ' ) END ) AS STE_Code ,
HotProessItem . PointCount , HotProessItem . RequiredT , HotProessItem . ActualT , HotProessItem . RequestTime ,
HotProessItem . ActualTime , HotProessItem . RecordChartNo ,
HotProessItem . HotProessDate , HotProessItem . HotProessTrustId , HotProessItem . HotProessItemId , HotProessItem . SortIndex ,
( SELECT ( case when HotHardCode is null then HardTestReportCode else HotHardCode end ) as HardTestReportCode FROM dbo . HJGL_CH_HardTestReport
2024-07-18 14:49:08 +08:00
WHERE HardTestReportId = t . HardTestReportId )
2024-05-08 17:17:11 +08:00
AS HardnessReportNo ,
HotProessItem . ProessTypes , JointInfo . JOT_JointDesc , isnull ( HotProessItem . Remark , ' ' ) as Remark
FROM dbo . HJGL_HotProessItem AS HotProessItem
LEFT JOIN dbo . HJGL_PW_JointInfo AS JointInfo ON JointInfo . JOT_ID = HotProessItem . JOT_ID
LEFT JOIN dbo . HJGL_PW_IsoInfo AS IsoInfo ON JointInfo . ISO_ID = IsoInfo . ISO_ID
left join Base_Project as Project on Project . ProjectId = IsoInfo . ProjectId
LEFT JOIN dbo . Project_WorkArea AS WorkArea ON IsoInfo . BAW_ID = WorkArea . WorkAreaId
LEFT JOIN dbo . HJGL_BS_Steel AS Steel ON JointInfo . STE_ID = Steel . STE_ID
LEFT JOIN dbo . HJGL_BS_Steel AS Steel2 ON JointInfo . STE_ID2 = Steel2 . STE_ID
left join ( select record . RepairMark , record . JOT_ID , h . HotProessItemId from dbo . HJGL_CH_HotProessTrustItem AS TrustItem
left join dbo . HJGL_CH_RepairItemRecord AS record ON record . RepairItemRecordId = TrustItem . TrustItemID
left join dbo . HJGL_HotProessItem h on h . JOT_ID = TrustItem . JOT_ID
where h . JOT_ID = TrustItem . JOT_ID and h . HotProessTrustId = TrustItem . HotProessTrustId and h . ProessTypes = TrustItem . ProessTypes ) v
on v . JOT_ID = HotProessItem . JOT_ID and v . HotProessItemId = HotProessItem . HotProessItemId
2024-07-18 14:49:08 +08:00
left join ( SELECT distinct re . HardTestReportId , item . JOT_ID , item . HotProessTrustId FROM dbo . HJGL_CH_HardTestReportItem item
left join dbo . HJGL_CH_HardTestReport re on item . HardTestReportId = re . HardTestReportId
WHERE ( re . FileType = 'R' or re . FileType is null ) ) t on t . JOT_ID = HotProessItem . JOT_ID and t . HotProessTrustId = HotProessItem . HotProessTrustId
2024-05-08 17:17:11 +08:00
WHERE CHARINDEX ( JointInfo . ProjectId , @ProjectId ) > 0 ";
listStr . Add ( new SqlParameter ( "@ProjectId" , projectIds ) ) ;
if ( this . drpIsoNo . SelectedValue ! = BLL . Const . _Null )
{
strSql + = @" AND IsoInfo.ISO_ID = @ISO_ID" ;
listStr . Add ( new SqlParameter ( "@ISO_ID" , this . drpIsoNo . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtSearchNo . Text . Trim ( ) ) )
{
strSql + = @" AND HotProessItem.RecordChartNo like @RecordChartNo" ;
listStr . Add ( new SqlParameter ( "@RecordChartNo" , "%" + this . txtSearchNo . Text . Trim ( ) + "%" ) ) ;
}
if ( this . rblIsPrint . SelectedValue = = "0" )
{
strSql + = @" AND HotProessItem.PrintDate is null" ;
}
else
{
strSql + = @" AND HotProessItem.PrintDate is not null" ;
}
}
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 ( ) ;
if ( this . drpIsoNo . SelectedValue ! = BLL . Const . _Null )
{
Model . HJGL_PW_IsoInfo iso = BLL . HJGL_PW_IsoInfoService . GetIsoInfoByIsoInfoId ( this . drpIsoNo . SelectedValue ) ;
if ( iso ! = null )
{
string projectPrefix = BLL . Base_ProjectService . GetProjectByProjectId ( iso . ProjectId ) . ProjectCode + "-" ;
string isoPrefix = BLL . Base_ProjectService . GetProjectByProjectId ( iso . ProjectId ) . ProjectCode + "-" + iso . ISO_IsoNo + "-" ;
var hotProess = ( from x in Funs . DB . HJGL_HotProess where x . HotProessNo . Contains ( projectPrefix ) select x ) . FirstOrDefault ( ) ;
if ( hotProess = = null ) //项目还未有打印记录
{
this . txtHotProessNo . Text = isoPrefix + "0001" ;
}
else
{
var isoHotProess = ( from x in Funs . DB . HJGL_HotProess where x . HotProessNo . Contains ( isoPrefix ) select x ) . FirstOrDefault ( ) ;
if ( isoHotProess ! = null ) //管线打印记录已存在,则保持原有打印记录编号
{
this . txtHotProessNo . Text = isoHotProess . HotProessNo ;
}
else
{
var hotProessNos = ( from x in Funs . DB . HJGL_HotProess where x . HotProessNo . Contains ( projectPrefix ) orderby x . HotProessNo . Substring ( x . HotProessNo . Length - 4 ) descending select x . HotProessNo . Substring ( x . HotProessNo . Length - 4 ) ) . ToList ( ) ;
this . txtHotProessNo . Text = isoPrefix + GetNo ( Convert . ToInt32 ( hotProessNos [ 0 ] ) + 1 ) ;
}
}
//this.txtHotProessNo.Text = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_HotProess", "HotProessNo", iso.ProjectId, BLL.Base_ProjectService.GetProjectByProjectId(iso.ProjectId).ProjectCode + "-" + DateTime.Now.Year.ToString());
}
}
var hardTestReportItems = from x in Funs . DB . HJGL_CH_HardTestReportItem select x ;
var hardTestReports = from x in Funs . DB . HJGL_CH_HardTestReport select x ;
for ( int i = 0 ; i < this . Grid1 . Rows . Count ; i + + )
{
string hotProessItemId = this . Grid1 . Rows [ i ] . DataKeys [ 0 ] . ToString ( ) ;
Model . HJGL_HotProessItem hotProessItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( hotProessItemId ) ;
if ( hotProessItem ! = null )
{
Model . HJGL_CH_HardTestReport hardTestReport = ( from x in hardTestReports
join y in hardTestReportItems
on x . HardTestReportId equals y . HardTestReportId
where y . JOT_ID = = hotProessItem . JOT_ID & & y . HotProessTrustId = = hotProessItem . HotProessTrustId
select x ) . FirstOrDefault ( ) ;
if ( hardTestReport ! = null & & hardTestReport . IsPrintTrust = = true ) //硬度委托打印后,不能修改热处理录入数据
{
this . Grid1 . Rows [ i ] . CellCssClasses [ 2 ] = "color" ;
}
}
this . Grid1 . Rows [ i ] . Values [ 8 ] = this . Grid1 . Rows [ i ] . Values [ 8 ] . ToString ( ) . Replace ( "±" , "±" ) ;
}
}
private string GetNo ( int i )
{
if ( i < 10 )
{
return "000" + i . ToString ( ) ;
}
else if ( i < 100 )
{
return "00" + i . ToString ( ) ;
}
else if ( i < 1000 )
{
return "0" + i . ToString ( ) ;
}
else
{
return i . ToString ( ) ;
}
}
#region 加 载 页 面 输 入 提 交 信 息
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad ( )
{
this . btnPrint . Hidden = false ;
this . btnPrintNew . Hidden = false ;
this . btnSave . Hidden = false ;
this . SimpleForm1 . Reset ( ) ; ///重置所有字段
}
#endregion
#endregion
/// <summary>
/// 判断是否修改
/// </summary>
/// <returns></returns>
private bool IsEdit ( )
{
bool isEdit = true ;
//var hotHardItem = Funs.DB.HJGL_View_HotHardItem.FirstOrDefault(x => x.HotProessId == this.HotProessId && x.HotHardID != null);
//if (hotHardItem != null)
//{
// isEdit = false;
//}
return isEdit ;
}
#region 分 页 排 序
#region 页 索 引 改 变 事 件
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region 排 序
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
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 ) ;
BindGrid ( ) ;
}
#endregion
#endregion
#region 关 闭 弹 出 窗 口 及 刷 新 页 面
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close ( object sender , WindowCloseEventArgs e )
{
this . BindGrid ( ) ;
}
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window3_Close ( object sender , WindowCloseEventArgs e )
{
string ids1 = string . Empty ;
string ids2 = string . Empty ;
if ( ! string . IsNullOrEmpty ( this . hdItemsString . Text . Trim ( ) ) & & this . hdItemsString . Text . Trim ( ) . Contains ( "|" ) )
{
ids1 = this . hdItemsString . Text . Trim ( ) . Split ( '|' ) [ 0 ] ;
ids2 = this . hdItemsString . Text . Trim ( ) . Split ( '|' ) [ 1 ] ;
}
if ( ! string . IsNullOrEmpty ( ids1 ) & & ! string . IsNullOrEmpty ( ids2 ) )
{
string strSql = string . Empty ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
strSql = @ "SELECT JointInfo.ProjectId,WorkArea.WorkAreaCode,WorkArea.WorkAreaId,JointInfo.JOT_ID,(CASE WHEN v.RepairMark IS NOT NULL THEN (JointInfo.JOT_JointNo+v.RepairMark)
ELSE JointInfo . JOT_JointNo END ) + isnull ( ( select Top 1 HardRepairMark from dbo . HJGL_CH_HotProessTrustItem a where a . JOT_ID = HotProessItem . JOT_ID and a . HotProessTrustId = HotProessItem . HotProessTrustId and a . ProessTypes = HotProessItem . ProessTypes ) , ' ' ) AS JOT_JointNo , IsoInfo . ISO_IsoNo , IsoInfo . ISO_ID , Steel . STE_Code , HotProessItem . PointCount , HotProessItem . RequiredT , HotProessItem . ActualT , HotProessItem . RequestTime , HotProessItem . ActualTime , HotProessItem . RecordChartNo , HotProessItem . HardnessReportNo , HotProessItem . HotProessDate , HotProessItem . HotProessTrustId , HotProessItem . HotProessItemId , HotProessItem . SortIndex , HotProessItem . ProessTypes , JointInfo . JOT_JointDesc , HotProessItem . Remark "
+ @" FROM dbo.HJGL_HotProessItem AS HotProessItem "
+ @" LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = HotProessItem.JOT_ID"
+ @" LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON JointInfo.ISO_ID = IsoInfo.ISO_ID"
+ @" LEFT JOIN dbo.Project_WorkArea AS WorkArea ON IsoInfo.BAW_ID = WorkArea.WorkAreaId"
+ @ " LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON IsoInfo.STE_ID = Steel.STE_ID
left join ( select record . RepairMark , record . JOT_ID , h . HotProessItemId from dbo . HJGL_CH_HotProessTrustItem AS TrustItem
left join dbo . HJGL_CH_RepairItemRecord AS record ON record . RepairItemRecordId = TrustItem . TrustItemID
left join dbo . HJGL_HotProessItem h on h . JOT_ID = TrustItem . JOT_ID
where h . JOT_ID = TrustItem . JOT_ID and h . HotProessTrustId = TrustItem . HotProessTrustId and h . ProessTypes = TrustItem . ProessTypes ) v
on v . JOT_ID = HotProessItem . JOT_ID and v . HotProessItemId = HotProessItem . HotProessItemId "
+ @"WHERE @Ids1 like '%'+JointInfo.JOT_ID+'%' and @Ids2 like '%'+HotProessItem.HotProessTrustId+'%' order by IsoInfo.ISO_IsoNo,JointInfo.JOT_JointNo" ;
listStr . Add ( new SqlParameter ( "@Ids1" , ids1 ) ) ;
listStr . Add ( new SqlParameter ( "@Ids2" , ids2 ) ) ;
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 ( ) ;
}
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged ( object sender , EventArgs e )
{
this . InitTreeMenu ( ) ;
this . BindGrid ( ) ;
}
#endregion
#region 热 处 理 表 打 印
/// <summary>
/// 热处理表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click ( object sender , EventArgs e )
{
if ( this . drpIsoNo . SelectedValue ! = BLL . Const . _Null )
{
string varValue = String . Empty ;
Model . HJGL_PW_IsoInfo iso = BLL . HJGL_PW_IsoInfoService . GetIsoInfoByIsoInfoId ( this . drpIsoNo . SelectedValue ) ;
if ( iso ! = null )
{
Model . HJGL_HotProess hotProess = new Model . HJGL_HotProess ( ) ;
hotProess . HotProessId = SQLHelper . GetNewID ( typeof ( Model . HJGL_HotProess ) ) ;
hotProess . ProjectId = iso . ProjectId ;
hotProess . HotProessNo = this . txtHotProessNo . Text . Trim ( ) ;
hotProess . ProessDate = DateTime . Now ;
BLL . HJGL_HotProessManageEditService . AddHotProess ( hotProess ) ;
}
string hotProessNo = this . txtHotProessNo . Text . Trim ( ) . Replace ( "/" , "," ) ;
string installName = string . Empty ;
installName = this . txtUnit . Text . Trim ( ) . Replace ( "/" , "," ) ;
string proessMethod = this . txtProessMethod . Text . Trim ( ) . Replace ( "/" , "," ) ;
string proessEquipment = this . txtProessEquipment . Text . Trim ( ) . Replace ( "/" , "," ) ;
string projectName = string . Empty ;
string reportId = string . Empty ;
if ( this . tvControlItem . SelectedNode ! = null )
{
Model . Base_Project selectProject = BLL . Base_ProjectService . GetProjectByProjectId ( this . tvControlItem . SelectedNodeID ) ;
if ( selectProject ! = null )
{
projectName = selectProject . ProjectName . Replace ( "/" , "," ) ;
}
}
var hotProessItems = from x in Funs . DB . View_HotProessItem where x . RecordChartNo ! = null & & x . RecordChartNo ! = "" select x ;
var items = from x in hotProessItems
where x . ISO_ID = = this . drpIsoNo . SelectedValue & & x . HotProessItemId ! = null
select x ;
if ( this . rblIsPrint . SelectedValue = = "0" )
{
items = items . Where ( x = > x . IsPrint = = null ) ;
}
else
{
items = items . Where ( x = > x . IsPrint = = true ) ;
}
int count = items . Count ( ) ; //Grid行数
if ( this . rblIsPrint . SelectedValue = = "0" )
{
foreach ( var item in items )
{
Model . HJGL_HotProessItem hItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( item . HotProessItemId ) ;
if ( hItem ! = null )
{
hItem . PrintDate = DateTime . Now ;
Funs . DB . SubmitChanges ( ) ;
}
}
}
string pageNum = Funs . GetPagesCountByPageSize ( 12 , 20 , count ) . ToString ( ) ;
varValue = projectName + "|" + installName + "|" + this . drpIsoNo . SelectedText . Replace ( "/" , "," ) + "|" + hotProessNo + "|" + proessMethod + "|" + proessEquipment + "|" + pageNum ;
varValue = HttpUtility . UrlEncodeUnicode ( varValue ) ;
bool isOther = false ; //是否存在一个口大于2个测温点的情况
var jotIds = ( from x in hotProessItems
where x . ISO_ID = = this . drpIsoNo . SelectedValue & & x . HotProessItemId ! = null
select x . JOT_ID ) . Distinct ( ) . ToList ( ) ; //所选管线焊口Id集合
//int jointCount = jotIds.Count; //所选管线焊口数
int jointCount = 0 ; //所选管线焊口数
foreach ( var jotId in jotIds )
{
var a = ( from x in hotProessItems
where x . JOT_ID = = jotId
select x ) . Count ( ) ;
if ( a > 2 ) //有焊口大于2个测温点
{
isOther = true ;
}
}
this . Grid1 . PageSize = 1000 ;
BindGrid ( ) ;
List < string > jointNoLists = new List < string > ( ) ;
for ( int i = 0 ; i < this . Grid1 . Rows . Count ; i + + )
{
System . Web . UI . WebControls . Label lbJOT_JointNo = ( System . Web . UI . WebControls . Label ) ( this . Grid1 . Rows [ i ] . FindControl ( "lbJOT_JointNo" ) ) ;
if ( ! string . IsNullOrEmpty ( this . Grid1 . Rows [ i ] . Values [ 13 ] . ToString ( ) ) )
{
jointNoLists . Add ( lbJOT_JointNo . Text ) ;
}
//if (lbJOT_JointNo.Text.Contains("R"))
//{
// jointCount++;
//}
}
jointCount = jointNoLists . Distinct ( ) . Count ( ) ;
if ( count = = jointCount ) //全部是一个测温点
{
reportId = Const . HJGL_HotProessReportId1 ;
}
else if ( count = = ( jointCount * 2 ) & & ! isOther ) //全部是两个测温点
{
reportId = Const . HJGL_HotProessReportId2 ;
}
else if ( count > jointCount & & count < jointCount * 2 & & ! isOther ) //全部由一或两个测温点组成
{
reportId = Const . HJGL_HotProessReportId3 ;
}
else //存在一个口大于2个测温点的情况
{
reportId = Const . HJGL_HotProessReportId4 ;
}
if ( count < = 12 )
{
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , reportId , this . drpIsoNo . SelectedValue , varValue , "打印 - " ) ) ) ;
}
else
{
PageContext . RegisterStartupScript ( Window4 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , Const . HJGL_HotProessReportTwoId , this . drpIsoNo . SelectedValue , varValue , "打印 - " ) ) ) ;
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , reportId , this . drpIsoNo . SelectedValue , varValue , "打印 - " ) ) ) ;
}
}
else
{
ShowNotify ( "请选择管线!" , MessageBoxIcon . Warning ) ;
return ;
}
}
/// <summary>
/// 打印(新)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrintNew_Click ( object sender , EventArgs e )
{
if ( this . drpIsoNo . SelectedValue ! = BLL . Const . _Null )
{
string varValue = String . Empty ;
Model . HJGL_PW_IsoInfo iso = BLL . HJGL_PW_IsoInfoService . GetIsoInfoByIsoInfoId ( this . drpIsoNo . SelectedValue ) ;
if ( iso ! = null )
{
Model . HJGL_HotProess hotProess = new Model . HJGL_HotProess ( ) ;
hotProess . HotProessId = SQLHelper . GetNewID ( typeof ( Model . HJGL_HotProess ) ) ;
hotProess . ProjectId = iso . ProjectId ;
hotProess . HotProessNo = this . txtHotProessNo . Text . Trim ( ) ;
hotProess . ProessDate = DateTime . Now ;
BLL . HJGL_HotProessManageEditService . AddHotProess ( hotProess ) ;
}
string hotProessNo = this . txtHotProessNo . Text . Trim ( ) . Replace ( "/" , "," ) ;
string installName = string . Empty ;
installName = this . txtUnit . Text . Trim ( ) . Replace ( "/" , "," ) ;
string proessMethod = this . txtProessMethod . Text . Trim ( ) . Replace ( "/" , "," ) ;
string proessEquipment = this . txtProessEquipment . Text . Trim ( ) . Replace ( "/" , "," ) ;
string projectName = string . Empty ;
string reportId = string . Empty ;
var hotProessItems = from x in Funs . DB . View_HotProessItem where x . RecordChartNo ! = null & & x . RecordChartNo ! = "" select x ;
var items = from x in hotProessItems
where x . ISO_ID = = this . drpIsoNo . SelectedValue & & x . HotProessItemId ! = null
select x ;
if ( this . rblIsPrint . SelectedValue = = "0" )
{
foreach ( var item in items )
{
Model . HJGL_HotProessItem hItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( item . HotProessItemId ) ;
if ( hItem ! = null )
{
hItem . PrintDate = DateTime . Now ;
Funs . DB . SubmitChanges ( ) ;
}
}
}
if ( this . tvControlItem . SelectedNode ! = null )
{
Model . Base_Project selectProject = BLL . Base_ProjectService . GetProjectByProjectId ( this . tvControlItem . SelectedNodeID ) ;
if ( selectProject ! = null )
{
projectName = selectProject . ProjectName . Replace ( "/" , "," ) ;
}
}
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@IsoId" , this . drpIsoNo . SelectedValue ) ) ;
listStr . Add ( new SqlParameter ( "@Flag" , "0" ) ) ;
listStr . Add ( new SqlParameter ( "@IsPrint" , this . rblIsPrint . SelectedValue ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = BLL . SQLHelper . GetDataTableRunProc ( "HJGL_spHotProessItem" , parameter ) ;
string page = Funs . GetPagesCountByPageSize ( 7 , 13 , tb . Rows . Count ) . ToString ( ) ;
varValue = projectName + "|" + installName + "|" + this . drpIsoNo . SelectedText . Replace ( "/" , "," ) + "|" + hotProessNo + "|" + proessMethod + "|" + proessEquipment + "|" + page ;
if ( ! string . IsNullOrEmpty ( varValue ) )
{
varValue = HttpUtility . UrlEncodeUnicode ( varValue ) ;
}
reportId = Const . HJGL_HotProessReportNewId1 ;
if ( tb . Rows . Count < = 7 )
{
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , reportId , this . drpIsoNo . SelectedValue + "|" + this . rblIsPrint . SelectedValue , varValue , "打印 - " ) ) ) ;
}
else
{
PageContext . RegisterStartupScript ( Window4 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , Const . HJGL_HotProessReportNewId2 , this . drpIsoNo . SelectedValue + "|" + this . rblIsPrint . SelectedValue , varValue , "打印 - " ) ) ) ;
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0" , reportId , this . drpIsoNo . SelectedValue + "|" + this . rblIsPrint . SelectedValue , varValue , "打印 - " ) ) ) ;
}
}
else
{
ShowNotify ( "请选择管线!" , MessageBoxIcon . Warning ) ;
return ;
}
}
#endregion
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
protected void TextBox2_TextChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
/// <summary>
/// 得到热处理类型
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertProessTypes ( object ProessTypes )
{
string proessTypes = string . Empty ;
if ( ProessTypes ! = null )
{
proessTypes = BLL . HJGL_PW_JointInfoService . ConvertProessTypes ( ProessTypes . ToString ( ) ) ;
}
return proessTypes ;
}
/// <summary>
/// 是否生成报告
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertReport ( object PrintDate )
{
if ( PrintDate ! = null )
{
if ( ! string . IsNullOrEmpty ( PrintDate . ToString ( ) ) )
{
return "已生成" ;
}
}
return "" ;
}
#region Grid 明 细 操 作 事 件
/// <summary>
/// 右键增加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click ( object sender , EventArgs e )
{
SaveData ( ) ;
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
JArray mergedData = Grid1 . GetMergedData ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int rowIndex = mergedRow . Value < int > ( "index" ) ;
string jot_id = values . Value < string > ( "JOT_ID" ) . ToString ( ) ;
if ( rowIndex = = this . Grid1 . SelectedRowIndex )
{
Model . HJGL_HotProessItem newHotProessItem = new Model . HJGL_HotProessItem ( ) ;
newHotProessItem . HotProessItemId = SQLHelper . GetNewID ( typeof ( Model . HJGL_HotProessItem ) ) ;
newHotProessItem . JOT_ID = jot_id ;
newHotProessItem . RequiredT = values . Value < string > ( "RequiredT" ) . ToString ( ) ;
newHotProessItem . ActualT = values . Value < string > ( "ActualT" ) . ToString ( ) ;
newHotProessItem . RequestTime = values . Value < string > ( "RequestTime" ) . ToString ( ) ;
newHotProessItem . ActualTime = values . Value < string > ( "ActualTime" ) . ToString ( ) ;
newHotProessItem . HotProessDate = Funs . GetNewDateTime ( values . Value < string > ( "HotProessDate" ) . ToString ( ) ) ;
newHotProessItem . RecordChartNo = values . Value < string > ( "RecordChartNo" ) . ToString ( ) ;
newHotProessItem . HotProessTrustId = values . Value < string > ( "HotProessTrustId" ) . ToString ( ) ;
newHotProessItem . ProessTypes = values . Value < string > ( "ProessTypes" ) . ToString ( ) ;
newHotProessItem . SortIndex = BLL . HJGL_HotProessManageEditService . GetSortIndex ( newHotProessItem . HotProessTrustId , jot_id , newHotProessItem . ProessTypes ) ;
newHotProessItem . Remark = values . Value < string > ( "Remark" ) . ToString ( ) ;
BLL . HJGL_HotProessManageEditService . AddHotProessItem ( newHotProessItem , "" , null ) ;
}
}
this . BindGrid ( ) ;
}
/// <summary>
/// 右键同上
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCopy_Click ( object sender , EventArgs e )
{
SaveData ( ) ;
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
//string[] strs = this.Grid1.SelectedCell; //选择的单元格
int rowId = this . Grid1 . SelectedRowIndex ;
string RequiredT = string . Empty ;
string ActualT = string . Empty ;
string RequestTime = string . Empty ;
string ActualTime = string . Empty ;
string HotProessDate = string . Empty ;
string RecordChartNo = string . Empty ;
string Remark = string . Empty ;
JArray mergedData = Grid1 . GetMergedData ( ) ;
if ( this . Grid1 . SelectedRowIndex > 0 )
{
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int rowIndex = mergedRow . Value < int > ( "index" ) ;
if ( rowIndex = = this . Grid1 . SelectedRowIndex - 1 ) //选择行的上一行
{
RequiredT = values . Value < string > ( "RequiredT" ) . ToString ( ) ;
ActualT = values . Value < string > ( "ActualT" ) . ToString ( ) ;
RequestTime = values . Value < string > ( "RequestTime" ) . ToString ( ) ;
ActualTime = values . Value < string > ( "ActualTime" ) . ToString ( ) ;
HotProessDate = values . Value < string > ( "HotProessDate" ) . ToString ( ) ;
RecordChartNo = values . Value < string > ( "RecordChartNo" ) . ToString ( ) ;
Remark = values . Value < string > ( "Remark" ) . ToString ( ) ;
}
if ( rowIndex = = this . Grid1 . SelectedRowIndex )
{
Model . HJGL_HotProessItem newHotProessItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( this . Grid1 . Rows [ rowIndex ] . DataKeys [ 0 ] . ToString ( ) ) ;
newHotProessItem . RequiredT = RequiredT ;
newHotProessItem . ActualT = ActualT ;
newHotProessItem . RequestTime = RequestTime ;
newHotProessItem . ActualTime = ActualTime ;
newHotProessItem . HotProessDate = Funs . GetNewDateTime ( HotProessDate ) ;
newHotProessItem . RecordChartNo = RecordChartNo ;
newHotProessItem . Remark = Remark ;
Funs . DB . SubmitChanges ( ) ;
}
}
this . BindGrid ( ) ;
this . Grid1 . SelectedRowIndex = rowId + 1 ;
}
}
/// <summary>
/// 右键删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click ( object sender , EventArgs e )
{
if ( CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , Const . HJGL_HotProessManageEditMenuId , Const . BtnDelete ) )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
var hardTestReportItems = from x in Funs . DB . HJGL_CH_HardTestReportItem select x ;
var hardTestReports = from x in Funs . DB . HJGL_CH_HardTestReport select x ;
foreach ( var item in this . Grid1 . SelectedRowIDArray )
{
Model . HJGL_HotProessItem hotProessItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( item ) ;
if ( hotProessItem ! = null )
{
Model . HJGL_CH_HardTestReport hardTestReport = ( from x in hardTestReports
join y in hardTestReportItems
on x . HardTestReportId equals y . HardTestReportId
where y . JOT_ID = = hotProessItem . JOT_ID & & y . HotProessTrustId = = hotProessItem . HotProessTrustId
select x ) . FirstOrDefault ( ) ;
var hotProessItems = from x in Funs . DB . HJGL_HotProessItem
where x . JOT_ID = = hotProessItem . JOT_ID & & x . HotProessTrustId = = hotProessItem . HotProessTrustId & & x . ProessTypes = = hotProessItem . ProessTypes
select x ;
//if (hardTestReport != null && hardTestReport.IsPrintTrust == true) //硬度委托打印后,不能删除热处理录入数据
//{
// //if (this.CurrUser.UserId == BLL.Const.GlyId) //管理员可以删除数据
// //{
// // BLL.HJGL_HotProessManageEditService.DeleteHotProessItemByHotProessItemId(item);
// //}
// Alert.ShowInTop("硬度委托已打印,不能删除热处理录入数据!", MessageBoxIcon.Warning);
// return;
//}
if ( hotProessItems . Count ( ) = = 1 ) //该委托对应的热处理数据只有一条
{
var hotProessTrustItem = ( from x in Funs . DB . HJGL_CH_HotProessTrustItem
where x . JOT_ID = = hotProessItem . JOT_ID & & x . HotProessTrustId = = hotProessItem . HotProessTrustId & & x . ProessTypes = = hotProessItem . ProessTypes
select x ) . FirstOrDefault ( ) ;
if ( hotProessTrustItem ! = null ) //热处理委托明细信息存在
{
Alert . ShowInTop ( "热处理委托明细只存在一条热处理录入数据,不能删除!" , MessageBoxIcon . Warning ) ;
return ;
}
}
else
{
BLL . HJGL_HotProessManageEditService . DeleteHotProessItemByHotProessItemId ( item ) ;
}
}
}
this . BindGrid ( ) ;
}
else
{
ShowNotify ( "您没有这个权限,请与管理员联系!" , MessageBoxIcon . Warning ) ;
}
}
#endregion
#region 提 交 事 件
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click ( object sender , EventArgs e )
{
if ( CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , Const . HJGL_HotProessManageEditMenuId , Const . BtnSave ) )
{
//int count = 0;
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// System.Web.UI.WebControls.CheckBoxList cblProessTypes = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblProessTypes"));
// for (int j = 0; j < cblProessTypes.Items.Count; j++)
// {
// if (cblProessTypes.Items[j].Selected)
// {
// count += 1;
// break;
// }
// }
//}
//if (count < this.Grid1.Rows.Count)
//{
// ShowNotify("热处理类型不能为空!", MessageBoxIcon.Warning);
// return;
//}
SaveData ( ) ;
ShowNotify ( "提交成功!" , MessageBoxIcon . Success ) ;
}
else
{
ShowNotify ( "您没有这个权限,请与管理员联系!" , MessageBoxIcon . Warning ) ;
return ;
}
}
#endregion
/// <summary>
/// 提交明细数据方法
/// </summary>
private void SaveData ( )
{
string isoidLog = string . Empty ; //是否同一管线标记
int i = 0 ; //检验数量
int flag = 0 ; //打印标记
string hardTestReportId = string . Empty ; //硬度检验报告主键
List < string > hotProessStates = new List < string > ( ) ; //热处理状态
string hotProessState = string . Empty ;
var results = from x in Funs . DB . HJGL_CH_HotProessResult select x ;
var hardTestReportItems = from x in Funs . DB . HJGL_CH_HardTestReportItem select x ;
var hardTestReports = from x in Funs . DB . HJGL_CH_HardTestReport select x ;
JArray mergedData = Grid1 . GetMergedData ( ) ;
foreach ( JObject mergedRow in mergedData )
{
string status = mergedRow . Value < string > ( "status" ) ;
JObject values = mergedRow . Value < JObject > ( "values" ) ;
int rowIndex = mergedRow . Value < int > ( "index" ) ;
string jot_id = values . Value < string > ( "JOT_ID" ) . ToString ( ) ;
string iso_No = values . Value < string > ( "ISO_IsoNo" ) . ToString ( ) ;
//判断是否可以修改数据
string hotProessItemId = this . Grid1 . Rows [ rowIndex ] . DataKeys [ 0 ] . ToString ( ) ;
Model . HJGL_HotProessItem newHotProessItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( hotProessItemId ) ;
Model . HJGL_HotProessItem hotProessItem = BLL . HJGL_HotProessManageEditService . GetHotProessItemByHotProessItemId ( hotProessItemId ) ;
if ( hotProessItem ! = null )
{
//Model.HJGL_CH_HardTestReport hardTestReport = (from x in hardTestReports
// join y in hardTestReportItems
// on x.HardTestReportId equals y.HardTestReportId
// where y.JOT_ID == hotProessItem.JOT_ID && y.HotProessTrustId == hotProessItem.HotProessTrustId
// select x).FirstOrDefault();
//if (hardTestReport != null && hardTestReport.IsPrintTrust == true) //硬度委托打印后,不能修改热处理录入数据
//{
// if (this.CurrUser.UserId == BLL.Const.GlyId) //管理员可以修改数据
// {
// newHotProessItem.PointCount = Funs.GetNewInt(values.Value<string>("PointCount").ToString());
// newHotProessItem.RequiredT = values.Value<string>("RequiredT").ToString();
// newHotProessItem.ActualT = values.Value<string>("ActualT").ToString();
// newHotProessItem.RequestTime = values.Value<string>("RequestTime").ToString();
// newHotProessItem.ActualTime = values.Value<string>("ActualTime").ToString();
// newHotProessItem.HotProessDate = Funs.GetNewDateTime(values.Value<string>("HotProessDate").ToString());
// newHotProessItem.RecordChartNo = values.Value<string>("RecordChartNo").ToString();
// Funs.DB.SubmitChanges();
// }
//}
//else
//{
newHotProessItem . PointCount = Funs . GetNewInt ( values . Value < string > ( "PointCount" ) . ToString ( ) ) ;
newHotProessItem . RequiredT = values . Value < string > ( "RequiredT" ) . ToString ( ) ;
newHotProessItem . ActualT = values . Value < string > ( "ActualT" ) . ToString ( ) ;
newHotProessItem . RequestTime = values . Value < string > ( "RequestTime" ) . ToString ( ) ;
newHotProessItem . ActualTime = values . Value < string > ( "ActualTime" ) . ToString ( ) ;
newHotProessItem . HotProessDate = Funs . GetNewDateTime ( values . Value < string > ( "HotProessDate" ) . ToString ( ) ) ;
newHotProessItem . RecordChartNo = values . Value < string > ( "RecordChartNo" ) . ToString ( ) ;
newHotProessItem . Remark = values . Value < string > ( "Remark" ) . ToString ( ) ;
Funs . DB . SubmitChanges ( ) ;
//}
}
if ( hotProessItem . ProessTypes . Contains ( "4" ) ) //消应力热处理需要进行硬度委托
{
//生成硬度委托记录
string hotProessTrustId = values . Value < string > ( "HotProessTrustId" ) . ToString ( ) ;
Model . HJGL_CH_HotProessResult result = results . FirstOrDefault ( x = > x . JOT_ID = = jot_id & & x . ProessTypes = = newHotProessItem . ProessTypes & & x . HotProessTrustId = = hotProessTrustId ) ;
if ( result ! = null & & ! string . IsNullOrEmpty ( newHotProessItem . RecordChartNo ) )
{
result . IsNeedHardTest = true ;
BLL . HJGL_CH_HotProessResultService . UpdateHotProessResult ( result ) ;
}
}
//if (hotProessItem.ProessTypes.Contains("4")) //消应力热处理需要进行硬度委托
//{
// //生成硬度委托记录
// string hotProessTrustId = values.Value<string>("HotProessTrustId").ToString();
// Model.HJGL_CH_HotProessResult result = results.FirstOrDefault(x => x.JOT_ID == jot_id && x.ProessTypes == newHotProessItem.ProessTypes && x.HotProessTrustId == hotProessTrustId);
// if (result != null && !string.IsNullOrEmpty(newHotProessItem.RecordChartNo))
// {
// result.IsNeedHardTest = true;
// BLL.HJGL_CH_HotProessResultService.UpdateHotProessResult(result);
// string proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(values.Value<string>("ProessTypes").ToString());
// Model.HJGL_CH_HardTestReportItem oldHardTestReportItem = BLL.HJGL_CH_HardTestReportService.GetHardTestReportItemByJotIDAndHotProessTrustId(jot_id, hotProessTrustId);
// if (oldHardTestReportItem == null) //该焊口尚未生成硬度检验报告记录
// {
// Model.HJGL_PW_JointInfo joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(jot_id);
// Model.HJGL_PW_IsoInfo iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID);
// if (isoidLog != joint.ISO_ID) //新管线的记录
// {
// flag = 0;
// Model.HJGL_CH_HardTestReport oldHardTestReport = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(hardTestReportId);
// if (oldHardTestReport != null) //更新之前硬度检验报告的热处理状态和检验数量
// {
// hotProessStates = hotProessStates.Distinct().ToList();
// foreach (var item in hotProessStates)
// {
// hotProessState = item + ",";
// }
// hotProessState = hotProessState.Substring(0, hotProessState.LastIndexOf(","));
// oldHardTestReport.HotProessState = hotProessState;
// oldHardTestReport.TestCount = i;
// BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReport(oldHardTestReport);
// }
// i = 0; //检验数量清零
// i++; //检验数量+1
// hotProessState = string.Empty; //热处理状态字符串清空
// hotProessStates.Clear(); //热处理状态集合清空
// hotProessStates.Add(proessTypes); //热处理状态集合添加元素
// isoidLog = joint.ISO_ID;
// hardTestReportId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReport));
// //生成硬度委托及硬度检验报告记录
// Model.HJGL_CH_HardTestReport hardTestReport = new Model.HJGL_CH_HardTestReport();
// hardTestReport.HardTestReportId = hardTestReportId;
// hardTestReport.HotHardCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_CH_HardTestReport", "HotHardCode", joint.ProjectId, BLL.Base_ProjectService.GetProjectCode(joint.ProjectId) + "-" + iso.ISO_IsoNo + "-");
// //八硫磺六个项目单独规则生成编号
// if (joint.ProjectId == "fe91191c-230d-4536-b80a-5756db1dc120" || joint.ProjectId == "64dbad31-e022-4933-94aa-b00ecdfa9dbb" || joint.ProjectId == "9ecef5cd-f522-4640-b95d-6462da08e3fb" || joint.ProjectId == "4adcc1af-341d-4006-a1c8-e205b14d4c74" || joint.ProjectId == "7061b8be-95d8-4047-9bf2-774e0f4d3329" || joint.ProjectId == "560239b5-4d83-4d58-b752-1caa3407ec34")
// {
// Model.Base_Project project = BLL.Base_ProjectService.GetProjectByProjectId(joint.ProjectId);
// string projectCode = string.Empty;
// if (project != null)
// {
// projectCode = project.ProjectCode.Substring(project.ProjectCode.Length - 1);
// }
// hardTestReport.HardTestReportCode = "HT2018-1073/" + projectCode + "-" + iso_No + "-YDBG-0001";
// }
// else
// {
// hardTestReport.HardTestReportCode = BLL.HJGL_CH_HardTestReportService.GetHardTestReportCodeByISO_ID(iso.ISO_ID, DateTime.Now);
// }
// hardTestReport.ProjectId = joint.ProjectId;
// hardTestReport.ISO_ID = iso.ISO_ID;
// hardTestReport.TestDate = DateTime.Now;
// hardTestReport.TrustUnitId = iso.BSU_ID;
// hardTestReport.TestStandard = "GB/T17394.1-2014";
// hardTestReport.STE_ID = iso.STE_ID;
// //项目承包单位信息
// hardTestReport.ContractUnit = "镇海石化建安工程有限公司";
// hardTestReport.TestMethod = "里氏硬度";
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReport(hardTestReport);
// //回写焊口硬度委托时间
// BLL.HJGL_PW_JointInfoService.WriteBackHardTrustDate(hotProessItem.JOT_ID, hardTestReport.TestDate);
// }
// else
// {
// i++; //检验数量+1
// hotProessStates.Add(proessTypes); //热处理状态集合添加元素
// //回写焊口硬度委托时间
// BLL.HJGL_PW_JointInfoService.WriteBackHardTrustDate(hotProessItem.JOT_ID, DateTime.Now);
// }
// //增加硬度检验报告明细信息
// flag++; //打印标记+1
// Model.HJGL_CH_HardTestReportItem newItem11 = new Model.HJGL_CH_HardTestReportItem();
// newItem11.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem11.HardTestReportId = hardTestReportId;
// newItem11.JOT_ID = jot_id;
// newItem11.TestPart = "焊缝";
// newItem11.SortIndex = 1;
// newItem11.Flag = flag;
// newItem11.IsShow = true;
// newItem11.HotProessTrustId = hotProessTrustId;
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem11);
// Model.HJGL_CH_HardTestReportItem newItem12 = new Model.HJGL_CH_HardTestReportItem();
// newItem12.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem12.HardTestReportId = hardTestReportId;
// newItem12.JOT_ID = jot_id;
// newItem12.TestPart = "焊缝";
// newItem12.SortIndex = 1;
// newItem12.Flag = flag;
// newItem12.HotProessTrustId = hotProessTrustId;
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem12);
// Model.HJGL_CH_HardTestReportItem newItem13 = new Model.HJGL_CH_HardTestReportItem();
// newItem13.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem13.HardTestReportId = hardTestReportId;
// newItem13.JOT_ID = jot_id;
// newItem13.TestPart = "焊缝";
// newItem13.SortIndex = 1;
// newItem13.Flag = flag;
// newItem13.HotProessTrustId = hotProessTrustId;
// if (!string.IsNullOrEmpty(joint.STE_ID2) && joint.STE_ID != joint.STE_ID2) //材质2不为空,且材质1与材质2不同
// {
// newItem13.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID).STE_Code;
// }
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem13);
// Model.HJGL_CH_HardTestReportItem newItem21 = new Model.HJGL_CH_HardTestReportItem();
// newItem21.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem21.HardTestReportId = hardTestReportId;
// newItem21.JOT_ID = jot_id;
// newItem21.TestPart = "热影响区";
// newItem21.SortIndex = 2;
// newItem21.Flag = flag;
// newItem21.IsShow = true;
// newItem21.HotProessTrustId = hotProessTrustId;
// if (!string.IsNullOrEmpty(joint.STE_ID2) && joint.STE_ID != joint.STE_ID2) //材质2不为空,且材质1与材质2不同
// {
// newItem21.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID).STE_Code;
// }
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem21);
// Model.HJGL_CH_HardTestReportItem newItem22 = new Model.HJGL_CH_HardTestReportItem();
// newItem22.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem22.HardTestReportId = hardTestReportId;
// newItem22.JOT_ID = jot_id;
// newItem22.TestPart = "热影响区";
// newItem22.SortIndex = 2;
// newItem22.Flag = flag;
// newItem22.HotProessTrustId = hotProessTrustId;
// if (!string.IsNullOrEmpty(joint.STE_ID2) && joint.STE_ID != joint.STE_ID2) //材质2不为空,且材质1与材质2不同
// {
// newItem22.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID).STE_Code;
// }
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem22);
// Model.HJGL_CH_HardTestReportItem newItem23 = new Model.HJGL_CH_HardTestReportItem();
// newItem23.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem23.HardTestReportId = hardTestReportId;
// newItem23.JOT_ID = jot_id;
// newItem23.TestPart = "热影响区";
// newItem23.SortIndex = 2;
// newItem23.Flag = flag;
// newItem23.HotProessTrustId = hotProessTrustId;
// if (!string.IsNullOrEmpty(joint.STE_ID2) && joint.STE_ID != joint.STE_ID2) //材质2不为空,且材质1与材质2不同
// {
// newItem23.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID).STE_Code;
// }
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem23);
// if (!string.IsNullOrEmpty(joint.STE_ID2) && joint.STE_ID != joint.STE_ID2) //材质2不为空,且材质1与材质2不同
// {
// Model.HJGL_CH_HardTestReportItem newItem51 = new Model.HJGL_CH_HardTestReportItem();
// newItem51.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem51.HardTestReportId = hardTestReportId;
// newItem51.JOT_ID = jot_id;
// newItem51.TestPart = "热影响区";
// newItem51.SortIndex = 5;
// newItem51.Flag = flag;
// newItem51.IsShow = true;
// newItem51.HotProessTrustId = hotProessTrustId;
// newItem51.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID2).STE_Code;
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem51);
// Model.HJGL_CH_HardTestReportItem newItem52 = new Model.HJGL_CH_HardTestReportItem();
// newItem52.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem52.HardTestReportId = hardTestReportId;
// newItem52.JOT_ID = jot_id;
// newItem52.TestPart = "热影响区";
// newItem52.SortIndex = 5;
// newItem52.Flag = flag;
// newItem52.HotProessTrustId = hotProessTrustId;
// newItem52.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID2).STE_Code;
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem52);
// Model.HJGL_CH_HardTestReportItem newItem53 = new Model.HJGL_CH_HardTestReportItem();
// newItem53.HardTestReportItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HardTestReportItem));
// newItem53.HardTestReportId = hardTestReportId;
// newItem53.JOT_ID = jot_id;
// newItem53.TestPart = "热影响区";
// newItem53.SortIndex = 5;
// newItem53.Flag = flag;
// newItem53.HotProessTrustId = hotProessTrustId;
// newItem53.Remark = BLL.HJGL_MaterialService.GetSteelBySteID(joint.STE_ID2).STE_Code;
// BLL.HJGL_CH_HardTestReportService.AddCH_HardTestReportItem(newItem53);
// }
// if (flag == 3) //逢3重置标识
// {
// flag = 0;
// }
// }
// }
//}
}
//更新之前硬度检验报告的热处理状态和检验数量
//Model.HJGL_CH_HardTestReport oldHardTestReport2 = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(hardTestReportId);
//if (oldHardTestReport2 != null)
//{
// hotProessStates = hotProessStates.Distinct().ToList();
// foreach (var item in hotProessStates)
// {
// hotProessState += item + ",";
// }
// hotProessState = hotProessState.Substring(0, hotProessState.LastIndexOf(","));
// oldHardTestReport2.HotProessState = hotProessState;
// oldHardTestReport2.TestCount = i;
// BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReport(oldHardTestReport2);
//}
}
/// <summary>
/// 批量处理热处理记录号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckSelect_Click ( object sender , EventArgs e )
{
string window = String . Format ( "HotProessManageItemFind.aspx" , "编辑 - " ) ;
PageContext . RegisterStartupScript ( Window3 . GetSaveStateReference ( hdItemsString . ClientID ) + Window3 . GetShowReference ( window ) ) ;
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HotProessManageItemFind.aspx", "编辑 - ")));
}
protected void rblIsPrint_SelectedIndexChanged ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
}
}