private void printInvoiceButton_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; Dictionary <string, object> parameters = new Dictionary <string, object>(10); if (!setReportParameters(parameters)) { return; } BillItemsDataSet dataset; if (!getReportDataSet(out dataset)) { return; } BillReportView form = new BillReportView(dataset, parameters); form.MdiParent = this.MdiParent; try { form.ShowReport(); } catch (Exception ex) { Cursor.Current = Cursors.Default; SystemSounds.Exclamation.Play(); string message = "An error occurred in printing the bill." + "\nThe error text is as follows:\n" + Global.getExceptionText(ex); MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error); ErrorLogger.LogError(ex); } Cursor.Current = Cursors.Default; }
private void printBill(int billID) { BillItemsDataSet dataset = getPrintDataSet(); Dictionary <string, object> parameters = getReportParameters(billID); BillReportView form = new BillReportView(dataset, parameters); form.MdiParent = this.MdiParent; try { form.ShowReport(); } catch (Exception ex) { SystemSounds.Hand.Play(); Cursor.Current = Cursors.Default; string message = "An error occurred in showing the Print Preview of the bill." + "\nThe error text is as follows:\n" + Global.getExceptionText(ex); MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Hand); ErrorLogger.LogError(ex); } }