private void PrintBestellung(bool secondPrint = false) { Logger.Debug("PrintBestellung()"); var ausgabestellen = new Data.FestManagerDataSetTableAdapters.AusgabestelleTableAdapter(); var ausgabe = ausgabestellen.GetData(); printDocument.PrinterSettings = new PrinterSettings { Copies = 1 }; printDocument.PrintController = new StandardPrintController(); if (_bestellungRow.BestellungId == 0) { MessageBox.Show(Resources.FormBestellung_PrintKassabon_Critical_error_restart_application, Resources.Critical_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!secondPrint) { for (var i = 0; i < ausgabe.Rows.Count; i++) { var row = (FestManagerDataSet.AusgabestelleRow)ausgabe.Rows[i]; PrintKassabon(row); } } if ((Settings.PrintDirektverkaufTwice && (int)personalIdComboBox.SelectedValue == Settings.DirektverkaufPersonalId) || Settings.PrintTwice || secondPrint) { _printAll = true; ausgabestellen = new Data.FestManagerDataSetTableAdapters.AusgabestelleTableAdapter(); ausgabe = ausgabestellen.GetKassaData(); if (ausgabe.Count > 0) { printDocument.PrinterSettings = new PrinterSettings { Copies = 1 }; var row = (FestManagerDataSet.AusgabestelleRow)ausgabe.Rows[0]; PrintKassabon(row); } else { MessageBox.Show(Resources.FormBestellung_PrintBestellung_Error_no_POS_printer_configured, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void buttonPrintBestellung_Click(object sender, EventArgs e) { try { if (_actualBestellungId > 0) { var ausgabestellen = new Data.FestManagerDataSetTableAdapters.AusgabestelleTableAdapter(); var ausgabe = ausgabestellen.GetKassaData(); if (ausgabe.Count > 0) { printDocument.PrinterSettings = new System.Drawing.Printing.PrinterSettings { Copies = 1 }; var row = (Data.FestManagerDataSet.AusgabestelleRow)ausgabe.Rows[0]; //int ausgabestelle = (int)row.AusgabestelleId; var kbTableAdapter = new Data.FestManagerDataSetTableAdapters.KassenbonTableAdapter(); var kbTable = new Data.FestManagerDataSet.KassenbonDataTable(); kbTableAdapter.FillByBestellung(kbTable, _actualBestellungId); if (kbTable.Rows.Count > 0) { printDocument.PrinterSettings.PrinterName = row.Drucker; var result = DialogResult.Retry; while (result == DialogResult.Retry) { try { printDocument.Print(); result = DialogResult.OK; } catch (InvalidAsynchronousStateException exc) { result = MessageBox.Show( Resources.FormBestellungenHistory_buttonPrintBestellung_Click_Printing_error + exc.Message, Resources.Error, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); } } } } else { MessageBox.Show( Resources.FormBestellungenHistory_buttonPrintBestellung_Click_Error_no_POS_printer); } } } catch (Exception ex) { MessageBox.Show(Resources.Database_Error_Message_Pfx + ex.Message, Resources.Database_Error_Message_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } }