Exemple #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.");
            }
        }
Exemple #2
0
 public void test()
 {
     ReceiptBuilder builder = new ReceiptBuilder();
     builder.AppendLine("First line in default");
     builder.Alignment = PrintAlignment.Center;
     builder.AppendLine("Second line centered");
     builder.Bold = true;
     builder.AppendLine("Third line is bold");
     builder.Reset();
     builder.AppendLine("Last line back in regular style");
     builder.FeedLines(5);
     builder.PartialCut();
 }
Exemple #3
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.");
            }
        }
Exemple #4
0
        private void CreatingResultForm_Load(object sender, EventArgs e)
        {
            Thread createResult = new Thread(new ThreadStart(() =>
            {
                double depositsum = 0.0;
                System.Threading.Thread.Sleep(2000);

                Cart purchs = DatabaseHandler.GetUserPurchaseSummary(profile, user);
                Cart cancs = DatabaseHandler.GetUserCancellationSummary(profile, user);
                Dictionary<Deposit, int> deps = DatabaseHandler.GetUserDepositReturns(user, profile);
                double depositReturnSum = 0.0;
                
                // calculate total sum of returned deposits
                foreach (KeyValuePair<Deposit, int> d in deps)
                    depositReturnSum += d.Key.Amount * d.Value;
                

                foreach (ArticleCount c in cancs.Container)
                    for (int j = 0; j < c.Count; j++)
                        purchs.Decrement(c.Article);

                _printstring = new ReceiptBuilder();

                _printstring.Alignment = PrintAlignment.Center;
                _printstring.DoubleHeight = true;
                _printstring.Font = FontType.B;
                _printstring.AppendLine(LoginForm.CashpointSettings["OrganizationName"]);
                _printstring.AppendLine("\r\n" + profile.Name + "\r\n");
                _printstring.Font = FontType.A;
                _printstring.DoubleWidth = true;
                _printstring.AppendLine("KASSENAUSWERTUNG\r\n");
                _printstring.DoubleHeight = false;
                _printstring.DoubleWidth = false;
                _printstring.Font = FontType.B;
                _printstring.AppendLine(DateTime.Now.ToString());
                _printstring.Reset();
                _printstring.FeedLines(2);
                _printstring.Bold = true;
                _printstring.AppendLine("VERANSTALTUNG");
                _printstring.Bold = false;
                _printstring.Alignment = PrintAlignment.Right;
                _printstring.AppendLine(profile.Name);
                _printstring.Alignment = PrintAlignment.Left;
                _printstring.Bold = true;
                _printstring.AppendLine("BENUTZER");
                _printstring.Bold = false;
                _printstring.Alignment = PrintAlignment.Right;
                _printstring.AppendLine(user.Username);
                _printstring.FeedLines(2);
                _printstring.Alignment = PrintAlignment.Left;

                _printstring.Bold = true;
                _printstring.AppendLine("ARTIKEL");
                _printstring.Bold = false;
                purchs.Sort(FHoner.Kasse.Frontend.Controller.Model.SortOrder.SortCriteria.Name);
                // add articles
                foreach (ArticleCount ac in purchs.Container)
                {
                    _printstring.AppendLine("  " + FormatItem(ac));
                }

                _printstring.Bold = true;
                _printstring.AppendLine("\nPFANDRUECKGABE");
                _printstring.Bold = false;
                // add deposit returns
                foreach (KeyValuePair<Deposit, int> dp in deps)
                {
                    _printstring.AppendLine("  " + FormatItem(dp));
                }

                // calculate deposit sum
                foreach (ArticleCount c in purchs.Container)
                    if (c.Article.Deposit.DepositID != -1)
                            depositsum += c.Article.Deposit.Amount * c.Count;
                // subtract returned deposit sum
                depositsum -= depositReturnSum;

                _printstring.Bold = true;
                _printstring.AppendLine("\nGESAMT");
                _printstring.Bold = false;
                _printstring.AppendLine("  Artikel   " + (purchs.Count - deps.Sum(x => x.Value)).ToString());
                _printstring.AppendLine("  Pfand     " + string.Format("{0:0.00}", depositsum));
                _printstring.AppendLine("  Umsatz    " + string.Format("{0:0.00}", purchs.Amount));
                //_printstring.AppendLine("  Summe     " + string.Format("{0:0.00}", purchs.AmountWithDeposit - depositReturnSum));

                _printstring.FeedLines(7);
                _printstring.PartialCut();

                if (!_cancelled)
                {
                    OnResultCreated(this, new ResultCreatedEventArgs(_printstring.ToString(), (int)duration.TotalMilliseconds));
                    this.Invoke(new Action(() => { this.Close(); }));
                }
            }));

            createResult.Start();
        }