Exemple #1
0
        private void CreateGauges()
        {
            c1Gauge1.Gauges.ClearAndDispose();
            if (_source == null || _source.Count == 0)
            {
                return;
            }
            var unitConv  = new UnitConverter();
            var colorConv = new BarColorConverter();
            var badConv   = new BadValueConverter();
            var goodConv  = new GoodValueConverter();
            int mul       = c1Gauge1.Height / 5;

            for (int i = 0; i < _source.Count; i++)
            {
                SaleGoalItem  item     = _source[i];
                var           goal     = (double)unitConv.Convert(item.Goal, null, null, null);
                var           sale     = (double)unitConv.Convert(item.Sales, null, null, null);
                var           color    = (Color)colorConv.Convert(item.CompletePrecent, null, null, null);
                var           badGoal  = (double)badConv.Convert(item.Goal, null, null, null);
                var           goodGoal = (double)goodConv.Convert(item.Goal, null, null, null);
                C1LinearGauge g        = new C1LinearGauge();
                g.Maximum         = 100;
                g.Viewport.Y      = i * mul;
                g.Viewport.X      = 80;
                g.Viewport.Height = mul;
                g.Pointer.Visible = false;
                var d = new C1GaugeRange()
                {
                    To = sale, Width = mul, Filling = new C1GaugeFilling()
                    {
                        Color = color
                    }
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                var width = mul * 2;
                d = new C1GaugeRange()
                {
                    To = badGoal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.FromArgb(0x4C000000)
                    }, Width = width
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                d = new C1GaugeRange()
                {
                    To = goodGoal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.FromArgb(0x26000000)
                    }, Width = width
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                g.Decorators.Add(new C1GaugeRange()
                {
                    From = goal - 0.2, To = goal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.Black
                    }, Width = width
                });

                g.FaceShapes.Add(new C1GaugeCaption()
                {
                    Text = item.Name, CenterPointX = -68.0 / Width
                });
                c1Gauge1.Gauges.Add(g);
            }
            var gauge = c1Gauge1.Gauges[_source.Count - 1];
            var marks = new C1GaugeMarks()
            {
                From = 0, To = 100, Interval = 20, Location = mul * 2 + 40, Shape = C1GaugeMarkShape.Round
            };

            gauge.Decorators.Add(marks);
            var labels = new C1GaugeLabels()
            {
                From = 0, To = 100, Interval = 20, Location = mul * 2 + 90
            };

            gauge.Decorators.Add(labels);
        }
Exemple #2
0
        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;
            }
        }