private void button1_Click(object sender, EventArgs e) { long tongtienthu = 0, tongtienchi = 0; int flag = 0; if (Convert.ToDateTime(dateTungay.Text) > Convert.ToDateTime(dateDenngay.Text)) { flag = 1; } if (flag == 0) { List <DSCT> tienthu = DALThongKeDoanhThu.ListSachthu(Convert.ToDateTime(dateTungay.Text), Convert.ToDateTime(dateDenngay.Text)); GVthu.DataSource = tienthu; List <DSCT> tienchi = DALThongKeDoanhThu.ListSachChi(Convert.ToDateTime(dateTungay.Text), Convert.ToDateTime(dateDenngay.Text)); GVchi.DataSource = tienchi; foreach (var i in tienthu) { tongtienthu = tongtienthu + i.Tienthu; } foreach (var i in tienchi) { tongtienchi = tongtienchi + i.Tienchi; } txtTienchi.Text = tongtienchi.ToString(); txtTienthu.Text = tongtienthu.ToString(); txtdoanhthu.Text = (tongtienthu - tongtienchi).ToString(); } else { MessageBox.Show("Ngày bắt đầu phải nhỏ hơn ngày kết thúc"); } }
public string VietBaoCao() { ReportDocument rd = new ReportDocument(); if (Loaibaocao == "Thống kê chi") { string path = Directory.GetCurrentDirectory() + @"\Thống kê chi"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { rd.Load(Directory.GetCurrentDirectory() + @"\CrystalReportThongKeDoanhThu.rpt"); rd.SetDataSource(DALThongKeDoanhThu.ListSachChi(Tungay, Denngay)); path = path + @"\" + Mota + ".pdf"; rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); return(path); } catch { return(path = ""); } } else { string path = Directory.GetCurrentDirectory() + @"\Thống kê thu"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { rd.Load(Directory.GetCurrentDirectory() + @"\REPORT\CrystalReportThongKeThu.rpt"); rd.SetDataSource(DALThongKeDoanhThu.ListSachthu(Tungay, Denngay)); path = path + @"\" + Mota + ".pdf"; rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); return(path); } catch { return(path = ""); } } }