using BLL;
using FineUIPro.Web.BaseInfo;
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 加载页面
///
/// 加载页面
///
///
///
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();
this.Panel1.Title = "质量验收数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_CWCEC) + ")";
}
}
#endregion
///
/// 绑定数据
///
private void BindGrid()
{
string strSql = @"select ProjectId,ProjectCode, ProjectName from Base_Project where ProjectState =1 ";
List listStr = new List();
string cpara = string.Empty;
if (this.drpProject.SelectedValue != Const._Null)
{
strSql += " AND projectId = @projectId"; ///状态为已完成
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));
// cpara += " AND c.RegisterDate >=" + this.txtStartTime.Text;
//}
//if (!string.IsNullOrEmpty(this.txtEndTime.Text))
//{
// strSql += " AND h.RegisterDate <=@EndTime";
// listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text));
// cpara += " AND c.RegisterDate <=" + this.txtEndTime.Text;
//}
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();
}
#region 查询
///
/// 查询
///
///
///
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region 表排序、分页、关闭窗口
///
/// 分页
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
///
/// 分页显示条数下拉框
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
///
/// 关闭弹出窗
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
///
/// 定义变量
///
private static IQueryable 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
select new Model.QualityAcceptanceItem
{
InspectionDetailId = x.InspectionDetailId,
ProjectId = z.ProjectId,
CheckAcceptType = z.CheckAcceptType,
IsOnceQualified = y.IsOnceQualified
};
///
/// 数量
///
///
///
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).Distinct().ToList();
cout1 = getT.Count();
}
return cout1;
}
///
/// 数量
///
///
///
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).Distinct().ToList();
cout1 = getT.Count();
}
return cout1;
}
///
/// 数量
///
///
///
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).Distinct().ToList();
var getT2 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue && x.IsOnceQualified == true).Distinct().ToList();
cout1 = getT1.Count() - getT2.Count();
}
return cout1;
}
///
/// 数量
///
///
///
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).Distinct().ToList();
var getT2 = getDataItemLists.Where(x => x.ProjectId == projectId.ToString() && x.CheckAcceptType == this.rbType.SelectedValue && x.IsOnceQualified == true).Distinct().ToList();
if (getT1.Count() > 0)
{
rate = Math.Round(getT2.Count() * 1.0 / getT1.Count() * 100, 2).ToString();
}
}
return rate;
}
}
}