private void btnPrint_Click(object sender, EventArgs e) { InvoicePrintItem report = new InvoicePrintItem(); List <InvoiceViewModel> _dataSource = new List <InvoiceViewModel>(); _dataSource.Add(SelectedInvoice); report.DataSource = _dataSource; report.FillDataSource(); using (ReportPrintTool printTool = new ReportPrintTool(report)) { // Invoke the Print dialog. printTool.PrintDialog(); } _presenter.Print(); this.Close(); }
private void btnPrintAll_Click(object sender, EventArgs e) { if (bgwMain.IsBusy || bgwExport.IsBusy) { return; } if (InvoiceListData == null || InvoiceListData.Count == 0) { return; } if (InvoiceListData.Where(x => x.Status == (int)DbConstant.InvoiceStatus.FeeNotFixed).Count() > 0) { this.ShowWarning("terdapat data yang belum dilengkapi dengan fee dalam grid, tidak bisa cetak semua"); } else { if (this.ShowConfirmation("Apakah anda yakin ingin mencetak semua data yang tampil pada daftar?") == DialogResult.Yes) { List <InvoiceViewModel> dsReport = InvoiceListData; if (dsReport != null && dsReport.Count > 0) { foreach (var itemReport in dsReport) { itemReport.ListInvoiceSparepart = _presenter.GetSparepartInvoice(itemReport.Id); } InvoicePrintItem report = new InvoicePrintItem(); report.DataSource = dsReport; report.FillDataSource(); using (ReportPrintTool printTool = new ReportPrintTool(report)) { // Invoke the Print dialog. printTool.PrintDialog(); } _presenter.PrintAll(); btnSearch.PerformClick(); } } } }