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 bool AddTeaToTG(string teaname, string tgname) { TeaGroupDal tgdal = new TeaGroupDal(); Teacher t = new Teacher(); TeaGroup tg = new TeaGroup(); IQueryable <Teacher> iqtea = teaDal.GetEntities(u => u.Tea_Name == teaname); foreach (var item in iqtea) { t = item; } IQueryable <TeaGroup> iqtg = tgdal.GetEntities(u => u.TG_Name == tgname); foreach (var item in iqtg) { tg = item; } DBSession db = new DBSession(); t.TeaGroup = tg; if (teaDal.UpdateEntity(t) != null) { db.SaveChanges(); return(true); } ; return(false); }
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 AddTeaGroup() { TeaGroupDal tgdal = new TeaGroupDal(); string depname = Request["dep"]; string tgname = Request["tgname"]; if (string.IsNullOrEmpty(tgname)) { Response.Write("小组名不能为空"); Response.End(); return(null); } IQueryable <TeaGroup> iq = tgdal.GetEntities(u => u.TG_Name == tgname); if (iq.Count() > 0) { Response.Write("小组已存在不能重复添加"); Response.End(); return(null); } DepartmentService depser = new DepartmentService(); Department dep = depser.GetDepartmentByName(depname); TeaGroup tg = new TeaGroup(); tg.TG_Name = tgname; tg.Department = dep; TeaGroupService tgser = new TeaGroupService(); tgser.Add(tg); Response.Write("添加成功"); Response.End(); return(null); }
public ActionResult GetAllMyFuZeLunWen() { Teacher s = (Teacher)Session["teacher"]; TeaGroup tg = s.TeaGroup; if (tg == null) { Response.Write(""); Response.End(); return(View()); } ChoseThemeService chosetser = new ChoseThemeService(); IQueryable <ChoseTheme> choiq = chosetser.GetAllChoseTheme(); StuFileService sfser = new StuFileService(); IList <int> stuidlist = new List <int>(); IList <string> strlist = new List <string>(); string str = ""; int m = 0; strlist.Add(tg.TG_Name); foreach (var item in choiq) { if (item.Theme.TeaGroup.TG_Id == tg.TG_Id) { //stuidlist.Add((int)item.Student.Stu_Id); StuFile sf = sfser.GetStuFileByStu((int)item.Student.Stu_Id); if (sf == null) { m++; } if (sf != null) { str = sf.Student.Stu_Name + "=" + sf.StuF_Name + "=" + sf.SubTime + "=" + sf.Url; strlist.Add(str); } } } //string str = ""; //for (int i = 0; i < stuidlist.Count(); i++) //{ // StuFile sf = sfser.GetStuFileByStu(stuidlist[i]); // if (sf == null) // { // m++; // } // if (sf!=null) // { // str = sf.Student.Stu_Name + "=" + sf.StuF_Name + "=" + sf.SubTime+"="+sf.Url; // strlist.Add(str); // } //} string outstr = js.Serialize(strlist); Response.Write(outstr); Response.End(); return(null); }
public bool Add(TeaGroup tg) { DBSession db = new DBSession(); if (tgdal.Add(tg) != null) { db.SaveChanges(); return(true); } ; return(false); }
public ActionResult AddOneTea() { DepartmentService depser = new DepartmentService(); TeaGroupDal tegd = new TeaGroupDal(); TeaGroup t = new TeaGroup(); IQueryable <TeaGroup> iq = tegd.GetEntities(u => u.TG_Id == 1); foreach (var item in iq) { t = item; } //DepartmentDal depdal = new DepartmentDal(); TeacherService teaser = new TeacherService(); string teanum = Request["teanum"]; string teaname = Request["teaname"]; string teasex = Request["teasex"]; string teadep = Request["teadep"]; Department dep = depser.GetDepartmentByName(teadep); Teacher tea = new Teacher(); tea.Tea_Num = teanum; if (teanum == "" || teaname == "") { Response.Write("工号姓名不能为空!"); Response.End(); return(null); } Teacher tea2 = teaser.GetTeacherByNum(teanum); if (tea2 != null) { Response.Write("此老师已存在,不能重复添加"); Response.End(); return(null); } tea.Tea_Name = teaname; tea.Tea_Pwd = "123"; tea.Tea_Sex = teasex; tea.Department = dep; // tea.Tea_Email = ""; tea.Tea_Photo = ""; tea.Tea_Tel = ""; // tea.TeaGroup = t; teaser.AddOneTea(tea); Response.Write("添加成功"); Response.End(); return(null); }
public TeaGroup GetTeaGroupById(int tgid) { TeaGroup tg = new TeaGroup(); IQueryable <TeaGroup> iq = tgdal.GetEntities(u => u.TG_Id == tgid); if (iq.Count() == 0) { return(null); } foreach (var item in iq) { tg = item; } return(tg); }
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); }