Example #1
0
        private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            Logger.Debug("printDocument_PrintPage()");

            var kbTableAdapter = new Data.FestManagerDataSetTableAdapters.KassenbonTableAdapter();
            var kbTable        = new FestManagerDataSet.KassenbonDataTable();

            try {
                if (_printAll)
                {
                    kbTableAdapter.FillByBestellung(kbTable, _bestellungRow.BestellungId);
                }
                else
                {
                    kbTableAdapter.FillByBestellungAndAusgabestelle(kbTable, _bestellungRow.BestellungId, _ausgabestelle);
                }
                if (kbTable.Rows.Count > 0)
                {
                    var kb = new Kassenbon(Settings, e.Graphics, kbTable);
                    // Important for Kassa-Prints:
                    kb.Draw(_printAll);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MessageBox.Show(Resources.Database_Error_Message_Pfx + ex.Message,
                                Resources.Database_Error_Message_Title, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void PrintKassabon(FestManagerDataSet.AusgabestelleRow row)
        {
            Logger.Debug("PrintKassabon()");

            try
            {
                var kbTableAdapter = new Data.FestManagerDataSetTableAdapters.KassenbonTableAdapter();
                var kbTable        = new FestManagerDataSet.KassenbonDataTable();

                if (_bestellungRow.BestellungId == 0)
                {
                    MessageBox.Show(Resources.FormBestellung_PrintKassabon_Critical_error_restart_application,
                                    Resources.Critical_Error,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                if (_printAll)
                {
                    kbTableAdapter.FillByBestellung(kbTable, _bestellungRow.BestellungId);
                }
                else
                {
                    _ausgabestelle = row.AusgabestelleId;
                    kbTableAdapter.FillByBestellungAndAusgabestelle(kbTable, _bestellungRow.BestellungId, _ausgabestelle);
                }

                if (kbTable.Rows.Count > 0)
                {
                    var print = true;
                    if (!Settings.PrintStornoOrders)
                    {
                        print = false;
                        for (var i = 0; i < kbTable.Rows.Count; i++)
                        {
                            var kbRow = (FestManagerDataSet.KassenbonRow)kbTable.Rows[i];
                            if (kbRow.Menge >= 0)
                            {
                                print = true;
                                break;
                            }
                        }
                    }

                    if (print)
                    {
                        printDocument.PrinterSettings.PrinterName = row.Drucker;

                        var result = DialogResult.Retry;
                        while (result == DialogResult.Retry)
                        {
                            try
                            {
                                printDocument.Print();
                                result = DialogResult.OK;
                            }
                            catch (InvalidPrinterException)
                            {
                                result = MessageBox.Show(
                                    Resources.Invalid_Printer,
                                    Resources.Invalid_Printer_Title,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                            }
                            catch (Exception ex)
                            {
                                result =
                                    MessageBox.Show(
                                        ex.Message,
                                        Resources.FormBestellung_PrintKassabon_Printing_error,
                                        MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MessageBox.Show(Resources.Database_Error_Message_Pfx + ex.Message,
                                Resources.Database_Error_Message_Title, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }