public void CancelEdit(StockView stock) { stock.Quantite = backup.Quantite; StockGrid.CancelEditRow(stock); RowOnUpdate = false; }
public ActionResult getStockHistory(string Search, int Page = 1) { StockView StockList = new StockView(); StockList.Paging = new ForPaging(Page); StockList.StockList = financeService.getStockList(StockList.Paging, Search); StockList.Search = Search; return(View(StockList)); }
private void StockView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) { // Set the ListViewItemSorter property to a new // ListViewItemComparer object. this.StockView.ListViewItemSorter = new ListViewItemComparer(e.Column); // Call the sort method to manually sort the column based on the // ListViewItemComparer implementation. StockView.Sort(); }
public List <StockView> ViewStockByDate(DateTime startDate, DateTime endDate) { List <StockView> stockViews = new List <StockView>(); List <PurchaseDetails> pds = new List <PurchaseDetails>(); List <SalesDetails> sds = new List <SalesDetails>(); var products = _productRepository.GetAll(); var purchases = _purchaseRepository .GetAll() .Where(c => c.Date >= startDate) .Where(c => c.Date <= endDate) .ToList(); var sales = _salesRepository .GetAll() .Where(c => c.Date >= startDate) .Where(c => c.Date <= endDate) .ToList(); foreach (var pr in purchases) { var p = _purchaseRepository.GetAllPurchaseDetails().Where(c => c.PurchaseId == pr.Id).ToList(); pds.AddRange(p); } foreach (var sl in sales) { var s = _salesRepository.GetAllSalesDetailses().Where(c => c.SalesId == sl.Id).ToList(); sds.AddRange(s); } foreach (var p in products) { var pd = pds.Where(c => c.ProductId == p.Id).ToList(); var sd = sds.Where(c => c.ProductId == p.Id).ToList(); if (pd.Count == 0 && sd.Count == 0) { continue; } StockView stockView = new StockView(); stockView.ReOrderLevel = p.ReOrderLevel; stockView.Product = p.Name; stockView.OpeningBalance = GetOpeningBalance(startDate, p.Id); stockView.StockIn = pd.AsEnumerable().Sum(c => (int?)c.Quantity) ?? 0; stockView.StockOut = sd.AsEnumerable().Sum(c => (int?)c.Quantity) ?? 0; stockView.ClosingBalance = stockView.OpeningBalance + stockView.StockIn - stockView.StockOut; stockViews.Add(stockView); } return(stockViews); }
// GET: Trading public ActionResult TradingHall() { StockView model = new StockView(); string number = Request.Params["number"]; string price = Request.Params["price"]; if (number != null && price != null) { if (number != "" && price != "") { model.StockViewList = stockService.GetStockList(pageIndex, pageSize).Where(r => r.Number == int.Parse(number)).Where(r => r.Price == decimal.Parse(price)).ToList(); model.totalPage = stockService.GetStockCount().Where(r => r.Number == int.Parse(number)).Where(r => r.Price == decimal.Parse(price)).ToList().Count; } else if (number != "" && price == "") { model.StockViewList = stockService.GetStockList(pageIndex, pageSize).Where(r => r.Number == int.Parse(number)).ToList(); model.totalPage = stockService.GetStockCount().Where(r => r.Number == int.Parse(number)).ToList().Count; } else if (number == "" && price != "") { model.StockViewList = stockService.GetStockList(pageIndex, pageSize).Where(r => r.Price == decimal.Parse(price)).ToList(); model.totalPage = stockService.GetStockCount().Where(r => r.Price == decimal.Parse(price)).ToList().Count; } } else if (number == null && price == null) { model.StockViewList = stockService.GetStockList(pageIndex, pageSize); model.totalPage = stockService.GetStockCount().Count; } for (int i = 0; i < model.StockViewList.Count; i++) { UserDTO usermodel = UserServer.GetModel(model.StockViewList[i].UserID); if (model != null) { model.StockViewList[i].UserCode = usermodel.UserCode; } } // model.totalPage = stockService.GetStockCount().Count; decimal s = (decimal)model.totalPage / (decimal)pageSize; model.showPageNum = int.Parse(Math.Ceiling(s).ToString()); return(View(model)); }
public void EditRow(StockView stock, bool isAdd) { backup = stock.DeepCopy(); RowOnUpdate = true; EstAjoutStock = isAdd; if (isAdd) { MinQuantite = Convert.ToDecimal(stock.Quantite); MaxQuantite = decimal.MaxValue; } else { MinQuantite = 0; MaxQuantite = Convert.ToDecimal(stock.Quantite); } StockGrid.EditRow(stock); }
private async void OnValidSubmit() { try { if (StockValidation.IdRack == 0) { Notification.Notify(NotificationSeverity.Warning, "Attention", "Le Rack choisi n'est pas bon."); return; } if (string.IsNullOrEmpty(StockValidation.ReferenceProduit)) { Notification.Notify(NotificationSeverity.Warning, "Attention", "La référence de produit choisie n'est pas bonne."); return; } Stock stock = StockValidation.ToStock(); await ContextSql.AddNewStock(stock); Notification.Notify(NotificationSeverity.Success, "Sauvegarde OK", "Sauvegarde OK"); // remise à zéro StockValidation = new EntreStockValidation(); StateHasChange.Invoke(); // Récupération de l'enregistrement StockView newStock = await ContextSql.GetStocks(stock.RackId, stock.ProduitId); Log.Information($"STOCK ENTREE - Ajout de {newStock.Quantite} de {newStock.ReferenceProduit} sur {newStock.GisementPos}"); AllStock.Add(newStock); await StockGrid.Reload(); } catch (Exception ex) { Log.Error(ex, "StockViewModel - OnValidSubmit"); Notification.Notify(NotificationSeverity.Success, "Error", "Erreur sur la sauvegarde"); } }
public async void OnUpdateRow(StockView stock) { try { // Suppression du stock if (stock.Quantite == 0) { await ContextSql.DeleteStockLine(stock.IdRack, stock.ReferenceProduit); Log.Information($"STOCK - Sortie : {stock.ReferenceProduit} - quantité mis à ZERO de {stock.GisementPos}"); AllStock = await ContextSql.GetStocks(); } else { await ContextSql.UpdateStock(stock.IdRack, stock.ReferenceProduit, stock.Quantite); // Si ce n'est pas un ajout de stock if (EstAjoutStock) { var quantiteEntre = stock.Quantite - backup.Quantite; Log.Information($"STOCK - Ajout : {stock.ReferenceProduit} - quantité : {quantiteEntre} {stock.Unite} sur {stock.GisementPos}"); } else { var quantiteSortie = backup.Quantite - stock.Quantite; await ContextSql.AddNewSortieStock(stock.ReferenceProduit, quantiteSortie, DateTime.Now); Log.Information($"STOCK - Sortie : {stock.ReferenceProduit} - quantité : {quantiteSortie} {stock.Unite} de {stock.GisementPos}"); } } RowOnUpdate = false; } catch (Exception ex) { Log.Error(ex, "Erreur sur OnUpdateRow"); } }
public List <StockView> ViewStock() { List <StockView> stockViews = new List <StockView>(); var products = _productRepository.GetAll(); foreach (var p in products) { StockView stockView = new StockView(); var pd = _purchaseRepository.GetAllPurchaseDetails().Where(c => c.ProductId == p.Id).ToList(); var sd = _salesRepository.GetAllSalesDetailses().Where(c => c.ProductId == p.Id).ToList(); stockView.Product = p.Name; stockView.ReOrderLevel = p.ReOrderLevel; stockView.OpeningBalance = 0; stockView.StockIn = pd.AsEnumerable().Sum(c => (int?)c.Quantity) ?? 0; stockView.StockOut = sd.AsEnumerable().Sum(c => (int?)c.Quantity) ?? 0; stockView.ClosingBalance = stockView.StockIn - stockView.StockOut; stockViews.Add(stockView); } return(stockViews); }
public async void SaveRow(StockView stock) { await StockGrid.UpdateRow(stock); RowOnUpdate = false; }
public CustomList <StockView> StockView1() { //StockView obj = new StockView(); return(StockView.StockView1()); }