Exemplo n.º 1
0
        public ActionResult DeanIndex(string searchName, string orderField = "State desc", int pageIndex = 1)
        {
            if (Session["type"] == null || (int)Session["type"] != 3)
            {
                return(Redirect("/TBsys/Login/Index"));
            }

            if (TimeChecked())
            {
                ViewBag.flag = 1;
            }
            else
            {
                ViewBag.flag = 0;
            }

            T_SH_Teacher teacher            = (T_SH_Teacher)Session["person"];
            IEnumerable <T_TB_Choose> query = db.T_TB_Choose.Where(m => m.T_TB_TeachingTask.DepartmentId == teacher.DepartmentId);

            if (string.IsNullOrEmpty(searchName))
            {
            }
            else
            {
                query = query.Where(m => m.T_TB_TeachingTask.CourseName.Contains(searchName));
            }

            #region 排序逻辑
            // orderField

            switch (orderField)
            {
            case "Id desc":
                query = query.OrderByDescending(m => m.Id);
                break;

            case "State desc":
                query = query.OrderBy(m => m.State);
                break;

            default:
                break;
            }
            #endregion

            #region 分页实现
            int recordCount = query.Count();
            query = query.Skip((pageIndex - 1) * pageSize).Take(pageSize);

            ViewBag.pageIndex   = pageIndex;
            ViewBag.pageSize    = pageSize;
            ViewBag.recordCount = recordCount;
            #endregion

            ViewBag.list = query.ToList();
            return(View());
        }
Exemplo n.º 2
0
        public JsonResult UpdatePwd(string oldpwd, string newpwd, string newpwd2)
        {
            string       stuId  = (string)Session["Id"];
            T_SH_Teacher person = db.T_SH_Teacher.Find(stuId);

            if (!person.Password.Equals(oldpwd))
            {
                return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
            }
            else if (!newpwd.Equals(newpwd2))
            {
                return(Json(new { code = 2 }, JsonRequestBehavior.AllowGet));
            }
            else if (newpwd.Equals("") || newpwd2.Equals(""))
            {
                return(Json(new { code = 3 }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                person.Password = newpwd;
                db.SaveChanges();
                return(Json(new { code = 0 }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        public ActionResult NoBookList(string orderField = "Index desc", int pageIndex = 1)
        {
            if (Session["type"] == null || (int)Session["type"] != 3)
            {
                return(Redirect("/TBsys/Login/Index"));
            }

            T_SH_Teacher teacher = (T_SH_Teacher)Session["person"];
            var          query   = db.T_TB_TeachingTask.Where(m => m.DepartmentId == teacher.DepartmentId && m.State != 4);

            #region 排序逻辑
            // orderField

            switch (orderField)
            {
            case "Index desc":
                query = query.OrderBy(m => m.TeacherId);
                break;

            default:
                break;
            }
            #endregion

            #region 分页实现
            int recordCount = query.Count();
            query = query.Skip((pageIndex - 1) * pageSize).Take(pageSize);

            ViewBag.pageIndex   = pageIndex;
            ViewBag.pageSize    = pageSize;
            ViewBag.recordCount = recordCount;
            #endregion

            ViewBag.list = query.ToList();
            return(View());
        }