public int CreatePO(StaffEF staff, PurchaseOrderFormDTO poForm) { PurchaseOrderEF po = new PurchaseOrderEF(); po.CreatedById = staff.StaffId; po.OrderDate = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; po.DeliverByDate = (long)(poForm.SupplyItemBy.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; po.SupplierCode = poForm.SupplierId; po.DeliveryAddress = poForm.DeliveryAdd; po.Description = poForm.Description; po.Status = "Pending Delivery"; po.OrderId = purchaseEFF.FindLastPOId(); purchaseEFF.AddToPurchaseOrder(po); for (int i = 0; i < poForm.SupplierDetailIds.Count(); i++) { PurchaseOrderDetailsEF podet = new PurchaseOrderDetailsEF(); podet.OrderId = po.OrderId; podet.ItemCode = poForm.Icodes[i]; podet.QuantityOrdered = poForm.Quantities[i]; purchaseEFF.AddToPurchaseOrderDetails(podet); } return(po.OrderId); }
public void UpdatePurchaseOrderToDelivered(StaffEF staff, PurchaseOrderEF po) { po.DateDeliveredOn = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; po.ReceivedById = staff.StaffId; po.Status = "Delivered"; purchaseEFF.SavePurchaseOrder(po); }
public void SavePurchaseOrder(PurchaseOrderEF po) { var existingRecord = context.PurchaseOrders.Find(po.OrderId); if (existingRecord != null) { context.Entry(existingRecord).CurrentValues.SetValues(po); context.SaveChanges(); } }
public ActionResult ViewPurchaseOrder(string purchaseOrderId, string choice) { bool validId = Int32.TryParse(purchaseOrderId, out int id); PurchaseOrderEF po = purchaseService.FindPOById(id); List <PurchaseOrderDetailsEF> pod = purchaseService.FindPODetailsByOrderId(id); StaffEF receivedBy = staffService.GetStaff(); ViewData["purchaseOrder"] = po; ViewData["purchaseOrderDetails"] = pod; if (choice == "Confirm Delivery" && po.Status == "Pending Delivery") { //set PO status to Delivered. purchaseService.UpdatePurchaseOrderToDelivered(receivedBy, po); //update stock transaction stockService.LogTransactionsForDeliveryOrder(po.OrderId); return(RedirectToAction("PurchaseOrderHistory", "ManagePurchase")); } return(View()); }
public void AddToPurchaseOrder(PurchaseOrderEF order) { context.PurchaseOrders.Add(order); context.SaveChanges(); }
public void UpdatePurchaseOrderToDeleted(PurchaseOrderEF po) { po.Status = "Deleted"; purchaseEFF.SavePurchaseOrder(po); }