Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public void SelectMonthsForResult()
 {
     if (SelectedMonth != null)
     {
         SelectedMonthCollection.Add(SelectedMonth);
     }
     else
     {
         foreach (var i in SelectedSales.Select(x => x.Month).Distinct().ToList())
         {
             SelectedMonthCollection.Add(i);
         }
     }
 }
Esempio n. 4
0
        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();
            }
        }