2022-09-05 16:36:31 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
2024-01-25 17:24:20 +08:00
using System.Linq ;
2024-03-07 16:12:32 +08:00
using System.Web ;
2022-09-05 16:36:31 +08:00
namespace FineUIPro.Web.HSSE.Check
{
public partial class OfficeCheck : PageBase
{
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
BindGrid ( ) ;
}
}
/// <summary>
/// 绑定明细
/// </summary>
public void BindGrid ( )
{
2024-01-25 17:24:20 +08:00
string strSql = @ "SELECT (CASE WHEN Rectify.States=1 THEN '待整改' WHEN Rectify.States=2 THEN '待确认' WHEN Rectify.States=3 THEN '已完成' ELSE '待签发' END) AS StatesName,
Rectify . RectifyCode , Item . RectifyItemId , Item . RectifyId , Item . WrongContent , Item . Requirement , Item . LimitTime , Item . RectifyResults , Item . IsRectify , Rectify . States , Rectify . ProjectId
FROM ProjectSupervision_RectifyItem AS Item
LEFT JOIN ProjectSupervision_Rectify AS Rectify ON Rectify . RectifyId = Item . RectifyId
WHERE Rectify . States ! = '0' AND Rectify . States IS NOT NULL ";
2022-09-05 16:36:31 +08:00
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
2024-01-25 17:24:20 +08:00
strSql + = " AND Rectify.ProjectId = @ProjectId" ;
strSql + = " AND Item.IsRectify = @IsRectify" ;
2022-09-05 16:36:31 +08:00
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
2024-01-25 17:24:20 +08:00
listStr . Add ( new SqlParameter ( "@IsRectify" , this . rbStates . SelectedValue ) ) ;
2022-09-05 16:36:31 +08:00
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
}
/// <summary>
/// 状态筛选事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void rbStates_SelectedIndexChanged ( object sender , EventArgs e )
{
BindGrid ( ) ;
2024-01-25 17:24:20 +08:00
if ( this . rbStates . SelectedValue = = "1" )
{
this . btnSubmit . Hidden = true ;
}
else
{
this . btnSubmit . Hidden = false ;
}
2022-09-05 16:36:31 +08:00
}
/// <summary>
/// Grid行点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowCommand ( object sender , GridCommandEventArgs e )
{
string itemId = Grid1 . DataKeys [ e . RowIndex ] [ 0 ] . ToString ( ) ;
if ( e . CommandName = = "AttachUrl" )
{
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Rectify&menuId={1}&type=0&strParam=1" , itemId , BLL . Const . CheckInfoMenuId ) ) ) ;
}
if ( e . CommandName = = "ReAttachUrl" )
{
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Rectify&menuId={1}&type=0&strParam=2" , itemId , BLL . Const . CheckInfoMenuId ) ) ) ;
var item = BLL . ProjectSupervision_RectifyItemService . GeRectifyItemById ( itemId ) ;
if ( item ! = null )
{
item . States = "1" ;
Funs . DB . SubmitChanges ( ) ;
}
int i = 0 ;
var lists = BLL . ProjectSupervision_RectifyItemService . GetRectifyItemByRectifyId ( item . RectifyId ) ;
foreach ( var j in lists )
{
if ( j . States = = "1" )
{
i + + ;
}
}
if ( i = = lists . Count )
{
var rectify = BLL . ProjectSupervision_RectifyService . GetRectifyById ( item . RectifyId ) ;
if ( rectify ! = null )
{
rectify . States = BLL . Const . State_2 ;
BLL . ProjectSupervision_RectifyService . UpdateRectify ( rectify ) ;
}
}
}
}
2024-01-25 17:24:20 +08:00
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSubmit_Click ( object sender , EventArgs e )
2025-10-10 14:33:21 +08:00
{
2024-01-25 17:24:20 +08:00
if ( Grid1 . SelectedRowIndexArray . Length > 0 )
{
foreach ( int rowIndex in Grid1 . SelectedRowIndexArray )
{
string rowID = Grid1 . DataKeys [ rowIndex ] [ 0 ] . ToString ( ) . Split ( ',' ) [ 0 ] ;
var getV = Funs . DB . ProjectSupervision_RectifyItem . FirstOrDefault ( x = > x . RectifyItemId = = rowID ) ;
if ( getV ! = null )
{
var getR = Funs . DB . ProjectSupervision_Rectify . FirstOrDefault ( x = > x . RectifyId = = getV . RectifyId ) ;
if ( getR ! = null & & getR . States ! = Const . State_3 )
{
getR . States = BLL . Const . State_2 ;
Funs . DB . SubmitChanges ( ) ;
2025-10-10 14:33:21 +08:00
}
2024-01-25 17:24:20 +08:00
}
}
BindGrid ( ) ;
ShowNotify ( "数据已提交成功!" ) ;
}
}
2024-03-07 16:12:32 +08:00
/// <summary>
/// 获取整改前图片(放于Img中)
/// </summary>
/// <param name="registrationId"></param>
/// <returns></returns>
protected string ConvertImageUrlByImage ( object RectifyItemId )
{
string url = string . Empty ;
if ( RectifyItemId ! = null )
{
var RectifyNoticesItem = BLL . AttachFileService . GetAttachFileByToKeyId ( RectifyItemId . ToString ( ) + "#1" ) ;
if ( RectifyNoticesItem ! = null )
{
url = HttpUtility . HtmlDecode ( BLL . UploadAttachmentService . ShowImage ( "../../" , RectifyNoticesItem . AttachUrl ) ) ;
}
}
return url ;
}
/// <summary>
/// 获取整改后图片
/// </summary>
/// <param name="registrationId"></param>
/// <returns></returns>
protected string ConvertImageUrlByImage2 ( object RectifyItemId )
{
string url = string . Empty ;
if ( RectifyItemId ! = null )
{
var RectifyNoticesItem = BLL . AttachFileService . GetAttachFileByToKeyId ( RectifyItemId . ToString ( ) + "#2" ) ;
if ( RectifyNoticesItem ! = null )
{
url = BLL . UploadAttachmentService . ShowImage ( "../../" , RectifyNoticesItem . AttachUrl ) ;
}
}
return url ;
}
2022-09-05 16:36:31 +08:00
}
}