SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/Hazard/ConstructionRiskMap.aspx.cs

118 lines
5.4 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.Services;
namespace FineUIPro.Web.ProjectData
{
public partial class ConstructionRiskMap : PageBase
{
public string Coordinate = "";
public string ProjectCode = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strSql = @"SELECT b.[MainItemId],b.[Coordinate],b.[MainItemName],count(*) num ,max(case when RiskLevel='低风险' then 1 when RiskLevel='一般风险' then 2 when RiskLevel='较大风险' then 3 else 4 end) RiskLevel
FROM [dbo].[HSSE_ConstructionRisk] a left join [dbo].[ProjectData_MainItem] b on a.[WorkAreaId]=b.[MainItemId]
where a.ProjectId=@ProjectId and a.States='4'
group by b.[MainItemId],b.[Coordinate],b.[MainItemName]";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
foreach (DataRow row in tb.Rows)
{
Coordinate += row["MainItemId"].ToString() + ";" + row["MainItemName"].ToString() + ";" + row["num"].ToString() + ";" + row["Coordinate"].ToString() + ";" + row["RiskLevel"].ToString() + ",";
}
Coordinate = Coordinate.TrimEnd(',');
ProjectCode = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId);
}
}
[WebMethod]
public static string getRisk(string WorkAreaId, string RiskLevel)
{
string res = "";
string strSql = @"SELECT [ConstructionRiskId]
,b.UnitName
,[ConstructionContent]
,[RefLicense]
,[LicenseDes]
,[RiskLevel]
,[States]
,[DateA]
,[DateZ]
,[DateWeek]
,[ProjectId]
,[Coordinate]
FROM [dbo].[HSSE_ConstructionRisk] a left join Base_Unit b on a.[UnitId] = b.[UnitId]
where a.WorkAreaId=@WorkAreaId and a.States='4'
";
//if (!string.IsNullOrEmpty(RiskLevel))
//{
// strSql += " and RiskLevel='" + RiskLevel + "'";
//}
if (!string.IsNullOrEmpty(RiskLevel))
{
//strSql += " and RiskLevel='" + drpRiskLevel.SelectedValue + "' ";
strSql += " and '" + RiskLevel + "' like '%'+RiskLevel+'%' ";
}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@WorkAreaId", WorkAreaId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
foreach (DataRow row in tb.Rows)
{
res += row["ConstructionRiskId"].ToString() + ";" + row["UnitName"].ToString() + ";" + Funs.GetNewDateTimeOrNow(row["DateA"].ToString()).ToString("yyyy-MM-dd") + "至" + Funs.GetNewDateTimeOrNow(row["DateZ"].ToString()).ToString("yyyy-MM-dd") + ";" + row["RiskLevel"].ToString() + ";" + row["ConstructionContent"].ToString() + ";" + row["Coordinate"].ToString() + ",";
}
res = res.TrimEnd(',');
return res;
}
protected void drpRiskLevel_SelectedIndexChanged(object sender, EventArgs e)
{
string riskLevel = "";
string strSql = @"SELECT b.[MainItemId],b.[Coordinate],b.[MainItemName],count(*) num ,max(case when RiskLevel='低风险' then 1 when RiskLevel='一般风险' then 2 when RiskLevel='较大风险' then 3 else 4 end) RiskLevel
FROM [dbo].[HSSE_ConstructionRisk] a left join [dbo].[ProjectData_MainItem] b on a.[WorkAreaId]=b.[MainItemId]
where a.ProjectId=@ProjectId and a.States='4'
";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
if (drpRiskLevel.SelectedItemArray.Length == 1 && this.drpRiskLevel.SelectedValue == string.Empty)
{
}
else
{
foreach (var item in this.drpRiskLevel.SelectedValueArray)
{
riskLevel += item + ",";
}
//strSql += " and RiskLevel='" + drpRiskLevel.SelectedValue + "' ";
strSql += " and '"+riskLevel+"' like '%'+RiskLevel+'%' ";
}
strSql += " group by b.[MainItemId],b.[Coordinate],b.[MainItemName] ";
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
foreach (DataRow row in tb.Rows)
{
Coordinate += row["MainItemId"].ToString() + ";" + row["MainItemName"].ToString() + ";" + row["num"].ToString() + ";" + row["Coordinate"].ToString() + ";" + row["RiskLevel"].ToString() + ",";
}
Coordinate = Coordinate.TrimEnd(',');
PageContext.RegisterStartupScript(" setRiskLevel('" + riskLevel + "'); clearOverlays() ; drawMap('" + Coordinate + "') ");
}
}
}