示例#1
0
        public static void InitComponents(MainWindow mainWindow)
        {
            Window = mainWindow;
            InitCellTemplates();
            ApplyCellTemplates();
            FillSpendFiltersTable();
            FillIncomeFiltersTable();
            FillSpendItemsTable();
            FillIncomeItemsTable();
            Report = new AnalysisReport(Window);
            Report.Init();

            Window.datePicker.Value = DateTime.Now.Date;

            CalculateMoneyLeft(null, null);
            Window.tabControl.Selecting += (o, e) =>
            {
                switch (e.TabPageIndex)
                {
                case 0:
                    UpdateSpendItemsTable(Window.spendGrid, Window.datePicker.Value.Date);
                    break;

                case 1:
                    UpdateIncomeItemsTable(Window.incomeGrid, Window.datePicker.Value.Date);
                    break;

                case 2:
                    TreeViewControl.FillSpendFilters(Window.AnalysisFiltersTree);
                    break;
                }
            };
        }
示例#2
0
        protected void BuildReport()
        {
            NoDataAnnotation.Visible = false;
            Selection = TreeViewControl.GetSelection(Window.AnalysisFiltersTree);
            var   values = DB.DBManager.GetSpendValuesForPeriod(Selection, Window.ParamsDateFrom.Value, Window.ParamsDateTo.Value);
            var   total  = values.Values.Sum();
            Chart chart  = Window.Chart;

            ChartArea spendChartArea = new ChartArea("Расходы");

            spendChartArea.BackColor            = Color.White;
            spendChartArea.AlignmentOrientation = AreaAlignmentOrientations.Vertical;
            chart.ChartAreas.Clear();
            chart.ChartAreas.Add(spendChartArea);

            Legend spendLegend = InitLegend(spendChartArea, "spendLegend", "Фильтры:");

            chart.Legends.Clear();
            chart.Legends.Add(spendLegend);

            chart.Series.Clear();
            Series series = new Series();

            series.Legend          = spendLegend.Name;
            series.ChartType       = SeriesChartType.Pie;
            series.ChartArea       = spendChartArea.Name;
            series.Palette         = ChartColorPalette.BrightPastel;
            series.XValueType      = ChartValueType.String;
            series.YValuesPerPoint = 1;
            series.YValueType      = ChartValueType.Double;
            foreach (var value in values)
            {
                DataPoint point           = series.Points.Add(new[] { value.Value });
                double    pointLabelValue = value.Value / total;
                point.Label        = value.Value > 0 ? pointLabelValue.ToString("P1") : string.Empty;
                point.LabelToolTip = point.LegendToolTip = value.Value.ToString("C2");
                point.LegendText   = point.ToolTip = value.Key;
            }
            chart.Series.Add(series);

            if (values.Keys.Count == 0)
            {
                NoDataAnnotation.Visible = true;
            }
        }
示例#3
0
        public void Init()
        {
            TreeViewControl.SetUpTree(Window.AnalysisFiltersTree);
            TreeViewControl.FillSpendFilters(Window.AnalysisFiltersTree);
            InitAnnotations();

            Window.buildButton.Click           = Window.buildButton.Click + StartBuildingReport;
            Window.ParamsDateFrom.ValueChanged = Window.ParamsDateFrom.ValueChanged + (o, e) =>
            {
                Window.ParamsDateTo.MinDate = Window.ParamsDateFrom.Value;
            };
            Window.ParamsDateTo.ValueChanged += (o, e) =>
            {
                Window.ParamsDateFrom.MaxDate = Window.ParamsDateTo.Value;
            };
            Window.ParamsDateFrom.Value = DateTime.Now.AddMonths(-1);
            Window.ParamsDateTo.Value   = DateTime.Now;
        }