using BLL; using FineUIPro.Web.Controls; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.HJGL.WeldingReport { public partial class OneWeekDeviceReport : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); List units = new List(); txtEndDate.SelectedDate = DateTime.Now ; txtStartDate.SelectedDate = DateTime.Now .AddDays(-7); var pUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId); if (pUnit == null || pUnit.UnitType == Const.ProjectUnitType_1) { units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2); //this.drpUnit.Enabled = false; this.drpUnit.DataTextField = "UnitName"; this.drpUnit.DataValueField = "UnitId"; this.drpUnit.DataSource = units; this.drpUnit.DataBind(); Funs.FineUIPleaseSelect(this.drpUnit); } else { units = BLL.UnitService.GetSubUnitsListBySupervisorUnitId(this.CurrUser.ProjectId, this.CurrUser.UnitId); this.drpUnit.Enabled = false; this.drpUnit.DataTextField = "UnitName"; this.drpUnit.DataValueField = "UnitId"; this.drpUnit.DataSource = units; this.drpUnit.DataBind(); this.drpUnit.SelectedValue = CurrUser.UnitId; } //BindGrid(); } } #endregion #region 绑定BindGrid /// /// 绑定数据 /// private void BindGrid() { string strSql = @" SELECT IsoInfo.ISO_ID+Unit.UnitId ISO_ID , WorkArea.ProjectId ,Unit.UnitCode --单位代码 ,Unit.UnitName --单位名称 ,WorkArea.WorkAreaCode ,WorkArea.WorkAreaName ,IsoInfo.ISO_IsoNo ,tfm.jotNnum tfmjotNnum ,tfm.passdonedin tfmpassdonedin ,tfm.nopassdonedin tfmnopassdonedin ,CAST((CASE ISNULL(tfm.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tfm.passdonedin , 0)-ISNULL(tfm.nopassdonedin , 0)) /(1.0 * tfm.passdonedin) END) AS DECIMAL(19,2)) AS tfmpassrate ,tofd.jotNnum tofdjotNnum ,tofd.passdonedin tofdpassdonedin ,tofd.nopassdonedin tofdnopassdonedin ,CAST((CASE ISNULL(tofd.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tofd.passdonedin , 0)-ISNULL(tofd.nopassdonedin , 0)) /(1.0 * tofd.passdonedin) END) AS DECIMAL(19,2)) AS tofdpassrate ,ut.jotNnum utjotNnum ,ut.passdonedin utpassdonedin ,ut.nopassdonedin utnopassdonedin ,CAST((CASE ISNULL(ut.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(ut.passdonedin , 0)-ISNULL(ut.nopassdonedin , 0)) /(1.0 * ut.passdonedin) END) AS DECIMAL(19,2)) AS utpassrate ,mt.jotNnum mtjotNnum ,mt.passdonedin mtpassdonedin ,mt.nopassdonedin mtnopassdonedin ,CAST((CASE ISNULL(mt.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(mt.passdonedin , 0)-ISNULL(mt.nopassdonedin , 0)) /(1.0 * mt.passdonedin) END) AS DECIMAL(19,2)) AS mtpassrate ,pt.jotNnum ptjotNnum ,pt.passdonedin ptpassdonedin ,pt.nopassdonedin ptnopassdonedin ,CAST((CASE ISNULL(pt.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(pt.passdonedin , 0)-ISNULL(pt.nopassdonedin , 0)) /(1.0 * pt.passdonedin) END) AS DECIMAL(19,2)) AS ptpassrate ,tfmback.jotNnum tfmbackjotNnum ,tfmback.passdonedin tfmbackpassdonedin ,tfmback.nopassdonedin tfmbacknopassdonedin ,CAST((CASE ISNULL(tfmback.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tfmback.passdonedin , 0)-ISNULL(tfmback.nopassdonedin , 0)) /(1.0 * tfmback.passdonedin) END) AS DECIMAL(19,2)) AS tfmbackpassrate ,tofdback.jotNnum tofdbackjotNnum ,tofdback.passdonedin tofdbackpassdonedin ,tofdback.nopassdonedin tofdbacknopassdonedin ,CAST((CASE ISNULL(tofdback.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tofdback.passdonedin , 0)-ISNULL(tofdback.nopassdonedin , 0)) /(1.0 * tofdback.passdonedin) END) AS DECIMAL(19,2)) AS tofdbackpassrate ,utback.jotNnum utbackjotNnum ,utback.passdonedin utbackpassdonedin ,utback.nopassdonedin utbacknopassdonedin ,CAST((CASE ISNULL(utback.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(utback.passdonedin , 0)-ISNULL(utback.nopassdonedin , 0)) /(1.0 * utback.passdonedin) END) AS DECIMAL(19,2)) AS utbackpassrate ,mtback.jotNnum mtbackjotNnum ,mtback.passdonedin mtbackpassdonedin ,mtback.nopassdonedin mtbacknopassdonedin ,CAST((CASE ISNULL(mtback.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(mtback.passdonedin , 0)-ISNULL(mtback.nopassdonedin , 0)) /(1.0 * mtback.passdonedin) END) AS DECIMAL(19,2)) AS mtbackpassrate ,ptback.jotNnum ptbackjotNnum ,ptback.passdonedin ptbackpassdonedin ,ptback.nopassdonedin ptbacknopassdonedin ,CAST((CASE ISNULL(ptback.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(ptback.passdonedin , 0)-ISNULL(ptback.nopassdonedin , 0)) /(1.0 * ptback.passdonedin) END) AS DECIMAL(19,2)) AS ptbackpassrate ,tfmtotal.jotNnum tfmtotaljotNnum ,tfmtotal.passdonedin tfmtotalpassdonedin ,tfmtotal.nopassdonedin tfmtotalnopassdonedin ,CAST((CASE ISNULL(tfmtotal.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tfmtotal.passdonedin , 0)-ISNULL(tfmtotal.nopassdonedin , 0)) /(1.0 * tfmtotal.passdonedin) END) AS DECIMAL(19,2)) AS tfmtotalpassrate ,tofdtotal.jotNnum tofdtotaljotNnum ,tofdtotal.passdonedin tofdtotalpassdonedin ,tofdtotal.nopassdonedin tofdtotalnopassdonedin ,CAST((CASE ISNULL(tofdtotal.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(tofdtotal.passdonedin , 0)-ISNULL(tofdtotal.nopassdonedin , 0)) /(1.0 * tofdtotal.passdonedin) END) AS DECIMAL(19,2)) AS tofdtotalpassrate ,uttotal.jotNnum uttotaljotNnum ,uttotal.passdonedin uttotalpassdonedin ,uttotal.nopassdonedin uttotalnopassdonedin ,CAST((CASE ISNULL(uttotal.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(uttotal.passdonedin , 0)-ISNULL(uttotal.nopassdonedin , 0)) /(1.0 * uttotal.passdonedin) END) AS DECIMAL(19,2)) AS uttotalpassrate ,mttotal.jotNnum mttotaljotNnum ,mttotal.passdonedin mttotalpassdonedin ,mttotal.nopassdonedin mttotalnopassdonedin ,CAST((CASE ISNULL(mttotal.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(mttotal.passdonedin , 0)-ISNULL(mttotal.nopassdonedin , 0)) /(1.0 * mttotal.passdonedin) END) AS DECIMAL(19,2)) AS mttotalpassrate ,pttotal.jotNnum pttotaljotNnum ,pttotal.passdonedin pttotalpassdonedin ,pttotal.nopassdonedin pttotalnopassdonedin ,CAST((CASE ISNULL(pttotal.passdonedin,0) WHEN 0 THEN 0 ELSE 100.0 * (ISNULL(pttotal.passdonedin , 0)-ISNULL(pttotal.nopassdonedin , 0)) /(1.0 * pttotal.passdonedin) END) AS DECIMAL(19,2)) AS pttotalpassrate from ProjectData_WorkArea AS WorkArea LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId =Unit.UnitId LEFT JOIN PW_IsoInfo AS IsoInfo on IsoInfo.WorkAreaId = WorkArea.WorkAreaId --3D-TFM LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2 group by a.ISO_ID ) as tfm on tfm.ISO_ID= IsoInfo.ISO_ID --tofd LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2 group by a.ISO_ID ) as tofd on tofd.ISO_ID= IsoInfo.ISO_ID --UT LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2 group by a.ISO_ID ) as ut on ut.ISO_ID= IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2 group by a.ISO_ID ) as mt on mt.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2 group by a.ISO_ID ) as pt on pt.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2 group by a.ISO_ID ) as tfmback on tfmback.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2 group by a.ISO_ID ) as tofdback on tofdback.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2 group by a.ISO_ID ) as utback on utback.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2 group by a.ISO_ID ) as mtback on mtback.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2 group by a.ISO_ID ) as ptback on ptback.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815') group by a.ISO_ID ) as tfmtotal on tfmtotal.ISO_ID= IsoInfo.ISO_ID --tofd LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1') group by a.ISO_ID ) as tofdtotal on tofdtotal.ISO_ID= IsoInfo.ISO_ID --UT LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4') group by a.ISO_ID ) as uttotal on uttotal.ISO_ID= IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f') group by a.ISO_ID ) as mttotal on mttotal.ISO_ID = IsoInfo.ISO_ID LEFT JOIN ( SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID from PW_JointInfo a left join CH_TrustItem b on a.JOT_ID = b.JOT_ID left join CH_Trust c on b.CH_TrustID = c.CH_TrustID left join CH_CheckItem d on a.JOT_ID = d.JOT_ID left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72') group by a.ISO_ID ) as pttotal on pttotal.ISO_ID = IsoInfo.ISO_ID where IsoInfo.ProjectId=@ProjectId and ( IsoInfo.Is_Standard=@IsStandard OR @IsStandard = '') "; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); listStr.Add(new SqlParameter("@date2", this.txtEndDate.SelectedDate.Value.AddDays(1).ToString("yyyy-MM-dd"))); listStr.Add(new SqlParameter("@date1", this.txtStartDate.SelectedDate.Value.ToString("yyyy-MM-dd"))); if (this.drpUnit.SelectedValue != BLL.Const._Null) { strSql += " and WorkArea.UnitId= @UnitId "; listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue)); } if (this.cb_IsStandard.SelectedIndexArray != null && this.cb_IsStandard.SelectedIndexArray.Length == 1) { listStr.Add(new SqlParameter("@IsStandard", this.cb_IsStandard.SelectedValueArray[0])); } else { listStr.Add(new SqlParameter("@IsStandard", "")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb1 = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb1.Rows.Count; Grid1.DataSource = tb1; Grid1.DataBind(); } /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { this.BindGrid(); } #endregion #region 日期选择事件 /// /// 开始日期选择事件 /// /// /// protected void txtStartDate_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim())) { this.txtEndDate.Text = Funs.GetNewDateTime(this.txtStartDate.Text.Trim()).Value.AddDays(6).ToShortDateString(); } } /// /// 结束日期选择事件 /// /// /// protected void txtEndDate_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim())) { this.txtStartDate.Text = Funs.GetNewDateTime(this.txtEndDate.Text.Trim()).Value.AddDays(-6).ToShortDateString(); } } #endregion /// /// /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); // 显示列 //var c = UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, Const.UnitAreaQualityMenuId); //if (c != null) //{ // this.GetShowColumn(c.Columns); //} } /// /// 显示的列 /// /// private void GetShowColumn(string column) { if (!string.IsNullOrEmpty(column)) { for (int i = 0; i < Grid1.Columns.Count; i++) { this.Grid1.Columns[i].Hidden = true; } List columns = column.Split(',').ToList(); foreach (var item in columns) { this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false; } } } #region 统计按钮事件 /// /// 统计 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { if (!txtStartDate.SelectedDate.HasValue|| !txtEndDate.SelectedDate.HasValue) { Alert.ShowInTop("请选择日期!", MessageBoxIcon.Warning); return; } BindGrid(); //OutputSummaryData(); } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("储罐/管道每周焊接量统计表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid1)); Response.End(); } /// /// 导出方法 /// /// /// private string GetGridTableHtml(Grid grid) { StringBuilder sb = new StringBuilder(); MultiHeaderTable mht = new MultiHeaderTable(); mht.ResolveMultiHeaderTable(Grid1.Columns); sb.Append(""); sb.Append(""); foreach (List rows in mht.MultiTable) { sb.Append(""); foreach (object[] cell in rows) { int rowspan = Convert.ToInt32(cell[0]); int colspan = Convert.ToInt32(cell[1]); GridColumn column = cell[2] as GridColumn; sb.AppendFormat("{3}", rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "", colspan != 1 ? " colspan=\"" + colspan + "\"" : "", colspan != 1 ? " style=\"text-align:center;\"" : "", column.HeaderText); } sb.Append(""); } int j = 0; foreach (GridRow row in grid.Rows) { sb.Append(""); int i = 0; foreach (GridColumn column in mht.Columns) { string html = row.Values[column.ColumnIndex].ToString(); if (column.ColumnID == "tfNumber") { html = (row.FindControl("labNumber1") as AspNet.Label).Text; } sb.AppendFormat("", html); i++; } j++; sb.Append(""); } var sumary = grid.SummaryData; if (sumary != null) { sb.Append(""); foreach (GridColumn column in grid.Columns) { try { if (column is GroupField) { if (((GroupField)column).Columns != null) { foreach (var item in ((GroupField)column).Columns) { if (!column.Hidden) { if (sumary.ContainsKey(item.ColumnID)) { sb.AppendFormat("", sumary.GetValue(item.ColumnID).ToString()); } else { sb.AppendFormat("", ""); } } } } } else if (column is RenderField) { if (!column.Hidden) { if (sumary.ContainsKey(column.ColumnID)) { sb.AppendFormat("", sumary.GetValue(column.ColumnID).ToString()); } else { sb.AppendFormat("", ""); } } } else { if (!column.Hidden) { sb.AppendFormat("", ""); } } } catch (Exception e) { sb.AppendFormat("", ""); } } sb.Append(""); } sb.Append("
{0}
{0}{0}{0}{0}{0}{0}
"); return sb.ToString(); } #endregion #region 下拉选择事件 /// /// 单位下拉选择事件 /// /// /// < param name="e"> protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { } #endregion } }