public BasicBar <int?> GetSalesPerProduct(int[] productList, DateTime?begin, DateTime?end) { BasicBar <int?> chart = new BasicBar <int?>(); DAL.SalesPerProduct[] query = repo.GetSalesPerProduct(productList, begin, end); string[] stores = GetStoreList(query); //Getting the list of years string[] products = query .OrderBy(r => r.Product) .Select(r => r.Product) .Distinct().ToArray(); chart.Categories = products; foreach (var store in stores) { Serie <int?> serie = new Serie <int?>() { Name = store, Data = new int?[products.Length] }; for (int i = 0; i < products.Length; i++) { int?value = query .Where(r => r.Store == store && r.Product == products[i]) .Select(r => r.Total) .FirstOrDefault(); serie.Data[i] = value; } chart.Series.Add(serie); } return(chart); }
private void button1_Click_1(object sender, EventArgs e) { var sample = new BasicBar(); sample.ShowDialog(); }