private void Selector_DateRangeChanged(object sender, DateRangeChangedEventArgs e) { DataService.GetService().DateRange = e.NewValue; c1DockingTab1_TabClick(null, EventArgs.Empty); }
private void Dashboard_Load(object sender, EventArgs e) { Visible = false; var dashboardLayout = new C1DashboardLayout(); var selector = new ValRangeSelector() { Dock = DockStyle.Bottom }; Series series; var g1 = new BulletGraphs() { Dock = DockStyle.Fill, Parent = panGauges1 }; var g2 = new BulletGraphs() { Dock = DockStyle.Fill, Parent = panGauges2 }; selector.DateRangeChanged += (s, ev) => { DataService.GetService().DateRange = ev.NewValue; g1.Source = DataService.GetService().CategorySalesVsGoal; labUnits1.Text = Strings.Resource.Unit_Text; chartSaleTopProd.DataSource = DataService.GetService().GetTopSaleProductList(3); chartSaleTopProd.AxisY.Format = Fmt; chartSaleTopProd.AxisX.LabelAngle = -45; chartSaleTopProd.Series.Clear(); series = new Series(); series.Binding = "Sales"; SetColor1(series); chartSaleTopProd.BindingX = "Name"; chartSaleTopProd.Series.Add(series); chartSaleTopProd.ChartType = C1.Chart.ChartType.Column; chartSaleTopProd.AnimationSettings = C1.Chart.AnimationSettings.All; chartCurrProfitVSPriorProfit.AnimationSettings = C1.Chart.AnimationSettings.All; chartSalesVsProfit.AnimationSettings = C1.Chart.AnimationSettings.All; gridTopSaleCustomer.DataSource = DataService.GetService().GetTopSaleCustomerList(7); gridTopSaleCustomer.Cols.Count = 4; gridTopSaleCustomer.Cols["Name"].StarWidth = "*"; gridTopSaleCustomer.Cols["Sales"].Format = "C0"; gridTopSaleCustomer.Cols["Sales"].StarWidth = "*"; gridTopSaleCustomer.Cols["Profit"].Format = "C0"; gridTopSaleCustomer.Cols["Profit"].StarWidth = "*"; gridTopSaleCustomer.Cols[0].WidthDisplay = 0; g2.Source = DataService.GetService().RegionSalesVsGoal; labUnits2.Text = Strings.Resource.Unit_Text; dashboardLayout.SetCaption(c1SplitterPanel4, Strings.Resource.CategorySales_Header); dashboardLayout.SetCaption(c1SplitterPanel8, Strings.Resource.TopSaleProducts_Header); dashboardLayout.SetCaption(c1SplitterPanel9, Strings.Resource.TopSaleCustomer_Header); dashboardLayout.SetCaption(c1SplitContainer1, Strings.Resource.RegionSales_Header); dashboardLayout.SetCaption(c1SplitterPanel6, Strings.Resource.BudgetVSProfit_Header); dashboardLayout.SetCaption(splPan1, Strings.Resource.SalesVsProfit_Header); dashboardLayout.SetCaption(splPan2, Strings.Resource.BudgetVSProfit_Header); }; Controls.Add(selector); c1SplitContainer1.Dock = DockStyle.Fill; chartCurrProfitVSPriorProfit.DataSource = DataService.GetService().BudgetItemList; chartCurrProfitVSPriorProfit.AxisY.Format = Fmt; series = new Series(); series.Binding = "Profit"; series.Name = Strings.Resource.CurrentYear_Series; SetColor1(series); chartCurrProfitVSPriorProfit.Series.Add(series); series = new Series(); series.Binding = "ProirProfit"; series.Name = Strings.Resource.PriorYear_Series; SetColor2(series); chartCurrProfitVSPriorProfit.Series.Add(series); chartCurrProfitVSPriorProfit.BindingX = "Date"; chartCurrProfitVSPriorProfit.ChartType = C1.Chart.ChartType.LineSymbols; chartCurrProfitVSPriorProfit.Legend.Position = C1.Chart.Position.Top; chartSalesVsProfit.DataSource = DataService.GetService().BudgetItemList; series = new Series(); series.Binding = "Sales"; series.Name = Strings.Resource.Sale_Series; series.AxisY = new Axis() { Position = C1.Chart.Position.Right, Title = Strings.Resource.Sale_Series, Format = Fmt }; SetColor1(series); chartSalesVsProfit.Series.Add(series); series = new Series(); series.Binding = "Profit"; series.Name = Strings.Resource.Profit_Series; series.ChartType = C1.Chart.ChartType.Line; series.AxisY = new Axis() { Position = C1.Chart.Position.Left, Title = Strings.Resource.Profit_Series, Format = Fmt }; SetColor2(series); chartSalesVsProfit.Series.Add(series); chartSalesVsProfit.BindingX = "Date"; gridTopSaleCustomer.Visible = true; dashboardLayout.Options.ToolIconAppearance = ToolIconAppearance.UpperRight; dashboardLayout.AttachToLayout(new SplitLayout(c1SplitContainer1)); selector.SendToBack(); Visible = true; }
void UpdataDataByDateRange() { ///saleCollection.Filter = new Predicate<object>(FilterByDateRange); ///saleCollection.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending)); ///budgetCollection.Filter = new Predicate<object>(FilterByDateRange); ///opportunityCollection.Filter = new Predicate<object>(FilterByDateRange); ///regionWiseSaleCollection.Filter = new Predicate<object>(FilterByDateRange); ///regionSaleGoalCollection.Filter = new Predicate<object>(FilterByDateRange); opportunityList = new List <Opportunity>(); foreach (OpportunityLevel value in Enum.GetValues(typeof(OpportunityLevel))) { opportunityList.Add(new Opportunity { Level = value, Sales = 0 }); } var campainTaskItems = new List <CampainTaskItem>(); var productSaleMap = new Dictionary <int, SaleItem>(); var customerSaleMap = new Dictionary <int, SaleItem>(); foreach (Sale sale in saleCollection) { var profit = DataService.GetService().FindProfitFormCurrentSale(sale); if (sale.Campaign.Name != "None") { campainTaskItems.Add(new CampainTaskItem(sale)); } if (customerSaleMap.ContainsKey(sale.CustomerId)) { customerSaleMap[sale.CustomerId].Sales += sale.Summ; customerSaleMap[sale.CustomerId].Profit += profit; } else { customerSaleMap.Add(sale.CustomerId, new SaleItem { Id = sale.CustomerId, Sales = sale.Summ, Profit = profit, Name = sale.Customer.ToString(), Date = sale.Date }); } if (productSaleMap.ContainsKey(sale.ProductId)) { productSaleMap[sale.ProductId].Sales += sale.Summ; productSaleMap[sale.ProductId].Profit += profit; } else { productSaleMap.Add(sale.ProductId, new SaleItem { Id = sale.ProductId, Sales = sale.Summ, Profit = profit, Name = sale.Product.ToString(), Date = sale.Date }); } } var regionSaleMap = new Dictionary <int, SaleGoalItem>(); var categorySaleMap = new Dictionary <int, SaleGoalItem>(); foreach (BudgetItem budget in budgetCollection) { if (categorySaleMap.ContainsKey(budget.CategoryId)) { categorySaleMap[budget.CategoryId].Sales += budget.Sales; categorySaleMap[budget.CategoryId].Profit += budget.Profit; categorySaleMap[budget.CategoryId].Goal += budget.Goal; } else { SaleGoalItem item = new SaleGoalItem(); item.Name = budget.Category.ToString(); item.Goal = budget.Goal; item.Sales = budget.Sales; item.Profit = budget.Profit; categorySaleMap.Add(budget.CategoryId, item); } } foreach (RegionSalesGoal region in regionSaleGoalCollection) { if (regionSaleMap.ContainsKey(region.RegionId)) { regionSaleMap[region.RegionId].Sales += region.Sales; regionSaleMap[region.RegionId].Profit += region.Profit; regionSaleMap[region.RegionId].Goal += region.Goal; } else { SaleGoalItem item = new SaleGoalItem(); item.Name = region.Region.ToString(); item.Goal = region.Goal; item.Sales = region.Sales; item.Profit = region.Profit; regionSaleMap.Add(region.RegionId, item); } } campainTaskCollection = new ListCollectionView(campainTaskItems); ///campainTaskCollection.Filter = new Predicate<object>(FilterByCampainTaskType); productSaleCollection = new ListCollectionView(productSaleMap.Values.ToList()); ///productSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); customerSaleCollection = new ListCollectionView(customerSaleMap.Values.ToList()); ///customerSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); regionSalesVsGoal = regionSaleMap.Values.ToList(); categorySalesVsGoal = categorySaleMap.Values.ToList(); foreach (OpportunityItem opportunity in opportunityCollection) { OpportunityItemList[opportunity.LevelId].Sales += opportunity.Sales; } }