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());
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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 void TestMethod_GetProfessorById()
        {
            ProfessorDao professorDao = new ProfessorDao();
            Professor    professor_2  = new Professor();

            professor_2 = professorDao.getProfessorById("zzw16211094");
            Console.WriteLine(professor_2.id);
        }
Beispiel #5
0
        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 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 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 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());
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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 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;
            }
        }
            }                                        //调剂导师

            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 = "";
                }
            }
Beispiel #13
0
        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>\"]" +
                   "}");
        }
Beispiel #14
0
 public string getProfessors()
 {
     try
     {
         ProfessorDao          professorDao = new ProfessorDao();
         StudentDao            studentDao   = new StudentDao();
         string                res          = "";
         List <Professor>      psList       = null;
         AdminProfessor        ap           = null;
         List <AdminProfessor> apsList      = new List <AdminProfessor>();
         psList = professorDao.listAllProfessor();
         if (psList == null)
         {
             return(res);
         }
         else
         {
             foreach (Professor p in psList)
             {
                 ap            = new AdminProfessor();
                 ap.proId      = p.id;
                 ap.proName    = p.name;
                 ap.proTitle   = p.title;
                 ap.proQuota   = (professorDao.getProfessorById(p.id)).quota;
                 ap.ProInfoUrl = (professorDao.getProfessorById(p.id)).infoURL;
                 int            ProFirstNum = 0, ProSecondNum = 0, ProAssignNum = 0;
                 List <Student> stlist = studentDao.listAllStudent();
                 if (stlist != null && stlist.Count > 0)
                 {
                     foreach (Student s in stlist)
                     {
                         if (s.firstWill == p.id && s.firstWillState == 1)
                         {
                             ProFirstNum++;
                         }
                         else if (s.secondWill == p.id && s.secondWillState == 1)
                         {
                             ProSecondNum++;
                         }
                         else if (s.dispensedWill == p.id)
                         {
                             ProAssignNum++;
                         }
                     }
                 }
                 ap.ProFirstNum  = ProFirstNum;
                 ap.ProSecondNum = ProSecondNum;
                 ap.ProAssignNum = ProAssignNum;
                 ap.ProRestNum   = ap.proQuota - ProFirstNum - ProSecondNum - ProAssignNum;
                 apsList.Add(ap);
             }
             JavaScriptSerializer serializer = new JavaScriptSerializer();
             var json = serializer.Serialize(apsList);
             res        = json.ToString();
             serializer = null;
         }
         return(res);
     }
     catch (Exception e)
     {
         LogUtil.writeLogToFile(e, Request);
         return("平台出现异常,请联系管理员:XXX");
     }
 }