public ExamPlan getExamPlanByID(string planID) { using (ISession session = getSession()) { ExamPlan examPlan = (ExamPlan)session.Get(typeof(ExamPlan), planID); examPlan.ProfessionID = examPlan.Profession.Id; examPlan.FacultyID = examPlan.Profession.Faculty.Id; NHibernateUtil.Initialize(examPlan.CouresSet); return(examPlan); } }
private void initStudentResult() { try { string ExamPlanID = context.Request.Form.Get("ExamPlanID"); PlanService planService = new PlanService(); ExamPlan examPlan = planService.getExamPlanByID(ExamPlanID); IList <ExamPlan> examPlanList = new List <ExamPlan>(); examPlanList.Add(examPlan); ExamResultService ers = new ExamResultService(); object[] obj = ers.searchExamResult(examPlanList, int.MaxValue, 1); if (obj[1] != null) { IList <ExamResult> examResultList = (IList <ExamResult>)obj[1]; foreach (ExamResult er in examResultList) { ers.del(er); } } Student student = new Student(); IList <Profession> professionList = new List <Profession>(); professionList.Add(examPlan.Profession); student.ProfessionList = professionList; StudentService ss = new StudentService(); object[] studentObjArr = ss.getStudentList(student, int.MaxValue, 1); if (studentObjArr[1] != null) { IList <Student> studentList = (IList <Student>)studentObjArr[1]; foreach (Student s in studentList) { ExamResult examResult = new ExamResult(); examResult.ExamPlan = examPlan; examResult.Student = s; ers.save(examPlan); IDictionary <string, string> map = new Dictionary <string, string>(); foreach (Coures c in examPlan.CouresSet) { map.Add(c.Name, "0"); } examResult.CouresScoreMap = map; ers.save(examResult); } } context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }
public ActionResult DeleteConfirmed(int id) { ExamPlan examPlan = db.ExamPlan.Find(id); foreach (var res in db.ExamResult.Where(e => e.ExamPlanId == id)) { db.ExamResult.Remove(res); } db.ExamPlan.Remove(examPlan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,LessonId,GroupId,TeacherId,ExamDate")] ExamPlan examPlan) { if (ModelState.IsValid) { db.Entry(examPlan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GroupId = new SelectList(db.Group, "Id", "Number", examPlan.GroupId); ViewBag.LessonId = new SelectList(db.Lesson, "Id", "Name", examPlan.LessonId); ViewBag.TeacherId = new SelectList(db.Teacher, "Id", "Name", examPlan.TeacherId); return(View(examPlan)); }
// GET: ExamPlans/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExamPlan examPlan = db.ExamPlan.Find(id); if (examPlan == null) { return(HttpNotFound()); } return(View(examPlan)); }
private void getPlanByID() { try { string ExamPlanID = context.Request.Form.Get("ExamPlanID"); PlanService planService = new PlanService(); ExamPlan examPlan = planService.getExamPlanByID(ExamPlanID); String json = JsonConvert.SerializeObject(examPlan); context.Response.Write(json); } catch (Exception e) { context.Response.Write("0"); } }
public void getColumn() { DepartmentService ds = new DepartmentService(); IList professionList = new ArrayList(); string ProfessionID = context.Request.Form.Get("ProfessionID"); string YearNo = context.Request.Form.Get("YearNo"); string LevelNo = context.Request.Form.Get("LevelNo"); if (!string.IsNullOrEmpty(ProfessionID)) { Profession profession = ds.getProfessionByID(ProfessionID); professionList.Add(profession); } PlanService ps = new PlanService(); object[] planObjArr = ps.searchPlan(professionList, YearNo, LevelNo, int.MaxValue, 1); if (planObjArr[1] != null) { IList <ExamPlan> examPlanList = (IList <ExamPlan>)planObjArr[1]; if (examPlanList == null) { return; } ExamPlan ep = examPlanList.ElementAt(0); ArrayList newArrayList = new ArrayList(); if (examPlanList.ElementAt(0).CouresSet == null) { return; } foreach (Coures c in examPlanList.ElementAt(0).CouresSet) { newArrayList.Add(c.Name); } newArrayList.Sort(); IList <Hashtable> columnList = new List <Hashtable>(); foreach (string s in newArrayList) { Hashtable ht = new Hashtable(); ht.Add("columnName", s); columnList.Add(ht); } String json = JsonConvert.SerializeObject(columnList); context.Response.Write(json); } }
// GET: ExamPlans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExamPlan examPlan = db.ExamPlan.Find(id); if (examPlan == null) { return(HttpNotFound()); } ViewBag.GroupId = new SelectList(db.Group, "Id", "Number", examPlan.GroupId); ViewBag.LessonId = new SelectList(db.Lesson, "Id", "Name", examPlan.LessonId); ViewBag.TeacherId = new SelectList(db.Teacher, "Id", "Name", examPlan.TeacherId); return(View(examPlan)); }
private void deleteExamPlan() { try { string ExamPlanID = context.Request.Form.Get("ExamPlanID"); PlanService planService = new PlanService(); ExamPlan examPlan = planService.getExamPlanByID(ExamPlanID); examPlan.CouresSet = null; planService.save(examPlan); planService.del(examPlan); context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }
public ActionResult Create([Bind(Include = "Id,LessonId,GroupId,TeacherId,ExamDate")] ExamPlan examPlan) { try { if (ModelState.IsValid) { db.ExamPlan.Add(examPlan); db.SaveChanges(); UpdateResults(examPlan.Id, examPlan.GroupId); return(RedirectToAction("Index")); } } catch (DataException) { ViewBag.LessonId = new SelectList(db.Lesson, "Id", "Name", examPlan.LessonId); ViewBag.GroupId = new SelectList(db.Group, "Id", "Number", examPlan.GroupId); ViewBag.TeacherId = new SelectList(db.Teacher, "Id", "Name", examPlan.TeacherId); ModelState.AddModelError("", "Такой экзамен уже существует!"); return(View(examPlan)); } return(View(examPlan)); }
private void saveCoures() { try { string ProfessionID = context.Request.Form.Get("Profession"); string FacultyID = context.Request.Form.Get("Faculty"); DepartmentService ds = new DepartmentService(); Profession profession = ds.getProfessionByID(ProfessionID); Faculty faculty = ds.getFacultyByID(FacultyID); if (profession != null && faculty != null) { ISet <Coures> couresSet = new HashedSet <Coures>(); string[] couresArr = context.Request.Form.GetValues("Coures"); CouresService cs = new CouresService(); foreach (string c in couresArr) { Coures coures = cs.getCouresByID(c); if (coures != null) { couresSet.Add(coures); } } ExamPlan p = new ExamPlan(); setValue(p, context); p.Profession = profession; p.Faculty = faculty; p.CouresSet = couresSet; PlanService ps = new PlanService(); ps.save(p); context.Response.Write("1"); } } catch (Exception e) { context.Response.Write("0"); } }