using System; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; 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.getInspectionManagementDetailListByCNProfessionalIdAndDate(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) { DateTime dt = DateTime.Now; string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString(); Response.Clear(); Response.Buffer = true; Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(""); Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("检查人检查次数统计" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/ms-excel"; this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); this.gvCheckManStatistics.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.Flush(); Response.End(); } } }