Example #1
0
        private void cbDoanhThu_Nam_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridDoanhThu.Rows.Add();
            int nam = int.Parse(cbDoanhThu_Nam.Text);

            chartDoanhThuTheoThang.Series.Clear();
            double TongTien = 0.0;
            Series series   = new Series
            {
                Name = "series2",
                IsVisibleInLegend = false,
                ChartType         = SeriesChartType.Column
            };

            chartDoanhThuTheoThang.Series.Add(series);
            for (int i = 1; i <= 12; i++)
            {
                double tien = thongKeBLL.LayDoanhThuTheoThang(i, nam);
                TongTien += tien;
                series.Points.Add(tien);
                var p1 = series.Points[i - 1];
                p1.AxisLabel  = "Tháng " + i;
                p1.LegendText = "Tháng " + i;
                if (tien > 0)
                {
                    p1.Label = string.Format("{0:#,###0}", tien);
                }
                dataGridDoanhThu.Columns[i].DefaultCellStyle.Format = "N2";
                dataGridDoanhThu.Rows[0].Cells[i].Value             = tien;
            }
            dataGridDoanhThu.Columns[0].DefaultCellStyle.Format = "N2";
            dataGridDoanhThu.Rows[0].Cells[0].Value             = TongTien;
        }