public ActionResult FinalWill() { try { HttpCookie accountCookie = Request.Cookies["Account"]; string id = accountCookie["userId"]; StudentDao studentDao = new StudentDao(); ProfessorDao professorDao = new ProfessorDao(); Student student = studentDao.getStudentById(id); if (student.firstWillState == 1) { ViewBag.Final = professorDao.getProfessorById(student.firstWill).name; } else if (student.secondWillState == 1) { ViewBag.Final = professorDao.getProfessorById(student.secondWill).name; } else if (student.dispensedWill != null) { ViewBag.Final = professorDao.getProfessorById(student.dispensedWill).name; } else { ViewBag.Final = "无"; } } catch (Exception e) { LogUtil.writeLogToFile(e, Request); ViewBag.Final = "出现错误,请联系管理员"; } //ViewBag.Final-最后选择结果 return(View()); }
// GET: Aluno public ActionResult Form(string professorId = "") { var professor = ProfessorDao.BuscaPorId(Convert.ToInt32(professorId)); if ((TempData["idAluno"] != null) && (!string.IsNullOrEmpty(TempData["idAluno"].ToString()))) { ViewBag.Aluno = AlunoDao.BuscaPorId(Convert.ToInt32(TempData["idAluno"].ToString())); } else { ViewBag.Aluno = new Aluno(professor); } if (TempData["mensagem"] != null) { ViewBag.Mensagem = TempData["mensagem"].ToString(); } else { ViewBag.Mensagem = string.Empty; } ViewBag.Alunos = AlunoDao.BuscaAlunosProfessor(Convert.ToInt32(professorId)); ViewBag.Professor = ProfessorDao.BuscaPorId(Convert.ToInt32(professorId)); return(View()); }
public void TestMethod_DeleteProfessorByIds() { string[] ids = { "xzy16211083", "jyf16211084" }; ProfessorDao professorDao = new ProfessorDao(); professorDao.deleteProfessorByIds(ids); }
public string listSelectedStudentsByProId(string proId) { try { ProfessorDao professorDao = new ProfessorDao(); StudentDao studentDao = new StudentDao(); List <Student> stlist = studentDao.listAllStudent(); List <Student> listSelectedStudents = new List <Student>(); string res = ""; foreach (Student s in stlist) { if (s.firstWill == proId && s.firstWillState == 1) { listSelectedStudents.Add(s); } else if (s.secondWill == proId && s.secondWillState == 1) { listSelectedStudents.Add(s); } else if (s.dispensedWill == proId) { listSelectedStudents.Add(s); } } JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.Serialize(listSelectedStudents); res = json.ToString(); return(res); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("平台出现异常,请联系管理员:XXX"); } }
public void TestMethod_UpdateProfessor() { ProfessorDao professorDao = new ProfessorDao(); bool isRight = professorDao.updateProfessor("zzw16211094", "new_zzw", "new_title", "new_info", 1, "new_remark"); Console.WriteLine(isRight); }
public void TestMethod_DeleteProfessorById() { ProfessorDao professorDao = new ProfessorDao(); int isRight = professorDao.deleteProfessorById("zzw16211094"); Console.WriteLine(isRight); }
public ActionResult Index() { ViewBag.Alunos = AlunoDao.BuscaAlunosMaior16(); ViewBag.Professores = ProfessorDao.BuscaProfessorMedia15_17(); return(View()); }
public ActionResult AdicionarOuSalvar(Professor professor) { try { ProfessorDao professorDao = new ProfessorDao(); if (professor.Id > 0) { professorDao.Atualizar(professor); TempData["mensagem"] = "Registro Alterado com sucesso"; } else { professorDao.Adicionar(professor); TempData["mensagem"] = "Cadastrado com sucesso"; } return(RedirectToAction("Form", "Professor")); } catch (Exception e) { TempData.Add("mensagem", e.Message); return(RedirectToAction("Form")); } }
public string listProfessors() { try { ProfessorDao professorDao = new ProfessorDao(); string retStr = ""; List <Professor> professors = professorDao.listAllProfessor(); List <TempProfessor> resultPro = new List <TempProfessor>(); if (professors != null) { foreach (var professor in professors) { TempProfessor tempProfessor = new TempProfessor(); tempProfessor.init(professor); resultPro.Add(tempProfessor); } } JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.Serialize(resultPro); retStr = json.ToString(); return(retStr); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("[]"); } }
public string addSingleProfessor(string name, string number, string title, string url, int needstudent, string passwd = "12345") { try { ProfessorDao professorDao = new ProfessorDao(); string res = ""; Professor professor = new Professor(); professor.name = name; professor.id = number; professor.title = title; professor.infoURL = url; professor.password = CryptoUtil.Md5Hash(passwd); professor.quota = needstudent; Exception e = new Exception("教师id重复"); if (professorDao.getProfessorById(number) != null) { throw (e); } else { res = "success"; professorDao.addProfessor(professor); } return(res); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("平台出现异常,请联系管理员:XXX"); } }
public string listProfessors() { try { ProfessorDao professor = new ProfessorDao(); List <Professor> proList = professor.listAllProfessor(); List <ProfessorInfoForStu> proInfoForStu = new List <ProfessorInfoForStu>(); string res = ""; foreach (Professor p in proList) { ProfessorInfoForStu pro = new ProfessorInfoForStu(); //不显示没有名额的老师 if (p.quota < 1) { continue; } pro.id = p.id; pro.name = p.name; pro.title = p.title; pro.infoUrl = p.infoURL; proInfoForStu.Add(pro); } JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.Serialize(proInfoForStu); res = json.ToString(); return(res); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("平台出现异常,请联系管理员:XXX"); } }
public ActionResult Contact() { ViewBag.Message = "Listagem de professor no qual é responsável por determinado aluno."; List <ProfessorModel> professor = new ProfessorDao().ObterTodos(); ViewBag.Professor = professor; return(View()); }
public void TestMethod_GetProfessorById() { ProfessorDao professorDao = new ProfessorDao(); Professor professor_2 = new Professor(); professor_2 = professorDao.getProfessorById("zzw16211094"); Console.WriteLine(professor_2.id); }
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 ProfessorInfo(string proId) { ProfessorDao professorDao = new ProfessorDao(); Professor p = professorDao.getProfessorById(proId); ViewBag.Name = p.name; ViewBag.Id = p.id; ViewBag.Url = p.infoURL; ViewBag.ProTitle = p.title; return(View()); }
public void TestMethod_ListAllProfessor() { ProfessorDao professorDao = new ProfessorDao(); Professor professor_2 = new Professor(); List <Professor> list = professorDao.listAllProfessor(); foreach (Professor professor in list) { Console.WriteLine(professor.id); } Console.WriteLine("right"); }
public string doLogin(string userId, string passwd, int role) { string retStr = "fail:登录失败,用户不存在或密码错误"; switch (role) { case 1: StudentDao studentDao = new StudentDao(); Student student = studentDao.getStudentById(userId); string s = CryptoUtil.Md5Hash(passwd); if (student != null && passwd == student.password) { Response.Cookies.Add(createCookie(userId, student.name, passwd, "student", 24 * 60)); retStr = "success:/Student/Index"; } break; case 2: ProfessorDao professorDao = new ProfessorDao(); Professor professor = professorDao.getProfessorById(userId); if (professor != null && passwd == professor.password) { Response.Cookies.Add(createCookie(userId, professor.name, passwd, "professor", 24 * 60)); retStr = "success:/professor/Index"; } break; case 3: DeanDao deanDao = new DeanDao(); Dean dean = deanDao.getDeanById(userId); if (dean != null && passwd == dean.password) { Response.Cookies.Add(createCookie(userId, dean.name, passwd, "dean", 24 * 60)); retStr = "success:/dean/Student"; } break; case 4: AdminDao adminDao = new AdminDao(); Admin admin = adminDao.getAdminById(userId); if (admin != null && passwd == admin.password) { Response.Cookies.Add(createCookie(userId, admin.name, passwd, "admin", 24 * 60)); retStr = "success:/admin/Index"; } break; default: break; } return(retStr); }
public ActionResult Excluir(string professorId) { try { var professorDao = new ProfessorDao(); professorDao.ExcluirId(Int32.Parse(professorId)); return(RedirectToAction("Form")); } catch (Exception e) { TempData["mensagem"] = e.Message; return(RedirectToAction("Form")); } }
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 string deleteSingleProfessor(string proId) { try { ProfessorDao professorDao = new ProfessorDao(); int res1 = professorDao.deleteProfessorById(proId); if (res1 == 1) { return("success"); } return("fail:没有找到对应的教师"); } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("平台出现异常,请联系管理员:XXX"); } }
public string setProfessorQuota(string proId, int quota) { ProfessorDao professorDao = new ProfessorDao(); try { if (professorDao.getProfessorById(proId) == null) { return("fail:未找到用户"); } if (professorDao.changeQuotaById(proId, quota)) { return("success"); } return("fail:修改失败"); } catch (Exception e) { return("fail:" + e.Message); } }
public string resetProfessorPassword(string proId, string password) { ProfessorDao professorDao = new ProfessorDao(); try { if (professorDao.getProfessorById(proId) == null) { return("fail:未找到用户"); } if (professorDao.changePasswordById(proId, password)) { return("success"); } return("fail:修改失败"); } catch (Exception e) { return("fail:" + e.Message); } }
public ActionResult Index() { HttpCookie accountCookie = Request.Cookies["Account"]; string id = accountCookie["userId"]; Professor professor = new ProfessorDao().getProfessorById(id); SettingDao settingDao = new SettingDao(); ViewBag.EndTime = settingDao.getCurrentSetting().firstEnd; int count = 0; StudentDao studentDao = new StudentDao(); foreach (Student s in studentDao.listAllStudent()) { if (s.firstWill == id && s.firstWillState == 1 || s.secondWill == id && s.secondWillState == 1) { count++; } } ViewBag.RemainNum = professor.quota - count; return(View()); }
public void TestMethod_AddProfessor() { ProfessorDao professorDao = new ProfessorDao(); Professor professor_1 = new Professor(); professor_1.id = "zzw16211094"; professor_1.name = "zzw"; professor_1.password = "******"; professor_1.remark = "test"; professor_1.quota = 0; professor_1.infoURL = "oldinfo"; professor_1.title = "software"; int result2 = professorDao.addProfessor(professor_1); Assert.AreEqual(1, result2); Professor professor_2 = new Professor(); professor_2.id = "jyf16211084"; professor_2.name = "jyf"; professor_2.password = "******"; professor_2.remark = "test"; professor_2.infoURL = "oldinfo"; professor_2.title = "software"; professor_2.quota = 0; int result3 = professorDao.addProfessor(professor_2); Professor professor_3 = new Professor(); professor_3.id = "xzy16211083"; professor_3.name = "xzy"; professor_3.password = "******"; professor_3.remark = "test"; professor_3.infoURL = "oldinfo"; professor_3.title = "software"; professor_3.quota = 0; int result4 = professorDao.addProfessor(professor_3); }
public ActionResult Professor() { HttpCookie accountCookie = Request.Cookies["Account"]; string id = accountCookie["userId"]; StudentDao studentDao = new StudentDao(); Student student = studentDao.getStudentById(id); if (string.IsNullOrEmpty(student.firstWill) || string.IsNullOrEmpty(student.secondWill)) { ViewBag.FirstWill = ""; ViewBag.SecondWill = ""; } else { ProfessorDao professorDao = new ProfessorDao(); Professor professor = professorDao.getProfessorById(student.firstWill); ViewBag.FirstWill = professor.name; professor = professorDao.getProfessorById(student.secondWill); ViewBag.SecondWill = professor.name; } return(View()); }
public ActionResult Form() { if ((TempData["idProfessor"] != null) && (!string.IsNullOrEmpty(TempData["idProfessor"].ToString()))) { ViewBag.Professor = ProfessorDao.BuscaPorId(Convert.ToInt32(TempData["idProfessor"].ToString())); } else { ViewBag.Professor = new Professor(); } if (TempData["mensagem"] != null) { ViewBag.Mensagem = TempData["mensagem"].ToString(); } else { ViewBag.Mensagem = string.Empty; } ViewBag.Professores = ProfessorDao.Lista(); return(View()); }
public string batchCreateTeachers(HttpPostedFileBase file) { var severPath = this.Server.MapPath("/ExcelFiles/"); if (!Directory.Exists(severPath)) { Directory.CreateDirectory(severPath); } var savePath = Path.Combine(severPath, file.FileName); Professor professor = null; string result = "{}"; bool flag = false; List <Professor> proList = new List <Professor>(); Workbook workbook = new Workbook(); Worksheet sheet = null; int error = 0; Response.ContentType = "application/json"; Response.Charset = "utf-8"; try { if (string.Empty.Equals(file.FileName) || (".xls" != Path.GetExtension(file.FileName) && ".xlsx" != Path.GetExtension(file.FileName))) { throw new Exception("文件格式不正确"); } file.SaveAs(savePath); workbook.LoadFromFile(savePath); sheet = workbook.Worksheets[0]; int row = sheet.Rows.Length; //获取不为空的行数 int col = sheet.Columns.Length; //获取不为空的列数 string tempId; string tempName; string tempTitle; string tempUrl; string tempQuota; string tempPass; int idcol = -11; int namecol = -11; int titlecol = -11; int idrow = -11; int urlcol = -11; int quotacol = -11; int passwordcol = -11; ProfessorDao professorDao = new ProfessorDao(); CellRange[] cellrange = sheet.Cells; int rangelength = cellrange.Length; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { tempId = cellrange[i * col + j].Value; if (tempId.Equals("工号")) { idcol = j; idrow = i + 1; } if (tempId.Equals("姓名")) { namecol = j; } if (tempId.Equals("职称")) { titlecol = j; } if (tempId.Equals("介绍页面url")) { urlcol = j; } if (tempId.Equals("最大招收学生数")) { quotacol = j; } if (tempId.Equals("密码")) { passwordcol = j; } } if (idcol >= 0 && namecol >= 0) { break; } } if (idcol < 0 || namecol < 0) { throw new Exception("表格格式不正确"); } for (int i = idrow; i < row; i++) { tempId = cellrange[i * col + idcol].Value; tempName = cellrange[i * col + namecol].Value; tempTitle = cellrange[i * col + titlecol].Value; tempUrl = cellrange[i * col + urlcol].Value; tempQuota = cellrange[i * col + quotacol].Value; tempPass = cellrange[i * col + passwordcol].Value; if (professorDao.getProfessorById(tempId) != null) { flag = true; result += "已存在教师:id:" + tempId + " 姓名:" + tempName + " 专业:" + tempId + "\n"; continue; } if (tempName != "") { professor = new Professor(); professor.id = tempId; professor.name = tempName; professor.title = tempTitle; professor.infoURL = tempUrl; professor.quota = int.Parse(tempQuota); professor.password = CryptoUtil.Md5Hash(tempPass); error = professorDao.addProfessor(professor); if (error < 1) { throw new Exception("数据库更新出错"); } } } } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("{\"error\":\"" + e.Message + "\"}"); } finally { workbook.Dispose(); sheet = null; workbook = null; } if (flag) { return("{\"error\":\"" + result + "\"}"); } return("{" + "\"initialPreview\":" + "[\"<div style=\\\"text-align:center;padding:50px 25px;color:#00a65a\\\"><i class=\\\"fa fa-check-square-o\\\" style=\\\"font-size:60px;opacity:0.6\\\"></i><p style=\\\"padding-top:10px;font-size:18px\\\">添加成功</p></div>\"]" + "}"); }
public void TestMethod_ChangePasswordById() { ProfessorDao professorDao = new ProfessorDao(); professorDao.changePasswordById("zzw16211094", "newPassword"); }
} //调剂导师 public void init(Student student) { this.id = student.id; this.name = student.name; this.infoChecked = student.infoChecked; this.willchecked = ((student.firstWill != null) && (student.secondWill != null)); this.age = student.age; this.Major = new MajorDao().getMajorById(student.majorId).name; this.phoneNumber = student.phoneNumber; this.onTheJob = student.onTheJob; this.email = student.email; this.resumeUrl = student.resumeUrl; ProfessorDao professorDao = new ProfessorDao(); if (professorDao.getProfessorById(student.firstWill) != null) { this.firstWill = professorDao.getProfessorById(student.firstWill).name; } else { this.firstWill = ""; } if (professorDao.getProfessorById(student.secondWill) != null) { this.secondWill = professorDao.getProfessorById(student.secondWill).name; } else { this.secondWill = ""; } if (student.firstWillState == 1) { if (professorDao.getProfessorById(student.firstWill) != null) { this.finalWill = professorDao.getProfessorById(student.firstWill).name; } else { this.finalWill = ""; } } else if (student.secondWillState == 1) { if (professorDao.getProfessorById(student.secondWill) != null) { this.finalWill = professorDao.getProfessorById(student.secondWill).name; } else { this.finalWill = ""; } } else { if (professorDao.getProfessorById(student.dispensedWill) != null) { this.finalWill = professorDao.getProfessorById(student.dispensedWill).name; } else { this.finalWill = ""; } } if (professorDao.getProfessorById(student.dispensedWill) != null) { this.dispensedWill = professorDao.getProfessorById(student.dispensedWill).name; } else { this.dispensedWill = ""; } }
public string changePassword(string oldpasswd, string newpasswd) { HttpCookie accountCookie = Request.Cookies["Account"]; string retStr = ""; try { switch (accountCookie["role"]) { case "student": StudentDao studentDao = new StudentDao(); Student student = studentDao.getStudentById(accountCookie["userId"]); if (student != null && student.password == oldpasswd) { studentDao.changePasswdById(student.id, newpasswd); retStr = "success"; } else { retStr = "fail:用户不存在或密码错误"; } return(retStr); case "professor": ProfessorDao professorDao = new ProfessorDao(); Professor professor = professorDao.getProfessorById(accountCookie["userId"]); if (professor != null && professor.password == oldpasswd) { professorDao.changePasswordById(professor.id, newpasswd); retStr = "success"; } else { retStr = "fail:用户不存在或密码错误"; } return(retStr); case "dean": DeanDao deanDao = new DeanDao(); Dean dean = deanDao.getDeanById(accountCookie["userId"]); if (dean != null && dean.password == oldpasswd) { deanDao.changeDeanPasswdById(dean.id, newpasswd); retStr = "success"; } else { retStr = "fail:用户不存在或密码错误"; } return(retStr); case "admin": AdminDao adminDao = new AdminDao(); Admin admin = adminDao.getAdminById(accountCookie["userId"]); if (admin != null && admin.password == oldpasswd) { adminDao.changePasswdById(admin.id, newpasswd); retStr = "success"; } else { retStr = "fail:用户不存在或密码错误"; } return(retStr); default: return("fail:没有权限"); } } catch (Exception) { throw; } }