예제 #1
0
        private void RefreshPortfolioPieChart(Dashboard dashboard)
        {
            if (_portfolioChart != null)
            {
                portfolioPanel.Controls.Remove(_portfolioChart);
            }
            _portfolioChart = new Chart();
            var chartArea = new ChartArea();
            _portfolioChart.ChartAreas.Add(chartArea);

            var parPercentage = 0 == dashboard.Olb ? 0 : Math.Round(100 * dashboard.Par / dashboard.Olb, 1);
            var performingPercentage = 100 - parPercentage;

            var numberFormatInfo = new NumberFormatInfo
            {
                NumberGroupSeparator = " ",
                NumberDecimalSeparator = ",",
            };

            var series = new Series();
            series.ChartType = SeriesChartType.Pie;
            var point = series.Points.Add(Convert.ToDouble(performingPercentage));
            point.LegendText = string.Format(
                "{0}: {1} %",
                GetString("Performing"),
                performingPercentage.ToString("N1", numberFormatInfo));
            //point.Color = Color.FromArgb(28, 151, 234);
            point.Color = Color.FromArgb(72, 234, 28);

            point = series.Points.Add(Convert.ToDouble(parPercentage));
            point.LegendText = string.Format(
                "{0}: {1} %",
                GetString("PAR"),
                parPercentage.ToString("N1", numberFormatInfo));
            point.Color = Color.FromArgb(234, 28, 28);

            AddLegend(_portfolioChart);
            AddTitle(_portfolioChart, GetString("Portfolio"));

            _portfolioChart.Series.Add(series);
            _portfolioChart.Location = new Point(0, 0);
            _portfolioChart.Dock = DockStyle.Fill;

            portfolioPanel.Controls.Add(_portfolioChart);
        }
예제 #2
0
        public Dashboard GetDashboard(int branchId, int subordinateId, int loanProductId)
        {
            var dashboard = new Dashboard();
            using (var connection = GetConnection())
            using (var command = new OpenCbsCommand("GetDashboard", connection)
                .AsStoredProcedure()
                .With("@date", TimeProvider.Today)
                .With("@userId", User.CurrentUser.Id)
                .With("@subordinateId", subordinateId)
                .With("@branchId", branchId)
                .With("@loanProductId", loanProductId)
                .WithTimeout(200))
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {

                    var portfolioLine = new PortfolioLine
                    {
                        Name = reader.GetString("name"),
                        Amount = reader.GetDecimal("amount"),
                        Quantity = reader.GetInt("quantity"),
                          Color = reader.GetString("color")
                    };
                    dashboard.PortfolioLines.Add(portfolioLine);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    var stat = new ActionStat
                    {
                        Date = reader.GetDateTime("date"),
                        AmountDisbursed = reader.GetDecimal("amount_disbursed"),
                        NumberDisbursed = reader.GetInt("number_disbursed"),
                        AmountRepaid = reader.GetDecimal("amount_repaid"),
                        NumberRepaid = reader.GetInt("number_repaid"),
                    };
                    dashboard.ActionStats.Add(stat);
                }
            }
            return dashboard;
        }
예제 #3
0
 private void RefreshParTable(Dashboard dashboard)
 {
     parListView.SetObjects(dashboard.PortfolioLines);
 }
예제 #4
0
        private void RefreshParPieChart(Dashboard dashboard)
        {
            if (_parChart != null)
            {
                parPanel.Controls.Remove(_parChart);
            }
            if (0 == dashboard.Par) return;

            _parChart = new Chart();
            var chartArea = new ChartArea();
            _parChart.ChartAreas.Add(chartArea);

            var values = dashboard.
                PortfolioLines.
                Where(line => line.Name.Contains("PAR")).
                Select(line => line.Amount).
                ToArray();
            var legends = dashboard.
                PortfolioLines.
                Where(line => line.Name.Contains("PAR")).Select(line => line.Name).ToArray();
                //Select(line => GetString(line.Name)).ToArray();

            var colors = new List<Color>();

            foreach (var line in dashboard.PortfolioLines)
                if (line.Color != "0")
                    colors.Add(ColorTranslator.FromHtml(line.Color));

            var series = new Series();
            series.ChartType = SeriesChartType.Pie;

            for (var i = 0; i < legends.Length; i++)
            {
                var value = Math.Round(0 == dashboard.Par ? 0 : 100 * values[i] / dashboard.Par, 1);
                var point = series.Points.Add(Convert.ToDouble(value));
                var numberFormat = Math.Round(value) == value ? "N0" : "N1";
                point.LegendText = string.Format("{0}: {1}%", legends[i], value.ToString(numberFormat));
                point.Color = colors[i];
            }

            AddLegend(_parChart);
            AddTitle(_parChart, GetString("PAR"));

            _parChart.Series.Add(series);
            _parChart.Location = new Point(0, 0);
            _parChart.Dock = DockStyle.Fill;

            parPanel.Controls.Add(_parChart);
        }
예제 #5
0
        private void RefreshOlbTrendChart(Dashboard dashboard)
        {
            if (_olbTrendChart != null)
            {
                olbTrendPanel.Controls.Remove(_olbTrendChart);
            }
            _olbTrendChart = new Chart();
            var chartArea = new ChartArea();
            chartArea.AxisX.LabelStyle.Font = chartArea.AxisY.LabelStyle.Font = new Font("Arial", 7f);
            chartArea.AxisX.IsLabelAutoFit = chartArea.AxisY.IsLabelAutoFit = false;

            var min = dashboard.ActionStats.Min(x => x.Olb);
            chartArea.AxisY.Minimum = Convert.ToDouble(min);
            _olbTrendChart.ChartAreas.Add(chartArea);

            var series = new Series();
            series.ChartType = SeriesChartType.Line;
            series.BorderWidth = 3;
            series.MarkerStyle = MarkerStyle.Circle;
            foreach (var actionStat in dashboard.ActionStats)
            {
                var value = Convert.ToDouble(actionStat.Olb);
                var point = series.Points.Add(value);
                point.AxisLabel = actionStat.Date.ToString("dd.MM");
            }

            _olbTrendChart.Series.Add(series);
            _olbTrendChart.Dock = DockStyle.Fill;
            AddTitle(_olbTrendChart, GetString("OlbTrend"));

            olbTrendPanel.Controls.Add(_olbTrendChart);
        }
예제 #6
0
        private void RefreshDisbursementsChart(Dashboard dashboard)
        {
            if (_disbursementsChart != null)
            {
                disbursementsPanel.Controls.Remove(_disbursementsChart);
            }
            _disbursementsChart = new Chart();
            var chartArea = new ChartArea();
            chartArea.AxisX.LabelStyle.Font = chartArea.AxisY.LabelStyle.Font = new Font("Arial", 7f);
            chartArea.AxisX.IsLabelAutoFit = chartArea.AxisY.IsLabelAutoFit = false;
            _disbursementsChart.ChartAreas.Add(chartArea);

            var series = new Series();
            foreach (var actionStat in dashboard.ActionStats)
            {
                var point = series.Points.Add(actionStat.NumberDisbursed);
                point.AxisLabel = actionStat.Date.ToString("dd.MM");
                point.Color = Color.FromArgb(28, 151, 234);
            }

            _disbursementsChart.Series.Add(series);
            _disbursementsChart.Dock = DockStyle.Fill;
            AddTitle(_disbursementsChart, GetString("NumberOfDisbursements"));

            disbursementsPanel.Controls.Add(_disbursementsChart);
        }
예제 #7
0
        private void RefreshParPieChart(Dashboard dashboard)
        {
            if (_parChart != null)
            {
                parPanel.Controls.Remove(_parChart);
            }
            if (0 == dashboard.Par) return;

            _parChart = new Chart();
            var chartArea = new ChartArea();
            _parChart.ChartAreas.Add(chartArea);

            var values = dashboard.
                PortfolioLines.
                Where(line => line.Name.StartsWith("PAR")).
                Select(line => line.Amount).
                ToArray();
            var legends = dashboard.
                PortfolioLines.
                Where(line => line.Name.StartsWith("PAR")).
                Select(line => GetString(line.Name)).
                ToArray();

            var colors = new[]
            {
                Color.FromArgb(234, 200, 28),
                Color.FromArgb(234, 160, 28),
                Color.FromArgb(234, 120, 28),
                Color.FromArgb(234, 80, 28),
                Color.FromArgb(234, 40, 28),
                Color.FromArgb(234, 0, 28),
            };

            var series = new Series();
            series.ChartType = SeriesChartType.Pie;
            for (var i = 0; i < 6; i++)
            {
                var value = Math.Round(0 == dashboard.Par ? 0 : 100 * values[i] / dashboard.Par, 1);
                var point = series.Points.Add(Convert.ToDouble(value));
                var numberFormat = Math.Round(value) == value ? "N0" : "N1";
                point.LegendText = string.Format("{0}: {1}%", legends[i], value.ToString(numberFormat));
                point.Color = colors[i];
            }

            AddLegend(_parChart);
            AddTitle(_parChart, GetString("PAR"));

            _parChart.Series.Add(series);
            _parChart.Location = new Point(0, 0);
            _parChart.Dock = DockStyle.Fill;

            parPanel.Controls.Add(_parChart);
        }