private void frmClasses_Load(object sender, EventArgs e) { dtSpareTime = new SqlHelper().getDs("select * from SpareTime_Data", "SpareTime").Tables[0]; thisday = CalendarTools.weekdays(CalendarTools.CaculateWeekDay(CurrentTime.Year, CurrentTime.Month, CurrentTime.Day)); thisweek = CalendarTools.WeekOfYear(CurrentTime.Year, CurrentTime.Month, CurrentTime.Day) - CalendarTools.WeekOfYear(Common.Year, Common.Month, Common.Day) + 1; DataRow[] dr = dtClasses.Select("Class_Week=" + thisweek + " and Class_Day=" + thisday + "", "Class_Number asc"); if (dr.Length != 0) { for (int i = 0; i < dr.Length; i++) { string[] strclass = new string[] { (i + 1).ToString(), CurrentTime.ToLongDateString() + " " + addseparator(Convert.ToInt32(dr[i][5])) + "节" + " (第" + (thisweek.ToString() + "周 第" + thisday.ToString() + "天") + ")", dr[i][2].ToString(), dr[i][8].ToString(), dr[i][10].ToString(), dr[i][9].ToString(), numbersupervisor(thisweek, thisday, Convert.ToInt32(dr[i][5])).ToString() }; ListViewItem lvi = new ListViewItem(strclass); listView1.Items.Add(lvi); } } }
public ActionResult ReferenceList(string year = "", string month = "", string day = "", int page = 1) { int i = 1; Common com = new Common(); List <ReferenceModel> referencelist = new List <ReferenceModel>(); if (year != "" && month != "" && day != "") { int a = int.Parse(month); int thisday = CalendarTools.weekdays(CalendarTools.CaculateWeekDay(int.Parse(year), int.Parse(month), int.Parse(day))); int thisweek = CalendarTools.WeekOfYear(int.Parse(year), int.Parse(month), int.Parse(day)) - CalendarTools.WeekOfYear(Common.Year, Common.Month, Common.Day) + 1; if (Session["Power"].ToString() == "管理员") { List <TeachersModel> telist = DBHelper.ExecuteList <TeachersModel>("select * from teachers where college='" + Session["College"].ToString() + "'", CommandType.Text, null); referencelist = (from t in telist join c in classlist on t.TeacherName equals c.TeacherName where t.College == Session["College"].ToString() && c.Week == thisweek && c.Day == thisday select new ReferenceModel { Cid = c.Cid, Id = i++, time = CalendarTools.getdata(Common.Year, thisweek, thisday - CalendarTools.weekdays(CalendarTools.CaculateWeekDay(Common.Year, Common.Month, Common.Day)), Common.Month, Common.Day).ToLongDateString() + "" + com.AddSeparator(c.ClassNumber) + "节", TeacherName = c.TeacherName, Address = c.Address, Major = c.Major, ClassType = c.ClassType, SupervisorsSum = numbersupervisor(c.Week, c.Day, c.ClassNumber) }).ToList(); } else { referencelist = (from c in classlist where c.Week == thisweek && c.Day == thisday select new ReferenceModel { Id = i++, Cid = c.Cid, time = CalendarTools.getdata(Common.Year, thisweek, thisday - CalendarTools.weekdays(CalendarTools.CaculateWeekDay(Common.Year, Common.Month, Common.Day)), Common.Month, Common.Day).ToLongDateString() + "" + com.AddSeparator(c.ClassNumber) + "节", TeacherName = c.TeacherName, Address = c.Address, Major = c.Major, ClassType = c.ClassType, SupervisorsSum = numbersupervisor(c.Week, c.Day, c.ClassNumber) }).ToList(); } } else { if (Session["Power"].ToString() == "管理员") { List <TeachersModel> telist = DBHelper.ExecuteList <TeachersModel>("select * from teachers where college='" + Session["College"].ToString() + "'", CommandType.Text, null); referencelist = (from t in telist join c in classlist on t.TeacherName equals c.TeacherName where t.College == Session["College"].ToString() select new ReferenceModel { Id = i++, Cid = c.Cid, time = CalendarTools.getdata(Common.Year, c.Week, c.Day - CalendarTools.weekdays(CalendarTools.CaculateWeekDay(Common.Year, Common.Month, Common.Day)), Common.Month, Common.Day).ToLongDateString() + "" + com.AddSeparator(c.ClassNumber) + "节", TeacherName = c.TeacherName, Address = c.Address, Major = c.Major, ClassType = c.ClassType, SupervisorsSum = numbersupervisor(c.Week, c.Day, c.ClassNumber) }).ToList(); } else { referencelist = (from c in classlist select new ReferenceModel { Id = i++, Cid = c.Cid, time = CalendarTools.getdata(Common.Year, c.Week, c.Day - CalendarTools.weekdays(CalendarTools.CaculateWeekDay(Common.Year, Common.Month, Common.Day)), Common.Month, Common.Day).ToLongDateString() + "" + com.AddSeparator(c.ClassNumber) + "节", TeacherName = c.TeacherName, Address = c.Address, Major = c.Major, ClassType = c.ClassType, SupervisorsSum = numbersupervisor(c.Week, c.Day, c.ClassNumber) }).ToList(); } } IPagedList <ReferenceModel> iplist = referencelist.ToPagedList(page, 10); return(PartialView(iplist)); }