166 lines
6.8 KiB
C#
166 lines
6.8 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ProjectData.DataAnalysis
|
|
{
|
|
public partial class HSSERectificationRate : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// 绑定表格
|
|
this.BindGridNew();
|
|
}
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
Model.SUBQHSEDB db = Funs.DB;
|
|
var thisUnit = BLL.CommonService.GetIsThisUnit();
|
|
if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && thisUnit.UnitId != this.CurrUser.UnitId)
|
|
{
|
|
var projects = from x in db.Base_Project
|
|
where (x.ProjectState == "1" || x.ProjectState == null) && x.UnitId == this.CurrUser.UnitId
|
|
&& (x.IsDelete == null || x.IsDelete == false)
|
|
join y in db.Project_HSSEData_HSSE on x.ProjectId equals y.ProjectId into g
|
|
orderby x.ProjectCode
|
|
select new
|
|
{
|
|
Projectid = x.ProjectId,
|
|
ProjectName = x.ProjectName,
|
|
GeneralClosedNum = g.Sum(y => y.GeneralClosedNum) ?? 0,
|
|
GeneralNotClosedNum = g.Sum(y => y.GeneralNotClosedNum) ?? 0,
|
|
MajorClosedNum = g.Sum(y => y.MajorClosedNum) ?? 0,
|
|
MajorNotClosedNum = g.Sum(y => y.MajorNotClosedNum) ?? 0,
|
|
GeneralRate = BLL.CommonService.getRate(g.Sum(y => y.GeneralNotClosedNum) ?? 0, g.Sum(y => y.GeneralClosedNum) ?? 0),
|
|
MajorRate = BLL.CommonService.getRate(g.Sum(y => y.MajorNotClosedNum) ?? 0, g.Sum(y => y.MajorClosedNum) ?? 0),
|
|
|
|
};
|
|
var list = Funs.LINQToDataTable(projects);
|
|
Grid1.RecordCount = list.Rows.Count;
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
var projects = from x in db.Base_Project
|
|
where (x.ProjectState == "1" || x.ProjectState == null)
|
|
&& (x.IsDelete == null || x.IsDelete == false)
|
|
join y in db.Project_HSSEData_HSSE on x.ProjectId equals y.ProjectId into g
|
|
orderby x.ProjectCode
|
|
select new
|
|
{
|
|
Projectid = x.ProjectId,
|
|
ProjectName = x.ProjectName,
|
|
GeneralClosedNum = g.Sum(y => y.GeneralClosedNum) ?? 0,
|
|
GeneralNotClosedNum = g.Sum(y => y.GeneralNotClosedNum) ?? 0,
|
|
MajorClosedNum = g.Sum(y => y.MajorClosedNum) ?? 0,
|
|
MajorNotClosedNum = g.Sum(y => y.MajorNotClosedNum) ?? 0,
|
|
GeneralRate = BLL.CommonService.getRate(g.Sum(y => y.GeneralNotClosedNum) ?? 0, g.Sum(y => y.GeneralClosedNum) ?? 0),
|
|
MajorRate = BLL.CommonService.getRate(g.Sum(y => y.MajorNotClosedNum) ?? 0, g.Sum(y => y.MajorClosedNum) ?? 0),
|
|
|
|
};
|
|
var list = Funs.LINQToDataTable(projects);
|
|
Grid1.RecordCount = list.Rows.Count;
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGridNew()
|
|
{
|
|
string strSql = @"select ProjectId,ProjectCode, ProjectName from Base_Project where ProjectState =1 and (isDelete IS NULL OR isDelete =0) ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
string cpara = string.Empty;
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 加载数据
|
|
protected int Count2(object projectId, string type)
|
|
{
|
|
int cout1 = 0;
|
|
if (projectId != null)
|
|
{
|
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States == "3");
|
|
if (type == "0")
|
|
{
|
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|
}
|
|
else
|
|
{
|
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|
}
|
|
cout1 = getT.Count();
|
|
}
|
|
return cout1;
|
|
}
|
|
|
|
protected int Count3(object projectId, string type)
|
|
{
|
|
int cout1 = 0;
|
|
if (projectId != null)
|
|
{
|
|
|
|
var getT = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States != "3" && x.States != "-1");
|
|
|
|
if (type == "0")
|
|
{
|
|
getT = getT.Where(x => x.Risk_Level == "重大");
|
|
}
|
|
else
|
|
{
|
|
getT = getT.Where(x => x.Risk_Level == "一般");
|
|
}
|
|
cout1 = getT.Count();
|
|
}
|
|
return cout1;
|
|
}
|
|
|
|
protected string Count4(object projectId, string type)
|
|
{
|
|
string rate = "0%";
|
|
if (projectId != null)
|
|
{
|
|
var getALL = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId == projectId.ToString() && x.ProblemTypes == "1" && x.States != "-1");
|
|
if (type == "0")
|
|
{
|
|
getALL = getALL.Where(x => x.Risk_Level == "重大");
|
|
}
|
|
else
|
|
{
|
|
getALL = getALL.Where(x => x.Risk_Level == "一般");
|
|
}
|
|
var getT = getALL.Where(x => x.ProjectId == projectId.ToString() && x.States == "3");
|
|
int coutall = getALL.Count();
|
|
int cout0 = getT.Count();
|
|
if (coutall > 0)
|
|
{
|
|
rate = Math.Round(cout0 * 1.0 / coutall * 100, 2).ToString()+"%";
|
|
}
|
|
}
|
|
return rate;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |