Пример #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);
            }
        }
        private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            var kbTableAdapter = new Data.FestManagerDataSetTableAdapters.KassenbonTableAdapter();
            var kbTable        = new Data.FestManagerDataSet.KassenbonDataTable();

            kbTableAdapter.FillByBestellung(kbTable, _actualBestellungId);
            if (kbTable.Rows.Count > 0)
            {
                var kb = new Kassenbon(Settings, e.Graphics, kbTable);
                // Important for Kassa-Prints:
                kb.Draw(true);
            }
        }
        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);
            }
        }
Пример #4
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);
            }
        }