コード例 #1
0
        // GET: Admin/DriverManage
        public ActionResult Index(int page = 1, int pageSize = 4)
        {
            MultipleAdmin modelMulti = new MultipleAdmin();

            DriverManageModel model = new DriverManageModel();
            DriverDAO         dao   = new DriverDAO();

            if (Request.Form["txtSearch"] != null)
            {
                Session["lastSearch"]  = Request.Form["txtSearch"];
                ViewData["lastSearch"] = Session["lastSearch"];
                if (Session["lastSearch"].ToString().Equals(""))
                {
                    model.ListDriver = dao.getListDriver(page, pageSize);
                    //after call another page
                    Session["lastSearch"] = null;
                }
                else
                {
                    model.ListDriver = dao.SearchByNameOrId(Session["lastSearch"].ToString(), page, pageSize);
                }
            }
            else if (Session["lastSearch"] != null)
            {
                ViewData["lastSearch"] = Session["lastSearch"];
                model.ListDriver       = dao.SearchByNameOrId(Session["lastSearch"].ToString(), page, pageSize);
            }
            else
            {
                model.ListDriver = dao.getListDriver(page, pageSize);
            }
            modelMulti.Divermanager     = model;
            modelMulti.CountHostRequest = new HostRequestDAO().CountHostRequest();

            return(View(modelMulti));
        }
コード例 #2
0
        public ActionResult SaveEdition()
        {
            DriverDAO dao      = new DriverDAO();
            String    username = Request.Form["txtUsername"];

            try
            {
                int    phonenumber = int.Parse(Request.Form["txtPhonenumber"]);
                String fullname    = Request.Form["txtFullname"];
                if (fullname.Trim().Length != 0 && phonenumber > 0)
                {
                    ParkinglotOnline.Models.Driver driver = new ParkinglotOnline.Models.Driver
                    {
                        Username    = username,
                        Fullname    = fullname,
                        PhoneNumber = phonenumber,
                    };
                    dao.UpdateDriver(driver);
                    ViewBag.Status = "Update \"" + username + "\" successfully !!!";
                }
                else
                {
                    ViewBag.Status = "Phone must be number and can't be blank any field";
                }
            }
            catch (Exception)
            {
                ViewBag.Status = "Phone must be number and can't be blank any field";
            }
            //search after edit
            DriverManageModel model = new DriverManageModel();

            model.ListDriver       = dao.SearchByNameOrId(username, 1, 4);
            ViewData["lastSearch"] = username;

            MultipleAdmin modelMulti = new MultipleAdmin();

            modelMulti.Divermanager = model;
            return(View("Index", modelMulti));
        }