Esempio n. 1
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");
            }
        }
Esempio n. 2
0
        public ActionResult delLimitUser()
        {
            if (loginStatus() == false)
            {
                return Redirect("Login");
            }
            Dictionary<string, String> ret = new Dictionary<string, string>();
            try
            {
                int id = int.Parse(Request["id"]);
                LimitUserModel model = new LimitUserModel();
                int row = model.delLimitUser(id);
                if(row==1){
                    ret.Add("status","success");
                }
                else{
                    ret.Add("status","failed");
                    ret.Add("error","delete error!");
                }

            }
            catch{
                ret.Add("status","failed");
                ret.Add("error","bad param!");
            }
            return Json(ret);
        }
Esempio n. 3
0
        public ActionResult AddLimitUser()
        {
            if (loginStatus() == false)
            {
                return Redirect("Login");
            }
            Dictionary<string, String> ret = new Dictionary<string, string>();
            try
            {
                string sid = Request["sid"];
                LimitUserModel model = new LimitUserModel();
                int row = model.addLimitUser(sid);
                if (row > 0)
                {
                    ret.Add("status", "success");

                }
                else
                {
                    ret.Add("status", "failed");
                    ret.Add("error", "add error");
                }
            }
            catch (Exception e)
            {
                ret.Add("status", "failed");
                ret.Add("error", "bad param!");
            }
            return Json(ret);

        }
Esempio n. 4
0
 public ActionResult LimitUser()
 {
     if (loginStatus() == false)
     {
         return Redirect("Login");
     }
     LimitUserModel model = new LimitUserModel();
     ViewBag.limituserList = model.getAllLimitUser();
     return View();
 }