Ejemplo n.º 1
0
        protected override void OnRequest()
        {
            base.OnRequest();

            string marketName       = getParameter("market_name");
            string cargoDescription = getParameter("cargo_description");

            CargoListModel cargoList = null;

            try
            {
                cargoList = new Controller.Cargo().GetCargoList(marketName, cargoDescription);
                WriteSuccess <CargoListModel>(cargoList);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }

            WriteEnd();
        }
Ejemplo n.º 2
0
        // GET: Cargo
        public ActionResult Index()
        {
            if (Session["Key"] == null)
            {
                return(RedirectToAction("../Login/Index"));
            }

            CargoListModel lista = CargoListModel.Get();

            return(View(lista));
        }
Ejemplo n.º 3
0
        protected override void OnRequest()
        {
            base.OnRequest();

            try
            {
                string cargoPlate       = getParameter("cargo_plate");
                string cargoDriver      = getParameter("cargo_driver");
                string cargoLicence     = getParameter("cargo_licence");
                string cargoContact     = getParameter("cargo_contact");
                string cargoDescription = getParameter("cargo_description");
                string marketName       = getParameter("market_name");

                CargoListModel cargoList = null;

                using (Controller.Cargo controllerCargo = new Controller.Cargo())
                {
                    cargoList = controllerCargo.GetCargoList(cargoPlate, cargoDriver, cargoLicence, cargoContact, cargoDescription, marketName);
                }

                DatagridModel <ViewCargoListModel> data = new DatagridModel <ViewCargoListModel>();
                data.total = (uint)cargoList.Count;
                data.rows  = cargoList;

                WriteJson(data);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
Ejemplo n.º 4
0
        public CargoListModel GetCargoList(string cargoPlate, string cargoDriver, string cargoLicence, string cargoContact, string cargoDescription, string marketName)
        {
            string where = "";
            if (!String.IsNullOrWhiteSpace(cargoPlate))
            {
                where += string.Format("view_cargolist.cargo_plate LIKE '%{0}%'", cargoPlate);
            }

            if (!String.IsNullOrWhiteSpace(cargoDriver))
            {
                if (!String.IsNullOrWhiteSpace(where))
                {
                    where += " AND ";
                }

                where += string.Format("view_cargolist.cargo_driver LIKE '%{0}%'", cargoDriver);
            }

            if (!String.IsNullOrWhiteSpace(cargoLicence))
            {
                if (!String.IsNullOrWhiteSpace(where))
                {
                    where += " AND ";
                }

                where += string.Format("view_cargolist.driver_licence LIKE '%{0}%'", cargoLicence);
            }

            if (!String.IsNullOrWhiteSpace(cargoContact))
            {
                if (!String.IsNullOrWhiteSpace(where))
                {
                    where += " AND ";
                }

                where += string.Format("view_cargolist.driver_contact LIKE '%{0}%'", cargoContact);
            }

            if (!String.IsNullOrWhiteSpace(cargoDescription))
            {
                if (!String.IsNullOrWhiteSpace(where))
                {
                    where += " AND ";
                }

                where += string.Format("view_cargolist.cargo_description LIKE '%{0}%'", cargoDescription);
            }


            if (!String.IsNullOrWhiteSpace(marketName))
            {
                if (!String.IsNullOrWhiteSpace(where))
                {
                    where += " AND ";
                }

                where += string.Format("view_cargolist.market_name = '{0}'", marketName);
            }


            List <ViewCargoListModel> list = db.SelectData <ViewCargoListModel>("view_cargolist", null, where, true, "view_cargolist.cargo_plate DESC");

            if (list == null)
            {
                throw new UnfulfilException("/language/database/no_record");
            }

            CargoListModel cargoList = new CargoListModel();

            foreach (ViewCargoListModel cargo in list)
            {
                cargoList.Add(cargo);
            }
            return(cargoList);
        }