/// <summary> /// Gets the count stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public int GetCountStock(StockStatusType stockType, int year) { int result = 0; foreach (var record in this.Records) { switch (stockType) { case StockStatusType.AfterYear: if (record.Date.Year <= year) { result += record.AmountChange; } break; case StockStatusType.Current: result += record.AmountChange; break; case StockStatusType.ForYear: if (record.Date.Year == year) { result += record.AmountChange; } break; } } return(result); }
/// <summary> /// Gets the price stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public double GetPriceStock(StockStatusType stockType, int year) { double result = 0; foreach (var record in this.Records) { switch (stockType) { case StockStatusType.AfterYear: if (record.Date.Year <= year) { result += record.PriceChange; } break; case StockStatusType.Current: result += record.PriceChange; break; case StockStatusType.ForYear: if (record.Date.Year == year) { result += record.PriceChange; } break; } } return(result); }
/// <summary> /// Gets the count stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public int GetCountStock(StockStatusType stockType, int year) { int result = 0; foreach (var card in this.Cards) { result += card.GetCountStock(stockType, year); } return(result); }
/// <summary> /// Gets the price stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public double GetPriceStock(StockStatusType stockType, int year) { double result = 0; foreach (var card in this.Cards) { result += card.GetPriceStock(stockType, year); } return(result); }
/// <summary> /// Gets the group stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public List <GroupStock> GetGroupStock(StockStatusType stockType, int year) { List <GroupStock> stock = new List <GroupStock>(); foreach (var group in this.Groups) { stock.Add(new GroupStock(group.Name, group.GetPriceStock(stockType, year), group.GetCountStock(stockType, year))); } return(stock); }
/// <summary> /// Gets the summary stock. /// </summary> /// <param name="stockType">Type of the stock.</param> /// <param name="year">The year.</param> /// <returns></returns> public GroupStock GetSummaryStock(StockStatusType stockType, int year) { int count = 0; double price = 0; foreach (var group in this.Groups) { count += group.GetCountStock(stockType, year); price += group.GetPriceStock(stockType, year); } return(new GroupStock("Celkem:", price, count)); }
/// <summary> /// Shows the stock panel. /// </summary> /// <param name="stockStatusType">Type of the stock status.</param> private void ShowStockPanel(StockStatusType stockStatusType) { this.selectedGroup = null; this.selectedCard = null; this.selectedRecord = null; this.selectedCustomer = null; this.ActivateMenuButtons(); this.recordsStackPanel.Visibility = System.Windows.Visibility.Collapsed; this.cardStackPanel.Visibility = System.Windows.Visibility.Collapsed; this.customerStackPanel.Visibility = System.Windows.Visibility.Collapsed; this.stockStackPanel.Visibility = System.Windows.Visibility.Visible; int year = stockStatusType == StockStatusType.Current ? -1 : this.selectedStockYear; List <GroupStock> stock = DataManager.Instance.GetGroupStock(stockStatusType, year); switch (stockStatusType) { case StockStatusType.Current: this.stockPanelTitle.Text = "Aktuální stav zásob"; break; case StockStatusType.AfterYear: this.stockPanelTitle.Text = String.Format("Stav zásob po roce {0}", this.selectedStockYear); break; case StockStatusType.ForYear: this.stockPanelTitle.Text = String.Format("Stav zásob pro rok {0}", this.selectedStockYear); break; } this.stockPriceListBox.ItemsSource = stock; this.stockCountAndPriceListBox.ItemsSource = stock; GroupStock summaryStock = DataManager.Instance.GetSummaryStock(stockStatusType, year); this.stockSummaryStackPanel.DataContext = new { SummaryName = summaryStock.Name, SummaryCount = String.Format("{0} ks", summaryStock.Count), SummaryPrice = String.Format("{0} Kč", summaryStock.Price) }; }