Exemplo n.º 1
0
        private void c1DockingTab1_TabClick(object sender, EventArgs e)
        {
            int selectedIndex = c1DockingTab1.SelectedIndex;

            DataService.GetService().CampainTaskType = (CampainTaskType)selectedIndex;
            _flex.Parent.Tag        = _flex.GroupDescriptions;
            _flex.GroupDescriptions = null;
            _flex.DataSource        = DataService.GetService().CampainTaskCollction.Cast <CampainTaskItem>().ToList();
            int r1 = _flex.Rows.Fixed;
            int r2 = _flex.Rows.Count - 1;

            if (r2 > 1)
            {
                Column col = _flex.Cols["Complete"];
                double max = _flex.Aggregate(AggregateEnum.Max, r1, col.Index, r2, col.Index);
                col.UserData  = max;
                col.TextAlign = TextAlignEnum.CenterCenter;
            }
            _flex.Cols[1].StarWidth = "*";
            _flex.Cols[2].StarWidth = "*";
            _flex.Cols[3].StarWidth = "*";
            _flex.Cols[5].StarWidth = "*";
            _flex.Parent            = c1DockingTab1.SelectedTab;
            _flexGroupPanel.Parent  = c1DockingTab1.SelectedTab;
            _flex.GroupDescriptions = _flex.Parent.Tag as IList <C1.Win.C1FlexGrid.GroupDescription>;
        }
Exemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();
            C1ThemeController.ApplicationTheme = "VS2013Dark";
            _btnHamb_Click(this, EventArgs.Empty);
            var worker = new BackgroundWorker();

            worker.DoWork += (s, e) =>
            {
                DataService service = DataService.GetService();
                service.InitializeDataService();
                _error = service.Error;
            };
            worker.RunWorkerCompleted += (s, e) =>
            {
                if (_error != null)
                {
                    MessageBox.Show(this, _error, Strings.Resource.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }
                _pages.Add(cmdDashboard, new Dashboard());
                _pages.Add(cmdAnalysis, new Analysis());
                _pages.Add(cmdReporting, new Reporting());
                _pages.Add(cmdTasks, new Tasks());
                _pages.Add(cmdProducts, new Products());
                _picSpinner.Visible = false;
                cmd_Click(cmdDashboard, ClickEventArgs.Empty);
            };
            worker.RunWorkerAsync();
        }
Exemplo n.º 3
0
        private void UpdataMapMark()
        {
            _vectorLayer.Items.Clear();
            var regionSalesCollection = new ListCollectionView(DataService.GetService().GetRegionWiseSales());

            if (regionSalesCollection.Count == 0)
            {
                return;
            }
            regionSalesCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending));
            double maxValue = (regionSalesCollection.GetItemAt(0) as RegionSaleItem).Sales;

            foreach (RegionSaleItem sales in regionSalesCollection)
            {
                C1.Win.Map.VectorPlacemark mark = new C1.Win.Map.VectorPlacemark();
                mark.Geometry             = new GeoPoint(sales.Locat.X, sales.Locat.Y);
                mark.Marker.Size          = CreateMarkBySale(sales.Sales, maxValue);
                mark.Marker.Shape         = MarkerShape.Circle;
                mark.Marker.Caption       = string.Format("{0:C}", sales.Sales);
                mark.Marker.LabelPosition = LabelPosition.Center;
                mark.Style.Stroke.Color   = sales.Profit > 0 ? Color.Orange : Color.RoyalBlue;
                mark.Style.BackColor      = mark.Style.Stroke.Color;
                _vectorLayer.Items.Add(mark);
            }
        }
Exemplo n.º 4
0
        private void c1DockingTab1_TabClick(object sender, EventArgs e)
        {
            var list = DataService.GetService().GetProductItemList((CategoryType)c1DockingTab1.SelectedIndex);

            listView1.Items.Clear();
            listView1.LargeImageList           = new ImageList();
            listView1.LargeImageList.ImageSize = new Size(256, 256 / 2);
            int i = 0;

            foreach (var item in list)
            {
                listView1.LargeImageList.Images.Add(item.ImageSource);
                listView1.Items.Add(item.Label, i++);
            }
            listView1.Parent = c1DockingTab1.SelectedTab;
        }
Exemplo n.º 5
0
        private void RangeSelector_Load(object sender, EventArgs e)
        {
            _items = DataService.GetService().DateSaleList;
            flexChart1.DataSource = _items;
            flexChart1.Series.Clear();
            var series = new Series();

            series.Binding      = "Sales";
            flexChart1.BindingX = "Month";
            flexChart1.Series.Add(series);
            flexChart1.AxisY.Labels      = false;
            flexChart1.AxisY.MajorGrid   = false;
            flexChart1.ChartType         = C1.Chart.ChartType.Line;
            _rangeSelector               = new RangeSelector(flexChart1);
            _rangeSelector.Maximum       = _items.Count - 1;
            _rangeSelector.UpperValue    = _rangeSelector.Maximum;
            _rangeSelector.ValueChanged += _rangeSelector_ValueChanged;

            _rangeSelector_ValueChanged(null, EventArgs.Empty);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 private void Selector_DateRangeChanged(object sender, DateRangeChangedEventArgs e)
 {
     DataService.GetService().DateRange = e.NewValue;
     c1DockingTab1_TabClick(null, EventArgs.Empty);
 }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
        private void Analysis_Load(object sender, EventArgs e)
        {
            dfOlap.AutoApply           = true;
            dfOlap.AutoGenerateFilters = false;
            dfOlap.FilterChanged      += DfOlap_FilterChanged;
            dfMap                     = new C1DataFilter();
            dfMap.AutoApply           = true;
            dfMap.AutoGenerateFilters = false;
            dfMap.FilterChanged      += DfMap_FilterChanged;

            var dashboardLayout = new C1DashboardLayout();

            _vectorLayer = new C1.Win.Map.VectorLayer()
            {
                LabelVisibility = LabelVisibility.Visible
            };
            _vectorLayer.LabelStyle.Font = new Font(Font.FontFamily, 7);

            Map.TileLayer.TileSource = new VirtualEarthRoadSource();
            Map.Layers.Add(_vectorLayer);

            var engine = OlapPanel.FlexPivotEngine;

            engine.DataSource = DataService.GetService().ProductWiseSaleCollection;
            InitOlap(engine);

            var selector = new ValRangeSelector()
            {
                Dock = DockStyle.Bottom
            };

            ChecklistFilter fCategories = new ChecklistFilter("Category", true);

            fCategories.HeaderText      = Strings.Resource.DataFilter_Categories;
            fCategories.ItemsSource     = DataService.GetService().ProductWiseSaleCollection;
            fCategories.ValueMemberPath = "Category";
            fCategories.SelectAll();
            dfOlap.Filters.Add(fCategories);
            dfMap.Filters.Add(fCategories);
            ChecklistFilter fModels = new ChecklistFilter("Product", true);

            fModels.HeaderText      = Strings.Resource.DataFilter_Products;
            fModels.ItemsSource     = fCategories.ItemsSource;
            fModels.ValueMemberPath = "Product";
            fModels.SelectAll();
            dfOlap.Filters.Add(fModels);
            dfMap.Filters.Add(fModels);
            RangeFilter fSales = new RangeFilter("Sales", true);

            fSales.HeaderText = Strings.Resource.DataFilter_Sales;
            var list = from prod in DataService.GetService().ProductWiseSaleCollection.Cast <ProductsWiseSaleItem>() select prod.Sales;

            fSales.Maximum = list.Max();
            fSales.Minimum = list.Min();
            dfOlap.Filters.Add(fSales);
            dfMap.Filters.Add(fSales);

            selector.DateRangeChanged += (s, ev) =>
            {
                dfOlap.DataSource = DataService.GetService().ProductWiseSaleCollection;
                dfMap.DataSource  = DataService.GetService().GetRegionWiseSalesWithCategory();

                DataService.GetService().GetRegionWiseSaleCollection = () => dfMap.View.ToList();

                DataService.GetService().DateRange = ev.NewValue;
                UpdataMapMark();

                chartOpportunities.DataSource = DataService.GetService().OpportunityItemList;
                chartOpportunities.Series.Clear();
                var series = new Series();
                series.Binding = series.Name = "Sales";
                chartOpportunities.Series.Add(series);
                chartOpportunities.BindingX           = "Level";
                chartOpportunities.DataLabel.Position = C1.Chart.LabelPosition.Center;
                chartOpportunities.DataLabel.Content  = "{}{y:C0}";
                chartOpportunities.ChartType          = C1.Chart.ChartType.Funnel;
            };
            Controls.Add(selector);
            dashboardLayout.Options.ToolIconAppearance = ToolIconAppearance.UpperRight;
            dashboardLayout.AttachToLayout(new SplitLayout(c1SplitContainerMain));
            IconBox settings = new IconBox()
            {
                BackgroundImage = Properties.Resources.settings_work_tool
            };

            settings.Click += (s, ev) =>
            {
                OlapPanel.Location = PointToClient(settings.PointToScreen(new Point(-2, settings.Height + 2)));
                if (OlapPanel.Right > Right)
                {
                    OlapPanel.Left = Right - OlapPanel.Width - 2;
                }
                OlapPanel.Parent  = this;
                OlapPanel.Visible = true;
                OlapPanel.BringToFront();
            };
            OlapPanel.MouseLeave += (s, ev) => OlapPanel.Visible = false;
            IconBox dataFilter = new IconBox()
            {
                BackgroundImage = Properties.Resources.C1DataFilter
            };

            dataFilter.Click += (s, ev) =>
            {
                dfOlap.Location = PointToClient(dataFilter.PointToScreen(new Point(-2, dataFilter.Height + 2)));
                if (dfOlap.Right > Right)
                {
                    dfOlap.Left = Right - dfOlap.Width - 2;
                }
                dfOlap.Parent  = this;
                dfOlap.Visible = true;
                dfOlap.BringToFront();
            };
            settings.VisibleChanged += (s, ev) => {
                settings.Visible   = dashboardLayout.GetSelectedItem()?.ItemContainer == c1SplitterPanelGrid;
                dataFilter.Visible = settings.Visible;
            };
            dfOlap.MouseLeave += (s, ev) => dfOlap.Visible = false;
            OlapGrid.Resize   += (s1, ev1) => { OlapPanel.Visible = false; dfOlap.Visible = false; };
            dashboardLayout.ItemContainerSelected += (s, ev) =>
            {
                settings.Visible   = dashboardLayout.GetSelectedItem()?.ItemContainer == c1SplitterPanelGrid;
                dataFilter.Visible = settings.Visible;
            };
            dashboardLayout.Options.HeaderElements.Add(dataFilter);
            dashboardLayout.Options.HeaderElements.Add(settings);
            dashboardLayout.SetCaption(c1SplitterPanelGrid, Strings.Resource.ProductWise_Header);
            dashboardLayout.SetCaption(c1SplitterPanel3, Strings.Resource.RegionWise_Header);
            dashboardLayout.SetCaption(c1SplitterPanel4, Strings.Resource.Opportunities_Header);
            this.c1SplitterPanelGrid.Width = 565;
            selector.SendToBack();
            ScanControls(this);
        }