Beispiel #1
0
 public ActionResult Student()
 {
     if (loginStatus() == false)
     {
         return Redirect("Login");
     }
     StudentModel model = new StudentModel();
     ViewBag.studentList =  model.getAllStudents();
     return View();
 }
Beispiel #2
0
        public ActionResult Login()
        {
            var sid      = Request.Params["sid"];
            var password = Request.Params["password"];
            StudentModel model = new StudentModel();
            int studentID = model.login(sid, password);
            if( studentID != -1)
            {
                Session["student"] = studentID;
                if (Request.Params["rememberme"] != null && Request.Params["rememberme"] != "")
                    Session.Timeout = 60 * 24 * 7;// one week
                else
                    Session.Timeout = 300; // 5 hours
                return Redirect("/Student");
            }
            else
            {
                ViewBag.login_failed = true ;
                //return Redirect("index");
                return View("Index");
            }

        }
Beispiel #3
0
        public ActionResult Register()
        {
            StudentModel studentModel = new StudentModel();
            LimitUserModel limituserModel = new LimitUserModel();
            try
            {
                var name = Request.Form["name"];
                var sid = Request.Form["sid"];
                var password = Request.Form["password"];
                if (name == "" || sid == "" || password == "")
                {
                    ViewBag.err = "请完整填写信息";
                    return View("~/Views/Index/Register.cshtml");
                }
                if (!limituserModel.isAllowed(sid))
                {
                    ViewBag.err = "学号被禁止注册";
                    return View("~/Views/Index/Register.cshtml");
                }

                var student = new StudentEntity() {sid=sid,name=name,password=password };
                var res = studentModel.register(student);
                if (res != 1)
                {
                    ViewBag.err = "注册失败,请检查所填信息";
                    return View("~/Views/Index/Register.cshtml");
                }
                else
                {
                    return View("~/Views/Index/Index.cshtml");
                }

            }
            catch (Exception e)
            {
                ViewBag.err = "注册失败,请检查所填信息";
                return View("~/Views/Index/Register.cshtml");
            }
        }
Beispiel #4
0
        public ActionResult delStudent()
        {
            if (loginStatus() == false)
            {
                return Redirect("Login");
            }
            Dictionary<string, String> ret = new Dictionary<string, string>();
            try
            {
                int id = int.Parse(Request["id"]);
                StudentModel model = new StudentModel();
                int row = model.delStudentById(id);
                if (row > 0)
                {
                    ret.Add("status", "success");
                }
                else
                {
                    ret.Add("status", "failed");
                    ret.Add("error", "delete error!");
                }
            }
            catch (Exception e)
            {
                ret.Add("status", "failed");
                ret.Add("error", "bad param!");
            }
            return Json(ret);

        }