// Kết thúc Khu vực Tổng quát // ---------------------------------------------- // Bắt đầu khu vực Chi phí private void ChiPhi() { Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0:#,##0đ} ({1:P})", chartPoint.Y, chartPoint.Participation); chartChiPhi.Series = new SeriesCollection { }; //for (int i = 1; i <= 12; i++) //{ // double value = PhieuNhapBUS.LayDoanhSoPhieuNhapTheoThang(i); // if (value != 0) // { // PieSeries pieSeries = new PieSeries(); // pieSeries.Title = "Tháng " + i; // pieSeries.Values = new ChartValues<double> { value }; // pieSeries.DataLabels = true; // pieSeries.LabelPoint = labelPoint; // pieSeries.PushOut = 5; // if (i == DateTime.Now.Month) // { // pieSeries.PushOut = 15; // } // chartChiPhi.Series.Add(pieSeries); // } //} List <ChiPhiDTO> lsChiPhi = PhieuNhapBUS.LayChiPhiPhieuNhap(); for (int i = 0; i < lsChiPhi.Count; i++) { PieSeries pieSeries = new PieSeries(); pieSeries.Title = "Tháng " + lsChiPhi[i].Thang; pieSeries.Values = new ChartValues <double> { lsChiPhi[i].ChiPhi }; pieSeries.DataLabels = true; pieSeries.LabelPoint = labelPoint; if (i == DateTime.Now.Month) { pieSeries.PushOut = 15; } else { pieSeries.PushOut = 5; } chartChiPhi.Series.Add(pieSeries); } if (chartChiPhi.Series.Count == 0) { MetroLabel lblThongBao = new MetroLabel(); lblThongBao.Text = "Không có dữ liệu thống kê"; lblThongBao.FontSize = MetroFramework.MetroLabelSize.Tall; lblThongBao.TextAlign = ContentAlignment.MiddleCenter; lblThongBao.Dock = DockStyle.Fill; panelChiPhi.Controls.Add(lblThongBao); lblThongBao.BringToFront(); } chartChiPhi.LegendLocation = LegendLocation.Right; lblCP_MoTa.Text += DateTime.Now.Year + ""; lblCP_TongChiPhi.Text += PhieuNhapBUS.LayDoanhSoPhieuNhapTheoNam(DateTime.Now.Year).ToString("#,##0đ"); }