2025-04-07 17:43:30 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
using System.Text ;
using AspNet = System . Web . UI . WebControls ;
namespace FineUIPro.Web.HSSE.InformationProject
{
public partial class LawRegulationIdentify : PageBase
{
/// <summary>
/// 项目id
/// </summary>
public string ProjectId
{
get
{
return ( string ) ViewState [ "ProjectId" ] ;
}
set
{
ViewState [ "ProjectId" ] = value ;
}
}
#region 加 载 页 面
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
this . ProjectId = this . CurrUser . LoginProjectId ;
if ( ! string . IsNullOrEmpty ( Request . Params [ "projectId" ] ) & & Request . Params [ "projectId" ] ! = this . ProjectId )
{
this . ProjectId = Request . Params [ "projectId" ] ;
}
Funs . DropDownPageSize ( this . ddlPageSize ) ;
2025-04-09 19:14:54 +08:00
this . ucTree . UnitId = this . CurrUser . UnitId ;
this . ucTree . ProjectId = this . ProjectId ;
if ( ! string . IsNullOrEmpty ( this . CurrUser . LoginProjectId ) )
{
this . panelLeftRegion . Hidden = true ;
////权限按钮方法
this . GetButtonPower ( ) ;
}
2025-04-07 17:43:30 +08:00
ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
// 绑定表格
BindGrid ( ) ;
}
}
2025-04-09 19:14:54 +08:00
/// <summary>
/// 公司级树加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void changeTree ( object sender , EventArgs e )
{
this . ProjectId = this . ucTree . ProjectId ;
this . BindGrid ( ) ;
this . GetButtonPower ( ) ;
if ( string . IsNullOrEmpty ( this . CurrUser . LoginProjectId ) )
{
btnNew . Hidden = true ;
}
}
2025-04-07 17:43:30 +08:00
#endregion
#region 绑 定 数 据
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid ( )
{
2025-04-09 19:14:54 +08:00
if ( string . IsNullOrEmpty ( this . ProjectId ) )
{
return ;
}
2025-04-07 17:43:30 +08:00
string strSql = "select LawRegulationIdentify.LawRegulationIdentifyId,LawRegulationIdentify.VersionNumber,LawRegulationIdentify.ProjectId,Users.UserName as IdentifyPersonName,LawRegulationIdentify.IdentifyDate,CodeRecords.Code AS LawRegulationIdentifyCode "
+ @" ,(CASE WHEN LawRegulationIdentify.States = " + BLL . Const . State_0 + " OR LawRegulationIdentify.States IS NULL THEN '待['+OperateUser.UserName+']提交' WHEN LawRegulationIdentify.States = " + BLL . Const . State_2 + " THEN '审核/审批完成' ELSE '待['+OperateUser.UserName+']办理' END) AS FlowOperateName"
+ @",LawRegulationIdentify.UpdateDate"
+ @" from Law_LawRegulationIdentify AS LawRegulationIdentify "
+ @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON LawRegulationIdentify.LawRegulationIdentifyId=FlowOperate.DataId AND FlowOperate.IsClosed <> 1"
+ @" LEFT JOIN Sys_User AS OperateUser ON FlowOperate.OperaterId=OperateUser.UserId "
+ @" LEFT JOIN Sys_User AS Users ON LawRegulationIdentify.IdentifyPerson=Users.UserId "
+ @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON LawRegulationIdentify.LawRegulationIdentifyId=CodeRecords.DataId WHERE 1=1 " ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
strSql + = " AND LawRegulationIdentify.ProjectId = @ProjectId" ;
if ( ! string . IsNullOrEmpty ( Request . Params [ "projectId" ] ) ) ///是否文件柜查看页面传项目值
{
listStr . Add ( new SqlParameter ( "@ProjectId" , Request . Params [ "projectId" ] ) ) ;
strSql + = " AND LawRegulationIdentify.States = @States" ; ///状态为已完成
listStr . Add ( new SqlParameter ( "@States" , BLL . Const . State_2 ) ) ;
}
else
{
2025-04-09 19:14:54 +08:00
listStr . Add ( new SqlParameter ( "@ProjectId" , this . ProjectId ) ) ;
2025-04-07 17:43:30 +08:00
}
if ( ! string . IsNullOrEmpty ( this . txtLawRegulationIdentifyCode . Text . Trim ( ) ) )
{
strSql + = " AND LawRegulationIdentifyCode LIKE @LawRegulationIdentifyCode" ;
listStr . Add ( new SqlParameter ( "@LawRegulationIdentifyCode" , "%" + this . txtLawRegulationIdentifyCode . Text . Trim ( ) + "%" ) ) ;
}
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 ( ) ;
}
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
Grid1 . PageIndex = e . NewPageIndex ;
BindGrid ( ) ;
}
/// <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 ( ) ;
}
protected void Grid1_FilterChange ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
protected void Window1_Close ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region Grid双击事件
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
btnMenuModify_Click ( null , null ) ;
}
#endregion
#region 增 加 、 修 改 、 删 除 数 据 方 法
/// <summary>
/// 增加按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click ( object sender , EventArgs e )
{
2025-04-09 19:14:54 +08:00
2025-04-07 17:43:30 +08:00
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "LawRegulationIdentifyEdit.aspx?LawRegulationIdentifyId={0}" , string . Empty , "编辑 - " ) ) ) ;
}
#region 编 辑
/// <summary>
/// 编辑按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuModify_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string LawRegulationIdentifyId = Grid1 . SelectedRowID ;
var lawRegulationIdentify = BLL . LawRegulationIdentifyService . GetLawRegulationIdentifyByLawRegulationIdentifyId ( LawRegulationIdentifyId ) ;
if ( lawRegulationIdentify ! = null )
{
if ( this . btnMenuModify . Hidden | | lawRegulationIdentify . States = = BLL . Const . State_2 ) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "LawRegulationIdentifyView.aspx?LawRegulationIdentifyId={0}" , LawRegulationIdentifyId , "查看 - " ) ) ) ;
}
else
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "LawRegulationIdentifyEdit.aspx?LawRegulationIdentifyId={0}" , LawRegulationIdentifyId , "编辑 - " ) ) ) ;
}
}
}
#endregion
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click ( object sender , EventArgs e )
{
this . DeleteData ( ) ;
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData ( )
{
if ( Grid1 . SelectedRowIndexArray . Length > 0 )
{
foreach ( int rowIndex in Grid1 . SelectedRowIndexArray )
{
string LawRegulationIdentifyId = Grid1 . DataKeys [ rowIndex ] [ 0 ] . ToString ( ) ;
var lawRegulationIdentify = BLL . LawRegulationIdentifyService . GetLawRegulationIdentifyByLawRegulationIdentifyId ( LawRegulationIdentifyId ) ;
if ( lawRegulationIdentify ! = null )
{
BLL . LogService . AddSys_Log ( this . CurrUser , lawRegulationIdentify . LawRegulationIdentifyCode , lawRegulationIdentify . LawRegulationIdentifyId , BLL . Const . LawRegulationIdentifyMenuId , BLL . Const . BtnDelete ) ;
BLL . LawRegulationSelectedItemService . DeleteLawRegulationSelectedItemByLawRegulationIdentifyId ( LawRegulationIdentifyId ) ;
BLL . LawRegulationIdentifyService . DeleteLawRegulationIdentify ( LawRegulationIdentifyId ) ;
}
}
BindGrid ( ) ;
}
}
#endregion
#region 获 取 按 钮 权 限
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower ( )
{
if ( Request . Params [ "value" ] = = "0" )
{
return ;
}
2025-04-09 19:14:54 +08:00
var buttonList = BLL . CommonService . GetAllButtonList ( this . ProjectId , this . CurrUser . UserId , BLL . Const . LawRegulationIdentifyMenuId ) ;
2025-04-07 17:43:30 +08:00
if ( buttonList . Count ( ) > 0 )
{
if ( buttonList . Contains ( BLL . Const . BtnAdd ) )
{
this . btnNew . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnModify ) )
{
this . btnMenuModify . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnDelete ) )
{
this . btnMenuDelete . Hidden = false ;
}
}
}
#endregion
#region 导 出 按 钮
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click ( object sender , EventArgs e )
{
Response . ClearContent ( ) ;
string filename = Funs . GetNewFileName ( ) ;
Response . AddHeader ( "content-disposition" , "attachment; filename=" + System . Web . HttpUtility . UrlEncode ( "法律法规辨识" + filename , System . Text . Encoding . UTF8 ) + ".xls" ) ;
Response . ContentType = "application/excel" ;
Response . ContentEncoding = System . Text . Encoding . UTF8 ;
this . Grid1 . PageSize = 500 ;
this . BindGrid ( ) ;
Response . Write ( GetGridTableHtml ( Grid1 ) ) ;
Response . End ( ) ;
}
#pragma warning disable CS0108 // “LawRegulationIdentify.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml ( Grid grid )
#pragma warning restore CS0108 // “LawRegulationIdentify.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
{
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>" ) ;
sb . Append ( "<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">" ) ;
sb . Append ( "<tr>" ) ;
foreach ( GridColumn column in grid . Columns )
{
sb . AppendFormat ( "<td>{0}</td>" , column . HeaderText ) ;
}
sb . Append ( "</tr>" ) ;
foreach ( GridRow row in grid . Rows )
{
sb . Append ( "<tr>" ) ;
foreach ( GridColumn column in grid . Columns )
{
string html = row . Values [ column . ColumnIndex ] . ToString ( ) ;
if ( column . ColumnID = = "tfNumber" )
{
html = ( row . FindControl ( "lblNumber" ) as AspNet . Label ) . Text ;
}
sb . AppendFormat ( "<td>{0}</td>" , html ) ;
}
sb . Append ( "</tr>" ) ;
}
sb . Append ( "</table>" ) ;
return sb . ToString ( ) ;
}
2025-04-09 19:14:54 +08:00
#endregion
2025-04-07 17:43:30 +08:00
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , FineUIPro . GridSortEventArgs e )
{
BindGrid ( ) ;
}
}
}