成达修改20230724
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using BLL;
|
||||
using BLL.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
@@ -367,29 +369,79 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.ClearContent();
|
||||
|
||||
string strSql = @"select CodeRecords.Code 清单编号, HazardList.VersionNo 版本号, WorkStage .WorkStageName 工作阶段, HazardList.WorkAreaName 单位工程, HazardList.IdentificationDate 评估时间,
|
||||
ControllingPersonUsers.UserName AS 风险责任人 , Users.UserName 编制人 , HazardList.CompileDate 编制日期,
|
||||
(CASE WHEN HazardList.States = 0 OR HazardList.States IS NULL THEN '待['+OperateUser.UserName+']提交' WHEN HazardList.States = 2 THEN '审核/审批完成' ELSE '待['+OperateUser.UserName+']办理' END) AS 状态,
|
||||
SupHazardListType.HazardListTypeName 危险源类别, HazardListType.HazardListTypeName 危险源项, HazardItems 危险因素明细,DefectsType 缺陷类型, MayLeadAccidents 可能导致的事故,
|
||||
HelperMethod 辅助方法, HazardJudge_L L,HazardJudge_E E,HazardJudge_C C, HazardJudge_D D, HazardLevel 危险级别, ControlMeasures 控制措施
|
||||
from Hazard_HazardList AS HazardList
|
||||
LEFT JOIN Sys_FlowOperate AS FlowOperate ON HazardList.HazardListId=FlowOperate.DataId AND FlowOperate.IsClosed <> 1
|
||||
LEFT JOIN Sys_User AS OperateUser ON FlowOperate.OperaterId=OperateUser.UserId
|
||||
LEFT JOIN Sys_User AS Users ON HazardList.CompileMan=Users.UserId
|
||||
LEFT JOIN Sys_User AS ControllingPersonUsers ON HazardList.ControllingPerson=ControllingPersonUsers.UserId
|
||||
LEFT JOIN Sys_CodeRecords AS CodeRecords ON HazardList.HazardListId=CodeRecords.DataId
|
||||
LEFT JOIN Hazard_HazardSelectedItem AS Item ON Item.HazardListId = HazardList.HazardListId
|
||||
LEFT JOIN Technique_HazardListType AS HazardListType ON HazardListType.HazardListTypeId=Item.HazardListTypeId
|
||||
LEFT JOIN Technique_HazardListType AS SupHazardListType ON HazardListType.HazardListTypeId=SupHazardListType.HazardListTypeId
|
||||
LEFT JOIN Base_WorkStage AS WorkStage on WorkStage.WorkStageId = Item.WorkStage
|
||||
WHERE 1=1 ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
strSql += " AND HazardList.ProjectId = @ProjectId";
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值
|
||||
{
|
||||
listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
|
||||
strSql += " AND HazardList.States = @States"; ///状态为已完成
|
||||
listStr.Add(new SqlParameter("@States", BLL.Const.State_2));
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtHazardListCode.Text.Trim()))
|
||||
{
|
||||
strSql += " AND HazardListCode LIKE @HazardListCode";
|
||||
listStr.Add(new SqlParameter("@HazardListCode", "%" + this.txtHazardListCode.Text.Trim() + "%"));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
tb.TableName = "风险评估";
|
||||
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 = Grid1.RecordCount;
|
||||
this.BindGrid();
|
||||
|
||||
string uploadfilepath = Server.MapPath("~/") + filename;
|
||||
NPOIHelper.DataSetToExcel(tb, uploadfilepath);
|
||||
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
string fileName = Path.GetFileName(filename);
|
||||
FileInfo info = new FileInfo(uploadfilepath);
|
||||
if (info.Exists)
|
||||
{
|
||||
long fileSize = info.Length;
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/x-zip-compressed";
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("风险评估" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("文件不存在!", MessageBoxIcon.Warning);
|
||||
}
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
|
||||
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#pragma warning disable CS0108 // “HazardList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||||
/// <summary>
|
||||
/// 导出方法
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
private string GetGridTableHtml(Grid grid)
|
||||
#pragma warning restore CS0108 // “HazardList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
if (this.drpHazardLevel.Items[i].Selected)
|
||||
{
|
||||
if (hazardTemplate.HazardLevel.ToString() == this.drpHazardLevel.Items[i].Value)
|
||||
if (hazardTemplate.HazardLevel == this.drpHazardLevel.Items[i].Value)
|
||||
{
|
||||
newHazardTemplates2.Add(hazardTemplate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user