private void ConvertResultBasedOnState() { Dictionary <int, double> totalByState = new Dictionary <int, double>(); foreach (string m in SelectedMonthCollection) { DataRow r = SalesResultTable.NewRow(); r[0] = m; for (int i = 0; i < SelectedStateCollection.Count; i++) { double totalSales = SelectedSales.Where(x => x.Month.Equals(m) && x.State.Equals(SelectedStateCollection[i]) && x.Year.Equals(SelectedYear)) .Select(selectItem => selectItem.TotalSales).FirstOrDefault(); r[i + 1] = totalSales; if (totalByState.ContainsKey(i)) { totalByState[i] += totalSales; } else { totalByState.Add(i, totalSales); } } SalesResultTable.Rows.Add(r); } }
public void SalesViewSelectionChanged(SelectionChangedEventArgs e) { foreach (Data.Sale sale in e.AddedItems) { SelectedSales.Add(sale); } foreach (Data.Sale sale in e.RemovedItems) { SelectedSales.Remove(sale); } TotalSelectedAmount = CalculateTotalSelectedAmount(); }
public void SelectMonthsForResult() { if (SelectedMonth != null) { SelectedMonthCollection.Add(SelectedMonth); } else { foreach (var i in SelectedSales.Select(x => x.Month).Distinct().ToList()) { SelectedMonthCollection.Add(i); } } }
public void FilterResult() { SelectedMonthCollection = new ObservableCollection <string>(); SelectedSales = AllSales.Where(x => SelectedStateCollection.Contains(x.State) && x.Country.Contains(SelectedCountry.CountryName) && x.Year.Equals(SelectedYear)).ToList(); if (SelectedMonth != null) { SelectedSales = SelectedSales.Where(x => x.Month.Equals(SelectedMonth)).ToList(); } if (SelectedCities != null) { SelectedSales = SelectedSales.Where(sale => SelectedCities.Select(r => r.Name).Contains(sale.City)).ToList(); } }