diff --git a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx index e4743f6..f8cb20a 100644 --- a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx +++ b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx @@ -64,6 +64,9 @@ Width="130px"> + + diff --git a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.cs b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.cs index 0a6c40f..fbf175e 100644 --- a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.cs @@ -5,7 +5,8 @@ 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.DataShow { public partial class QualityInstruments : PageBase @@ -202,11 +203,11 @@ namespace FineUIPro.Web.DataShow if (projectId != null) { var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text); - var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text); + var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text); var getD1 = from x in Funs.DB.Comprehensive_InspectionMachine - where x.ProjectId == projectId.ToString() && x.IsOnSite == true && x.InspectionType.Contains("计量") - //&& x.CompileDate == Funs.minSysDate - select x; + where x.ProjectId == projectId.ToString() && x.IsOnSite == true && x.InspectionType.Contains("计量") + //&& x.CompileDate == Funs.minSysDate + select x; if (datetime1.HasValue) { getD1 = getD1.Where(x => x.CompileDate >= datetime1); @@ -216,7 +217,8 @@ namespace FineUIPro.Web.DataShow getD1 = getD1.Where(x => x.CompileDate <= datetime2); } - cout1 = getD1.Count(); + // cout1 = getD1.Count(); + cout1 = getD1.ToList().Sum(x => x.UnitsCount ?? 1); } return cout1; } @@ -232,46 +234,124 @@ namespace FineUIPro.Web.DataShow if (projectId != null) { var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text); - var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text); + var datetime2 = Funs.GetNewDateTime(this.txtEndTime.Text); var getD1 = from x in Funs.DB.Comprehensive_InspectionMachine - where x.ProjectId == projectId.ToString() && x.IsOnSite == true && x.InspectionType.Contains("计量") && x.IsCheckOK == true - // && x.CompileDate == Funs.minSysDate - select x; + where x.ProjectId == projectId.ToString() && x.IsOnSite == true && + x.InspectionType.Contains("计量") && x.IsCheckOK == true + // && x.CompileDate == Funs.minSysDate + select x; if (datetime1.HasValue) { getD1 = getD1.Where(x => x.CompileDate >= datetime1); } + if (datetime2.HasValue) { getD1 = getD1.Where(x => x.CompileDate <= datetime2); } - - cout1 = getD1.Count(); + + // cout1 = getD1.Count(); + cout1 = getD1.ToList().Sum(x => x.UnitsCount ?? 1); } return cout1; } #region 合计 private void OutputSummaryData() { - string strSql = @"select ProjectId,ProjectCode, ProjectName , - isnull((select count(*) from Comprehensive_InspectionMachine as a where a.ProjectId=P.ProjectId and a.IsOnSite=1 and a.InspectionType like '%计量%' ),0) as Count1, - isnull((select count(*) from Comprehensive_InspectionMachine as a where a.ProjectId=P.ProjectId and a.IsOnSite=1 and a.InspectionType like '%计量%' and a.IsCheckOK=1 ),0) as Count2 - from Base_Project as P where ProjectState =1 and (isDelete IS NULL OR isDelete =0)"; - List listStr = new List(); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); - int Count1 = 0, Count2 = 0; - foreach (DataRow row in tb.Rows) - { - Count1 += Convert.ToInt32(row["Count1"]); - Count2 += Convert.ToInt32(row["Count2"]); - } - JObject summary = new JObject(); - summary.Add("ProjectName", "合计:"); - summary.Add("Count1", Count1.ToString()); - summary.Add("Count2", Count2.ToString()); - Grid1.SummaryData = summary; - } + string strSql = @"select ProjectId,ProjectCode, ProjectName , + isnull((select sum(isnull(a.UnitsCount,1)) from Comprehensive_InspectionMachine as a where a.ProjectId=P.ProjectId and a.IsOnSite=1 and a.InspectionType like '%计量%' ),0) as Count1, + isnull((select sum(isnull(a.UnitsCount,1)) from Comprehensive_InspectionMachine as a where a.ProjectId=P.ProjectId and a.IsOnSite=1 and a.InspectionType like '%计量%' and a.IsCheckOK=1 ),0) as Count2 + from Base_Project as P where ProjectState =1 and (isDelete IS NULL OR isDelete =0) and (ProjectAttribute == 'GONGCHENG' OR ProjectAttribute IS NULL) "; + List listStr = new List(); + SqlParameter[] parameter = listStr.ToArray(); + DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); + int Count1 = 0, Count2 = 0; + foreach (DataRow row in tb.Rows) + { + Count1 += Convert.ToInt32(row["Count1"]); + Count2 += Convert.ToInt32(row["Count2"]); + } + JObject summary = new JObject(); + summary.Add("ProjectName", "合计:"); + summary.Add("Count1", Count1.ToString()); + summary.Add("Count2", Count2.ToString()); + Grid1.SummaryData = summary; + } + #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; + this.Grid1.PageSize = this.Grid1.RecordCount; + this.BindGrid(); + Response.Write(GetGridTableHtml(Grid1)); + Response.End(); + } + + /// + /// 导出方法 + /// + /// + /// + private string GetGridTableHtml(Grid grid) + { + StringBuilder sb = new StringBuilder(); + sb.Append(""); + sb.Append(""); + sb.Append(""); + foreach (GridColumn column in grid.Columns) + { + sb.AppendFormat("", column.HeaderText); + } + + sb.Append(""); + foreach (GridRow row in grid.Rows) + { + sb.Append(""); + foreach (GridColumn column in grid.Columns) + { + string html = row.Values[column.ColumnIndex].ToString(); + if (column.ColumnID == "tfNumber") + { + html = (row.FindControl("lblNumber") as AspNet.Label).Text; + } + + if (column.ColumnID == "Count1") + { + html = (row.FindControl("Label2") as AspNet.Label).Text; + } + + if (column.ColumnID == "Count2") + { + html = (row.FindControl("Label1") as AspNet.Label).Text; + } + + sb.AppendFormat("", html); + } + + sb.Append(""); + } + + sb.Append("
{0}
{0}
"); + + return sb.ToString(); + } + + #endregion + + } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.designer.cs index e2a9226..b3f432f 100644 --- a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstruments.aspx.designer.cs @@ -122,6 +122,15 @@ namespace FineUIPro.Web.DataShow /// protected global::FineUIPro.DatePicker txtEndTime; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// btnClose 控件。 /// diff --git a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstrumentsItem.aspx.cs b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstrumentsItem.aspx.cs index 9e97d80..e013418 100644 --- a/SUBQHSE/FineUIPro.Web/DataShow/QualityInstrumentsItem.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/DataShow/QualityInstrumentsItem.aspx.cs @@ -42,7 +42,7 @@ namespace FineUIPro.Web.DataShow from Comprehensive_InspectionMachine C left join Base_Unit U on C.UnitId=U.UnitId left join Base_CNProfessional CN on C.CNProfessionalId=CN.CNProfessionalId - where C.ProjectId = @ProjectId"; + where C.InspectionType = '计量' and C.ProjectId = @ProjectId"; List listStr = new List(); strSql += " AND C.ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));