SGGL_JT/SUBQHSE/FineUIPro.Web/ProjectData/DataAnalysis/HJGLOnesPassRate.aspx.cs

175 lines
6.6 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 HJGLOnesPassRate : 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_HJGLData_HJGL on x.ProjectId equals y.ProjectId into g
orderby x.ProjectCode
select new
{
Projectid = x.ProjectId,
ProjectName = x.ProjectName,
TotalFilmNum = g.Sum(y => y.TotalFilmNum) ?? 0,
OKFilmNum = g.Sum(y => y.OKFilmNum) ?? 0,
OnesPassRate = BLL.CommonService.getRate(g.Sum(y => y.OKFilmNum) ?? 0, g.Sum(y => y.TotalFilmNum) ?? 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_HJGLData_HJGL on x.ProjectId equals y.ProjectId into g
orderby x.ProjectCode
select new
{
Projectid = x.ProjectId,
ProjectName = x.ProjectName,
TotalFilmNum = g.Sum(y => y.TotalFilmNum) ?? 0,
OKFilmNum = g.Sum(y => y.OKFilmNum) ?? 0,
OnesPassRate = BLL.CommonService.getRate(g.Sum(y => y.OKFilmNum) ?? 0, g.Sum(y => y.TotalFilmNum) ?? 0),
};
var list = Funs.LINQToDataTable(projects);
Grid1.RecordCount = list.Rows.Count;
Grid1.DataSource = list;
Grid1.DataBind();
}
}
#endregion
/// <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>();
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();
}
/// <summary>
/// 总片数
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
protected decimal Count3(object projectId)
{
decimal cout1 = 0;
if (projectId != null)
{
var getC1 = from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectId.ToString()
select new { x.CHT_TotalFilm, y.CHT_CheckDate };
if (getC1.Count() > 0)
{
cout1 = getC1.Sum(x => x.CHT_TotalFilm ?? 0);
}
}
return cout1;
}
/// <summary>
/// 合格片数
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
protected decimal Count4(object projectId)
{
decimal cout1 = 0;
if (projectId != null)
{
var getC1 = from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectId.ToString()
select new { x.CHT_PassFilm, y.CHT_CheckDate };
if (getC1.Count() > 0)
{
cout1 = getC1.Sum(x => x.CHT_PassFilm ?? 0);
}
}
return cout1;
}
/// <summary>
/// 合格率
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
protected string Count5(object projectId)
{
int cout1 = 0;
if (projectId != null)
{
var getC1 = from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectId.ToString()
select new { x.CHT_TotalFilm, y.CHT_CheckDate };
if (getC1.Count() > 0)
{
cout1 = getC1.Sum(x => x.CHT_TotalFilm ?? 0);
}
}
int cout2 = 0;
if (projectId != null)
{
var getC1 = from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
where y.ProjectId == projectId.ToString()
select new { x.CHT_PassFilm, y.CHT_CheckDate };
if (getC1.Count() > 0)
{
cout2 = getC1.Sum(x => x.CHT_PassFilm ?? 0);
}
}
return BLL.CommonService.getRate(cout2, cout1);
}
}
}