public void PurchaseOrderTest() { using (var Session = NhibernateLayer.OpenSession()) { using (var Transaction = Session.BeginTransaction()) { PurchaseOrderItemUnitTest purchaseOrderItem1 = new PurchaseOrderItemUnitTest(); var POrderItemID = purchaseOrderItem1.GetPurchaseOrderItem(); PurchaseOrderItem purchaseOrderitem1 = Session.Get <PurchaseOrderItem>(POrderItemID); PurchaseOrder PurchaseOrder1 = new PurchaseOrder { Title = "Ali", CreationDate = DateTime.Now }; PurchaseOrder1.PurchaseOrderItems.Add(purchaseOrderitem1); Session.Save(PurchaseOrder1); Transaction.Commit(); var res = Session.Get <PurchaseOrder>(PurchaseOrder1.Id); Assert.AreEqual(res.Id, PurchaseOrder1.Id); } } }
public async Task <bool> UpdateItemAsync(PurchaseOrderItem poItem) { var cmd = QueriesCreatingHelper.CreateQueryUpdate(poItem); var rs = await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection); return(rs != 0); }
protected void rpItems_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { PurchaseOrderItem lineItem = e.Item.DataItem as PurchaseOrderItem; if (lineItem != null) { if (PurchaseMap.ContainsKey(lineItem.Product_Code)) { PurchaseMap[lineItem.Product_Code] += lineItem.Long * lineItem.Width * lineItem.Quantity.Value; } else { PurchaseMap.Add(lineItem.Product_Code, lineItem.Long * lineItem.Width * lineItem.Quantity.Value); } } } if (e.Item.ItemType == ListItemType.Footer) { foreach (var item in PurchaseMap) { e.Item.Controls.Add(new Label() { Text = string.Format("{0} : {1} ", item.Key, item.Value), CssClass = "footerlabel" }); } } }
public ActionResult AddItemsToPO(Model.PurchaseOrder model) { Model.PurchaseOrder po = poService.GetPurchaseOrderById(model.Id); Model.PurchaseOrderItem poItem; if (po.TotalAmount == null) { po.TotalAmount = 0; } foreach (var orItem in model.ORItems) { if (orItem.AddToPO) { poItem = new PurchaseOrderItem { BudgetLineId = orItem.BudgetLineId, OrderRequestItemId = orItem.Id, PurchaseOrderId = po.Id, Quantity = (int)orItem.Quantity, Remarks = orItem.Remarks, TotalPrice = orItem.EstimatedPrice, UnitPrice = (double)orItem.EstimatedUnitPrice }; po.TotalAmount += orItem.EstimatedPrice; poService.SavePOItem(poItem); } } if (po.OrderRequest == null) { po.OrderRequestId = model.OrderRequestId; } poService.SaveReviewedPO(po); return(LoadPOItems(po.Id)); }
public ActionResult AddPPItemsToPO(Model.ProcurementPlan pp) { Model.PurchaseOrder po = poService.GetPurchaseOrderById(pp.PurchaseOrderId); Model.PurchaseOrderItem poItem; Model.ProcurementPlanItem item; if (po.TotalAmount == null) { po.TotalAmount = 0; } foreach (var ppItem in pp.PPItemList) { if (ppItem.AddedToOR) { item = ppService.GetProcurementPlanItemById(ppItem.Id); poItem = new PurchaseOrderItem { BudgetLineId = item.BudgetLineId, ProcurementPlanItemId = item.Id, PurchaseOrderId = po.Id, Quantity = ppItem.QuantityToOrder, TotalPrice = ppItem.TotalCost, UnitPrice = (double)ppItem.UnitCost }; po.TotalAmount += ppItem.TotalCost; poService.SavePOItem(poItem); } } poService.SaveReviewedPO(po); return(LoadPOItems(po.Id)); }
public long AddPurchaseOrderItem(PurchaseOrderItem item) { var query = PurchaseOrderQueries.InsertPurchaseOrderItem; var parameters = DataHelper.ExtractParameters(item); return(dbContext.Execute <long>(query, parameters)); }
protected void AddProductButton_Click(object sender, EventArgs e) { if (IsValid) { string barcode = BarcodeTextBox.Text; double quantity = Convert.ToDouble(QuantityTextBox.Text); var foundProduct = SupplierProduct.findProductByBarcode(currentOrder.supplier_id, barcode); if (foundProduct != null) { if (currentOrder.PurchaseOrderItemsBypurchaseorder_.Where(i => i.barcode == barcode).Count() > 0) { AddProductsErrorLabel.Text = "This item is already in the order. Please delete and add again."; } else { PurchaseOrderItem newOrderItem = currentOrder.CreatePurchaseOrderItem(); newOrderItem.barcode = foundProduct.barcode; newOrderItem.cost_price = foundProduct.CalculateApplicableCost(quantity, permission.is_member); newOrderItem.description = foundProduct.description; newOrderItem.product_code = foundProduct.product_code; newOrderItem.quantity = quantity; newOrderItem.Save(); } currentOrder.Refresh(); PopulateOrderItems(); } else { AddProductsErrorLabel.Text = "Product not found"; } } }
public ActionResult Create([Bind(Include = "PurchaseOrderId,AlbumId,Quantity,TotalAmount")] PurchaseOrderItem purchaseOrderItem) { var purchaseOrderItemExists = this.StoreAccountManager.Get <PurchaseOrderItem>() .Any( m => m.AlbumId == purchaseOrderItem.AlbumId); if (purchaseOrderItemExists) { ModelState.AddModelError(string.Empty, "purchaseOrderItem already exists"); return(RedirectToAction("Index")); } if (ModelState.IsValid) { purchaseOrderItem.CalculateTotalOrderItemAmount(); this.StoreAccountManager.Add(purchaseOrderItem); this.StoreAccountManager.Save(); return(RedirectToAction("Index")); } this.PopulatePurchaseOrdersDropdownList(purchaseOrderItem.PurchaseOrderId); this.PopulateAlbumDropdownList(purchaseOrderItem.AlbumId); return(View(purchaseOrderItem)); }
public void GeneratePO(Product prod, int week, int year, PurchaseOrderType pot, int repositionpoint) { PurchaseOrderStatus pos = 0; PurchaseOrder po = GetPurchaseOrder(prod.Provider, pot, pos); PurchaseOrderItem poi = new PurchaseOrderItem(); poi.PurchaseOrder = po; poi.Product = prod; if (pot == (PurchaseOrderType)1) { poi.Forecast = ControllerManager.Forecast.GetProductInfo(prod, Config.CurrentWeek + 1, Config.CurrentDate.Year); poi.QuantitySuggested = poi.Forecast.QuantitySuggested; poi.Quantity = poi.Forecast.QuantitySuggested; } else if (pot == (PurchaseOrderType)2) { poi.Forecast = ControllerManager.Forecast.GetProductInfo(prod, Config.CurrentWeek + 1, Config.CurrentDate.Year); poi.QuantitySuggested = repositionpoint; poi.Quantity = repositionpoint; } po.PurchaseOrderItems.Add(poi); this.Save(po); }
public Guid PurchaseOrderItemId() { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { var IDItem = ItemId(); Item item = session.Get <Item>(IDItem); var IDRack = RackId(); Rack rack = session.Get <Rack>(IDRack); var purchaseOrderItem = new PurchaseOrderItem { NetPrice = "12", Quantity = "43", TotalPrice = "67", UnitPrice = "67", Rack = rack, Item = item }; session.Save(purchaseOrderItem); transaction.Commit(); purchaseOrderItem = session.Get <PurchaseOrderItem>(purchaseOrderItem.Id); return(purchaseOrderItem.Id); } } }
public async Task HandleAsync(CreatePurchaseOrderCommand command) { //Issue: Crossing the boundary context to cut shot the time. //This should call the Basket Api and get the details. Not the repository directly. var basketSpecification = new BasketWithItemsSpecification(command.BasketId); var basket = await _basketAsyncRepository.GetSingleAsync(basketSpecification); var items = new List <PurchaseOrderItem>(); foreach (var basketItem in basket.BasketItems) { var catalogItem = await _catalogItemAsyncRepository.GetByIdAsync(basketItem.CatalogItemId); var itemOrdered = new CatalogItemOrdered(catalogItem.Id, (CatalogItemType)catalogItem.CatalogType, catalogItem.Name, catalogItem.PictureUri); var orderItem = new PurchaseOrderItem(itemOrdered, basketItem.UnitPrice, basketItem.Quantity); items.Add(orderItem); } var purchaseOrderId = Guid.NewGuid(); var purchaseOrderIdNumberMapping = new PurchaseOrderIdNumberMapping { PurchaseOrderId = purchaseOrderId }; _purchaseOrderIdNumberMappingAsyncRepository.Add(purchaseOrderIdNumberMapping); await _unitOfWork.SaveChangesAsync(); var purchaseOrder = new Domain.PurchaseOrder(purchaseOrderId, purchaseOrderIdNumberMapping.Id, basket.BuyerId, command.Address, items); await _shopAggregateRepositoryService.SaveAsync(purchaseOrder); }
public void PurchaseOrderItemTest() { using (var session = NhibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { var itemId = GetItemId(); Item item = session.Get <Item>(itemId); var racckId = GetRackId(); Rack rack = session.Get <Rack>(racckId); PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem { NetPrice = 30, UnitPrice = 50, Quantity = 900, Item = item, Rack = rack }; session.Save(purchaseOrderItem); transaction.Commit(); var res = session.Get <PurchaseOrderItem>(purchaseOrderItem.Id); Assert.AreEqual(purchaseOrderItem.NetPrice, res.NetPrice); } } }
internal void SaveDOForPOItems(int poItemId, int receivedQuantity) { PurchaseOrderItem poItm = db.PurchaseOrderItems.Where(p => p.PurchaeOrderItemID == poItemId).FirstOrDefault(); poItm.ReceivedQuantity = receivedQuantity; db.SaveChanges(); }
public void GeneratePO(Product prod, int week, int year, PurchaseOrderType pot, int repositionpoint) { PurchaseOrderStatus pos = PurchaseOrderStatus.Open; // Busco si ya existe una orden de compra abierta para este proveedor PurchaseOrder po = GetPurchaseOrder(prod.Provider, pot, pos); PurchaseOrderItem poi = new PurchaseOrderItem(); poi.PurchaseOrder = po; poi.Product = prod; poi.Forecast = ControllerManager.Forecast.GetProductInfo(prod, Config.CurrentWeek + 1, Config.CurrentDate.Year); if (pot == PurchaseOrderType.Forecast) { poi.QuantitySuggested = poi.Forecast.QuantitySuggested; poi.Quantity = poi.Forecast.QuantitySuggested; } else if (pot == PurchaseOrderType.Manual) { poi.QuantitySuggested = repositionpoint; poi.Quantity = repositionpoint; } po.PurchaseOrderItems.Add(poi); this.Save(po); }
public async Task <int> AddItemAsync(PurchaseOrderItem poItem) { var cmd = QueriesCreatingHelper.CreateQueryInsert(poItem); cmd += ";SELECT LAST_INSERT_ID();"; return((await DALHelper.ExecuteQuery <int>(cmd, dbTransaction: DbTransaction, connection: DbConnection)).First()); }
public ActionResult Create([Bind(Include = "POItemID,ProductID,Quantity,Received,PurchaseOrderID")] PurchaseOrderItem purchaseOrderItem) { if (ModelState.IsValid) { // Instantiate foreign key field for Inventory PurchaseOrderItem ans; ans = purchaseOrderItem; _540GPWorkingBuild.Models.Inventory inv; inv = db.Inventories.Find(Int32.Parse(Request["ProductID"].ToString())); ans.Inventory = inv; //Instantiate foreign key for PurchaseOrder _540GPWorkingBuild.Models.PurchaseOrder po; po = db.PurchaseOrders.Find(Int32.Parse(Session["currPo"].ToString())); ans.PurchaseOrder = po; // Set initial received value to zero ans.Received = 0; // Save database db.PurchaseOrderItems.Add(ans); db.SaveChanges(); // Bounce user to the detail page for the purchase order return(RedirectToAction("Details", "PurchaseOrders", new { id = po.PurchaseOrderID.ToString() })); } ViewBag.ProductID = new SelectList(db.Inventories, "ProductID", "Name", purchaseOrderItem.ProductID); ViewBag.PurchaseOrderID = new SelectList(db.PurchaseOrders, "PurchaseOrderID", "PurchaseOrderID", purchaseOrderItem.PurchaseOrderID); return(View(purchaseOrderItem)); }
static void Main(string[] args) { using (var session = NhibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem { NetPrice = 30, UnitPrice = 50, Quantity = 900 }; session.Save(purchaseOrderItem); transaction.Commit(); List <PurchaseOrderItem> purchase = session.Query <PurchaseOrderItem>() .Where(x => x.Quantity == 900).ToList(); foreach (var p in purchase) { Console.WriteLine(p.Id); } Console.ReadKey(); } } }
public ActionResult DeleteConfirmed(int id) { PurchaseOrderItem purchaseOrderItem = db.PurchaseOrderItems.Find(id); db.PurchaseOrderItems.Remove(purchaseOrderItem); db.SaveChanges(); return(RedirectToAction("Index")); }
public static bool IsValid(this PurchaseOrderCreateRequest request, PurchaseOrderItem inventory) { if (inventory == null || (inventory.Quantity < request.Quantity)) { return(false); } return(true); }
bool IInventoryStore.Create(PurchaseOrderItem created) { created.Id = new Guid(); lock (_inventory) _inventory.PurchaseOrderItems.Add(created); return(true); }
public ActionResult DeleteConfirmed(int id) { PurchaseOrderItem purchaseOrderItem = this.StoreAccountManager.GetById <PurchaseOrderItem>(id).CalculateTotalOrderItemAmount(); this.StoreAccountManager.Delete(purchaseOrderItem); this.StoreAccountManager.Save(); return(RedirectToAction("Index")); }
public ActionResult RenderEditorRow(int itemId) { PurchaseOrderItem poItem = new PurchaseOrderItem(); poItem.Item = itemRepo.GetById(itemId); return(PartialView("_EditorRow", poItem)); }
public bool CreateItem(PurchaseOrderItem item) { var itemObj = AutoMapper.Mapper.Map <Core.Model.PurchaseOrderItem>(item); var obj = Work.POItemRepository.Create(itemObj); Work.POItemRepository.Save(); return(obj.Id > 0); }
public async Task <int> InsertPOItemAsync(PurchaseOrderItem poItem, UserSession userSession) { poItem.IsDeleted = false; poItem.CreatedBy = userSession.Id; poItem.CreatedDate = DateTime.Now; poItem.ModifiedBy = userSession.Id; poItem.ModifiedDate = DateTime.Now; return(await _purchaseOrderRepository.AddItemAsync(poItem)); }
public ActionResult RenderEditorRow(int itemId) { PurchaseOrderItem reqPurchaseItem = new PurchaseOrderItem { Item = itemRepo.GetById(itemId) }; return(PartialView("_EditorRow", reqPurchaseItem)); }
public ActionResult Edit(PurchaseOrderItem item) { if (ModelState.IsValid) { _unitOfWork.PurchaseOrderItems.Update(item); _unitOfWork.Complete(); } return(RedirectToAction("Details", new { id = item.PurchaseOrderId })); }
public void ReceivingLogsSave(ReceivingLogsDTO receivingLogsDTO) { PurchaseOrderItem poItem = poItemRepo.Find(receivingLogsDTO.PurchaseOrderItemId); PurchaseOrder po = context.PurchaseOrders.Find(poItem.PurchaseOrderId); po.Status = (int)EPurchaseOrderStatus.Saved; bool poExist = context.PurchaseOrders.Count(p => p.RRNo == receivingLogsDTO.RRNo) > 0; if (!poExist) { try { po.RRNo = poRepo.GenerateReNumber(receivingLogsDTO.DateReceived); po.ReceivedDate = receivingLogsDTO.DateReceived; } catch { po.RRNo = poRepo.GenerateReNumber(DateTime.Now); po.ReceivedDate = DateTime.Now; } } else { po.RRNo = receivingLogsDTO.RRNo; po.ReceivedDate = receivingLogsDTO.DateReceived; } context.SaveChanges(); PurchaseOrderItem pItem = poItemRepo.Find(receivingLogsDTO.PurchaseOrderItemId); foreach (ReceivingLogsDTO.Item item in receivingLogsDTO.Items) { Receiving receiving = new Receiving(); int poitem = poItem.ItemId; if (item.Id != 0) { receiving.Id = item.Id; receiving.TransactionLogId = item.TransLogId; } else { receiving.TransactionLogId = InsertLogs(poItem.ItemId, item.Quantity, item.DateReceived, itemRepo.GetItemType(poItem.ItemId)); } receiving.PurchaseOrderItemId = receivingLogsDTO.PurchaseOrderItemId; receiving.Quantity = item.Quantity; receiving.SerialNo = item.SerialNo; receiving.DrNo = receivingLogsDTO.DrNo; receiving.DateReceived = item.DateReceived; receivingRepo.Save(receiving, pItem.ItemId, pItem.Item.UnitCost.ToString("N")); } }
public async void Delete(PurchaseOrderItem data) { var table = _purchaseOrderItemTable; if (await GetPoItem(data.Id) == null) { return; } await table.DeleteAsync(data); }
public async Task <PurchaseOrderItem> AddPurchaseOrderItemAsync(PurchaseOrderItem orderItem) { _context.Create(orderItem); await _context.CommitAsync(); return(await _context.PurchaseOrderItems .Include(p => p.PurchaseOrder) .Include(p => p.Item) .FirstAsync(e => e.Id == orderItem.Id)); }
// GET: PurchaseOrderItems/Create public ActionResult AddPurchaseItem() { PurchaseOrderItem poi = new PurchaseOrderItem(); using (sithar_dbEntities1 db = new sithar_dbEntities1()) { poi.ItemCollection = db.Items.ToList <Item>(); } return(View(poi)); }
public bool Remove(PurchaseOrderItem entity) { return base.Remove(entity); }
public void Add(PurchaseOrderItem entity) { base.Add(entity); }
public bool Contains(PurchaseOrderItem entity) { return base.Contains(entity); }
public int IndexOf(PurchaseOrderItem entity) { return base.IndexOf(entity); }
public void Insert(int index, PurchaseOrderItem entity) { base.Insert(index, entity); }