857 lines
		
	
	
		
			51 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			857 lines
		
	
	
		
			51 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | ||
| using System.Collections;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Data;
 | ||
| using System.Data.SqlClient;
 | ||
| using System.Linq;
 | ||
| using System.Text;
 | ||
| using System.Web.Services.Description;
 | ||
| using BLL;
 | ||
| using Newtonsoft.Json.Linq;
 | ||
| using NPOI.SS.Formula.Functions;
 | ||
| 
 | ||
| namespace FineUIPro.Web.Transfer.Chart
 | ||
| {
 | ||
|     public partial class PunchlistFromChartNew : PageBase
 | ||
|     {
 | ||
|         protected void Page_Load(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (!IsPostBack)
 | ||
|             {
 | ||
|                 ddlSubSysNo.Hidden = true;
 | ||
|                 ddlDateType.Hidden = true;
 | ||
|                 drpChartType.Hidden = true;
 | ||
|                 BtnAnalyse.Hidden = true;
 | ||
| 
 | ||
|                 var systemNos = Funs.DB.Transfer_PunchlistFrom.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).GroupBy(p => new { p.Sub_Sys_No }).Select(p => new { SubSysNo = p.Key.Sub_Sys_No }).ToList();
 | ||
|                 int indexRow = 1;
 | ||
|                 ddlSubSysNo.Items.Insert(0, new FineUIPro.ListItem("ALL", ""));
 | ||
|                 foreach (var t in systemNos)
 | ||
|                 {
 | ||
|                     ddlSubSysNo.Items.Insert(indexRow, new FineUIPro.ListItem(t.SubSysNo, t.SubSysNo));
 | ||
|                     indexRow++;
 | ||
|                 }
 | ||
|                 AnalyseData();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// x轴30天日期
 | ||
|         /// </summary>
 | ||
|         public string AllxDate;
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 当天计划完成量
 | ||
|         /// </summary>
 | ||
|         public string wcl1;
 | ||
|         /// <summary>
 | ||
|         /// 当天实际完成量
 | ||
|         /// </summary>
 | ||
|         public string wcl2;
 | ||
|         /// <summary>
 | ||
|         /// 累计计划完成量
 | ||
|         /// </summary>
 | ||
|         public string wcl3;
 | ||
|         /// <summary>
 | ||
|         /// 累计实际完成量
 | ||
|         /// </summary>
 | ||
|         public string wcl4;
 | ||
|         /// <summary>
 | ||
|         /// 统计方法
 | ||
|         /// </summary>
 | ||
|         private void AnalyseData()
 | ||
|         {
 | ||
|             string _systemNo = ddlSubSysNo.SelectedValue;
 | ||
|             if (_systemNo == null)
 | ||
|                 _systemNo = "";
 | ||
|             _systemNo = _systemNo.Trim();
 | ||
|             //_systemNo为空则查全部
 | ||
|             var forms = from x in Funs.DB.Transfer_PunchlistFrom
 | ||
|                         where x.ProjectId == this.CurrUser.LoginProjectId && (x.Sub_Sys_No == _systemNo || _systemNo == "")
 | ||
|                         select x;
 | ||
| 
 | ||
|             string _dateType = ddlDateType.SelectedValue;
 | ||
| 
 | ||
|             #region 按照当前日期前一周数据
 | ||
|             AllxDate = "";
 | ||
|             if (_dateType == "1")
 | ||
|             {
 | ||
|                 #region 加载尾项完成统计表(30天以内)
 | ||
|                 var nowDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
 | ||
|                 for (var i = nowDate.AddDays(-30); i <= nowDate; i = i.AddDays(1))
 | ||
|                 {
 | ||
|                     //i是日期
 | ||
| 
 | ||
|                     var d = i.Month.ToString() + "月" + i.Day.ToString() + "日";
 | ||
|                     DateTime startTime = Convert.ToDateTime(i.ToString("yyyy-MM-dd") + " 00:00:00");
 | ||
|                     DateTime endTime = Convert.ToDateTime(i.ToString("yyyy-MM-dd") + " 23:59:59");
 | ||
|                     //当天计划完成量
 | ||
|                     var dtjhwcl = forms.Where(x => x.Required_Date >= startTime && x.Required_Date <= endTime).Count();
 | ||
|                     wcl1 += "'" + dtjhwcl + "',";
 | ||
|                     //当天实际完成量
 | ||
|                     var dtsjwcl = forms.Where(x => x.Actual_Date >= startTime && x.Actual_Date <= endTime).Count();
 | ||
|                     wcl2 += "'" + dtsjwcl + "',";
 | ||
|                     //累计计划完成量
 | ||
|                     var ljjhwcl = forms.Where(x => x.Required_Date <= endTime).Count();
 | ||
|                     wcl3 += "'" + ljjhwcl + "',";
 | ||
|                     //累计实际完成量
 | ||
|                     var ljsjwcl = forms.Where(x => x.Actual_Date <= endTime).Count();
 | ||
|                     wcl4 += "'" + ljsjwcl + "',";
 | ||
| 
 | ||
|                     AllxDate += "'" + d + "',";
 | ||
|                 }
 | ||
|                 if (AllxDate.Length > 0)
 | ||
|                 {
 | ||
|                     AllxDate = AllxDate.Substring(0, AllxDate.Length - 1);
 | ||
|                     wcl1 = wcl1.Substring(0, wcl1.Length - 1);
 | ||
|                     wcl2 = wcl2.Substring(0, wcl2.Length - 1);
 | ||
|                     wcl3 = wcl3.Substring(0, wcl3.Length - 1);
 | ||
|                     wcl4 = wcl4.Substring(0, wcl4.Length - 1);
 | ||
|                 }
 | ||
|                 #endregion
 | ||
| 
 | ||
| 
 | ||
|                 /////按单位统计
 | ||
|                 //DataTable dtTime = new DataTable();
 | ||
|                 //dtTime.Columns.Add("日期", typeof(string));
 | ||
|                 //dtTime.Columns.Add("计划完成数量", typeof(string));
 | ||
|                 //dtTime.Columns.Add("实际完成数量", typeof(string));
 | ||
|                 //for (int i = 6; i >= 0; i--)
 | ||
|                 //{
 | ||
|                 //    DataRow rowTime = dtTime.NewRow();
 | ||
|                 //    DateTime QueryTime = DateTime.Now.AddDays(i * -1);
 | ||
|                 //    rowTime["日期"] = QueryTime.ToString("yyyy/MM/dd");
 | ||
|                 //    DateTime startTime = Convert.ToDateTime(QueryTime.ToString("yyyy-MM-dd") + " 00:00:00");
 | ||
|                 //    DateTime endTime = Convert.ToDateTime(QueryTime.ToString("yyyy-MM-dd") + " 23:59:59");
 | ||
|                 //    //rowTime["计划完成数量"] = forms.Where(x => x.Required_Date >= startTime && x.Required_Date <= endTime).Count();
 | ||
|                 //    //rowTime["实际完成数量"] = forms.Where(x => x.Actual_Date >= startTime && x.Actual_Date <= endTime).Count();
 | ||
|                 //    rowTime["计划完成数量"] = forms.Where(x => x.Required_Date <= endTime).Count();
 | ||
|                 //    rowTime["实际完成数量"] = forms.Where(x => x.Actual_Date <= endTime).Count();
 | ||
|                 //    dtTime.Rows.Add(rowTime);
 | ||
|                 //}
 | ||
|                 //this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项完成统计分析", this.drpChartType.SelectedValue, 1300, 550, false));
 | ||
| 
 | ||
|                 ///按单位统计
 | ||
|                 DataTable dtTime1 = new DataTable();
 | ||
|                 dtTime1.Columns.Add("日期", typeof(string));
 | ||
|                 dtTime1.Columns.Add("计划完成百分比(%)", typeof(string));
 | ||
|                 dtTime1.Columns.Add("实际完成百分比(%)", typeof(string));
 | ||
|                 for (int i = 6; i >= 0; i--)
 | ||
|                 {
 | ||
|                     DataRow rowTime = dtTime1.NewRow();
 | ||
|                     DateTime QueryTime = DateTime.Now.AddDays(i * -1);
 | ||
|                     rowTime["日期"] = QueryTime.ToString("yyyy/MM/dd");
 | ||
|                     DateTime startTime = Convert.ToDateTime(QueryTime.ToString("yyyy-MM-dd") + " 00:00:00");
 | ||
|                     DateTime endTime = Convert.ToDateTime(QueryTime.ToString("yyyy-MM-dd") + " 23:59:59");
 | ||
|                     double jhCount = forms.Where(x => x.Required_Date <= endTime).Count();
 | ||
|                     double sjCount = forms.Where(x => x.Actual_Date <= endTime).Count();
 | ||
|                     double allCount = forms.Count();
 | ||
|                     rowTime["计划完成百分比(%)"] = allCount == 0 ? "0.00" : (jhCount / allCount * 100).ToString("0.00");
 | ||
|                     rowTime["实际完成百分比(%)"] = allCount == 0 ? "0.00" : (sjCount / allCount * 100).ToString("0.00");
 | ||
|                     dtTime1.Rows.Add(rowTime);
 | ||
|                 }
 | ||
|                 this.ChartAccidentTime1.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime1, "尾项完成统计分析", this.drpChartType.SelectedValue, 1300, 550, false));
 | ||
|             }
 | ||
|             #endregion
 | ||
| 
 | ||
|             //按照当前月份到一月份的数据
 | ||
|             if (_dateType == "2")
 | ||
|             {
 | ||
|                 /////按单位统计
 | ||
|                 //DataTable dtTime = new DataTable();
 | ||
|                 //dtTime.Columns.Add("月份", typeof(string));
 | ||
|                 //dtTime.Columns.Add("计划完成数量", typeof(string));
 | ||
|                 //dtTime.Columns.Add("实际完成数量", typeof(string));
 | ||
|                 //for (int i = 1; i <= DateTime.Now.Month; i++)
 | ||
|                 //{
 | ||
|                 //    DataRow rowTime = dtTime.NewRow();
 | ||
|                 //    DateTime QueryTime =Convert.ToDateTime($"{DateTime.Now.Year.ToString()}-{i}-1 00:00:00");
 | ||
|                 //    rowTime["月份"] = QueryTime.ToString("yyyy/MM");
 | ||
|                 //    DateTime startTime = QueryTime;
 | ||
|                 //    DateTime endTime = Convert.ToDateTime(QueryTime.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") + " 23:59:59");
 | ||
|                 //    //rowTime["计划完成数量"] = forms.Where(x => x.Required_Date >= startTime && x.Required_Date <= endTime).Count();
 | ||
|                 //    //rowTime["实际完成数量"] = forms.Where(x => x.Actual_Date >= startTime && x.Actual_Date <= endTime).Count();
 | ||
|                 //    rowTime["计划完成数量"] = forms.Where(x =>  x.Required_Date <= endTime).Count();
 | ||
|                 //    rowTime["实际完成数量"] = forms.Where(x => x.Actual_Date <= endTime).Count();
 | ||
|                 //    dtTime.Rows.Add(rowTime);
 | ||
|                 //}
 | ||
|                 //this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项完成统计分析", this.drpChartType.SelectedValue, 1300, 550, false));
 | ||
| 
 | ||
|                 ///按单位统计
 | ||
|                 DataTable dtTime1 = new DataTable();
 | ||
|                 dtTime1.Columns.Add("月份", typeof(string));
 | ||
|                 dtTime1.Columns.Add("计划完成百分比(%)", typeof(string));
 | ||
|                 dtTime1.Columns.Add("实际完成百分比(%)", typeof(string));
 | ||
|                 for (int i = 1; i <= DateTime.Now.Month; i++)
 | ||
|                 {
 | ||
|                     DataRow rowTime = dtTime1.NewRow();
 | ||
|                     DateTime QueryTime = Convert.ToDateTime($"{DateTime.Now.Year.ToString()}-{i}-1 00:00:00");
 | ||
|                     rowTime["月份"] = QueryTime.ToString("yyyy/MM");
 | ||
|                     DateTime startTime = QueryTime;
 | ||
|                     DateTime endTime = Convert.ToDateTime(QueryTime.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") + " 23:59:59");
 | ||
|                     double jhCount = forms.Where(x => x.Required_Date <= endTime).Count();
 | ||
|                     double sjCount = forms.Where(x => x.Actual_Date <= endTime).Count();
 | ||
|                     double allCount = forms.Count();
 | ||
|                     rowTime["计划完成百分比(%)"] = allCount == 0 ? "0.00" : (jhCount / allCount * 100).ToString("0.00");
 | ||
|                     rowTime["实际完成百分比(%)"] = allCount == 0 ? "0.00" : (sjCount / allCount * 100).ToString("0.00");
 | ||
|                     dtTime1.Rows.Add(rowTime);
 | ||
|                 }
 | ||
|                 this.ChartAccidentTime1.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime1, "尾项完成统计分析", this.drpChartType.SelectedValue, 1300, 550, false));
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 统计分析
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void BtnAnalyse_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.AnalyseData();
 | ||
|             BindGrid1();
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 图形变换 
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void drpChartType_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.AnalyseData();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 现在日期类型
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlDateType_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.AnalyseData();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 选择System No
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlSubSysNo_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.AnalyseData();
 | ||
|             BindGrid1();
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         #region 加载
 | ||
|         #region 分页、排序
 | ||
|         /// <summary>
 | ||
|         /// 分页下拉
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | ||
|             BindGrid1();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页索引事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | ||
|         {
 | ||
|             BindGrid1();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 排序
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | ||
|         {
 | ||
|             Grid1.SortDirection = e.SortDirection;
 | ||
|             Grid1.SortField = e.SortField;
 | ||
|             BindGrid1();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页下拉
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue);
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页索引事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
 | ||
|         {
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 排序
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | ||
|         {
 | ||
|             Grid2.SortDirection = e.SortDirection;
 | ||
|             Grid2.SortField = e.SortField;
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 查询绑定数据
 | ||
|         /// </summary>
 | ||
|         public void BindGrid1()
 | ||
|         {
 | ||
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|             string _systemNo = string.Empty;
 | ||
|             _systemNo = ddlSubSysNo.SelectedValue;
 | ||
|             StringBuilder strSql = new StringBuilder("");
 | ||
|             strSql.AppendLine(" IF OBJECT_ID('tempdb..#AllPunchlistFromSortTemp1') IS NOT NULL drop table #AllPunchlistFromSortTemp1; ");
 | ||
|             strSql.AppendLine(" IF OBJECT_ID('tempdb..#PunchlistFromSortTemp1') IS NOT NULL drop table #PunchlistFromSortTemp1; ");
 | ||
|             strSql.AppendLine(" select * INTO #AllPunchlistFromSortTemp1 from  Transfer_PunchlistFrom(NOLOCK) where ProjectId=@ProjectId ");
 | ||
|             if (!string.IsNullOrWhiteSpace(_systemNo))
 | ||
|             {
 | ||
|                 strSql.AppendLine(" AND Sub_Sys_No=@SubSysNo ");
 | ||
|                 listStr.Add(new SqlParameter("@SubSysNo", _systemNo));
 | ||
|             }
 | ||
|             strSql.AppendLine(@" select Disc,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Countf, cast(0 as decimal(18, 2)) Cat_A_CountWUH, cast(0 as decimal(18, 2)) Cat_A_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Countf, cast(0 as decimal(18, 2)) Cat_B_CountWUH, cast(0 as decimal(18, 2)) Cat_B_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Countf, cast(0 as decimal(18, 2)) Cat_C_CountWUH, cast(0 as decimal(18, 2)) Cat_C_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Countf, cast(0 as decimal(18, 2)) Cat_D_CountWUH, cast(0 as decimal(18, 2)) Cat_D_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) allCount, cast(0 as decimal(18, 2)) allfinshedCount, cast(0 as decimal(18, 2)) allWUH, cast(0 as decimal(18, 2)) allBASF
 | ||
|                                  INTO #PunchlistFromSortTemp1 
 | ||
|                                  from #AllPunchlistFromSortTemp1 Group by Disc; ");
 | ||
|             strSql.AppendLine(@" update  a set 
 | ||
|                                  allCount=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc),
 | ||
|                                  allfinshedCount=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc and b.Status = 'Completed'),
 | ||
|                                  allWUH=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  allBASF=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc and (b.Verified_Date is not null or b.Verified_Date!='')),
 | ||
| 
 | ||
|                                  a.Cat_A_Count=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a')),
 | ||
| 
 | ||
|                                  a.Cat_A_Countf=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_A_CountWUH=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_A_CountBASF=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                  ,a.Cat_B_Count=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b')) ,
 | ||
| 
 | ||
|                                  a.Cat_B_Countf=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_B_CountWUH=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_B_CountBASF=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
| 
 | ||
|                                 ,a.Cat_C_Count=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c')) ,
 | ||
| 
 | ||
|                                 a.Cat_C_Countf=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_C_CountWUH=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_C_CountBASF=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 ,a.Cat_D_Count=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d')) ,
 | ||
|                                 a.Cat_D_Countf=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_D_CountWUH=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_D_CountBASF=(select count(1) from #AllPunchlistFromSortTemp1 b where a.Disc=b.Disc AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 from #PunchlistFromSortTemp1 a;");
 | ||
|             strSql.AppendLine("select *  from #PunchlistFromSortTemp1 ");
 | ||
|             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | ||
|             strSql.AppendLine(" order by Disc ");
 | ||
|             SqlParameter[] parameter = listStr.ToArray();
 | ||
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql.ToString(), parameter);
 | ||
|             Grid1.RecordCount = tb.Rows.Count;
 | ||
|             var table = this.GetPagedDataTable(Grid1, tb);
 | ||
|             Grid1.DataSource = table;
 | ||
|             Grid1.DataBind();
 | ||
| 
 | ||
|             //合计
 | ||
|             int cat_A_Count = 0;
 | ||
|             int cat_B_Count = 0;
 | ||
|             int cat_C_Count = 0;
 | ||
|             int cat_D_Count = 0;
 | ||
| 
 | ||
|             int Cat_A_Countf = 0, Cat_A_CountWUH = 0, Cat_A_CountBASF = 0,
 | ||
|                 Cat_B_Countf = 0, Cat_B_CountWUH = 0, Cat_B_CountBASF = 0,
 | ||
|                 Cat_C_Countf = 0, Cat_C_CountWUH = 0, Cat_C_CountBASF = 0,
 | ||
|                 Cat_D_Countf = 0, Cat_D_CountWUH = 0, Cat_D_CountBASF = 0,
 | ||
|                 allCount = 0, allfinshedCount = 0, allWUH = 0, allBASF = 0;
 | ||
|             foreach (DataRow row in tb.Rows)
 | ||
|             {
 | ||
|                 cat_A_Count += Convert.ToInt32(row["Cat_A_Count"]);
 | ||
|                 cat_B_Count += Convert.ToInt32(row["Cat_B_Count"]);
 | ||
|                 cat_C_Count += Convert.ToInt32(row["Cat_C_Count"]);
 | ||
|                 cat_D_Count += Convert.ToInt32(row["Cat_D_Count"]);
 | ||
|                 //
 | ||
|                 Cat_A_Countf += Convert.ToInt32(row["Cat_A_Countf"]);
 | ||
|                 Cat_A_CountWUH += Convert.ToInt32(row["Cat_A_CountWUH"]);
 | ||
|                 Cat_A_CountBASF += Convert.ToInt32(row["Cat_A_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_B_Countf += Convert.ToInt32(row["Cat_B_Countf"]);
 | ||
|                 Cat_B_CountWUH += Convert.ToInt32(row["Cat_B_CountWUH"]);
 | ||
|                 Cat_B_CountBASF += Convert.ToInt32(row["Cat_B_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_C_Countf += Convert.ToInt32(row["Cat_C_Countf"]);
 | ||
|                 Cat_C_CountWUH += Convert.ToInt32(row["Cat_C_CountWUH"]);
 | ||
|                 Cat_C_CountBASF += Convert.ToInt32(row["Cat_C_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_D_Countf += Convert.ToInt32(row["Cat_D_Countf"]);
 | ||
|                 Cat_D_CountWUH += Convert.ToInt32(row["Cat_D_CountWUH"]);
 | ||
|                 Cat_D_CountBASF += Convert.ToInt32(row["Cat_D_CountBASF"]);
 | ||
| 
 | ||
|                 allCount += Convert.ToInt32(row["allCount"]);
 | ||
|                 allfinshedCount += Convert.ToInt32(row["allfinshedCount"]);
 | ||
|                 allWUH += Convert.ToInt32(row["allWUH"]);
 | ||
|                 allBASF += Convert.ToInt32(row["allBASF"]);
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             JObject summary = new JObject();
 | ||
|             summary.Add("Disc", "合计");
 | ||
|             summary.Add("Cat_A_Count", cat_A_Count.ToString());
 | ||
|             summary.Add("Cat_B_Count", cat_B_Count.ToString());
 | ||
|             summary.Add("Cat_C_Count", cat_C_Count.ToString());
 | ||
|             summary.Add("Cat_D_Count", cat_D_Count.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_A_Countf", Cat_A_Countf.ToString());
 | ||
|             summary.Add("Cat_A_CountWUH", Cat_A_CountWUH.ToString());
 | ||
|             summary.Add("Cat_A_CountBASF", Cat_A_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_B_Countf", Cat_B_Countf.ToString());
 | ||
|             summary.Add("Cat_B_CountWUH", Cat_B_CountWUH.ToString());
 | ||
|             summary.Add("Cat_B_CountBASF", Cat_B_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_C_Countf", Cat_C_Countf.ToString());
 | ||
|             summary.Add("Cat_C_CountWUH", Cat_C_CountWUH.ToString());
 | ||
|             summary.Add("Cat_C_CountBASF", Cat_C_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_D_Countf", Cat_D_Countf.ToString());
 | ||
|             summary.Add("Cat_D_CountWUH", Cat_D_CountWUH.ToString());
 | ||
|             summary.Add("Cat_D_CountBASF", Cat_D_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("allCount", allCount.ToString());
 | ||
|             summary.Add("allfinshedCount", allfinshedCount.ToString());
 | ||
|             summary.Add("allWUH", allWUH.ToString());
 | ||
|             summary.Add("allBASF", allBASF.ToString());
 | ||
| 
 | ||
| 
 | ||
|             Grid1.SummaryData = summary;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 查询绑定数据
 | ||
|         /// </summary>
 | ||
|         public void BindGrid2()
 | ||
|         {
 | ||
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|             string _systemNo = string.Empty;
 | ||
|             _systemNo = ddlSubSysNo.SelectedValue;
 | ||
|             StringBuilder strSql = new StringBuilder("");
 | ||
|             strSql.AppendLine(" IF OBJECT_ID('tempdb..#AllPunchlistFromSortTemp2') IS NOT NULL drop table #AllPunchlistFromSortTemp2; ");
 | ||
|             strSql.AppendLine(" IF OBJECT_ID('tempdb..#PunchlistFromSortTemp2') IS NOT NULL drop table #PunchlistFromSortTemp2; ");
 | ||
|             strSql.AppendLine(" select * INTO #AllPunchlistFromSortTemp2 from  Transfer_PunchlistFrom(NOLOCK) where ProjectId=@ProjectId ");
 | ||
|             if (!string.IsNullOrWhiteSpace(_systemNo))
 | ||
|             {
 | ||
|                 strSql.AppendLine(" AND Sub_Sys_No=@SubSysNo ");
 | ||
|                 listStr.Add(new SqlParameter("@SubSysNo", _systemNo));
 | ||
|             }
 | ||
|             strSql.AppendLine(@" select Action_By,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Countf, cast(0 as decimal(18, 2)) Cat_A_CountWUH, cast(0 as decimal(18, 2)) Cat_A_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Countf, cast(0 as decimal(18, 2)) Cat_B_CountWUH, cast(0 as decimal(18, 2)) Cat_B_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Countf, cast(0 as decimal(18, 2)) Cat_C_CountWUH, cast(0 as decimal(18, 2)) Cat_C_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Countf, cast(0 as decimal(18, 2)) Cat_D_CountWUH, cast(0 as decimal(18, 2)) Cat_D_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) allCount, cast(0 as decimal(18, 2)) allfinshedCount, cast(0 as decimal(18, 2)) allWUH, cast(0 as decimal(18, 2)) allBASF
 | ||
|                                  INTO #PunchlistFromSortTemp2 
 | ||
|                                  from #AllPunchlistFromSortTemp2 Group by Action_By; ");
 | ||
|             strSql.AppendLine(@" update  a set 
 | ||
|                                  allCount=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By),
 | ||
|                                  allfinshedCount=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By and b.Status = 'Completed'),
 | ||
|                                  allWUH=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  allBASF=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By and (b.Verified_Date is not null or b.Verified_Date!='')),
 | ||
| 
 | ||
|                                  a.Cat_A_Count=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a')),
 | ||
| 
 | ||
|                                  a.Cat_A_Countf=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_A_CountWUH=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_A_CountBASF=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                  ,a.Cat_B_Count=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b')) ,
 | ||
| 
 | ||
|                                  a.Cat_B_Countf=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_B_CountWUH=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_B_CountBASF=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
| 
 | ||
|                                 ,a.Cat_C_Count=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c')) ,
 | ||
| 
 | ||
|                                 a.Cat_C_Countf=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_C_CountWUH=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_C_CountBASF=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 ,a.Cat_D_Count=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d')) ,
 | ||
|                                 a.Cat_D_Countf=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_D_CountWUH=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_D_CountBASF=(select count(1) from #AllPunchlistFromSortTemp2 b where a.Action_By=b.Action_By AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 from #PunchlistFromSortTemp2 a;");
 | ||
| 
 | ||
|             strSql.AppendLine("select *  from #PunchlistFromSortTemp2 ");
 | ||
|             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | ||
|             strSql.AppendLine(" order by Action_By ");
 | ||
|             SqlParameter[] parameter = listStr.ToArray();
 | ||
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql.ToString(), parameter);
 | ||
|             Grid2.RecordCount = tb.Rows.Count;
 | ||
|             var table = this.GetPagedDataTable(Grid2, tb);
 | ||
|             Grid2.DataSource = table;
 | ||
|             Grid2.DataBind();
 | ||
| 
 | ||
|             //合计
 | ||
|             int cat_A_Count = 0;
 | ||
|             int cat_B_Count = 0;
 | ||
|             int cat_C_Count = 0;
 | ||
|             int cat_D_Count = 0;
 | ||
| 
 | ||
|             int Cat_A_Countf = 0, Cat_A_CountWUH = 0, Cat_A_CountBASF = 0,
 | ||
|                 Cat_B_Countf = 0, Cat_B_CountWUH = 0, Cat_B_CountBASF = 0,
 | ||
|                 Cat_C_Countf = 0, Cat_C_CountWUH = 0, Cat_C_CountBASF = 0,
 | ||
|                 Cat_D_Countf = 0, Cat_D_CountWUH = 0, Cat_D_CountBASF = 0,
 | ||
|                 allCount = 0, allfinshedCount = 0, allWUH = 0, allBASF = 0;
 | ||
|             foreach (DataRow row in tb.Rows)
 | ||
|             {
 | ||
|                 cat_A_Count += Convert.ToInt32(row["Cat_A_Count"]);
 | ||
|                 cat_B_Count += Convert.ToInt32(row["Cat_B_Count"]);
 | ||
|                 cat_C_Count += Convert.ToInt32(row["Cat_C_Count"]);
 | ||
|                 cat_D_Count += Convert.ToInt32(row["Cat_D_Count"]);
 | ||
|                 //
 | ||
|                 Cat_A_Countf += Convert.ToInt32(row["Cat_A_Countf"]);
 | ||
|                 Cat_A_CountWUH += Convert.ToInt32(row["Cat_A_CountWUH"]);
 | ||
|                 Cat_A_CountBASF += Convert.ToInt32(row["Cat_A_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_B_Countf += Convert.ToInt32(row["Cat_B_Countf"]);
 | ||
|                 Cat_B_CountWUH += Convert.ToInt32(row["Cat_B_CountWUH"]);
 | ||
|                 Cat_B_CountBASF += Convert.ToInt32(row["Cat_B_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_C_Countf += Convert.ToInt32(row["Cat_C_Countf"]);
 | ||
|                 Cat_C_CountWUH += Convert.ToInt32(row["Cat_C_CountWUH"]);
 | ||
|                 Cat_C_CountBASF += Convert.ToInt32(row["Cat_C_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_D_Countf += Convert.ToInt32(row["Cat_D_Countf"]);
 | ||
|                 Cat_D_CountWUH += Convert.ToInt32(row["Cat_D_CountWUH"]);
 | ||
|                 Cat_D_CountBASF += Convert.ToInt32(row["Cat_D_CountBASF"]);
 | ||
| 
 | ||
|                 allCount += Convert.ToInt32(row["allCount"]);
 | ||
|                 allfinshedCount += Convert.ToInt32(row["allfinshedCount"]);
 | ||
|                 allWUH += Convert.ToInt32(row["allWUH"]);
 | ||
|                 allBASF += Convert.ToInt32(row["allBASF"]);
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             JObject summary = new JObject();
 | ||
|             summary.Add("Action_By", "合计");
 | ||
|             summary.Add("Cat_A_Count", cat_A_Count.ToString());
 | ||
|             summary.Add("Cat_B_Count", cat_B_Count.ToString());
 | ||
|             summary.Add("Cat_C_Count", cat_C_Count.ToString());
 | ||
|             summary.Add("Cat_D_Count", cat_D_Count.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_A_Countf", Cat_A_Countf.ToString());
 | ||
|             summary.Add("Cat_A_CountWUH", Cat_A_CountWUH.ToString());
 | ||
|             summary.Add("Cat_A_CountBASF", Cat_A_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_B_Countf", Cat_B_Countf.ToString());
 | ||
|             summary.Add("Cat_B_CountWUH", Cat_B_CountWUH.ToString());
 | ||
|             summary.Add("Cat_B_CountBASF", Cat_B_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_C_Countf", Cat_C_Countf.ToString());
 | ||
|             summary.Add("Cat_C_CountWUH", Cat_C_CountWUH.ToString());
 | ||
|             summary.Add("Cat_C_CountBASF", Cat_C_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_D_Countf", Cat_D_Countf.ToString());
 | ||
|             summary.Add("Cat_D_CountWUH", Cat_D_CountWUH.ToString());
 | ||
|             summary.Add("Cat_D_CountBASF", Cat_D_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("allCount", allCount.ToString());
 | ||
|             summary.Add("allfinshedCount", allfinshedCount.ToString());
 | ||
|             summary.Add("allWUH", allWUH.ToString());
 | ||
|             summary.Add("allBASF", allBASF.ToString());
 | ||
| 
 | ||
| 
 | ||
|             Grid2.SummaryData = summary;
 | ||
|         }
 | ||
| 
 | ||
|         protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (TabStrip1.ActiveTabIndex == 0)
 | ||
|             {
 | ||
|                 ddlSubSysNo.Hidden = true;
 | ||
|                 ddlDateType.Hidden = true;
 | ||
|                 drpChartType.Hidden = true;
 | ||
|                 BtnAnalyse.Hidden = true;
 | ||
| 
 | ||
|             }
 | ||
|             else if (TabStrip1.ActiveTabIndex == 2)
 | ||
|             {
 | ||
|                 ddlSubSysNo.Hidden = false;
 | ||
|                 ddlDateType.Hidden = true;
 | ||
|                 drpChartType.Hidden = true;
 | ||
|                 BtnAnalyse.Hidden = false;
 | ||
|                 BindGrid1();
 | ||
|             }
 | ||
|             else if (TabStrip1.ActiveTabIndex == 3)
 | ||
|             {
 | ||
|                 ddlSubSysNo.Hidden = false;
 | ||
|                 ddlDateType.Hidden = true;
 | ||
|                 drpChartType.Hidden = true;
 | ||
|                 BtnAnalyse.Hidden = false;
 | ||
|                 BindGrid2();
 | ||
|             }
 | ||
|             else if (TabStrip1.ActiveTabIndex == 4)
 | ||
|             {
 | ||
|                 ddlDateType.Hidden = true;
 | ||
|                 drpChartType.Hidden = true;
 | ||
|                 ddlSubSysNo.Hidden = true;
 | ||
|                 BtnAnalyse.Hidden = false;
 | ||
|                 BindGrid3();
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 this.AnalyseData();
 | ||
|                 ddlSubSysNo.Hidden = false;
 | ||
|                 ddlDateType.Hidden = false;
 | ||
|                 drpChartType.Hidden = false;
 | ||
|                 BtnAnalyse.Hidden = false;
 | ||
|             }
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 跟踪
 | ||
|         /// <summary>
 | ||
|         /// 数据绑定
 | ||
|         /// </summary>
 | ||
|         public void BindGrid3()
 | ||
|         {
 | ||
|             StringBuilder strSql = new StringBuilder("");
 | ||
|             strSql.AppendLine("IF OBJECT_ID('tempdb..#AllPunchlistFromProgressTemp') IS NOT NULL drop table #AllPunchlistFromProgressTemp; ");
 | ||
|             strSql.AppendLine("IF OBJECT_ID('tempdb..#PunchlistFromProgressTemp') IS NOT NULL drop table #PunchlistFromProgressTemp; ");
 | ||
| 
 | ||
|             strSql.AppendLine(" select * INTO #AllPunchlistFromProgressTemp from  Transfer_PunchlistFrom(NOLOCK) where ProjectId=@ProjectId ");
 | ||
|             //strSql.AppendLine(" select Sub_Sys_No,count(Sub_Sys_No) SystemNoCount,cast(0 as decimal(18,2)) ActualDateCount ");
 | ||
|             //strSql.AppendLine(" ,cast(0 as decimal(18,2)) ClearedByCount,cast(0 as decimal(18,2)) ConfirmedByCount,cast(0 as decimal(18,2)) VerifiedByCount ");
 | ||
|             //strSql.AppendLine(" INTO #PunchlistFromProgressTemp from #AllPunchlistFromProgressTemp where ProjectId = @ProjectId group by Sub_Sys_No ");
 | ||
|             //strSql.AppendLine(" update  a set a.ActualDateCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND isnull(b.Actual_Date,'')<>'')  ");
 | ||
|             //strSql.AppendLine(" ,a.ClearedByCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND isnull(b.Cleared_By,'')<>'') ");
 | ||
|             //strSql.AppendLine(" ,a.ConfirmedByCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND isnull(b.Confirmed_By,'')<>'')  ");
 | ||
|             //strSql.AppendLine(" ,a.VerifiedByCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND isnull(b.Verified_By,'')<>'') ");
 | ||
| 
 | ||
|             strSql.AppendLine(@" select Sub_Sys_No,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_A_Countf,cast(0 as decimal(18, 2)) Cat_A_CountPercent, cast(0 as decimal(18, 2)) Cat_A_CountWUH, cast(0 as decimal(18, 2)) Cat_A_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_B_Countf,cast(0 as decimal(18, 2)) Cat_B_CountPercent, cast(0 as decimal(18, 2)) Cat_B_CountWUH, cast(0 as decimal(18, 2)) Cat_B_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_C_Countf,cast(0 as decimal(18, 2)) Cat_C_CountPercent, cast(0 as decimal(18, 2)) Cat_C_CountWUH, cast(0 as decimal(18, 2)) Cat_C_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Count,
 | ||
|                                  cast(0 as decimal(18, 2)) Cat_D_Countf,cast(0 as decimal(18, 2)) Cat_D_CountPercent, cast(0 as decimal(18, 2)) Cat_D_CountWUH, cast(0 as decimal(18, 2)) Cat_D_CountBASF,
 | ||
|                                  cast(0 as decimal(18, 2)) allCount,cast(0 as decimal(18, 2)) allfinshedCount,cast(0 as decimal(18, 2)) allCountPercent,cast(0 as decimal(18, 2)) allWUH, cast(0 as decimal(18, 2)) allBASF
 | ||
|                                  INTO #PunchlistFromProgressTemp 
 | ||
|                                  from #AllPunchlistFromProgressTemp Group by Sub_Sys_No; ");
 | ||
|             strSql.AppendLine(@" update  a set 
 | ||
|                                  allCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No),
 | ||
|                                  allfinshedCount=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No and b.Status = 'Completed'),
 | ||
|                                  allWUH=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  allBASF=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No and (b.Verified_Date is not null or b.Verified_Date!='')),
 | ||
| 
 | ||
|                                  a.Cat_A_Count=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a')),
 | ||
| 
 | ||
|                                  a.Cat_A_Countf=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_A_CountWUH=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_A_CountBASF=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='A' or isnull(b.Cat,'')='a') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                  ,a.Cat_B_Count=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b')) ,
 | ||
| 
 | ||
|                                  a.Cat_B_Countf=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and b.Status = 'Completed'),
 | ||
|                                  a.Cat_B_CountWUH=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                  a.Cat_B_CountBASF=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='B' or isnull(b.Cat,'')='b') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
| 
 | ||
|                                 ,a.Cat_C_Count=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c')) ,
 | ||
| 
 | ||
|                                 a.Cat_C_Countf=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_C_CountWUH=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_C_CountBASF=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='C' or isnull(b.Cat,'')='c') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 ,a.Cat_D_Count=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d')) ,
 | ||
|                                 a.Cat_D_Countf=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and b.Status = 'Completed'),
 | ||
|                                 a.Cat_D_CountWUH=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Confirmed_Date is not null or b.Confirmed_Date!='')),
 | ||
|                                 a.Cat_D_CountBASF=(select count(1) from #AllPunchlistFromProgressTemp b where a.Sub_Sys_No=b.Sub_Sys_No AND (isnull(b.Cat,'')='D' or isnull(b.Cat,'')='d') and (b.Verified_Date is not null or b.Verified_Date!=''))
 | ||
| 
 | ||
|                                 from #PunchlistFromProgressTemp a;");
 | ||
| 
 | ||
| 
 | ||
|             strSql.AppendLine(@" update a set 
 | ||
|                                 a.Cat_A_CountPercent=(case ISNULL(a.Cat_A_Count,0) when 0 then 0 else  CONVERT(DECIMAL(10,2),100*(ISNULL(a.Cat_A_Countf,0)*1.0/ISNULL(a.Cat_A_Count,0)))  end ),
 | ||
|                                 a.Cat_B_CountPercent=(case ISNULL(a.Cat_B_Count,0) when 0 then 0 else  CONVERT(DECIMAL(10,2),100*(ISNULL(a.Cat_B_Countf,0)*1.0/ISNULL(a.Cat_B_Count,0)))  end ),
 | ||
|                                 a.Cat_C_CountPercent=(case ISNULL(a.Cat_C_Count,0) when 0 then 0 else  CONVERT(DECIMAL(10,2),100*(ISNULL(a.Cat_C_Countf,0)*1.0/ISNULL(a.Cat_C_Count,0)))  end ),
 | ||
|                                 a.Cat_D_CountPercent=(case ISNULL(a.Cat_D_Count,0) when 0 then 0 else  CONVERT(DECIMAL(10,2),100*(ISNULL(a.Cat_D_Countf,0)*1.0/ISNULL(a.Cat_D_Count,0)))  end ),
 | ||
|                                 a.allCountPercent=(case ISNULL(a.allCount,0) when 0 then 0 else  CONVERT(DECIMAL(10,2),100*(ISNULL(a.allfinshedCount,0)*1.0/ISNULL(a.allCount,0)))  end )
 | ||
|                                 from #PunchlistFromProgressTemp a; ");
 | ||
| 
 | ||
|             strSql.AppendLine(" select *  from #PunchlistFromProgressTemp ");
 | ||
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | ||
| 
 | ||
|             strSql.AppendLine(" order by Sub_Sys_No ");
 | ||
|             SqlParameter[] parameter = listStr.ToArray();
 | ||
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql.ToString(), parameter);
 | ||
|             Grid3.RecordCount = tb.Rows.Count;
 | ||
|             var table = this.GetPagedDataTable(Grid3, tb);
 | ||
|             Grid3.DataSource = table;
 | ||
|             Grid3.DataBind();
 | ||
| 
 | ||
|             //合计
 | ||
|             int cat_A_Count = 0;
 | ||
|             int cat_B_Count = 0;
 | ||
|             int cat_C_Count = 0;
 | ||
|             int cat_D_Count = 0;
 | ||
| 
 | ||
|             int Cat_A_Countf = 0, Cat_A_CountWUH = 0, Cat_A_CountBASF = 0,
 | ||
|                 Cat_B_Countf = 0, Cat_B_CountWUH = 0, Cat_B_CountBASF = 0,
 | ||
|                 Cat_C_Countf = 0, Cat_C_CountWUH = 0, Cat_C_CountBASF = 0,
 | ||
|                 Cat_D_Countf = 0, Cat_D_CountWUH = 0, Cat_D_CountBASF = 0,
 | ||
|                 allCount = 0, allfinshedCount = 0, allWUH = 0, allBASF = 0;
 | ||
| 
 | ||
|             foreach (DataRow row in tb.Rows)
 | ||
|             {
 | ||
|                 cat_A_Count += Convert.ToInt32(row["Cat_A_Count"]);
 | ||
|                 cat_B_Count += Convert.ToInt32(row["Cat_B_Count"]);
 | ||
|                 cat_C_Count += Convert.ToInt32(row["Cat_C_Count"]);
 | ||
|                 cat_D_Count += Convert.ToInt32(row["Cat_D_Count"]);
 | ||
| 
 | ||
|                 Cat_A_Countf += Convert.ToInt32(row["Cat_A_Countf"]);
 | ||
|                 Cat_A_CountWUH += Convert.ToInt32(row["Cat_A_CountWUH"]);
 | ||
|                 Cat_A_CountBASF += Convert.ToInt32(row["Cat_A_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_B_Countf += Convert.ToInt32(row["Cat_B_Countf"]);
 | ||
|                 Cat_B_CountWUH += Convert.ToInt32(row["Cat_B_CountWUH"]);
 | ||
|                 Cat_B_CountBASF += Convert.ToInt32(row["Cat_B_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_C_Countf += Convert.ToInt32(row["Cat_C_Countf"]);
 | ||
|                 Cat_C_CountWUH += Convert.ToInt32(row["Cat_C_CountWUH"]);
 | ||
|                 Cat_C_CountBASF += Convert.ToInt32(row["Cat_C_CountBASF"]);
 | ||
| 
 | ||
|                 Cat_D_Countf += Convert.ToInt32(row["Cat_D_Countf"]);
 | ||
|                 Cat_D_CountWUH += Convert.ToInt32(row["Cat_D_CountWUH"]);
 | ||
|                 Cat_D_CountBASF += Convert.ToInt32(row["Cat_D_CountBASF"]);
 | ||
| 
 | ||
|                 allCount += Convert.ToInt32(row["allCount"]);
 | ||
|                 allfinshedCount += Convert.ToInt32(row["allfinshedCount"]);
 | ||
|                 allWUH += Convert.ToInt32(row["allWUH"]);
 | ||
|                 allBASF += Convert.ToInt32(row["allBASF"]);
 | ||
|             }
 | ||
| 
 | ||
|             var Cat_A_CountPercent = Cat_A_Countf > 0 && cat_A_Count > 0 ? 100 * ((float)Cat_A_Countf / (float)cat_A_Count) : 0;
 | ||
|             var Cat_B_CountPercent = Cat_B_Countf > 0 && cat_B_Count > 0 ? 100 * ((float)Cat_B_Countf / (float)cat_B_Count) : 0;
 | ||
|             var Cat_C_CountPercent = Cat_C_Countf > 0 && cat_C_Count > 0 ? 100 * ((float)Cat_C_Countf / (float)cat_C_Count) : 0;
 | ||
|             var Cat_D_CountPercent = Cat_D_Countf > 0 && cat_D_Count > 0 ? 100 * ((float)Cat_D_Countf / (float)cat_D_Count) : 0;
 | ||
|             var allCountPercent = allfinshedCount > 0 && allCount > 0 ? 100 * ((float)allfinshedCount / (float)allCount) : 0;
 | ||
| 
 | ||
|             //var Cat_A_CountPercent = Cat_A_Countf > 0 && cat_A_Count > 0 ? 100 * ((decimal)(Cat_A_Countf / cat_A_Count)) : 0;
 | ||
|             //var Cat_B_CountPercent = Cat_B_Countf > 0 && cat_B_Count > 0 ? 100 * ((decimal)(Cat_B_Countf / cat_B_Count)) : 0;
 | ||
|             //var Cat_C_CountPercent = Cat_C_Countf > 0 && cat_C_Count > 0 ? 100 * ((decimal)(Cat_C_Countf / cat_C_Count)) : 0;
 | ||
|             //var Cat_D_CountPercent = Cat_D_Countf > 0 && cat_D_Count > 0 ? 100 * ((decimal)(Cat_D_Countf / cat_D_Count)) : 0;
 | ||
|             //var allCountPercent = allfinshedCount > 0 && allCount > 0 ? 100 * ((decimal)(allfinshedCount / allCount)) : 0;
 | ||
| 
 | ||
|             JObject summary = new JObject();
 | ||
|             summary.Add("SubSysNo", "合计");
 | ||
|             summary.Add("Cat_A_Count", cat_A_Count.ToString());
 | ||
|             summary.Add("Cat_B_Count", cat_B_Count.ToString());
 | ||
|             summary.Add("Cat_C_Count", cat_C_Count.ToString());
 | ||
|             summary.Add("Cat_D_Count", cat_D_Count.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_A_Countf", Cat_A_Countf.ToString());
 | ||
|             summary.Add("Cat_A_CountPercent", Cat_A_CountPercent.ToString("F2"));
 | ||
|             summary.Add("Cat_A_CountWUH", Cat_A_CountWUH.ToString());
 | ||
|             summary.Add("Cat_A_CountBASF", Cat_A_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_B_Countf", Cat_B_Countf.ToString());
 | ||
|             summary.Add("Cat_B_CountPercent", Cat_B_CountPercent.ToString("F2"));
 | ||
|             summary.Add("Cat_B_CountWUH", Cat_B_CountWUH.ToString());
 | ||
|             summary.Add("Cat_B_CountBASF", Cat_B_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_C_Countf", Cat_C_Countf.ToString());
 | ||
|             summary.Add("Cat_C_CountPercent", Cat_C_CountPercent.ToString("F2"));
 | ||
|             summary.Add("Cat_C_CountWUH", Cat_C_CountWUH.ToString());
 | ||
|             summary.Add("Cat_C_CountBASF", Cat_C_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("Cat_D_Countf", Cat_D_Countf.ToString());
 | ||
|             summary.Add("Cat_D_CountPercent", Cat_D_CountPercent.ToString("F2"));
 | ||
|             summary.Add("Cat_D_CountWUH", Cat_D_CountWUH.ToString());
 | ||
|             summary.Add("Cat_D_CountBASF", Cat_D_CountBASF.ToString());
 | ||
| 
 | ||
|             summary.Add("allCount", allCount.ToString());
 | ||
|             summary.Add("allfinshedCount", allfinshedCount.ToString());
 | ||
|             summary.Add("allCountPercent", allCountPercent.ToString("F2"));
 | ||
|             summary.Add("allWUH", allWUH.ToString());
 | ||
|             summary.Add("allBASF", allBASF.ToString());
 | ||
| 
 | ||
|             Grid3.SummaryData = summary;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页下拉
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlPageSize3_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Grid3.PageSize = Convert.ToInt32(ddlPageSize3.SelectedValue);
 | ||
|             BindGrid3();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页索引事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e)
 | ||
|         {
 | ||
|             BindGrid3();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 排序
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid3_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | ||
|         {
 | ||
|             Grid3.SortDirection = e.SortDirection;
 | ||
|             Grid3.SortField = e.SortField;
 | ||
|             BindGrid3();
 | ||
|         }
 | ||
|         #endregion
 | ||
|     }
 | ||
| } |