20260907 安全管理数据
This commit is contained in:
@@ -0,0 +1,435 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.ReportManage.SafeEnvBudget
|
||||
{
|
||||
public partial class SafetyManagementData : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载页面
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
////权限按钮方法
|
||||
this.GetButtonPower();
|
||||
btnNew.OnClientClick = Window1.GetShowReference("SafetyManagementDataEdit.aspx") + "return false;";
|
||||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
private DataTable GetSourceDataTable()
|
||||
{
|
||||
string strSql = @" select s.DataId,
|
||||
s.ProjectId,
|
||||
s.UnitId,
|
||||
s.ReportDate,
|
||||
s.ConAndEPCCount,
|
||||
s.SurveyAndDesignCount,
|
||||
s.WorkingHours,
|
||||
s.SafeDrivingMileage,
|
||||
s.SubSupervise_InspectionItems,
|
||||
s.SubSupervise_Inspections,
|
||||
s.SubSupervise_HSE_Total,
|
||||
s.SubSupervise_HSE_Larger,
|
||||
s.SubSupervise_HSE_Generally,
|
||||
s.SubSupervise_HSE_Slight,
|
||||
s.SubSupervise_Quality_Total,
|
||||
s.SubSupervise_Quality_Larger,
|
||||
s.SubSupervise_Quality_Generally,
|
||||
s.SubSupervise_Quality_Slight,
|
||||
s.SubVideo_InspectionItems,
|
||||
s.SubVideo_InspectionsMin,
|
||||
s.SubVideo_HSE_Total,
|
||||
s.SubVideo_HSE_Larger,
|
||||
s.SubVideo_HSE_Generally,
|
||||
s.SubVideo_HSE_Slight,
|
||||
s.SubVideo_Quality_Total,
|
||||
s.SubVideo_Quality_Larger,
|
||||
s.SubVideo_Quality_Generally,
|
||||
s.SubVideo_Quality_Slight,
|
||||
s.HQ_InspectionItems,
|
||||
s.HQ_Inspections,
|
||||
s.HQ_HSE_Total,
|
||||
s.HQ_HSE_Larger,
|
||||
s.HQ_HSE_Generally,
|
||||
s.HQ_HSE_Slight,
|
||||
s.HQ_Quality_Total,
|
||||
s.HQ_Quality_Larger,
|
||||
s.HQ_Quality_Generally,
|
||||
s.HQ_Quality_Slight,
|
||||
s.Quality_Employee_Count,
|
||||
s.Quality_Employee_Score,
|
||||
s.Quality_Contractor_Count,
|
||||
s.Quality_Contractor_Score,
|
||||
s.Quality_Employee_Fine,
|
||||
s.Quality_Employee_FineAmount,
|
||||
s.Quality_Contractor_Fine,
|
||||
s.Quality_Contractor_FineAmount,
|
||||
s.Quality_Contractor_Deduction,
|
||||
s.Quality_Contractor_DeductionAmount,
|
||||
s.Quality_ProjectDepartment_Fine,
|
||||
s.Quality_ProjectDepartment_FineAmount,
|
||||
s.HSE_Employee_Count,
|
||||
s.HSE_Employee_Score,
|
||||
s.HSE_Contractor_Count,
|
||||
s.HSE_Contractor_Score,
|
||||
s.HSE_Employee_Fine,
|
||||
s.HSE_Employee_FineAmount,
|
||||
s.HSE_Contractor_Fine,
|
||||
s.HSE_Contractor_FineAmount,
|
||||
s.HSE_Contractor_Deduction,
|
||||
s.HSE_Contractor_DeductionAmount,
|
||||
s.HSE_ProjectDepartment_Fine,
|
||||
s.HSE_ProjectDepartment_FineAmount,
|
||||
s.LeaderSupervision_HSECheck_Leaders,
|
||||
s.LeaderSupervision_HSECheck_Count,
|
||||
s.LeaderSupervision_HSECheck_Hazards,
|
||||
s.LeaderSupervision_SafetyLectures_Leaders,
|
||||
s.LeaderSupervision_SafetyLectures_Count,
|
||||
s.LeaderSupervision_SafetyLectures_Attendees,
|
||||
s.LeaderSupervision_Activities_Leaders,
|
||||
s.LeaderSupervision_Activities_Count,
|
||||
s.HSEMeasures_OfficesCount,
|
||||
s.HSEMeasures_TrainingBooths,
|
||||
s.HSEMeasures_Toolboxs,
|
||||
s.HSEMeasures_Consultant_Projects,
|
||||
s.HSEMeasures_Consultant_Count,
|
||||
s.HSEMeasures_FiveStar_Star2,
|
||||
s.HSEMeasures_FiveStar_Star3,
|
||||
s.HSEMeasures_FiveStar_Star4,
|
||||
s.HSEMeasures_FiveStar_Star5,
|
||||
s.HSEMeasures_Contractor_Interviewees,
|
||||
s.HSEMeasures_PilotProject_Headquarters,
|
||||
s.HSEMeasures_PilotProject_Branch,
|
||||
s.Construction_Teams_Totals,
|
||||
s.Construction_Teams_Compliant,
|
||||
s.Construction_ModelTeams_Headquarters,
|
||||
s.Construction_ModelTeams_CPECC,
|
||||
s.Construction_ModelTeams_Group,
|
||||
s.HSETraining_ThreeCategory,
|
||||
s.HSETraining_TrainingPersons,
|
||||
s.HSETraining_ContractorTraining,
|
||||
s.CompileMan,
|
||||
s.CompileDate,
|
||||
u.UnitName
|
||||
from SafetyManagementData as s
|
||||
left join Base_Unit as u on u.UnitId = s.UnitId where s.ProjectId=@projectId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
||||
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
|
||||
{
|
||||
strSql += " AND s.ReportDate >= @StartTime";
|
||||
listStr.Add(new SqlParameter("@StartTime", Funs.GetNewDateTime(this.txtStartTime.Text.Trim())));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
||||
{
|
||||
strSql += " AND s.ReportDate <= @EndTime";
|
||||
listStr.Add(new SqlParameter("@EndTime", Funs.GetNewDateTime(this.txtEndTime.Text.Trim())));
|
||||
}
|
||||
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
return tb;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
DataTable tb = GetSourceDataTable();
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 表排序、分页、关闭窗口
|
||||
/// <summary>
|
||||
/// 分页
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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 Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭弹出窗
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs 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 btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string rowId = Grid1.SelectedRowID;
|
||||
if (!string.IsNullOrEmpty(rowId))
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyManagementDataEdit.aspx?dataId={0}", rowId, "编辑 - ")));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var data = BLL.SafetyManagementDataService.GetSafetyManagementDataById(rowID);
|
||||
if (data != null)
|
||||
{
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, data.DataId, data.DataId, BLL.Const.ProjectSafetyManagementDataMenuId, BLL.Const.BtnDelete);
|
||||
BLL.SafetyManagementDataService.DeleteSafetyManagementDataByDataId(rowID);
|
||||
}
|
||||
}
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Request.Params["value"] == "0")
|
||||
{
|
||||
return;
|
||||
}
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectSafetyManagementDataMenuId);
|
||||
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.btnMenuDel.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateTime? startTime = Funs.GetNewDateTime(this.txtStartTime.Text.Trim());
|
||||
DateTime? endTime = Funs.GetNewDateTime(this.txtEndTime.Text.Trim());
|
||||
if (startTime > endTime)
|
||||
{
|
||||
Alert.ShowInTop("开始日期不能大于结束日期!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
this.BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.ClearContent();
|
||||
string fileName = System.Web.HttpUtility.UrlEncode($"安全管理数据" + Funs.GetNewFileName(), System.Text.Encoding.UTF8);
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
|
||||
DataTable dtAll = GetSourceDataTable();
|
||||
string html = GetGridMultiHeaderTableHtml(Grid1, dtAll);
|
||||
Response.Write(html);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多表头导出
|
||||
/// </summary>
|
||||
public string GetGridMultiHeaderTableHtml(Grid grid, DataTable dtSource)
|
||||
{
|
||||
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;\">");
|
||||
|
||||
MultiHeaderTable mht = new MultiHeaderTable();
|
||||
mht.ResolveMultiHeaderTable(grid.Columns);
|
||||
|
||||
foreach (List<object[]> rows in mht.MultiTable)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
foreach (object[] cell in rows)
|
||||
{
|
||||
int rowspan = Convert.ToInt32(cell[0]);
|
||||
int colspan = Convert.ToInt32(cell[1]);
|
||||
GridColumn column = cell[2] as GridColumn;
|
||||
if (column.Hidden == false)
|
||||
{
|
||||
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
|
||||
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
|
||||
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
|
||||
colspan != 1 ? " style=\"text-align:center;\"" : "",
|
||||
column.HeaderText);
|
||||
}
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
|
||||
int rowIndex = 0;
|
||||
foreach (DataRow dr in dtSource.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
foreach (GridColumn column in mht.Columns)
|
||||
{
|
||||
if (column.ColumnID == "ckbIsSelected" || column.ColumnID == "Punish" || column.ColumnID == "Del")
|
||||
continue;
|
||||
|
||||
string cellValue = "";
|
||||
if (column.ColumnID == "tfNumber")
|
||||
{
|
||||
//导出序号:全部数据的序号
|
||||
cellValue = (rowIndex + 1).ToString();
|
||||
}
|
||||
else if (column.ColumnID == "ReportDate")
|
||||
{
|
||||
cellValue = string.Format("{0:yyyy-MM}", dr[column.ColumnID]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(column.ColumnID) && dtSource.Columns.Contains(column.ColumnID))
|
||||
{
|
||||
cellValue = dr[column.ColumnID] == DBNull.Value ? "" : dr[column.ColumnID].ToString();
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("<td style=\"mso-number-format:'\\@';\">{0}</td>", System.Web.HttpUtility.HtmlEncode(cellValue));
|
||||
//sb.AppendFormat("<td>{0}</td>", System.Web.HttpUtility.HtmlEncode(cellValue));
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
rowIndex++;
|
||||
}
|
||||
sb.Append("</table>");
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user