public string getAllDeans() { string rel = ""; try { JavaScriptSerializer serializer = new JavaScriptSerializer(); DeanDao deanDao = new DeanDao(); MajorDao majorDao = new MajorDao(); List <Dean> deans = new List <Dean>(); deans = deanDao.listAllDeans(); List <RetDean> ret = new List <RetDean>(); Major tmpMajor = new Major(); foreach (Dean tmp in deans) { RetDean tmpdean = new RetDean(); tmpMajor = majorDao.getMajorById(tmp.majorId); tmpdean.Number = tmp.id; tmpdean.MajorResponsible = tmpMajor.name; tmpdean.TeacherName = tmp.name; ret.Add(tmpdean); } var json = serializer.Serialize(ret); rel = json.ToString(); return(rel); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("[]"); } }
public string getStudentInfo() { string res = ""; StudentDao studentDao = new StudentDao(); MajorDao majorDao = new MajorDao(); ProfessorDao professorDao = new ProfessorDao(); List <Student> students = studentDao.listAllStudent(); List <AdminStudent> adminStudents = new List <AdminStudent>(); List <Major> majors = majorDao.listAllMajor(); if (students == null) { return(res); } else { foreach (Student s in students) { AdminStudent Astudent = new AdminStudent(); Astudent.id = s.id; Astudent.StuName = s.name; Astudent.major = majorDao.getMajorById(s.majorId).name; //专业方向? Astudent.infoCommited = s.infoChecked; if (s.firstWill != null && s.secondWill != null) { Astudent.twoWillCommited = true; } else { Astudent.twoWillCommited = false; } if (s.firstWillState == 1) { Astudent.FinalTutor = professorDao.getProfessorById(s.firstWill).name; } else if (s.secondWillState == 1) { Astudent.FinalTutor = professorDao.getProfessorById(s.secondWill).name; } else if (s.dispensedWill == null || s.dispensedWill == "") { Astudent.FinalTutor = null; } else { Astudent.FinalTutor = professorDao.getProfessorById(s.dispensedWill).name; } adminStudents.Add(Astudent); } JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.Serialize(adminStudents); res = json.ToString(); serializer = null; } return(res); }
public ActionResult StudentInfo(string stuId) { ProfessorDao professorDao = new ProfessorDao(); StudentDao studentDao = new StudentDao(); MajorDao majorDao = new MajorDao(); Student s = studentDao.getStudentById(stuId); ViewBag.Id = s.id; ViewBag.Name = s.name; ViewBag.Age = s.age; ViewBag.Gender = s.gender ? "男" : "女"; ViewBag.Email = s.email; ViewBag.Major = majorDao.getMajorById(s.majorId).name; ViewBag.OnJob = (s.onTheJob ? "在职" : "脱产"); ViewBag.Phone = s.phoneNumber; ViewBag.ResumeUrl = s.resumeUrl; if (s.firstWill != null) { ViewBag.FirstWillName = professorDao.getProfessorById(s.firstWill).name; } if (s.secondWill != null) { ViewBag.SecondWillName = professorDao.getProfessorById(s.secondWill).name; } if (s.dispensedWill != null) { ViewBag.DispensedWillName = professorDao.getProfessorById(s.dispensedWill).name; } if (s.firstWillState == 1) { ViewBag.FinalWillName = ViewBag.FirstWillName; } else if (s.secondWillState == 1) { ViewBag.FinalWillName = ViewBag.SecondWillName; } else if (s.dispensedWill != null && s.dispensedWill != "") { ViewBag.FinalWillName = ViewBag.DispensedWillName; } else { ViewBag.FinalWillName = "无"; } return(View()); }
public void TestMajorMethod_major_add_get_delete() { MajorDao majorDao = new MajorDao(); Major major = new Major(); // major.id = "a323456"; major.name = "英语"; major.remark = "123sdaSDSA"; // majorDao.addMajor(major); major = majorDao.getMajorById(major.id); ValidResult validResult = ValidateHelper.IsValid(major); Assert.AreEqual(1, majorDao.deleteMajorById(major.id)); if (!validResult.IsVaild) { foreach (ErrorMember errorMember in validResult.ErrorMembers) { Debug.WriteLine(errorMember.ErrorMemberName + ":" + errorMember.ErrorMessage); } } }
public ActionResult Index() { HttpCookie accountCookie = Request.Cookies["Account"]; string id = accountCookie["userId"]; StudentDao studentDao = new StudentDao(); Student student = studentDao.getStudentById(id); ViewBag.StuName = student.name; ViewBag.StuAge = student.age.ToString(); ViewBag.StuGender = student.gender ? "男" : "女"; ViewBag.StuTel = student.phoneNumber; ViewBag.StuEmail = student.email; ViewBag.StuId = student.id; ViewBag.StuGraSchool = student.graSchool; ViewBag.StuGraMajor = student.graMajor; ViewBag.ResumeUrl = student.resumeUrl; ViewBag.OnTheJob = student.onTheJob; MajorDao majorDao = new MajorDao(); Major major = majorDao.getMajorById(student.majorId); ViewBag.StuMajor = major.name; SettingDao settingDao = new SettingDao(); Setting setting = settingDao.getCurrentSetting(); if (setting.mode == 1) { ViewBag.Deadline = setting.infoEnd; } else { ViewBag.Deadline = ""; } return(View()); }