106 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			106 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | 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; | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 加载页面 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 BindGvInspectionManagement(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 查询按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSearch_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGvInspectionManagement(); | |||
|  |         } | |||
|  | 
 | |||
|  |         #region 绑定GridView | |||
|  |         /// <summary> | |||
|  |         /// 绑定 | |||
|  |         /// </summary> | |||
|  |         /// <param name="cNProfessionalId"></param> | |||
|  |         public void BindGvInspectionManagement() | |||
|  |         { | |||
|  |             List<Model.NCRStatisc> StatisticsList = new List<Model.NCRStatisc>(); | |||
|  |             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<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, string.Empty, StartDate, DateTime.Now, false); | |||
|  |             List<string> 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 | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 导出 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         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("<meta http-equiv=Content-Type content=text/html;charset=UTF-8>"); | |||
|  | 
 | |||
|  |             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(); | |||
|  |         } | |||
|  |     } | |||
|  | } |