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 CQMSProblemRate : PageBase { protected void Page_Load(object sender, EventArgs e) { // 绑定表格 //this.BindGrid(); //修改日期2023-6-30 09:29:09 BindGridNew(); } #region 绑定数据 /// /// 绑定数据 /// 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_CQMSData_CQMS on x.ProjectId equals y.ProjectId into g orderby x.ProjectCode select new { Projectid = x.ProjectId, ProjectName = x.ProjectName, ProblemNum = g.Sum(y => y.ProblemNum) ?? 0, ProblemCompletedNum = g.Sum(y => y.ProblemCompletedNum) ?? 0, ProblemNotCompletedNum = g.Sum(y => y.ProblemNotCompletedNum) ?? 0, ProblemRate = BLL.CommonService.getRate(g.Sum(y => y.ProblemCompletedNum) ?? 0, g.Sum(y => y.ProblemNotCompletedNum) ?? 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_CQMSData_CQMS on x.ProjectId equals y.ProjectId into g orderby x.ProjectCode select new { Projectid = x.ProjectId, ProjectName = x.ProjectName, ProblemNum = g.Sum(y => y.ProblemNum) ?? 0, ProblemCompletedNum = g.Sum(y => y.ProblemCompletedNum) ?? 0, ProblemNotCompletedNum = g.Sum(y => y.ProblemNotCompletedNum) ?? 0, ProblemRate = BLL.CommonService.getRate(g.Sum(y => y.ProblemCompletedNum) ?? 0, g.Sum(y => y.ProblemNotCompletedNum) ?? 0), }; var list = Funs.LINQToDataTable(projects); Grid1.RecordCount = list.Rows.Count; Grid1.DataSource = list; Grid1.DataBind(); } } /// /// 绑定grid /// private void BindGridNew() { string strSql = @"select ProjectId,ProjectCode, ProjectName from Base_Project where ProjectState =1 and (isDelete IS NULL OR isDelete =0) "; List listStr = new List(); 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 /// /// 数量 /// /// /// protected int Count1(object projectId) { int cout1 = 0; if (projectId != null) { var getT = Funs.DB.Check_CheckControl.Where(x => x.ProjectId == projectId.ToString()); cout1 = getT.Count(); } return cout1; } protected int Count2(object projectId) { int cout1 = 0; if (projectId != null) { var getT = Funs.DB.Check_CheckControl.Where(x => x.ProjectId == projectId.ToString() && x.State == "7"); cout1 = getT.Count(); } return cout1; } protected int Count3(object projectId) { int cout1 = 0; if (projectId != null) { var getT = Funs.DB.Check_CheckControl.Where(x => x.ProjectId == projectId.ToString() && x.State != "7"); cout1 = getT.Count(); } return cout1; } protected string Count4(object projectId) { string rate = "0%"; if (projectId != null) { var getALL = Funs.DB.Check_CheckControl.Where(x => x.ProjectId == projectId.ToString()); var getT = getALL.Where(x => x.ProjectId == projectId.ToString() && x.State == "7"); int coutall = getALL.Count(); int cout0 = getT.Count(); if (coutall > 0) { rate = Math.Round(cout0 * 1.0 / coutall * 100, 2).ToString()+"%"; } } return rate; } } }