public ViewResult Duty(FormCollection fc) { var year = int.Parse(fc.Get("year") ?? DateTime.Now.Year.ToString()); var month = int.Parse(fc.Get("month") ?? DateTime.Now.Month.ToString()); var date = new DateTime(year, month, 1); date = date.AddDays(-date.Day); date = date.AddDays(-(int)date.DayOfWeek); var years = new List <dynamic>(); for (int i = 0; i < 10; i++) { years.Add(new { value = (DateTime.Now.Year - i).ToString(), text = (DateTime.Now.Year - i).ToString() }); } var months = new List <dynamic>(); for (int i = 1; i <= 12; i++) { months.Add(new { value = i.ToString(), text = (i + "月") }); } ViewData["date"] = date; ViewData["currentmonth"] = month; ViewData["year"] = new SelectList(years, "value", "text", year); ViewData["month"] = new SelectList(months, "value", "text", month); var user = OperatorProvider.Provider.Current(); UserBLL userBLL = new UserBLL(); var users = userBLL.GetDeptUsers(user.DeptId).ToList(); ViewData["users"] = users; var from = DateTime.Today.AddDays((1 - DateTime.Today.Day)); from = from.AddDays(-GetDay(from.DayOfWeek)); var to = from.AddDays(42); var bll = new WorkmeetingBLL(); var data = bll.GetDutyData(user.DeptId, from, to); var list = new List <string>(); var d = from; while (d < to) { list.Add(string.Join(",", data.Where(x => x.UnSignDate.Ticks == d.Ticks).Select(x => x.UserName))); d = d.AddDays(1); } return(View(list)); }