| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.IO; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  | using System.Runtime.Remoting.Contexts; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  | using Model; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.JDGL.Check | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class WeekPlanStatisc : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         private static List<Model.JDGL_WeekPlan> StatisticsList = new List<Model.JDGL_WeekPlan>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 this.txtMonths.Text = string.Format("{0:yyyy-MM}", DateTime.Now); | 
					
						
							|  |  |  |  |                 this.txtYear.Text = string.Format("{0:yyyy}", DateTime.Now); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 this.drpWeekNo.DataTextField = "Text"; | 
					
						
							|  |  |  |  |                 this.drpWeekNo.DataValueField = "Value"; | 
					
						
							|  |  |  |  |                 var weekPlans = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId orderby x.StartDate descending select x.WeekNo).Distinct().OrderByDescending(x => x).ToList(); | 
					
						
							|  |  |  |  |                 if (weekPlans.Count() > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ListItem[] list = new ListItem[weekPlans.Count()]; | 
					
						
							|  |  |  |  |                     for (int i = 0; i < weekPlans.Count(); i++) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         list[i] = new ListItem(weekPlans[i], weekPlans[i]); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     this.drpWeekNo.DataSource = list; | 
					
						
							|  |  |  |  |                     this.drpWeekNo.DataBind(); | 
					
						
							|  |  |  |  |                     this.drpWeekNo.SelectedValue = list[0].Value; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpWeekNo.DataSource = null; | 
					
						
							|  |  |  |  |                     this.drpWeekNo.DataBind(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 BindStatisc(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void btnSearch_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.drpWeekNo.SelectedValue)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("周号不能为空!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region 绑定GridView | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="cNProfessionalId"></param> | 
					
						
							|  |  |  |  |         public void BindStatisc() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             var cycle = this.ckCycle.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             //周期集合 | 
					
						
							|  |  |  |  |             List<JDGL_WeekPlan> totalList = new List<JDGL_WeekPlan>(); | 
					
						
							|  |  |  |  |             //累计集合 | 
					
						
							|  |  |  |  |             List<JDGL_WeekPlan> sumTotalList = new List<JDGL_WeekPlan>(); | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |             string weekNo2 = string.Empty; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             if (cycle == "0") | 
					
						
							|  |  |  |  |             {//按周 | 
					
						
							|  |  |  |  |                 var weekPlan = db.JDGL_WeekPlan.FirstOrDefault(x => x.WeekNo == this.drpWeekNo.SelectedValue); | 
					
						
							|  |  |  |  |                 if (weekPlan != null) | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     if (weekPlan.StartDate != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.StartDate); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (weekPlan.EndDate != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.EndDate); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     var lastWeekPlan = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.StartDate < weekPlan.StartDate orderby x.StartDate descending select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     if (lastWeekPlan != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         weekNo2 = lastWeekPlan.WeekNo; | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 else | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     this.txtStartDate.Text = string.Empty; | 
					
						
							|  |  |  |  |                     this.txtEndDate.Text = string.Empty; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //周期集合 | 
					
						
							|  |  |  |  |                 totalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == weekNo2 select x).ToList(); | 
					
						
							|  |  |  |  |                 if (totalList.Count() > 0) | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     var startDate = totalList.First().StartDate; | 
					
						
							|  |  |  |  |                     sumTotalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.StartDate <= startDate select x).ToList(); | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             else if (cycle == "1") | 
					
						
							|  |  |  |  |             {//按月 | 
					
						
							|  |  |  |  |                 DateTime months = Convert.ToDateTime(this.txtMonths.Text + "-01"); | 
					
						
							|  |  |  |  |                 //周期集合 | 
					
						
							|  |  |  |  |                 totalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.EndDate == months select x).ToList(); | 
					
						
							|  |  |  |  |                 //累计集合 | 
					
						
							|  |  |  |  |                 sumTotalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.EndDate <= months select x).ToList(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (cycle == "2") | 
					
						
							|  |  |  |  |             {//按年(以上一年度12月份至本年度11月份为一个周期) | 
					
						
							|  |  |  |  |                 DateTime sDate = Convert.ToDateTime(this.txtYear.Text + "-12-01").AddYears(-1); | 
					
						
							|  |  |  |  |                 DateTime eDate = Convert.ToDateTime(this.txtYear.Text + "-12-01"); | 
					
						
							|  |  |  |  |                 //周期集合 | 
					
						
							|  |  |  |  |                 totalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.EndDate >= sDate && x.EndDate < eDate select x).ToList(); | 
					
						
							|  |  |  |  |                 //累计集合 | 
					
						
							|  |  |  |  |                 sumTotalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.EndDate < eDate select x).ToList(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (cycle == "3") | 
					
						
							|  |  |  |  |             {//按项目周期 | 
					
						
							|  |  |  |  |                 //周期集合 | 
					
						
							|  |  |  |  |                 totalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); | 
					
						
							|  |  |  |  |                 //累计集合 | 
					
						
							|  |  |  |  |                 sumTotalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             StatisticsList = new List<Model.JDGL_WeekPlan>(); | 
					
						
							|  |  |  |  |             int i = 1; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             ////周期集合 | 
					
						
							|  |  |  |  |             //var totalList = from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == weekNo2 select x; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |             if (this.ckType.SelectedValue == "1")  //按责任单位 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var pUnit = from x in db.Project_ProjectUnit | 
					
						
							|  |  |  |  |                             join y in db.Base_Unit on x.UnitId equals y.UnitId | 
					
						
							|  |  |  |  |                             where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 | 
					
						
							|  |  |  |  |                             orderby y.UnitCode | 
					
						
							|  |  |  |  |                             select y; | 
					
						
							|  |  |  |  |                 foreach (var item in pUnit) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     //周期集合 | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                     var list = totalList.Where(x => x.UnitId == item.UnitId); | 
					
						
							|  |  |  |  |                     Model.JDGL_WeekPlan JDGL_WeekPlan = new Model.JDGL_WeekPlan(); | 
					
						
							|  |  |  |  |                     JDGL_WeekPlan.WorkContent = item.UnitName; | 
					
						
							|  |  |  |  |                     int a = list.Count(); | 
					
						
							|  |  |  |  |                     int b = list.Count(x => x.IsOK == true); | 
					
						
							|  |  |  |  |                     JDGL_WeekPlan.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                     JDGL_WeekPlan.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                     if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_WeekPlan.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_WeekPlan.Remark = "0%"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     StatisticsList.Add(JDGL_WeekPlan); | 
					
						
							|  |  |  |  |                     i++; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else   //按五环责任人 | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 var users = UserService.GetUserList(); | 
					
						
							|  |  |  |  |                 var dutyPersonIds = (from x in db.JDGL_WeekPlan | 
					
						
							|  |  |  |  |                                      where x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                      select x.DutyPerson).Distinct().ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 var userIds = string.Join(",", dutyPersonIds.ToArray()).Split(',').Distinct().Where(x => x != null && x != "").ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //var user = (from x in db.Sys_User | 
					
						
							|  |  |  |  |                 //            join y in db.JDGL_WeekPlan on x.UserId equals y.DutyPerson | 
					
						
							|  |  |  |  |                 //            where y.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                 //            orderby x.UserId | 
					
						
							|  |  |  |  |                 //            select x).Distinct().ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 foreach (var item in userIds) | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     var user = users.Where(x => x.UserId == item).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     //周期集合 | 
					
						
							|  |  |  |  |                     //var list = totalList.Where(x => x.DutyPerson == item.UserId); | 
					
						
							|  |  |  |  |                     var list = totalList.Where(x => x.DutyPerson.Contains(item)); | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                     Model.JDGL_WeekPlan JDGL_WeekPlan = new Model.JDGL_WeekPlan(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     JDGL_WeekPlan.WorkContent = user.UserName; | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |                     int a = list.Count(); | 
					
						
							|  |  |  |  |                     int b = list.Count(x => x.IsOK == true); | 
					
						
							|  |  |  |  |                     JDGL_WeekPlan.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                     JDGL_WeekPlan.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                     if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_WeekPlan.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_WeekPlan.Remark = "0%"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     StatisticsList.Add(JDGL_WeekPlan); | 
					
						
							|  |  |  |  |                     i++; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (StatisticsList.Count() > 0)   //增加总计 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.JDGL_WeekPlan StatisticsLast = new Model.JDGL_WeekPlan(); | 
					
						
							|  |  |  |  |                 StatisticsLast.WorkContent = "合计"; | 
					
						
							|  |  |  |  |                 int a = totalList.Count(); | 
					
						
							|  |  |  |  |                 int b = totalList.Count(x => x.IsOK == true); | 
					
						
							|  |  |  |  |                 StatisticsLast.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                 StatisticsLast.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                 if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     StatisticsLast.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     StatisticsLast.Remark = "0%"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 StatisticsList.Add(StatisticsLast); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             ////增加累计 | 
					
						
							|  |  |  |  |             //List<Model.JDGL_WeekPlan> sumTotalList = new List<Model.JDGL_WeekPlan>(); | 
					
						
							|  |  |  |  |             //if (totalList.Count() > 0) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    var startDate = totalList.First().StartDate; | 
					
						
							|  |  |  |  |             //    sumTotalList = (from x in db.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.StartDate <= startDate select x).ToList(); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //Model.JDGL_WeekPlan StatisticsSum = new Model.JDGL_WeekPlan(); | 
					
						
							|  |  |  |  |             //StatisticsSum.WorkContent = "累计"; | 
					
						
							|  |  |  |  |             //int c = sumTotalList.Count(); | 
					
						
							|  |  |  |  |             //int d = sumTotalList.Count(x => x.IsOK == true); | 
					
						
							|  |  |  |  |             //StatisticsSum.UnitId = c.ToString(); | 
					
						
							|  |  |  |  |             //StatisticsSum.DutyPerson = d.ToString(); | 
					
						
							|  |  |  |  |             //if (c != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    StatisticsSum.Remark = Math.Round((double)d / (double)c * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    StatisticsSum.Remark = "0%"; | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //StatisticsList.Add(StatisticsSum); | 
					
						
							|  |  |  |  |             this.Grid1.DataSource = StatisticsList; | 
					
						
							|  |  |  |  |             this.Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 统计周期 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void ckCycle_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var cycle = this.ckCycle.SelectedValue; | 
					
						
							|  |  |  |  |             if (cycle == "0") | 
					
						
							|  |  |  |  |             {//按周 | 
					
						
							|  |  |  |  |                 this.drpWeekNo.Hidden = false; | 
					
						
							|  |  |  |  |                 this.txtStartDate.Hidden = false; | 
					
						
							|  |  |  |  |                 this.txtEndDate.Hidden = false; | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = true; | 
					
						
							| 
									
										
										
										
											2024-07-15 15:11:50 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             else if (cycle == "1") | 
					
						
							|  |  |  |  |             {//按月份 | 
					
						
							|  |  |  |  |                 this.drpWeekNo.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtStartDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtEndDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = false; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (cycle == "2") | 
					
						
							|  |  |  |  |             {//按年份 | 
					
						
							|  |  |  |  |                 this.drpWeekNo.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtStartDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtEndDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = false; | 
					
						
							| 
									
										
										
										
											2024-07-15 15:11:50 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             {//按项目周期 | 
					
						
							|  |  |  |  |                 this.drpWeekNo.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtStartDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtEndDate.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = true; | 
					
						
							| 
									
										
										
										
											2024-07-15 15:11:50 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             BindStatisc(); | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 统计汇总 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-05-15 16:01:09 +08:00
										 |  |  |  |         protected void ckType_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.ckType.SelectedValue == "1") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Grid1.Columns[1].HeaderText = "责任单位"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Grid1.Columns[1].HeaderText = "五环责任人"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region 导出按钮 | 
					
						
							|  |  |  |  |         /// 导出按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnOut_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //string rootPath = Server.MapPath("~/"); | 
					
						
							|  |  |  |  |             //string initTemplatePath = Const.JDGL_WeekPlanTemlUrl; | 
					
						
							|  |  |  |  |             //string uploadfilepath = string.Empty; | 
					
						
							|  |  |  |  |             //string newUrl = string.Empty; | 
					
						
							|  |  |  |  |             //uploadfilepath = rootPath + initTemplatePath; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //if (StatisticsList != null) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    string projectName = BLL.ProjectService.GetShortNameByProjectId(this.CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |             //    newUrl = uploadfilepath.Replace("NCR统计模板", "NCR统计(" + projectName + DateTime.Now.ToString("yyyyMMdd") + ")"); | 
					
						
							|  |  |  |  |             //    File.Copy(uploadfilepath, newUrl); | 
					
						
							|  |  |  |  |             //    // 第一步:读取文件流 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.IWorkbook workbook; | 
					
						
							|  |  |  |  |             //    using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        //workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); | 
					
						
							|  |  |  |  |             //        workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream); | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    // 创建单元格样式 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); | 
					
						
							|  |  |  |  |             //    cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; | 
					
						
							|  |  |  |  |             //    cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; | 
					
						
							|  |  |  |  |             //    cellStyle.WrapText = true;//自动换行 | 
					
						
							|  |  |  |  |             //    var font = workbook.CreateFont(); | 
					
						
							|  |  |  |  |             //    font.FontHeightInPoints = 11; | 
					
						
							|  |  |  |  |             //    cellStyle.SetFont(font); | 
					
						
							|  |  |  |  |             //    // 第二步:创建新数据行 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.IRow row = sheet.GetRow(0); | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ICell cell; | 
					
						
							|  |  |  |  |             //    int i = 2; | 
					
						
							|  |  |  |  |             //    foreach (var item in StatisticsList) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        // 第二步:创建新数据行 | 
					
						
							|  |  |  |  |             //        row = sheet.CreateRow(i); | 
					
						
							|  |  |  |  |             //        // 添加数据 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(0); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.WorkName);//工作名称 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(1); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.CheckNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(2); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.OKNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(3); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.NotOKNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(4); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.OKRate); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(5); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.Remark); | 
					
						
							|  |  |  |  |             //        i++; | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    // 第三步:写入文件流 | 
					
						
							|  |  |  |  |             //    using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        workbook.Write(stream); | 
					
						
							|  |  |  |  |             //        workbook.Close(); | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    string fileName = Path.GetFileName(newUrl); | 
					
						
							|  |  |  |  |             //    FileInfo info = new FileInfo(newUrl); | 
					
						
							|  |  |  |  |             //    long fileSize = info.Length; | 
					
						
							|  |  |  |  |             //    Response.Clear(); | 
					
						
							|  |  |  |  |             //    Response.ContentType = "application/x-zip-compressed"; | 
					
						
							|  |  |  |  |             //    Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); | 
					
						
							|  |  |  |  |             //    Response.AddHeader("Content-Length", fileSize.ToString()); | 
					
						
							|  |  |  |  |             //    Response.TransmitFile(newUrl, 0, fileSize); | 
					
						
							|  |  |  |  |             //    Response.Flush(); | 
					
						
							|  |  |  |  |             //    Response.Close(); | 
					
						
							|  |  |  |  |             //    File.Delete(newUrl); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    Alert.ShowInTop("当前无记录,无法导出!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导出方法 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="grid"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         //private string GetGridTableHtml(Grid grid) | 
					
						
							|  |  |  |  |         //{ | 
					
						
							|  |  |  |  |         //    StringBuilder sb = new StringBuilder(); | 
					
						
							|  |  |  |  |         //    sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>"); | 
					
						
							|  |  |  |  |         //    sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); | 
					
						
							|  |  |  |  |         //    sb.Append("<tr>"); | 
					
						
							|  |  |  |  |         //    grid.PageSize = 10000; | 
					
						
							|  |  |  |  |         //    BindStatisc(); | 
					
						
							|  |  |  |  |         //    foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |         //    { | 
					
						
							|  |  |  |  |         //        sb.AppendFormat("<td>{0}</td>", column.HeaderText); | 
					
						
							|  |  |  |  |         //    } | 
					
						
							|  |  |  |  |         //    sb.Append("</tr>"); | 
					
						
							|  |  |  |  |         //    foreach (GridRow row in grid.Rows) | 
					
						
							|  |  |  |  |         //    { | 
					
						
							|  |  |  |  |         //        sb.Append("<tr>"); | 
					
						
							|  |  |  |  |         //        foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |         //        { | 
					
						
							|  |  |  |  |         //            string html = row.Values[column.ColumnIndex].ToString(); | 
					
						
							|  |  |  |  |         //            if (column.ColumnID == "tfNumber") | 
					
						
							|  |  |  |  |         //            { | 
					
						
							|  |  |  |  |         //                html = (row.FindControl("labNumber") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |         //            } | 
					
						
							|  |  |  |  |         //            sb.AppendFormat("<td>{0}</td>", html); | 
					
						
							|  |  |  |  |         //        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //        sb.Append("</tr>"); | 
					
						
							|  |  |  |  |         //    } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //    sb.Append("</table>"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //    return sb.ToString(); | 
					
						
							|  |  |  |  |         //} | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |