This commit is contained in:
geh 2026-04-09 16:09:11 +08:00
parent ad4f329930
commit bc4dac08a2
4 changed files with 124 additions and 32 deletions

View File

@ -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>

View File

@ -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,7 +203,7 @@ 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
@ -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,21 +234,24 @@ 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
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;
}
@ -254,9 +259,9 @@ namespace FineUIPro.Web.DataShow
#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)";
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);
@ -272,6 +277,81 @@ namespace FineUIPro.Web.DataShow
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
}
}

View File

@ -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>

View File

@ -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"]));