public void DeleteTg(int tgid) { TeacherDal teadal = new TeacherDal(); DBSession db = new DBSession(); ThemeDal thdal = new ThemeDal(); IQueryable <TeaGroup> iq = tgdal.GetEntities(u => u.TG_Id == tgid); TeaGroup tg = new TeaGroup(); foreach (var item in iq) { tg = item; } if (tgdal.DeleteEntity(tg) != null) { IQueryable <Teacher> tiq = teadal.GetEntities(u => u.TeaGroup == tg); foreach (var item in tiq) { item.TeaGroup = null; } IQueryable <Theme> theiq = thdal.GetEntities(u => u.TeaGroup == tg); foreach (var item in theiq) { item.TeaGroup = null; } } ; db.SaveChanges(); }
public ActionResult GetTeaBySou() { string key = Request["key"]; if (string.IsNullOrEmpty(key)) { string str1 = js.Serialize("请输入正确的Key值"); Response.Write(str1); Response.End(); return(View()); } string dep = Request["dep"]; TeacherDal teadal1 = new TeacherDal(); IQueryable <Teacher> iq = teadal1.GetEntities(u => (u.Tea_Name.Contains(key) || (u.TeaGroup == null ? false : u.TeaGroup.TG_Name.Contains(key))) && u.Department.Dep_Name == dep); IList <string> strlist = new List <string>(); string str = ""; foreach (var item in iq) { if (item.TeaGroup != null) { str = item.Tea_Id + "-" + item.Tea_Name + "-" + item.Tea_Sex + "-" + item.TeaGroup.TG_Name; } if (item.TeaGroup == null) { str = item.Tea_Id + "-" + item.Tea_Name + "-" + item.Tea_Sex + "-" + " "; } strlist.Add(str); } string s = js.Serialize(strlist); Response.Write(s); Response.End(); return(View()); }
public ActionResult GetTeaGroupByDep() { string dep = Request["dep"]; TeaGroupDal tgdal = new TeaGroupDal(); TeacherDal teadal = new TeacherDal(); IQueryable <TeaGroup> iq = tgdal.GetEntities(u => u.Department.Dep_Name == dep); IList <string> ls = new List <string>(); foreach (var item in iq) { string lstr = ""; IList <string> l = new List <string>(); l.Add(item.TG_Id + "-" + item.TG_Name + "-"); TeaGroup t = item; IQueryable <Teacher> teaiq = teadal.GetEntities(u => u.TeaGroup == t); foreach (var item1 in teaiq) { l.Add(item1.Tea_Name + " "); } for (int i = 0; i < l.Count(); i++) { lstr = lstr + l[i]; } ls.Add(lstr); } string str = js.Serialize(ls); // Session["tgmanage"] = ls; Response.Write(str); string s = string.Empty; Response.End(); return(View()); }
public ActionResult GetTeasByTg() { Session["tgid"] = null; int tgid = Convert.ToInt32(Request["tgid"]); Session["tgid"] = tgid; TeacherDal teadal1 = new TeacherDal(); IQueryable <Teacher> iq = teadal1.GetEntities(u => u.TeaGroup.TG_Id == tgid); string str = js.Serialize(iq); Response.Write(str); Response.End(); return(View()); }
public ActionResult GetTeaListByTgId() { TeaGroupService tgser = new TeaGroupService(); TeacherDal teadal = new TeacherDal(); int tgid = Convert.ToInt32(Request["tgid"]); TeaGroup tg = tgser.GetTeaGroupById(tgid); string str = tg.TG_Name + "-"; IQueryable <Teacher> teaiq = teadal.GetEntities(u => u.TeaGroup == tg); foreach (var item in teaiq) { str = str + item.Tea_Name + "-"; } Response.Write(str); Response.End(); return(null); }
/// <summary> /// 根据老师的工号查询老师对象 /// </summary> /// <param name="num">老师的工号</param> /// <returns>老师对象</returns> public Teacher GetTeacherByNum(string num) { string teanum = num.Trim(); Teacher s = new Teacher(); IQueryable <Teacher> teaiq = teaDal.GetEntities(tea => tea.Tea_Num == teanum); if (teaiq.Count() == 0) { return(null); } foreach (var item in teaiq) { s = item; } return(s); }