// // 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)); }
//HazmatItem convertToHazmatItem(PendingItems items, string orderNo); public HazmatItem convertToHazmatItem(HazmatInfo item, string orderNo) { HazmatItem hazmatItem = new HazmatItem(); AllItems allItem = context.AllItems.SingleOrDefault(i => i.INV_ITEM_ID == item.InvItemID); if (allItem != null) { hazmatItem.ErgNo = null; hazmatItem.HazardClass = allItem.HAZ_CLASS_CD; hazmatItem.HazmatInfoId = item.HazmatInfoID; hazmatItem.ItemId = item.InvItemID; hazmatItem.OrderLineItemId = 0; hazmatItem.OrderLineNo = Convert.ToInt16(item.OrderLineNo); hazmatItem.PackingGroup = allItem.PACKING_CD; hazmatItem.Placard = allItem.PAG_PLACARD_TYPE; hazmatItem.Qty = Convert.ToInt16(item.Qty); hazmatItem.ShipName = allItem.PAG_SHIPPING_NAME; hazmatItem.Size = allItem.INV_ITEM_SIZE; hazmatItem.UnitLbs = Convert.ToInt16(allItem.INV_ITEM_WEIGHT); hazmatItem.TotalLbs = hazmatItem.Qty * hazmatItem.UnitLbs; hazmatItem.UnnaNo = allItem.MSDS_ID; hazmatItem.Uom = allItem.UNIT_MEASURE_STD; } return(hazmatItem); }
public ActionResult DeleteConfirmed(int id) { HazmatInfo hazmatmodel = db.HazmatInfoes.Find(id); db.HazmatInfoes.Remove(hazmatmodel); db.SaveChanges(); return(RedirectToAction("Today", "Hazmat")); }
// // UPdate quantity public void UpdateQty(int hazmatInfoId, int qty) { HazmatInfo manifest = hazmatRepository.GetItemByInfoId(hazmatInfoId); manifest.Qty = qty; hazmatRepository.UpdateHazmatInfo(manifest); hazmatRepository.Save(); }
// // Update vehicle number public void UpdateVehicleNumber(string orderNo, string vinNumber) { HazmatInfo manifest = hazmatRepository.GetShipment(orderNo); manifest.VINNumber = vinNumber; hazmatRepository.UpdateHazmatInfo(manifest); hazmatRepository.Save(); }
// // Get last lineitem inserted public ActionResult GetLastItem() { HazmatInfo query = (from i in hazmatRepository.GetHazmatInfo() orderby i.HazmatInfoID descending select i).First(); return(Json(query, JsonRequestBehavior.AllowGet)); }
// // GET: /Hazmat/Delete/5 public ActionResult Delete(int id = 0) { HazmatInfo hazmatmodel = db.HazmatInfoes.Find(id); if (hazmatmodel == null) { return(HttpNotFound()); } return(View(hazmatmodel)); }
public ActionResult Create(HazmatInfo hazmatmodel) { if (ModelState.IsValid) { db.HazmatInfoes.Add(hazmatmodel); db.SaveChanges(); return(RedirectToAction("Create")); } return(View(hazmatmodel)); }
public ActionResult Edit(HazmatInfo hazmatmodel) { ViewModel viewModel = new ViewModel(); viewModel.Shipment = hazmatmodel; if (ModelState.IsValid) { db.Entry(hazmatmodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View("Create", hazmatmodel)); }
// // GET: /Hazmat/Ship/5 public ActionResult Ship(int id) { ViewModel viewModel = new ViewModel(); HazmatInfo shipment = db.HazmatInfoes.Find(id); string orderNo = shipment.OrderNo; List <HazmatItem> items = new List <HazmatItem>(); items = hazmatRepository.GetOrderLineItems(orderNo).ToList(); viewModel.Shipment = shipment; viewModel.Items = items; VehicleDropDownList(); LocationDropDownList(); PS_LocationAll shipper = new PS_LocationAll(); shipper = hazmatRepository.GetPSLocation(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.ToString(); ViewBag.Shipper = shipperAddress; if (shipment.Location != null) { PS_LocationAll receiver = new PS_LocationAll(); receiver = hazmatRepository.GetPSLocation(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.ToString(); ViewBag.Receiver = receiverAddress; } if (shipment == null) { return(HttpNotFound()); } List <HazmatPlacard> placards = new List <HazmatPlacard>(); foreach (HazmatItem item in items.GroupBy(p => p.Placard).Select(grp => grp.First())) { placards.Add(hazmatRepository.GetHazmatPlacard(item.Placard)); } viewModel.Placards = placards; return(View(viewModel)); }
// // Print public ActionResult UpdatePrint(string orderNo) { HazmatInfo shipment = hazmatRepository.GetShipment(orderNo); List <HazmatInfo> shipments = hazmatRepository.GetAllPendingByShipper(shipment.FromBU).Where(s => s.ToBU == shipment.ToBU).ToList(); if (shipments.Count != 0) { foreach (HazmatInfo item in shipments) { item.ShippingFlag = true; hazmatRepository.UpdateHazmatInfo(item); hazmatRepository.Save(); } } else { shipment.ShippingFlag = true; hazmatRepository.UpdateHazmatInfo(shipment); hazmatRepository.Save(); } return(RedirectToAction("Home", "Home")); }
// // Add lineitem for current manual shipping manifest public void AddOrderLineItem(string inv_item_id, string fromBu, string toBu, string orderNo, int?qty, string VINNumber, string placardType) { HazmatInfo item = new HazmatInfo(); item.InvItemID = inv_item_id; item.FromBU = fromBu; item.ToBU = toBu; item.OrderNo = orderNo; item.Qty = qty; item.InsertBy = User.Identity.Name; item.InsertDate = DateTime.Now.Date; item.ShippingType = "MANUAL"; item.ShippingID = orderNo; item.VINNumber = VINNumber; item.PlacardType = placardType; item.ShippingFlag = false; item.ProcessFlag = false; item.AddressFlag = false; item.QuantChangedFlag = false; hazmatRepository.InsertHazmatInfo(item); hazmatRepository.Save(); }
//HazmatInfo GetShipment(string orderNo); public HazmatInfo GetShipment(string orderNo) { HazmatInfo shipment = context.HazmatInfoes.FirstOrDefault(s => s.OrderNo == orderNo); return(shipment); }
//void UpdateHazmatInfo(HazmatInfo manifest); public void UpdateHazmatInfo(HazmatInfo manifest) { context.Entry(manifest).State = EntityState.Modified; }
//void InsertHazmatInfo(HazmatInfo manifest); public void InsertHazmatInfo(HazmatInfo manifest) { context.HazmatInfoes.Add(manifest); }
// // 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)); }