private void BtVietBaoCao_Click(object sender, EventArgs e) { labelmota.Show(); txtMoTa.Show(); if (txtMoTa.Text == "") { MessageBox.Show("Mời nhập mô tả cho file"); } else { BUSThongKeTonKho thongke = new BUSThongKeTonKho(); thongke.Mota = txtMoTa.Text; thongke.Tungay = DALThongKeTonKho.layngaydau().Ngaynhap; thongke.Denngay = Convert.ToDateTime(dateTimePicker2.Text); string path = thongke.VietBaoCao(); if (path != "") { MessageBox.Show("Lưu báo cáo thành công"); DialogResult result = MessageBox.Show("Có muốn xem báo cáo vừa ghi ?", "Xem báo cáo", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { ProcessStartInfo ps = new ProcessStartInfo(); ps.FileName = Path.GetFileName(path); ps.WorkingDirectory = Path.GetDirectoryName(path); Process.Start(ps); } } else { MessageBox.Show("Đã tồn tại file, mời nhập lại mô tả"); } } }
public string VietBaoCao() { ReportDocument rd = new ReportDocument(); string path = Directory.GetCurrentDirectory() + @"\Thống kê tồn kho"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { rd.Load(Directory.GetCurrentDirectory() + @"\REPORT\CrystalReportThongKeTonKho.rpt"); rd.SetDataSource(DALThongKeTonKho.ThongKe(Tungay, Denngay)); path = path + @"\" + Mota + ".pdf"; rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); return(path); } catch { return(path = ""); } }
private void BtXemtonkho_Click(object sender, EventArgs e) { GVthongke.DataSource = DALThongKeTonKho.ThongKe(DALThongKeTonKho.layngaydau().Ngaynhap, Convert.ToDateTime(dateTimePicker2.Text)); }