This commit is contained in:
parent
ad4f329930
commit
bc4dac08a2
|
|
@ -64,6 +64,9 @@
|
|||
Width="130px">
|
||||
</f:DatePicker>
|
||||
<f:ToolbarFill runat="server"></f:ToolbarFill>
|
||||
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" ToolTip="导出" Icon="FolderUp" Text="导出"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
<f:Button ID="btnClose" EnablePostBack="false" ToolTip="关闭" Text="关闭" runat="server" Icon="SystemClose" OnClientClick="closeNow();">
|
||||
</f:Button>
|
||||
</Items>
|
||||
|
|
|
|||
|
|
@ -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<SqlParameter> listStr = new List<SqlParameter>();
|
||||
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<SqlParameter> listStr = new List<SqlParameter>();
|
||||
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 导出按钮
|
||||
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出方法
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
private string GetGridTableHtml(Grid grid)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||||
sb.Append("<tr>");
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
{
|
||||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
}
|
||||
|
||||
sb.Append("</tr>");
|
||||
foreach (GridRow row in grid.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
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("<td>{0}</td>", html);
|
||||
}
|
||||
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
|
||||
sb.Append("</table>");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -122,6 +122,15 @@ namespace FineUIPro.Web.DataShow
|
|||
/// </remarks>
|
||||
protected global::FineUIPro.DatePicker txtEndTime;
|
||||
|
||||
/// <summary>
|
||||
/// btnOut 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnOut;
|
||||
|
||||
/// <summary>
|
||||
/// btnClose 控件。
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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<SqlParameter> listStr = new List<SqlParameter>();
|
||||
strSql += " AND C.ProjectId = @ProjectId";
|
||||
listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
|
||||
|
|
|
|||
Loading…
Reference in New Issue