Esempio n. 1
0
 private void btnDrucken_Click(object sender, EventArgs e)
 {
     if (isBestellung)
     {
         loadKundendaten(FindKunde(index));
         RecieptPrint obj            = new RecieptPrint(listView1.Items.Count);
         string[]     Artikel_Nummer = new string[listView1.Items.Count];
         string[]     Artikel_Text   = new string[listView1.Items.Count];
         double[]     Artikel_Preis  = new double[listView1.Items.Count];
         int[]        Artikel_Anzahl = new int[listView1.Items.Count];
         for (int i = 0; i < listView1.Items.Count; i++)
         {///MMMMMMMM
             if (listView1.Items[i].SubItems[0].Text == "+" || listView1.Items[i].SubItems[0].Text == "-")
             {
                 Artikel_Nummer[i] = "";
                 Artikel_Text[i]   = listView1.Items[i].SubItems[0].Text + " " + listView1.Items[i].SubItems[1].Text;
                 Artikel_Preis[i]  = Convert.ToDouble(listView1.Items[i].SubItems[4].Text);
                 Artikel_Anzahl[i] = Convert.ToInt32(listView1.Items[i].SubItems[3].Text);
             }
             else
             {
                 // add artikle to printReciept obj
                 Artikel_Nummer[i] = listView1.Items[i].SubItems[0].Text;
                 Artikel_Text[i]   = listView1.Items[i].SubItems[1].Text;
                 Artikel_Preis[i]  = Convert.ToDouble(listView1.Items[i].SubItems[4].Text);
                 Artikel_Anzahl[i] = Convert.ToInt32(listView1.Items[i].SubItems[3].Text);
             }
             obj.Artikel_Nummer = Artikel_Nummer;
             obj.Artikel_Text   = Artikel_Text;
             obj.Artikel_Preis  = Artikel_Preis;
             obj.Artikel_Anzahl = Artikel_Anzahl;
             if (Artikel_Nummer[0].Substring(0, 1) == "5" || Artikel_Nummer[0].Substring(0, 1) == "6" || Artikel_Nummer[0].Substring(0, 1) == "7" || Artikel_Nummer[0].Substring(0, 1) == "8" || Artikel_Nummer[0].Substring(0, 1) == "9")
             {
                 obj.Title_Text           = Globals.TITLE_NAME;
                 obj.Addresse_Text_Line1  = Globals.LINE1_ADDRESS;
                 obj.Addresse_Text_Line2  = Globals.LINE2_TELE;
                 obj.Addresse_Text_Line3  = Globals.LINE3_TELE2;
                 obj.Oeffenung_Text_Line1 = Globals.LINE4_OPENTIME;
             }
             else
             {
                 obj.Title_Text           = Globals.TITLE_NAME;
                 obj.Addresse_Text_Line1  = Globals.LINE1_ADDRESS;
                 obj.Addresse_Text_Line2  = Globals.LINE2_TELE;
                 obj.Addresse_Text_Line3  = Globals.LINE3_TELE2;
                 obj.Oeffenung_Text_Line1 = Globals.LINE4_OPENTIME;
             }
             obj.Bestellung_Text     = "Bestellung " + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString();
             obj.KundenName_Text     = KundenName;
             obj.KundenNr_Text       = KundenTelefone;
             obj.KundenAddresse_Text = KundenAddresse + " " + KundenPLZ + " " + KundenOrt;
             obj.Hinweise_Text       = KundenHinweis;
             obj.MwSt7          = 0; //TotalMwst7;
             obj.MwSt19         = 0; // TotalMwst19;
             obj.Rabatt         = Rabbatt;
             obj.Anfahrt_Kosten = AnfahrtKosten;
             obj.Gesamt_Betrag  = Convert.ToDouble(textBox1.Text);
             obj.Print();
         }
     }
     else
     {
         listView1.Print();
     }
 }
Esempio n. 2
0
        private void btnDrucken_Click(object sender, EventArgs e)
        {
            RecieptPrint obj = new RecieptPrint(lvBestellDetail.Items.Count);

            string[] Artikel_Nummer = new string[lvBestellDetail.Items.Count];
            string[] Artikel_Text   = new string[lvBestellDetail.Items.Count];
            double[] Artikel_Preis  = new double[lvBestellDetail.Items.Count];
            int[]    Artikel_Anzahl = new int[lvBestellDetail.Items.Count];
            for (int i = 0; i < lvBestellDetail.Items.Count; i++)
            {
                if (lvBestellDetail.Items[i].SubItems[0].Text == "+" || lvBestellDetail.Items[i].SubItems[0].Text == "-")
                {
                    Artikel_Nummer[i] = "";
                    Artikel_Text[i]   = lvBestellDetail.Items[i].SubItems[0].Text + " " + lvBestellDetail.Items[i].SubItems[1].Text;
                    Artikel_Preis[i]  = Convert.ToDouble(lvBestellDetail.Items[i].SubItems[3].Text);
                    Artikel_Anzahl[i] = Convert.ToInt32(lvBestellDetail.Items[i].SubItems[2].Text);
                }
                else
                {
                    // add artikle to printReciept obj
                    Artikel_Nummer[i] = lvBestellDetail.Items[i].SubItems[0].Text;
                    Artikel_Text[i]   = lvBestellDetail.Items[i].SubItems[1].Text;
                    Artikel_Preis[i]  = Convert.ToDouble(lvBestellDetail.Items[i].SubItems[3].Text);
                    Artikel_Anzahl[i] = Convert.ToInt32(lvBestellDetail.Items[i].SubItems[2].Text);
                }
            }
            obj.Artikel_Nummer = Artikel_Nummer;
            obj.Artikel_Text   = Artikel_Text;
            obj.Artikel_Preis  = Artikel_Preis;
            obj.Artikel_Anzahl = Artikel_Anzahl;
            bool isGrillPfane = checkArtikel(Artikel_Nummer[0]);

            if (isGrillPfane)
            {
                obj.Title_Text           = Globals.TITLE_NAME;
                obj.Addresse_Text_Line1  = Globals.LINE1_ADDRESS;
                obj.Addresse_Text_Line2  = Globals.LINE2_TELE;
                obj.Addresse_Text_Line3  = Globals.LINE3_TELE2;
                obj.Oeffenung_Text_Line1 = Globals.LINE4_OPENTIME;
            }
            else
            {
                obj.Title_Text           = Globals.TITLE_NAME;
                obj.Addresse_Text_Line1  = Globals.LINE1_ADDRESS;
                obj.Addresse_Text_Line2  = Globals.LINE2_TELE;
                obj.Addresse_Text_Line3  = Globals.LINE3_TELE2;
                obj.Oeffenung_Text_Line1 = Globals.LINE4_OPENTIME;
            }

            obj.Bestellung_Text     = "Bestellung - " + BestellNr + " - " + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString();
            obj.KundenName_Text     = KundenName;
            obj.idkunde             = kundenreference.ToString();
            obj.KundenNr_Text       = KundenTelefone;
            obj.KundenAddresse_Text = KundenAddresse + " " + KundenPLZ + " " + KundenOrt;
            obj.Hinweise_Text       = KundenHinweis;
            obj.MwSt7          = TotalMwst7;
            obj.MwSt19         = TotalMwst19;
            obj.Rabatt         = Rabbatt;
            obj.Anfahrt_Kosten = AnfahrtKosten;
            obj.Gesamt_Betrag  = Convert.ToDouble(tbGesamt.Text);
            // paper sizes
            int a5index = 0;

            System.Drawing.Printing.PaperSize pkSize;
            for (int k = 0; k < obj.PrinterSettings.PaperSizes.Count; k++)
            {
                pkSize = obj.PrinterSettings.PaperSizes[k];
                if (pkSize.PaperName.ToString() == "A5")
                {
                    a5index = k;
                }
            }
            if (obj.PrinterSettings.PaperSizes[a5index].PaperName == "A5")
            {
                obj.DefaultPageSettings.PaperSize = obj.PrinterSettings.PaperSizes[a5index];
            }
            try
            {
                obj.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Es ist ein Fehler beim Drücken Aufgetreten \n" + ex.Message);
            }
        }