Exemplo n.º 1
0
        //HazmatLocation GetLocationByDesc(string desc);
        public HazmatLocation GetLocationByDesc(string desc)
        {
            HazmatLocation location = new HazmatLocation();
            // Check if location is of type PS_PAG_LOCATION, if found, it is of type PS_PAG_LOCATION
            PS_PAG_LOCATION_VW tempLoc1 = context.PS_PAG_LOCATION_VW.Where(l => l.DESCRSHORT == desc).FirstOrDefault();

            if (tempLoc1 != null)
            {
                location.Address1   = tempLoc1.ADDRESS1.TrimEnd();
                location.City       = tempLoc1.CITY.TrimEnd();
                location.Descr      = tempLoc1.DESCR.TrimEnd();
                location.DescrShort = tempLoc1.DESCRSHORT.TrimEnd();
                location.Location   = tempLoc1.LOCATION.TrimEnd();
                location.Postal     = tempLoc1.POSTAL.TrimEnd();
                location.State      = tempLoc1.STATE.TrimEnd();
            }
            // Not of type PS_PAG_LOCATION, but instead of type PS_LocationAll
            if (tempLoc1 == null)
            {
                PS_LocationAll tempLoc2 = GetPSLocation(desc);
                location.Address1   = tempLoc2.ADDRESS1.TrimEnd();
                location.City       = tempLoc2.CITY.TrimEnd();
                location.Descr      = tempLoc2.DESCR.TrimEnd();
                location.DescrShort = tempLoc2.DESCR.TrimEnd();
                location.Location   = tempLoc2.LOCATION.TrimEnd();
                location.Postal     = tempLoc2.POSTAL.ToString();
                location.State      = tempLoc2.STATE.TrimEnd();
            }
            return(location);
        }
Exemplo n.º 2
0
        //
        // GET: /Hazmat/Modify
        public ActionResult Modify(string orderNo)
        {
            ViewModel         viewModel = new ViewModel();
            List <HazmatItem> items     = new List <HazmatItem>();
            HazmatInfo        shipment  = hazmatRepository.GetShipment(orderNo);
            HazmatLocation    shipper   = hazmatRepository.GetLocationById(shipment.FromBU);

            string[] shipperAddress = new string[5];
            shipperAddress[0] = shipper.Descr;
            shipperAddress[1] = shipper.Address1;
            shipperAddress[2] = shipper.City;
            shipperAddress[3] = shipper.State;
            shipperAddress[4] = shipper.Postal;
            ViewBag.Shipper   = shipperAddress;

            HazmatLocation receiver = hazmatRepository.GetLocationById(shipment.FromBU);

            string[] receiverAddress = new string[5];
            receiverAddress[0] = receiver.Descr;
            receiverAddress[1] = receiver.Address1;
            receiverAddress[2] = receiver.City;
            receiverAddress[3] = receiver.State;
            receiverAddress[4] = receiver.Postal;
            ViewBag.Receiver   = receiverAddress;

            items = hazmatRepository.GetOrderLineItems(shipment.OrderNo).ToList();
            VehicleDropDownList();
            viewModel.Items    = items;
            viewModel.Shipment = shipment;

            return(View(viewModel));
        }
Exemplo n.º 3
0
        //
        // GET: /Hazmat/PrintPreview
        public ActionResult PrintPreview(string orderNo)
        {
            ViewModel viewModel = new ViewModel();
            // Get all items for this shipment
            HazmatInfo shipment = hazmatRepository.GetShipment(orderNo);
            // Get other possible pending shipments that have the same shipper and receiver
            var caller = Request.UrlReferrer.ToString();
            List <HazmatInfo>    shipments = new List <HazmatInfo>();
            List <HazmatItem>    items     = new List <HazmatItem>();
            List <HazmatPlacard> placards  = new List <HazmatPlacard>();

            if (!caller.Contains("Today"))
            {
                shipments = hazmatRepository.GetAllPendingByShipper(shipment.FromBU).Where(s => s.ToBU == shipment.ToBU).ToList();
                items     = shipments.Select(tempItem => hazmatRepository.convertToHazmatItem(tempItem, tempItem.OrderNo)).ToList();
                placards  = items.GroupBy(p => p.Placard).Select(grp => grp.First()).Select(item => hazmatRepository.GetHazmatPlacard(item.Placard)).ToList();
            }
            else
            {
                shipments.Add(shipment);
                items.Add(hazmatRepository.convertToHazmatItem(shipment, shipment.OrderNo));
                placards.Add(hazmatRepository.GetHazmatPlacard(items[0].Placard));
            }
            if (shipment.FromBU != null)
            {
                HazmatLocation shipper        = hazmatRepository.GetLocationById(shipment.FromBU);
                string[]       shipperAddress = new string[5];
                shipperAddress[0] = shipper.Descr;
                shipperAddress[1] = shipper.Address1;
                shipperAddress[2] = shipper.City;
                shipperAddress[3] = shipper.State;
                shipperAddress[4] = shipper.Postal;
                ViewBag.Shipper   = shipperAddress;
            }

            if (shipment.Location != null)
            {
                HazmatLocation receiver        = hazmatRepository.GetLocationByDesc(shipment.Location);
                string[]       receiverAddress = new string[5];
                receiverAddress[0] = receiver.Descr;
                receiverAddress[1] = receiver.Address1;
                receiverAddress[2] = receiver.City;
                receiverAddress[3] = receiver.State;
                receiverAddress[4] = receiver.Postal;
                ViewBag.Receiver   = receiverAddress;
            }
            if (shipment.ToBU != null)
            {
                HazmatLocation receiver        = hazmatRepository.GetLocationById(shipment.ToBU);
                string[]       receiverAddress = new string[5];
                receiverAddress[0] = receiver.Descr;
                receiverAddress[1] = receiver.Address1;
                receiverAddress[2] = receiver.City;
                receiverAddress[3] = receiver.State;
                receiverAddress[4] = receiver.Postal;
                ViewBag.Receiver   = receiverAddress;
            }

            viewModel.Shipments = shipments;
            viewModel.Shipment  = shipment;
            viewModel.Placards  = placards;
            viewModel.Items     = items;
            VehicleDropDownList();

            return(View("PrintPreview", viewModel));
        }