2022-09-05 16:36:31 +08:00
using BLL ;
using Newtonsoft.Json.Linq ;
using System ;
using System.Data ;
using System.Data.SqlClient ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web.UI.WebControls ;
using AspNet = System . Web . UI . WebControls ;
namespace FineUIPro.Web.CQMS.Material
{
public partial class InspectionView : PageBase
{
/// <summary>
/// 主键
/// </summary>
public string InspectionId
{
get
{
return ( string ) ViewState [ "InspectionId" ] ;
}
set
{
ViewState [ "InspectionId" ] = value ;
}
}
/// <summary>
/// 办理类型
/// </summary>
public string State
{
get
{
return ( string ) ViewState [ "State" ] ;
}
set
{
ViewState [ "State" ] = value ;
}
}
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
BLL . UnitService . GetUnit ( this . drpUnit , this . CurrUser . LoginProjectId , true ) ;
InspectionId = Request . Params [ "InspectionId" ] ;
if ( ! string . IsNullOrEmpty ( InspectionId ) )
{
Model . Material_Inspection inspection = BLL . CQMS_InspectionService . GetInspectionByInspectionId ( InspectionId ) ;
txtInspectionCode . Text = inspection . InspectionCode ;
if ( ! string . IsNullOrEmpty ( inspection . UnitId ) )
{
drpUnit . SelectedValue = inspection . UnitId ;
}
if ( inspection . IsSpotCheck ! = null )
{
if ( inspection . IsSpotCheck = = true )
{
this . rblIsSpotCheck . SelectedValue = "True" ;
}
else
{
this . rblIsSpotCheck . SelectedValue = "False" ;
}
}
if ( inspection . IsNoticeAndSupervision ! = null )
{
if ( inspection . IsNoticeAndSupervision = = true )
{
this . rblIsNoticeAndSupervision . SelectedValue = "True" ;
}
else
{
this . rblIsNoticeAndSupervision . SelectedValue = "False" ;
}
}
BindData ( inspection . InspectionType ) ;
gvApprove . DataSource = BLL . CQMS_InspectionApproveService . getListData ( this . InspectionId ) ;
gvApprove . DataBind ( ) ;
}
}
}
private void BindData ( string type )
{
if ( type = = "M" ) //材料报验
{
string strSql = @ "select C.*,C.MaterialId as Id,M.MainItemName,U.UnitName from [dbo].[Material_Material] C
left join [ dbo ] . [ ProjectData_MainItem ] M on C . MainItemId = M . MainItemId
left join [ dbo ] . [ Base_Unit ] U on U . UnitId = C . UnitId where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
strSql + = " AND C.InspectionId = @InspectionId" ;
listStr . Add ( new SqlParameter ( "@InspectionId" , this . InspectionId ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
Grid1 . RecordCount = tb . Rows . Count ;
tb = GetFilteredTable ( Grid1 . FilteredData , tb ) ;
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
}
else
{
string strSql = @ "select C.*,C.EquipmentId as Id,C.EquipmentName as MaterialName,C.EquipmentCode as MaterialCode,M.MainItemName,U.UnitName from [dbo].[Material_Equipment] C
left join [ dbo ] . [ ProjectData_MainItem ] M on C . MainItemId = M . MainItemId
left join [ dbo ] . [ Base_Unit ] U on U . UnitId = C . UnitId where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
strSql + = " AND C.InspectionId = @InspectionId" ;
listStr . Add ( new SqlParameter ( "@InspectionId" , this . InspectionId ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
Grid1 . RecordCount = tb . Rows . Count ;
tb = GetFilteredTable ( Grid1 . FilteredData , tb ) ;
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
this . Grid1 . Columns [ 4 ] . HeaderText = "设备名称" ;
this . Grid1 . Columns [ 6 ] . HeaderText = "设备位号" ;
this . Grid1 . Columns [ 7 ] . Hidden = true ;
}
}
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
}
protected void WindowAtt_Close ( object sender , WindowCloseEventArgs e )
{
}
/// <summary>
/// 时间转换
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public string ConvertDate ( object date )
{
if ( date ! = null )
{
return string . Format ( "{0:yyyy-MM-dd}" , Convert . ToDateTime ( date ) ) ;
}
else
{
return null ;
}
}
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
protected string ConvertState ( object state )
{
if ( state ! = null )
{
if ( state . ToString ( ) = = BLL . Const . Inspection_ReCompile )
{
return "重新编制" ;
}
else if ( state . ToString ( ) = = BLL . Const . Inspection_Compile )
{
return "编制" ;
}
else if ( state . ToString ( ) = = BLL . Const . Inspection_Audit1 )
{
2023-02-23 09:37:24 +08:00
return "总包专业工程师审批" ;
2022-09-05 16:36:31 +08:00
}
else if ( state . ToString ( ) = = BLL . Const . Inspection_Audit2 )
{
return "监理工程师审批" ;
}
else if ( state . ToString ( ) = = BLL . Const . Inspection_SpotCheck )
{
return "正在抽检" ;
}
else if ( state . ToString ( ) = = BLL . Const . Inspection_Complete )
{
return "审批完成" ;
}
else
{
return "" ;
}
}
return "" ;
}
protected void imgBtnFile_Click ( object sender , EventArgs e )
{
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/Material&menuId={1}" , this . InspectionId , BLL . Const . InspectionMenuId ) ) ) ;
}
private string GetStringByArray ( string [ ] array )
{
string str = string . Empty ;
foreach ( var item in array )
{
if ( item ! = BLL . Const . _Null )
{
str + = item + "," ;
}
}
if ( ! string . IsNullOrEmpty ( str ) )
{
str = str . Substring ( 0 , str . LastIndexOf ( "," ) ) ;
}
return str ;
}
}
}