2023-03-29 14:32:57 +08:00
|
|
|
|
using BLL;
|
|
|
|
|
using FineUIPro.Web.BaseInfo;
|
2023-11-11 16:02:42 +08:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2023-03-29 14:32:57 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.DataShow
|
|
|
|
|
{
|
|
|
|
|
public partial class QualityAcceptance : PageBase
|
|
|
|
|
{
|
|
|
|
|
#region 加载页面
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
|
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
|
BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
|
|
|
|
// 绑定表格t
|
|
|
|
|
BindGrid();
|
2023-11-11 16:02:42 +08:00
|
|
|
|
|
|
|
|
|
// 合计
|
|
|
|
|
|
|
|
|
|
this.Panel1.Title = "质量验收数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.CommonService.GetThisUnitId()) + ")";
|
2023-03-29 14:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
2023-11-02 15:40:43 +08:00
|
|
|
|
string strSql = @"select ProjectId,ProjectCode, ProjectName from Base_Project where (ProjectState2 is null or ProjectState2 !=9) and ProjectState =1 ";
|
2023-03-29 14:32:57 +08:00
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
2023-06-09 14:28:23 +08:00
|
|
|
|
string cpara = string.Empty;
|
2023-03-29 14:32:57 +08:00
|
|
|
|
if (this.drpProject.SelectedValue != Const._Null)
|
|
|
|
|
{
|
2023-06-09 14:28:23 +08:00
|
|
|
|
strSql += " AND projectId = @projectId"; ///状态为已完成
|
2023-03-29 14:32:57 +08:00
|
|
|
|
listStr.Add(new SqlParameter("@projectId", this.drpProject.SelectedValue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (!string.IsNullOrEmpty(this.txtStartTime.Text))
|
|
|
|
|
//{
|
|
|
|
|
// strSql += " AND h.RegisterDate >=@StartTime";
|
|
|
|
|
// listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
|
2023-06-09 14:28:23 +08:00
|
|
|
|
|
|
|
|
|
// cpara += " AND c.RegisterDate >=" + this.txtStartTime.Text;
|
2023-03-29 14:32:57 +08:00
|
|
|
|
//}
|
|
|
|
|
//if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
|
|
|
|
//{
|
|
|
|
|
// strSql += " AND h.RegisterDate <=@EndTime";
|
|
|
|
|
// listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text));
|
2023-06-09 14:28:23 +08:00
|
|
|
|
|
|
|
|
|
// cpara += " AND c.RegisterDate <=" + this.txtEndTime.Text;
|
2023-03-29 14:32:57 +08:00
|
|
|
|
//}
|
2023-06-09 14:28:23 +08:00
|
|
|
|
|
2023-03-29 14:32:57 +08:00
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
|
Grid1.DataSource = table;
|
|
|
|
|
Grid1.DataBind();
|
2023-11-11 16:02:42 +08:00
|
|
|
|
OutputSummaryData();
|
2023-03-29 14:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 表排序、分页、关闭窗口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 排序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页显示条数下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭弹出窗
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2023-06-09 14:28:23 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 定义变量
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static IQueryable<Model.QualityAcceptanceItem> getDataItemLists = from x in Funs.DB.ProcessControl_InspectionManagementDetail
|
|
|
|
|
join y in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals y.InspectionId
|
|
|
|
|
join z in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals z.BreakdownProjectId
|
2023-11-11 16:02:42 +08:00
|
|
|
|
where x.CreateDate > Funs.minSysDate
|
2023-06-09 14:28:23 +08:00
|
|
|
|
select new Model.QualityAcceptanceItem
|
|
|
|
|
{
|
|
|
|
|
InspectionDetailId = x.InspectionDetailId,
|
|
|
|
|
ProjectId = z.ProjectId,
|
|
|
|
|
CheckAcceptType = z.CheckAcceptType,
|
|
|
|
|
IsOnceQualified = y.IsOnceQualified
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected int Count1(object projectId)
|
|
|
|
|
{
|
|
|
|
|
int cout1 = 0;
|
|
|
|
|
if (projectId != null)
|
|
|
|
|
{
|
|
|
|
|
var getT = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue);
|
|
|
|
|
cout1 = getT.Count();
|
|
|
|
|
}
|
|
|
|
|
return cout1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected int Count2(object projectId)
|
|
|
|
|
{
|
|
|
|
|
int cout1 = 0;
|
|
|
|
|
if (projectId != null)
|
|
|
|
|
{
|
|
|
|
|
var getT = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue && x.IsOnceQualified == true);
|
|
|
|
|
cout1 = getT.Count();
|
|
|
|
|
}
|
|
|
|
|
return cout1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected int Count3(object projectId)
|
|
|
|
|
{
|
|
|
|
|
int cout1 = 0;
|
|
|
|
|
if (projectId != null)
|
|
|
|
|
{
|
|
|
|
|
var getT1 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue);
|
|
|
|
|
var getT2 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue && x.IsOnceQualified == true);
|
|
|
|
|
cout1 = getT1.Count() - getT2.Count();
|
|
|
|
|
}
|
|
|
|
|
return cout1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected string Count4(object projectId)
|
|
|
|
|
{
|
|
|
|
|
string rate = string.Empty;
|
|
|
|
|
if (projectId != null)
|
|
|
|
|
{
|
|
|
|
|
var getT1 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue);
|
|
|
|
|
var getT2 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue && x.IsOnceQualified == true);
|
|
|
|
|
if (getT1.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
rate = Math.Round(getT2.Count() * 1.0 / getT1.Count() * 100, 2).ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rate;
|
|
|
|
|
}
|
2023-11-11 16:02:42 +08:00
|
|
|
|
|
|
|
|
|
#region 合计
|
|
|
|
|
private void OutputSummaryData()
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"select a.ProjectId,a.ProjectCode, a.ProjectName,a.UnitId,isnull(Count1,0) as Count1,
|
|
|
|
|
isnull(Count2,0) as Count2
|
|
|
|
|
from Base_Project a
|
|
|
|
|
|
|
|
|
|
left join (select count(*) as Count1,z.ProjectId From ProcessControl_InspectionManagementDetail x
|
|
|
|
|
left join ProcessControl_InspectionManagement y on x.InspectionId=y.InspectionId
|
|
|
|
|
left join WBS_BreakdownProject z on x.ControlPointType=z.BreakdownProjectId group by z.ProjectId) as b
|
|
|
|
|
on a.ProjectId= b.ProjectId
|
|
|
|
|
|
|
|
|
|
left join (select count(*) as Count2,z.ProjectId,IsOnceQualified From ProcessControl_InspectionManagementDetail x
|
|
|
|
|
left join ProcessControl_InspectionManagement y on x.InspectionId=y.InspectionId
|
|
|
|
|
left join WBS_BreakdownProject z on x.ControlPointType=z.BreakdownProjectId
|
|
|
|
|
group by z.ProjectId,y.IsOnceQualified) as c
|
|
|
|
|
on a.ProjectId= c.ProjectId and IsOnceQualified=1
|
|
|
|
|
|
|
|
|
|
where ProjectState =1 and (ProjectState2 is null or ProjectState2 !=9) ";
|
|
|
|
|
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());
|
|
|
|
|
summary.Add("Count3", (Count1- Count2).ToString());
|
|
|
|
|
if (Count1 > 0)
|
|
|
|
|
{
|
|
|
|
|
summary.Add("Count4", Math.Round(Count2 * 1.0 / Count1 * 100, 2).ToString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
summary.Add("Count4", "0");
|
|
|
|
|
}
|
|
|
|
|
Grid1.SummaryData = summary;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2023-03-29 14:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|