public void Select(HttpRequestBase req, Container_List_FreeTime container_list_free) { TmTab_ResearchCon tmTab_RC = new TmTab_ResearchCon(); //1,2,3,4,5,6,7 tmTab_RC.WeekStart = !string.IsNullOrEmpty(req.Form["weekStart"]) ? Convert.ToInt32(req.Form["weekStart"]) : 1; tmTab_RC.WeekEnd = !string.IsNullOrEmpty(req.Form["weekEnd"]) ? Convert.ToInt32(req.Form["weekEnd"]) : 7; //1,3,5,7,9,10,12 tmTab_RC.SectionStart = !string.IsNullOrEmpty(req.Form["sectionStart"]) ? Convert.ToInt32(req.Form["sectionStart"]) : 1; tmTab_RC.SectionEnd = !string.IsNullOrEmpty(req.Form["sectionEnd"]) ? Convert.ToInt32(req.Form["sectionEnd"]) : 12; object value = null; value = req.Form["grdID"]; UserStatus us = new UserStatus(); us.Grd = new Grade() { ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0 }; value = req.Form["collageID"]; us.Clg = new Collage() { ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0 }; value = req.Form["depID"]; us.Dep = new Department() { ID = !string.IsNullOrEmpty(value.ToString()) ? Convert.ToInt32(value) : 0 }; tmTabDal = new TimeTableDAL(); tmTabDal.Select(us, tmTab_RC); tmTabDal.ReturnUnitToPool(); container_list_free.list_free = tmTabDal.list_free; }
public void Select(UserStatus user, TmTab_ResearchCon tmTab_RC) { Dictionary<int,string> dayDictionary = null; this.GetDays(tmTab_RC.WeekStart, tmTab_RC.WeekEnd,out dayDictionary); string strDay = null; foreach (var d in dayDictionary) { strDay += d.Value + ","; } string con = this.GetCondition(user); dalBase.sql = "SELECT db_users.id,db_users.stuNum,db_users.stuName,db_users.phone," + "db_users.sex,db_users.short_phone," + //"db_collage.collagename,db_grade.grdname,db_department.depname" + strDay + "db_user_timetable.class " + "FROM db_users,db_collage,db_department,db_grade,db_user_timetable " + "WHERE db_users.collageid = db_collage.collageid " + "AND db_users.depid = db_department.depid " + "AND db_users.grdid = db_grade.grdid " + "AND db_users.id = db_user_timetable.id " + "AND db_user_timetable.class BETWEEN @classStart AND @classEnd " + con; //+ "ORDER BY db_user_timetable.class"//+ " GROUP BY db_user_timetable.class " dalBase.List_param = new List<MySqlParameter>() { new MySqlParameter("@classStart",tmTab_RC.SectionStart), new MySqlParameter("@classEnd",tmTab_RC.SectionEnd) }; dalBase.Run(Behavious.SELECT_WITH_MUTIPARAM, false); list_free.Clear(); while (dalBase.DataRead.Read()) { int id = Convert.ToInt32(dalBase.DataRead["id"]); string section = Convert.ToString(dalBase.DataRead["class"]); string day; string free = section; int freeCount = 0; foreach(var d in dayDictionary) { day = Convert.ToString(d.Value); if (Convert.ToChar(dalBase.DataRead[day]) == '0') { free += "*" + d.Key; freeCount++; } } free += "#"; if (freeCount == 0) continue; UserFreeTime u_ft = list_free.Find(model => model.ID == id);; if (u_ft == null) { string a = dalBase.DataRead["sex"].ToString(); u_ft = new UserFreeTime() { ID = id, UserID = dalBase.DataRead["stuNum"].ToString(), UserName = dalBase.DataRead["stuName"].ToString(), Phone = dalBase.DataRead["phone"].ToString(), Phone_short = dalBase.DataRead["short_phone"].ToString(), Sex = Convert.ToByte(dalBase.DataRead["sex"]), FreeTime = free }; list_free.Add(u_ft); } else { u_ft.FreeTime += free; } } dalBase.CloseConnect(); }