using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.UI.WebControls; using BLL; namespace FineUIPro.Web.CQMS.ProcessControl { public partial class CheckManStatistics : PageBase { public DateTime StartDate; public DateTime EndDate; public int SunNumber; /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGvInspectionManagement(); } } /// /// 查询按钮 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGvInspectionManagement(); } #region 绑定GridView /// /// 绑定 /// /// public void BindGvInspectionManagement() { List StatisticsList = new List(); Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); StartDate = Convert.ToDateTime(project.StartDate); EndDate = DateTime.Now; if (!string.IsNullOrEmpty(this.txtStartTime.Text)) { StartDate = Convert.ToDateTime(this.txtStartTime.Text); } if (!string.IsNullOrEmpty(this.txtEndTime.Text)) { EndDate = Convert.ToDateTime(this.txtEndTime.Text); } //统计所给时间段的全部数量 List managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, string.Empty, StartDate, DateTime.Now, false); List compileMans = managementListSunNumber.Select(x => x.CompileMan).Distinct().ToList(); foreach (var item in compileMans) { Model.Sys_User user = BLL.UserService.GetUserByUserId(item); if (user != null) { Model.NCRStatisc Statistics = new Model.NCRStatisc(); Statistics.WorkName = user.UserName; Statistics.CheckNum = managementListSunNumber.Where(x => x.CompileMan == item).Count(); StatisticsList.Add(Statistics); } } Model.NCRStatisc StatisticsLast = new Model.NCRStatisc(); StatisticsLast.WorkName = "合计"; StatisticsLast.CheckNum = managementListSunNumber.Count(); StatisticsList.Add(StatisticsLast); this.gvCheckManStatistics.DataSource = StatisticsList; this.gvCheckManStatistics.DataBind(); } #endregion /// /// 导出 /// /// /// 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 = Encoding.UTF8; this.gvCheckManStatistics.PageSize = gvCheckManStatistics.RecordCount; BindGvInspectionManagement(); Response.Write(GetGridTableHtml2(gvCheckManStatistics)); Response.End(); } } }