Пример #1
0
 private void PrintDoc_Elements(System.Drawing.Printing.PrintPageEventArgs e)
 {
     GC.Collect();
     //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΤΙΜΟΛΟΓΙΟΥ
     e.Graphics.DrawString(DocName, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 130 + (SelectNameCmb.SelectedIndex == 4 ? 30 : (SelectNameCmb.SelectedIndex == 2 ? 10 : (SelectNameCmb.SelectedIndex == 1 ? 63 : (SelectNameCmb.SelectedIndex == 5 ? 63 :0)))), 250);
     e.Graphics.DrawString(DocSeries, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 588, 250);
     e.Graphics.DrawString(DocIdId, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 690, 250);
     e.Graphics.DrawString(Convert.ToDateTime(DocDate).Day.ToString() + '/' + Convert.ToDateTime(DocDate).Month.ToString() + '/' + Convert.ToDateTime(DocDate).Year.ToString(), new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 821, 250);
     //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΠΕΛΑΤΗ
     e.Graphics.DrawString(CustomerId, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170 + (SelectNameCmb.SelectedIndex == 4 ? 50 : 0), 329);
     e.Graphics.DrawString(CustomerName, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 356);
     e.Graphics.DrawString(CustomerAddress, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 383);
     e.Graphics.DrawString(CustomerRegion, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 410);
     e.Graphics.DrawString(CustomerOccupation, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 438);
     e.Graphics.DrawString(CustomerAfm, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 466);
     e.Graphics.DrawString(CustomerEmail, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 493);
     e.Graphics.DrawString(CustomerPhone.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 329);
     e.Graphics.DrawString(CustomerPhone2.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 356);
     e.Graphics.DrawString(CustomerTk, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 411);
     e.Graphics.DrawString(CustomerTax_office, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 466);
     if (SelectNameCmb.SelectedIndex == 0 || SelectNameCmb.SelectedIndex == 1 || SelectNameCmb.SelectedIndex == 2 || SelectNameCmb.SelectedIndex == 5)
     {
         //ΕΚΤΥΠΩΣΗ ΛΟΙΠΩΝ ΣΤΟΙΧΕΙΩΝ ΤΙΜΟΛΟΓΙΟΥ
         e.Graphics.DrawString(DocDisNotes, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 307);   //SXET PARASTATIKA
         e.Graphics.DrawString(DocFrom, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 336);
         e.Graphics.DrawString(DocTo, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 365);
         e.Graphics.DrawString(DocReason, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 394);
         e.Graphics.DrawString(DocPayment, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 423);
         e.Graphics.DrawString((DocDisc == "" ?"" : chk.GrNumber(DocDisc) + " %"), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 452);
         //e.Graphics.DrawString(CustomerTax_office, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 804, 487);  METAFORIKO MESO
         //ΕΚΤΥΠΩΣΗ ΠΡΟΙΟΝΤΩΝ
         int     rest         = proditems;
         int     cnt          = DocProds.Rows.Count - proditems;
         bool    hasmorepages = false;
         decimal vat          = chk.Return_Vat(CustomerId);
         for (int i = 1; i <= rest; i++)
         {
             if (i == 19)
             {
                 hasmorepages = true;
                 break;
             }
             string qnt  = DocProds.Rows[i - 1 + cnt][2].ToString();
             string val  = DocProds.Rows[i - 1 + cnt][3].ToString();
             string disc = DocProds.Rows[i - 1 + cnt][4].ToString();
             if (val != "")
             {
                 decimal totval  = Convert.ToDecimal(Math.Round(Convert.ToDouble(qnt) * Convert.ToDouble(val), 2));
                 decimal totdisc = Convert.ToDecimal(Math.Round(totval * Convert.ToDecimal(((disc == "") ? "0" : disc)) / 100, 2));
                 totdisc += Convert.ToDecimal(Math.Round((totval - totdisc) * Convert.ToDecimal(DocDisc) / 100, 2));
                 decimal totdiscval = totval - totdisc;
                 decimal totvat     = Convert.ToDecimal(Math.Round(totdiscval * vat / 100, 2));
                 e.Graphics.DrawString(chk.GrNumber(val), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(632, 558 + i * 25, 58, 25), format);
                 e.Graphics.DrawString(chk.GrNumber((totval).ToString()), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(696, 558 + i * 25, 72, 25), format);
                 e.Graphics.DrawString(((disc == "0") ? "" : chk.GrNumber(disc.ToString())), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(780, 558 + i * 25, 60, 25), format);
                 e.Graphics.DrawString(((totdisc == 0) ? "" : chk.GrNumber(totdisc.ToString())), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(847, 558 + i * 25, 55, 25), format);
                 e.Graphics.DrawString(chk.GrNumber((totdiscval).ToString()), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(908, 558 + i * 25, 63, 25), format);
                 e.Graphics.DrawString((vat).ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(976, 558 + i * 25, 24, 25), format);
                 e.Graphics.DrawString(chk.GrNumber((totvat).ToString()), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(1006, 558 + i * 25, 52, 25), format);
                 sumval  += Convert.ToDecimal(totval);
                 sumdisc += Convert.ToDecimal(totdisc);
                 sumvat  += Convert.ToDecimal(totvat);
             }
             string descr = DocProds.Rows[i - 1 + cnt][1].ToString();
             string Unit  = DocProds.Rows[i - 1 + cnt][5].ToString();
             if (descr.Length > 60)
             {
                 descr = descr.Substring(0, 60);
             }
             if (Unit.Length > 4)
             {
                 Unit = Unit.Substring(0, 4);
             }
             e.Graphics.DrawString(DocProds.Rows[i - 1 + cnt][0].ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 33, 558 + i * 25);
             e.Graphics.DrawString(descr, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 120, 558 + i * 25);
             e.Graphics.DrawString(Unit, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 520, 558 + i * 25);
             e.Graphics.DrawString(chk.GrQuant(qnt), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(561, 558 + i * 25, 65, 25), format);
             proditems--;
             sumquant += Convert.ToDouble(qnt);
         }
         //e.Graphics.DrawString(PrevCreditCustomerTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 145, 1052);
         //ΕΚΤΥΠΩΣΗ ΑΡΙΘΜΙΣΗΣ ΣΕΛΙΔΩΝ ΤΙΜΟΛΟΓΙΟΥ
         e.Graphics.DrawString("Σελίδα " + pagecount + " από " + (DocProds.Rows.Count / 18 + 1), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 45, 1505);
         pagecount++;
         //ΕΚΤΥΠΩΣΗ ΣΥΝΟΛΩΝ ΤΙΜΟΛΟΓΙΟΥ
         if (hasmorepages == false)
         {
             e.Graphics.DrawString(chk.GrQuant(sumquant.ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 645, 1052);
             e.Graphics.DrawString(chk.GrNumber(sumval.ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(924, 1059, 120, 25), format);
             e.Graphics.DrawString(chk.GrNumber(sumdisc.ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(924, 1105, 120, 25), format);
             e.Graphics.DrawString(chk.GrNumber((sumval - sumdisc).ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(924, 1151, 120, 25), format);
             e.Graphics.DrawString(chk.GrNumber(sumvat.ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(924, 1197, 120, 25), format);
             e.Graphics.DrawString(chk.GrNumber((sumval - sumdisc + sumvat).ToString()), new Font("Arial", 12, System.Drawing.FontStyle.Bold), Brushes.Black, new Rectangle(924, 1273, 120, 25), format);
             //e.Graphics.DrawString((Convert.ToDecimal(PrevCreditCustomerTxt.Text) + (PayInvoiceCmb.GetItemText(PayInvoiceCmb.SelectedItem) == "Πίστωση" ? sumval - sumdisc + sumvat : 0)).ToString(), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 391, 1052);
             proditems = DocProds.Rows.Count;
             sumquant  = 0;
             sumval    = 0;
             sumdisc   = 0;
             sumvat    = 0;
             pagecount = 1;
             GC.Collect();
         }
         e.HasMorePages = hasmorepages;
     }
     else if (SelectNameCmb.SelectedIndex == 3 || SelectNameCmb.SelectedIndex == 4)
     {
         //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΑΠΟΔΕΙΞΗΣ
         for (int i = 1; i <= proditems; i++)
         {
             e.Graphics.DrawString(DocProds.Rows[i - 1][0].ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 110, 560 + i * 25);
             e.Graphics.DrawString(Convert.ToDateTime(DocProds.Rows[i - 1][1].ToString()).Day.ToString() + '/' + Convert.ToDateTime(DocProds.Rows[i - 1][1].ToString()).Month.ToString() + '/' + Convert.ToDateTime(DocProds.Rows[i - 1][1].ToString()).Year.ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 375, 560 + i * 25);
             e.Graphics.DrawString(chk.GrNumber(DocProds.Rows[i - 1][2].ToString()), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(585, 560 + i * 25, 100, 25), format);
             e.Graphics.DrawString(DocProds.Rows[i - 1][3].ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 725, 560 + i * 25);
         }
         e.Graphics.DrawString(chk.GrNumber(ReceiptCash), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1105, 100, 25), format);
         e.Graphics.DrawString(chk.GrNumber(DocPrice), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1178, 100, 25), format);
         string fullname1 = "";
         string fullname2 = "";
         if (DocPrice != "")
         {
             try
             {
                 int     decim = 0;
                 decimal price = decimal.Parse(DocPrice);
                 if (price != Math.Truncate(price))
                 {
                     decim = (int)((price - Math.Truncate(price)) * 100);
                 }
                 fullname1 = chk.Number_fullname(Convert.ToInt32(Math.Truncate(price))) + " ευρώ";
                 fullname2 = (decim == 0 ? "" : " και " + chk.Number_fullname(decim) + " λεπτά");
             }
             catch (Exception)
             {
             }
         }
         e.Graphics.DrawString(fullname1, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1080);
         e.Graphics.DrawString(fullname2, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1108);
     }
 }
Пример #2
0
        private void PreviewDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            GC.Collect();
            e.Graphics.DrawImage(RecDrawImg, 0, 0, 1094, 1546);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΑΠΟΔΕΙΞΗΣ
            e.Graphics.DrawString("Απόδειξη Είσπραξης Μετρητών", new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 130, 250);
            e.Graphics.DrawString(SeriesReceiptTxt.Text, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 588, 250);
            e.Graphics.DrawString(IdReceiptTxt.Text, new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 690, 250);
            e.Graphics.DrawString(DateTimeReceiptPicker.Value.Day.ToString() + '/' + DateTimeReceiptPicker.Value.Month.ToString() + '/' + DateTimeReceiptPicker.Value.Year.ToString(), new Font("Arial", 14, System.Drawing.FontStyle.Regular), Brushes.Black, 821, 250);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΠΕΛΑΤΗ
            e.Graphics.DrawString(IdCustomerTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 329);
            e.Graphics.DrawString(NameCustomerTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 356);
            e.Graphics.DrawString(CustomerAddress, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 383);
            e.Graphics.DrawString(CustomerRegion, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 410);
            e.Graphics.DrawString(CustomerOccupation, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 438);
            e.Graphics.DrawString(AfmCustomerTxt.Text, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 466);
            e.Graphics.DrawString(CustomerEmail, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 170, 493);
            e.Graphics.DrawString(CustomerPhone.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 329);
            e.Graphics.DrawString(CustomerPhone2.Substring(0, 10), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 356);
            e.Graphics.DrawString(CustomerTk, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 411);
            e.Graphics.DrawString(CustomerTax_office, new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, 460, 466);
            //ΕΚΤΥΠΩΣΗ ΣΤΟΙΧΕΙΩΝ ΑΠΟΔΕΙΞΗΣ
            DateTime dt;

            for (int i = 1; i <= Convert.ToInt16(ValueDocItemsTxt.Text); i++)
            {
                if (ProductsPanel.Controls.Find("ValueDocIdTxt" + i, true).First().Text != "" && ProductsPanel.Controls.Find("ValueDocIssuerTxt" + i, true).First().Text != "")
                {
                    if (ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text != "" && ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text != "0")
                    {
                        dt = ((DateTimePicker)ProductsPanel.Controls.Find("ValueDocDatePkr" + i, true).First()).Value;
                        e.Graphics.DrawString(ProductsPanel.Controls.Find("ValueDocIdTxt" + i, true).First().Text, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 110, 560 + i * 25);
                        e.Graphics.DrawString(dt.Day.ToString() + '/' + dt.Month.ToString() + '/' + dt.Year.ToString(), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 375, 560 + i * 25);
                        e.Graphics.DrawString(chk.GrNumber(ProductsPanel.Controls.Find("ValueDocPriceTxt" + i, true).First().Text), new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(585, 560 + i * 25, 100, 25), format);
                        e.Graphics.DrawString(ProductsPanel.Controls.Find("ValueDocIssuerTxt" + i, true).First().Text, new Font("Arial", 10, System.Drawing.FontStyle.Regular), Brushes.Black, 725, 560 + i * 25);
                    }
                }
            }
            //ΕΚΤΥΠΩΣΗ ΣΥΝΟΛΩΝ ΑΠΟΔΕΙΞΗΣ
            e.Graphics.DrawString(chk.GrNumber(CashTxt.Text), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1105, 100, 25), format);
            e.Graphics.DrawString(chk.GrNumber(PriceReceiptTxt.Text), new Font("Arial", 12, System.Drawing.FontStyle.Regular), Brushes.Black, new Rectangle(828, 1178, 100, 25), format);
            string fullname1 = "";
            string fullname2 = "";

            if (PriceReceiptTxt.Text != "")
            {
                try
                {
                    int     decim = 0;
                    decimal price = decimal.Parse(PriceReceiptTxt.Text);
                    if (price != Math.Truncate(price))
                    {
                        decim = (int)((price - Math.Truncate(price)) * 100);
                    }
                    fullname1 = chk.Number_fullname(Convert.ToInt32(Math.Truncate(price))) + " ευρώ";
                    fullname2 = (decim == 0 ? "" : " και " + chk.Number_fullname(decim) + " λεπτά");
                }
                catch (Exception)
                {
                }
            }
            if (NotesTxt.Text != "")
            {
                string Note1 = NotesTxt.Text;
                string Note2 = "";
                if (Note1.Length > 70)
                {
                    Note2 = Note1.Substring(70);
                    Note1 = Note1.Substring(0, 70);
                    if (Note2.Length > 70)
                    {
                        Note2 = Note2.Substring(0, 70);
                    }
                }
                e.Graphics.DrawString(Note1, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 39, 1180);
                e.Graphics.DrawString(Note2, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 39, 1205);
            }
            e.Graphics.DrawString(fullname1, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1080);
            e.Graphics.DrawString(fullname2, new Font("Arial", 11, System.Drawing.FontStyle.Italic), Brushes.Black, 43, 1108);
        }