Example #1
0
        public void PrintDepositReturnReceipt(string organization, Cart articles, User person)
        {
            if (profile == null)
                throw new Exception("Druck konnte nicht ausgeführt werden: Kein Profil angegeben.");
            
            ReceiptBuilder printedBy = new ReceiptBuilder();
            printedBy.Alignment = PrintAlignment.Center;
            printedBy.Font = FontType.B;
            printedBy.FeedLines(1);
            printedBy.Append("Gebucht auf " + person.Username);
            printedBy.Font = FontType.A;
            printedBy.Alignment = PrintAlignment.Right;
            printedBy.FeedLines(1);

            try
            {
                StringBuilder builder = new StringBuilder();

                builder.Append("\x1B\x40");
                builder.Append("\x1B\x61\x1");
                builder.Append("\x1B\x21\x0");
                builder.Append(organization);
                builder.Append("\x1B\x64\x1");
                builder.Append("\x1B\x21\x29");
                builder.Append(profile.Name + "\n\nPfandrückgabe\n\n"); // max 21 Zeichen!
                builder.Append("\n\xa");

                //Beginn Artikel
                foreach (ArticleCount ac in articles.Container)
                {
                    if (ac.Article.Deposit == Deposit.NullDeposit) 
                        continue;

                    builder.Append("\x1B\x21\x1");
                    builder.Append("\x1B\x61\x0"); //linksbündig
                    builder.Append("    " + ac.Count + "x " + string.Format("{0:0.00 EUR}", ac.Article.Deposit.Amount));
                    builder.Append("\x1B\x21\x0");
                    builder.Append("    " + ac.Article.Deposit.Name + "\xA");
                    builder.Append("\x1B\x61\x2"); //rechtsbündig
                    builder.Append(string.Format("{0:0.00 EUR}", ac.Article.Deposit.Amount * ac.Count) + "    ");
                    builder.Append("\x1B\x64\x1"); //drucken + LF 2x
                }

                //ende Artikel
                builder.Append("\x1B\x64\x1"); //drucken + LF 1x
                builder.Append("------------------------------------------");
                //Endsumme
                builder.Append("\x1B\x64\x1"); //drucken + LF 1x
                builder.Append("\x1B\x21\x29"); //Schriftgröße (Chr B, emph, d-width)
                builder.Append("SUMME         " + string.Format("{0:0.00 EUR}", articles.AmountWithDeposit - articles.Amount));
                //Ende Endsumme
                builder.Append("\x1B\x64\x2"); //drucken + LF 2x
                builder.Append(printedBy.ToString());
                builder.Append("\x1B\x61\x2"); //rechtsbündig
                builder.Append("\x1B\x21\x1"); //Schriftgröße (klein)
                builder.Append(DateTime.Now.ToShortDateString());
                builder.Append("\x1D\x56\x42");
                builder.Append("\x1B\x64\x05");     // line feed
                builder.Append("\x1D\x56\x1");      // partial cut


                Thread t = new Thread(delegate() { PrintThread(builder.ToString()); });
                t.Start();
            }
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
                throw new Exception("Drucker nicht erreichbar.");
            }
        }
Example #2
0
        public void PrintBons(string organization, Cart articles, User person)
        {
            if (profile == null)
                throw new Exception("Druck konnte nicht ausgeführt werden: Kein Profil angegeben.");

            ReceiptBuilder printedBy = new ReceiptBuilder();
            printedBy.Alignment = PrintAlignment.Center;
            printedBy.Font = FontType.B;
            printedBy.FeedLines(1);
            printedBy.Append("Ausgestellt von " + person.Username);
            printedBy.Font = FontType.A;
            printedBy.Alignment = PrintAlignment.Right;

            try
            {
                StringBuilder builder = new StringBuilder();

                ReadOnlyCollection<Article> ro = articles.ToSeperatedArticleCollection();
                foreach (Article art in ro)
                {
                    if (!art.DoPrint) continue;

                    builder.Append("\x1B\x40");
                    builder.Append("\x1B\x61\x1");
                    builder.Append("\x1B\x21\x0");
                    builder.Append(organization);
                    builder.Append("\x1B\x64\x1");
                    builder.Append("\x1B\x21\x29");
                    builder.Append(profile.Name + "\xA");  // max 21 Zeichen!
                    builder.Append("\xa");
                    builder.Append("\x1B\x21\x38");
                    builder.Append("\x1B\x2D\x2");
                    builder.Append(art.Name + "\xA");
                    builder.Append("\x1B\x21\x0");
                    builder.Append(printedBy.ToString());
                    //builder.Append("\r\nAusgestellt von " + person.Username + "\r\n");
                    builder.Append("\x1B\x64\x2");
                    builder.Append("\x1B\x61\x2");
                    builder.Append(DateTime.Now.ToString("D") + "\xA");
                    builder.Append("\x1D\x56\x42\x0");
                    builder.Append("@@@@@");
                }


                Thread t = new Thread(delegate() { PrintThread(builder.ToString()); });
                t.Start();
            }
            catch (Exception ex)
            {
                WriteLog("Fehler beim Drucken der Bons: " + ex.Message);
                throw new Exception("Drucker nicht erreichbar.");
            }
        }