public ActionResult ShowVeto()
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                var db       = new TeacherRewardEntities();
                var Teachers = db.Users.Where(x => x.Department == userDetails.Department && x.isAdmin == false);
                var Vetos    = db.Veto.Select(x => x);

                Dictionary <string, string> vetoTeachers = new Dictionary <string, string>();
                foreach (var each in Vetos)
                {
                    if (Teachers.Where(x => x.ID == each.ID).Any())
                    {
                        vetoTeachers[each.ID] = each.Comment;
                    }
                }
                ViewBag.VetoDic = vetoTeachers;

                return(View(Teachers));
            }
        }
        public ActionResult UpdateInfo(string ID = null)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (ID == null)
                {
                    return(RedirectToAction("Error", "Admin"));
                }
                CommonWork();

                getDepartmentList();
                getPerformList();

                TeacherRewardEntities db = new TeacherRewardEntities();
                var curTeacherInfo       = db.TeacherInfo.SingleOrDefault(x => x.ID == ID);

                return(View(curTeacherInfo));
            }
        }
        public ActionResult ShowDetail(string ID = null)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (ID == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                CommonWork();
                getDepartmentList();

                using (TeacherRewardEntities db = new TeacherRewardEntities()) {
                    AllInfo allinfo = new AllInfo();
                    allinfo.TInfo    = db.TeacherInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TCTask   = db.TeacherCrosswiseTaskInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TPrize   = db.TeacherPrizeInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TProject = db.TeacherProjectInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TPThesis = db.TeacherPublishThesisInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TTThesis = db.TeacherTeachThesisInfo.Where(x => x.ID == ID).FirstOrDefault();
                    allinfo.TTask    = db.TeacherTaskInfo.Where(x => x.ID == ID).FirstOrDefault();
                    return(View(allinfo));
                }
            }
        }
        public ActionResult UpdateInfo(string ID, int ShiDe = -1, int BossScore = -1, int SuperScore = -1, int StuScore = -1, int DutyTime = -1, int beLate = -1, int didnotShowup = -1, int DepartWork = -1)
        {
            if (ShiDe == -1)
            {
                return(UpdateInfo(ID));
            }
            TeacherRewardEntities db = new TeacherRewardEntities();
            var thisTeacherInfo      = db.TeacherInfo.SingleOrDefault(x => x.ID == ID);

            //计算分值
            thisTeacherInfo.ShiDe       = Cal_PerformScore(ShiDe);
            thisTeacherInfo.BossScore   = Cal_PerformScore(BossScore);
            thisTeacherInfo.SuperScore  = Cal_PerformScore(SuperScore);
            thisTeacherInfo.StuScore    = Cal_PerformScore(StuScore);
            thisTeacherInfo.DutyTime    = Cal_DutyTimeScore(DutyTime);
            thisTeacherInfo.Showup      = Cal_ShowupScore(beLate, didnotShowup);
            thisTeacherInfo.DepartWorks = Cal_DepartWorkScore(DepartWork);

            try {
                db.SaveChanges();
                return(RedirectToAction("PostInfo", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            } finally {
                db.Dispose();
            }
        }
        /// <summary>
        /// 提交信息页面
        /// </summary>
        /// <returns></returns>
        public ActionResult PostInfo()
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                CommonWork();
                TeacherRewardEntities db = new TeacherRewardEntities();
                var thisTeacherScore     = db.TeacherScore.Where(x => x.ID == userDetails.ID).FirstOrDefault();
                if (thisTeacherScore != null && thisTeacherScore.FinalScore != 0)                   //主任已计算总分
                {
                    ViewBag.AlreadyCaled = true;
                }
                else
                {
                    ViewBag.AlreadyCaled = false;
                }

                getListsReady();

                return(View());
            }
        }
 public ActionResult Authorize(Users user)
 {
     using (TeacherRewardEntities db = new TeacherRewardEntities()) {
         var userDetails = db.Users.Where(x => x.ID == user.ID && x.Password == user.Password).FirstOrDefault();
         if (userDetails == null)
         {
             user.ErrMsg = "用户名或密码错误";
             return(View("Index", user));
         }
         else
         {
             ///
             ///使用userDetails而不是user,因为user对象中的isAdmin和Department没有赋值(用户只输入了ID和密码)
             ///
             Session["userID"]  = userDetails.ID;
             Session["isAdmin"] = userDetails.isAdmin;
             Session["Depart"]  = userDetails.Department;
             if (userDetails.isAdmin)
             {
                 return(RedirectToAction("Index", "Admin"));
             }
             else
             {
                 return(RedirectToAction("Index", "Home"));
             }
         }
     }
 }
        public ActionResult ShowAll(string ID = null, string Name = null, int SearchByDepart = 0, string sortBy = "none", bool ShowCheck = false)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                CommonWork();

                getDepartmentList();
                getSortList();
                getisSelectedList();

                TeacherRewardEntities db = new TeacherRewardEntities();
                var TeacherScores        = db.TeacherScore.Select(x => x);

                //筛选信息
                if (ShowCheck == true)
                {
                    TeacherScores = TeacherScores.Where(x => x.isSelected == true);
                }
                if (!String.IsNullOrEmpty(ID))
                {
                    TeacherScores = TeacherScores.Where(x => x.ID.Contains(ID));
                }
                if (!String.IsNullOrEmpty(Name))
                {
                    TeacherScores = TeacherScores.Where(x => x.Name.Contains(Name));
                }
                if (SearchByDepart != 0)
                {
                    TeacherScores = TeacherScores.Where(x => x.Depart == SearchByDepart);
                }
                switch (sortBy)
                {
                case "low":
                    TeacherScores = TeacherScores.OrderBy(x => x.FinalScore);
                    break;

                case "high":
                    TeacherScores = TeacherScores.OrderByDescending(x => x.FinalScore);
                    break;

                default:
                    break;
                }

                return(View(TeacherScores));
            }
        }
        public ActionResult UnDoDeduction(string ID)
        {
            TeacherRewardEntities db = new TeacherRewardEntities();
            var delEntry             = db.Deduction.Where(x => x.ID == ID).FirstOrDefault();

            try {
                db.Deduction.Remove(delEntry);
                db.SaveChanges();
                return(RedirectToAction("ShowDeduction", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            }
        }
        public ActionResult PostInfo(string ID = null, string Name = null, bool isNotReady = false)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                TeacherRewardEntities db = new TeacherRewardEntities();

                if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() == 0)
                {
                    ViewBag.NoInfos = true;
                }
                else
                {
                    ViewBag.NoInfos = false;
                }

                getDepartmentList();
                getisSelectedList();

                var TeacherInfos = db.TeacherInfo.Select(x => x);
                TeacherInfos = TeacherInfos.Where(x => x.Depart == userDetails.Department);

                //筛选信息
                if (isNotReady == true)
                {
                    TeacherInfos = TeacherInfos.Where(x => x.DutyTime == 0);
                }
                if (!String.IsNullOrEmpty(ID))
                {
                    TeacherInfos = TeacherInfos.Where(x => x.ID.Contains(ID));
                }
                if (!String.IsNullOrEmpty(Name))
                {
                    TeacherInfos = TeacherInfos.Where(x => x.Name.Contains(Name));
                }

                return(View(TeacherInfos));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 以下get函数为DropdownList准备字典
        /// </summary>
        ///
        private void getDepartmentList()
        {
            TeacherRewardEntities    db  = new TeacherRewardEntities();
            Dictionary <int, string> dic = new Dictionary <int, string> {
                { 0, "全部" }
            };
            var departs = db.Department.Select(x => x);

            foreach (var i in departs)
            {
                dic.Add(i.ID, i.Name);
            }
            ViewBag.Department     = dic;
            ViewBag.SearchByDepart = new SelectList(dic, "Key", "Value");
            db.Dispose();
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取当前用户的用户信息和部门信息
        /// </summary>
        private void CommonWork()
        {
            TeacherRewardEntities db = new TeacherRewardEntities();

            string userID = Session["userID"].ToString();

            this.userDetails = db.Users.Where(x => x.ID == userID).FirstOrDefault();

            int userdp = this.userDetails.Department;

            this.userDepart = db.Department.Where(x => x.ID == userdp).FirstOrDefault();

            ViewBag.curUserID   = this.userDetails.ID.ToString();
            ViewBag.curUserName = this.userDetails.Name.ToString();
            ViewBag.userDepart  = this.userDepart.Name.ToString();
        }
Exemplo n.º 12
0
        public ActionResult Select(string ID = null, int isSelect = -1)
        {
            if (ID == null || isSelect == -1)
            {
                return(RedirectToAction("Error", "Admin"));
            }
            TeacherRewardEntities db = new TeacherRewardEntities();
            var thisTeacherScore     = db.TeacherScore.Single(x => x.ID == ID);

            thisTeacherScore.isSelected = isSelect == 1 ? true : false;
            try {
                db.SaveChanges();
                return(RedirectToAction("ShowAll", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            } finally {
                db.Dispose();
            }
        }
Exemplo n.º 13
0
 public ActionResult ChangePwd(Users user)
 {
     CommonWork();
     if (this.userDetails.Password != user.Password)
     {
         user.ErrMsg = "原密码输入错误";
         return(View(user));
     }
     using (TeacherRewardEntities db = new TeacherRewardEntities()) {
         var updateuser = db.Users.Single(x => x.ID == userDetails.ID);
         updateuser.Password = user.NewPassword;
         try {
             db.Configuration.ValidateOnSaveEnabled = false;
             db.SaveChanges();
             db.Configuration.ValidateOnSaveEnabled = true;
             return(RedirectToAction("Logout", "Login"));
         } catch (Exception) {
             return(RedirectToAction("Index", "Admin"));
         }
     }
 }
Exemplo n.º 14
0
        public ActionResult DoVeto(string ID, VetoViewModel form)
        {
            if (ID == null || form.veto.Comment == null)
            {
                return(RedirectToAction("Error", "Admin"));
            }

            TeacherRewardEntities db = new TeacherRewardEntities();
            Veto newVeto             = new Veto();

            newVeto.ID      = ID;
            newVeto.Comment = form.veto.Comment;

            try {
                db.Veto.Add(newVeto);
                db.SaveChanges();
                return(RedirectToAction("ShowVeto", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            }
        }
Exemplo n.º 15
0
        public ActionResult ShowDeduction()
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                var db         = new TeacherRewardEntities();
                var Teachers   = db.Users.Where(x => x.Department == userDetails.Department && x.isAdmin == false);
                var Deductions = db.Deduction.Select(x => x);

                Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >();
                foreach (var each in Deductions)
                {
                    if (Teachers.Where(x => x.ID == each.ID).Any())
                    {
                        List <string> tmp = new List <string>();
                        tmp.Add(each.Supervisior.ToString());
                        tmp.Add(each.Accident.ToString());
                        tmp.Add(each.SuperComment);
                        tmp.Add(each.AccidentComment);
                        dic[each.ID] = tmp;
                    }
                }

                ViewBag.DeducDic = dic;

                return(View(Teachers));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 取得当前最大值
        /// </summary>
        private string[] getHighSocores()
        {
            string[] Score           = new string[6];
            TeacherRewardEntities db = new TeacherRewardEntities();
            var ThisDepartInfos      = db.TeacherInfo.Where(x => x.Depart == this.userDepart.ID);

            if (ThisDepartInfos.FirstOrDefault() == null)
            {
                Score[0] = Score[1] = Score[2] = Score[3] = Score[4] = Score[5] = "无信息";
                return(Score);
            }
            else
            {
                Score[0] = ThisDepartInfos.OrderByDescending(x => x.extTeachingTime).First().extTeachingTime.ToString();
                Score[1] = ThisDepartInfos.OrderByDescending(x => x.Prize).First().Prize.ToString();
                Score[2] = ThisDepartInfos.OrderByDescending(x => x.extProject).First().extProject.ToString();
                Score[3] = ThisDepartInfos.OrderByDescending(x => x.extTeachThesis).First().extTeachThesis.ToString();
                Score[4] = ThisDepartInfos.OrderByDescending(x => x.extPublishThesis).First().extPublishThesis.ToString();
                Score[5] = ThisDepartInfos.OrderByDescending(x => x.extTask).First().extTask.ToString();

                return(Score);
            }
        }
Exemplo n.º 17
0
        public ActionResult DoDeduction(string ID)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                TeacherRewardEntities db = new TeacherRewardEntities();
                DeducViewModel        this_unfortunate_teacher_agiain = new DeducViewModel();
                this_unfortunate_teacher_agiain.user = db.Users.Where(x => x.ID == ID).FirstOrDefault();

                return(View(this_unfortunate_teacher_agiain));
            }
        }
Exemplo n.º 18
0
        public ActionResult DoDeduction(string ID, DeducViewModel form)
        {
            if (ID == null)
            {
                return(RedirectToAction("Error", "Admin"));
            }

            var db           = new TeacherRewardEntities();
            var newDeduction = new Deduction();

            newDeduction.ID              = ID;
            newDeduction.SuperComment    = form.deduction.SuperComment;
            newDeduction.Supervisior     = form.deduction.Supervisior;
            newDeduction.Accident        = form.deduction.Accident;
            newDeduction.AccidentComment = form.deduction.AccidentComment;

            try {
                db.Deduction.Add(newDeduction);
                db.SaveChanges();
                return(RedirectToAction("ShowDeduction", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            }
        }
Exemplo n.º 19
0
        public ActionResult CalFinalScore(int Affirm = -1)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();
                TeacherRewardEntities db = new TeacherRewardEntities();
                //检查
                if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() == 0)
                {
                    ViewBag.ReadyStatus = 0;                    //没有教师填写信息
                }
                else if (db.TeacherInfo.Where(x => x.DutyTime == 0 && x.Depart == userDetails.Department).Count() != 0)
                {
                    ViewBag.ReadyStatus = 1;                    //存在主任未评分的教师信息
                }
                else if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() != db.Users.Where(x => x.Department == userDetails.Department && x.isAdmin == false).Count())
                {
                    ViewBag.ReadyStatus = 2;                                                                             //本系内部分教师未填写信息
                }
                else if (db.TeacherScore.Where(x => x.KPIScore == 0 && x.Depart == userDetails.Department).Count() == 0) //已经评分完毕
                {
                    ViewBag.ReadyStatus = 3;
                }
                else
                {
                    ViewBag.ReadyStatus = 4;
                }

                if (Affirm == -1)
                {
                    return(View());
                }
                else
                {
                    string[] HighScores   = getHighSocores();
                    var      TeacherInfos = db.TeacherInfo.Where(x => x.Depart == userDetails.Department);
                    foreach (TeacherInfo each in TeacherInfos)
                    {
                        var thisTeacherScore = db.TeacherScore.Single(x => x.ID == each.ID);
                        thisTeacherScore.KPIScore   = Cal_KPIScore(each, HighScores);
                        thisTeacherScore.CPIScore   = Cal_CPIScore(each, HighScores);
                        thisTeacherScore.FinalScore = thisTeacherScore.KPIScore + thisTeacherScore.CPIScore;
                    }
                    try {
                        db.SaveChanges();
                        return(RedirectToAction("Success", "Admin"));
                    } catch (Exception) {
                        return(RedirectToAction("Error", "Admin"));
                    } finally {
                        db.Dispose();
                    }
                }
            }
        }
Exemplo n.º 20
0
        public ActionResult Submit(AllInfo form, int Project1Level, int Project2Level, int Project3Level, int Project4Level, int Task1Level, int Task2Level, int Task3Level, int Task4Level, int CTask, int Task1, int Task2, int Task3, int Task4, int PThesisLevel1, int PThesisLevel2, int PThesisLevel3, int PThesisLevel4, int PThesis1, int PThesis2, int PThesis3, int PThesis4, int TeachingAward, int TeachThesis1Type, int TeachThesis2Type, int TeachThesis3Type, int TeachThesis4Type, int TeachThesis1, int TeachThesis2, int TeachThesis3, int TeachThesis4, int Project1, int Project2, int Project3, int Project4, int PrizeLevel1, int PrizeLevel2, int PrizeLevel3, int PrizeLevel4, int Prize1, int Prize2, int Prize3, int Prize4)
        {
            CommonWork();
            getListsReady();

            //计算各分值
            int[] TeachingTimeScore = Cal_TeachingTimeScore(Convert.ToInt32(form.TInfo.baseTeachingTime));
            int   PrizeScore        = Cal_PrizeScore(new int[] { Prize1, Prize2, Prize3, Prize4 }, new int[] { PrizeLevel1, PrizeLevel2, PrizeLevel3, PrizeLevel4 });

            double[] ProjectScore       = Cal_ProjectScore(new int[] { Project1, Project2, Project3, Project4 });
            int[]    TeachThesisScore   = Cal_TeachThesisScore(new int[] { TeachThesis1, TeachThesis2, TeachThesis3, TeachThesis4 }, new int[] { TeachThesis1Type, TeachThesis2Type, TeachThesis3Type, TeachThesis4Type });
            int      TeachingAwardScore = Cal_TeachingAwardScore(TeachingAward);

            double[] PublishThesisScore = Cal_PublishThesisScore(new int[] { PThesisLevel1, PThesisLevel2, PThesisLevel3, PThesisLevel4 }, new int[] { PThesis1, PThesis2, PThesis3, PThesis4 });
            double[] TaskScore          = Cal_TaskScore(new int[] { Task1, Task2, Task3, Task4 });
            double   CrosswiseTaskScore = Cal_CrosswiseTaskScore(CTask);

            //竞赛、项目、教学论文/教材、发表论文、纵向课题、横向课题的详细信息
            putPrizeInfo(ref form, new int[] { Prize1, Prize2, Prize3, Prize4 }, new int[] { PrizeLevel1, PrizeLevel2, PrizeLevel3, PrizeLevel4 });
            putProjectInfo(ref form, new int[] { Project1, Project2, Project3, Project4 }, new int[] { Project1Level, Project2Level, Project3Level, Project4Level });
            putTeachThesisInfo(ref form, new int[] { TeachThesis1, TeachThesis2, TeachThesis3, TeachThesis4 }, new int[] { TeachThesis1Type, TeachThesis2Type, TeachThesis3Type, TeachThesis4Type });
            putPublishThesisInfo(ref form, new int[] { PThesis1, PThesis2, PThesis3, PThesis4 }, new int[] { PThesisLevel1, PThesisLevel2, PThesisLevel3, PThesisLevel4 });
            putTaskInfo(ref form, new int[] { Task1, Task2, Task3, Task4 }, new int[] { Task1Level, Task2Level, Task3Level, Task4Level });
            putCrosswiseTaskInfo(ref form, CTask);
            form.TCTask.ID = form.TPrize.ID = form.TProject.ID = form.TPThesis.ID = form.TTask.ID = form.TTThesis.ID = userDetails.ID;

            TeacherRewardEntities db = new TeacherRewardEntities();
            //新数据
            TeacherInfo              insertion            = new TeacherInfo();
            TeacherScore             newScore             = new TeacherScore();
            TeacherPrizeInfo         newPrizeInfo         = new TeacherPrizeInfo();
            TeacherProjectInfo       newProjectInfo       = new TeacherProjectInfo();
            TeacherTeachThesisInfo   newTeachThesisInfo   = new TeacherTeachThesisInfo();
            TeacherPublishThesisInfo newPublishThesisInfo = new TeacherPublishThesisInfo();
            TeacherTaskInfo          newTaskInfo          = new TeacherTaskInfo();
            TeacherCrosswiseTaskInfo newCTaskInfo         = new TeacherCrosswiseTaskInfo();
            //重新提交数据
            var curTeacherInfo = db.TeacherInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curPrizeInfo   = db.TeacherPrizeInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curProjectInfo = db.TeacherProjectInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curTThesisInfo = db.TeacherTeachThesisInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curPThesisInfo = db.TeacherPublishThesisInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curTaskInfo    = db.TeacherTaskInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();
            var curCTaskInfo   = db.TeacherCrosswiseTaskInfo.Where(x => x.ID == userDetails.ID).FirstOrDefault();

            if (curTeacherInfo != null)
            {
                curTeacherInfo.baseTeachingTime  = TeachingTimeScore[0];
                curTeacherInfo.extTeachingTime   = TeachingTimeScore[1];
                curTeacherInfo.Prize             = PrizeScore;
                curTeacherInfo.baseProject       = ProjectScore[0];
                curTeacherInfo.extProject        = ProjectScore[1];
                curTeacherInfo.baseTeachThesis   = TeachThesisScore[0];
                curTeacherInfo.extTeachThesis    = TeachThesisScore[1];
                curTeacherInfo.TeachingAward     = TeachingAwardScore;
                curTeacherInfo.basePublishThesis = PublishThesisScore[0];
                curTeacherInfo.extPublishThesis  = PublishThesisScore[1];
                curTeacherInfo.baseTask          = TaskScore[0];
                curTeacherInfo.extTask           = TaskScore[1];
                curTeacherInfo.CrosswiseTask     = CrosswiseTaskScore;

                curPrizeInfo   = form.TPrize;
                curProjectInfo = form.TProject;
                curTThesisInfo = form.TTThesis;
                curPThesisInfo = form.TPThesis;
                curTaskInfo    = form.TTask;
                curCTaskInfo   = form.TCTask;
            }
            else
            {
                insertion.ID                = userDetails.ID;
                insertion.Name              = userDetails.Name;
                insertion.Depart            = userDepart.ID;
                insertion.baseTeachingTime  = TeachingTimeScore[0];
                insertion.extTeachingTime   = TeachingTimeScore[1];
                insertion.Prize             = PrizeScore;
                insertion.baseProject       = ProjectScore[0];
                insertion.extProject        = ProjectScore[1];
                insertion.baseTeachThesis   = TeachThesisScore[0];
                insertion.extTeachThesis    = TeachThesisScore[1];
                insertion.TeachingAward     = TeachingAwardScore;
                insertion.basePublishThesis = PublishThesisScore[0];
                insertion.extPublishThesis  = PublishThesisScore[1];
                insertion.baseTask          = TaskScore[0];
                insertion.extTask           = TaskScore[1];
                insertion.CrosswiseTask     = CrosswiseTaskScore;

                newScore.ID         = userDetails.ID;
                newScore.Name       = userDetails.Name;
                newScore.Depart     = userDepart.ID;
                newScore.isSelected = false;

                newCTaskInfo         = form.TCTask;
                newPrizeInfo         = form.TPrize;
                newProjectInfo       = form.TProject;
                newTeachThesisInfo   = form.TTThesis;
                newPublishThesisInfo = form.TPThesis;
                newTaskInfo          = form.TTask;
            }
            //写入数据库
            try {
                if (curTeacherInfo == null)                   //如果没有旧条目,则添加新条目
                {
                    db.TeacherInfo.Add(insertion);
                    db.TeacherScore.Add(newScore);
                    db.TeacherPrizeInfo.Add(newPrizeInfo);
                    db.TeacherProjectInfo.Add(newProjectInfo);
                    db.TeacherPublishThesisInfo.Add(newPublishThesisInfo);
                    db.TeacherTeachThesisInfo.Add(newTeachThesisInfo);
                    db.TeacherTaskInfo.Add(newTaskInfo);
                    db.TeacherCrosswiseTaskInfo.Add(newCTaskInfo);
                }
                db.SaveChanges();
                return(RedirectToAction("Success", "Home"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Home"));
            } finally {
                db.Dispose();
            }
        }
Exemplo n.º 21
0
        public ActionResult PostInfo(string ID = null, string Name = null, bool isNotReady = false)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                TeacherRewardEntities db = new TeacherRewardEntities();

                if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() == 0)
                {
                    ViewBag.NoInfos = true;
                }
                else
                {
                    ViewBag.NoInfos = false;
                }

                getDepartmentList();
                getisSelectedList();

                var Teachers = db.Users.Where(x => x.Department == userDetails.Department && x.isAdmin == false);
                foreach (var each in Teachers)
                {
                    if (!db.TeacherInfo.Where(x => x.ID == each.ID).Any())
                    {
                        TeacherInfo  NewInfo  = new TeacherInfo();
                        TeacherScore NewScore = new TeacherScore();

                        NewInfo.ID     = each.ID;
                        NewInfo.Name   = each.Name;
                        NewInfo.Depart = each.Department;

                        NewScore.ID     = each.ID;
                        NewScore.Name   = each.Name;
                        NewScore.Depart = each.Department;

                        db.TeacherInfo.Add(NewInfo);
                        db.TeacherScore.Add(NewScore);
                    }
                }

                try {
                    db.SaveChanges();
                } catch {
                    return(RedirectToAction("Error", "Admin"));
                }

                var TeacherInfos = db.TeacherInfo.Select(x => x);
                TeacherInfos = TeacherInfos.Where(x => x.Depart == userDetails.Department);

                //筛选信息
                if (isNotReady == true)
                {
                    TeacherInfos = TeacherInfos.Where(x => x.DutyTime == 0);
                }
                if (!String.IsNullOrEmpty(ID))
                {
                    TeacherInfos = TeacherInfos.Where(x => x.ID.Contains(ID));
                }
                if (!String.IsNullOrEmpty(Name))
                {
                    TeacherInfos = TeacherInfos.Where(x => x.Name.Contains(Name));
                }

                return(View(TeacherInfos));
            }
        }
Exemplo n.º 22
0
        public ActionResult CalFinalScore(int Affirm = -1)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();
                TeacherRewardEntities db = new TeacherRewardEntities();
                //检查
                if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() == 0)
                {
                    ViewBag.ReadyStatus = 0;                    //没有教师填写信息
                }
                else if (db.TeacherInfo.Where(x => x.DutyTime == 0 && x.Depart == userDetails.Department).Count() != 0)
                {
                    ViewBag.ReadyStatus = 1;                    //存在主任未评分的教师信息
                }
                else if (db.TeacherScore.Where(x => x.Depart == userDetails.Department).Count() != db.Users.Where(x => x.Department == userDetails.Department && x.isAdmin == false).Count())
                {
                    ViewBag.ReadyStatus = 2;                                                                             //本系内部分教师未填写信息
                }
                else if (db.TeacherScore.Where(x => x.KPIScore == 0 && x.Depart == userDetails.Department).Count() == 0) //已经评分完毕
                {
                    ViewBag.ReadyStatus = 3;
                }
                else
                {
                    ViewBag.ReadyStatus = 4;
                }

                if (Affirm == -1)
                {
                    return(View());
                }
                else
                {
                    string[] HighScores   = getHighSocores();                                              //当前最高分数
                    var      TeacherInfos = db.TeacherInfo.Where(x => x.Depart == userDetails.Department); //分数表
                    var      Vetos        = db.Veto.Select(x => x);                                        //否决表
                    var      Deductions   = db.Deduction.Select(x => x);                                   //减分表

                    foreach (TeacherInfo each in TeacherInfos)
                    {
                        if (Vetos.Where(x => x.ID == each.ID).Any())                           //被否决的教师不算分
                        {
                            continue;
                        }
                        double DeductionScore = 0;
                        if (Deductions.Where(x => x.ID == each.ID).Any())
                        {
                            var this_unfortunate_teacher = Deductions.Where(x => x.ID == each.ID).FirstOrDefault();
                            DeductionScore = Cal_DeductionScore(this_unfortunate_teacher);
                        }
                        var thisTeacherScore = db.TeacherScore.Single(x => x.ID == each.ID);
                        thisTeacherScore.KPIScore   = Cal_KPIScore(each, HighScores);
                        thisTeacherScore.CPIScore   = Cal_CPIScore(each, HighScores);
                        thisTeacherScore.FinalScore = thisTeacherScore.KPIScore + thisTeacherScore.CPIScore - DeductionScore;
                    }

                    try {
                        db.SaveChanges();
                        return(RedirectToAction("Success", "Admin"));
                    } catch (Exception) {
                        return(RedirectToAction("Error", "Admin"));
                    } finally {
                        db.Dispose();
                    }
                }
            }
        }