using BrightIdeasSoftware; using DatenDB; using Deckungsbeitrag.Properties; using System; using System.Collections.Generic; using System.Configuration; using System.Drawing; using System.Drawing.Printing; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Web; using System.Web.Configuration; using System.Web.UI; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using ZXing; using ZXing.QrCode.Internal; using Control = System.Windows.Forms.Control; namespace Deckungsbeitrag { public class Funktionen { public static Color beladeband = Settings.Default.Beladeband; public static Color waschstr = Settings.Default.Waschstrasse; public static Color presse = Settings.Default.Presse; public static Color trockner = Settings.Default.Trockner; public static Color entladeband = Settings.Default.Entladeband; public static Color hubband = Settings.Default.Hubband; public FormAufleger _aufleger; public static Auftrag _auftrag; public static Kunde _adresse; private int currentPage = 0; public int totalPages = 0; int i = 0; int j = 0; public Funktionen() { } public static HeaderFormatStyle GetHeader() { HeaderFormatStyle headerFormat = new HeaderFormatStyle(); headerFormat.SetBackColor(Properties.Settings.Default.Wirlblau); headerFormat.SetForeColor(Color.White); headerFormat.Hot.BackColor = Color.SteelBlue; headerFormat.Pressed.BackColor = Color.DimGray; return headerFormat; } public static Font Get_Label_Font(Font font, string text, Size size) { Font f = font; Size s = size; if (!string.IsNullOrEmpty(text)) { while (s.Height > TextRenderer.MeasureText(text, f).Height) { f = new Font(font.FontFamily, f.Size + 1); } } return f; } public Label[] GetFachLabels(int fach, Maschine maschine, int height, Point loc, int width, string screen) { Label[] labels = new Label[5]; Label extra = new Label(); Label lblkunde = new Label(); Label label = new Label(); Label lbltag = new Label(); Label lblpro = new Label(); lblpro.Tag = extra.Tag = label.Tag = lbltag.Tag = lblkunde.Tag = Fach.GetFach(maschine.MaschineID, fach); lblpro.AutoSize = extra.AutoSize = label.AutoSize = lbltag.AutoSize = lblkunde.AutoSize = false; lblpro.Height = extra.Height = label.Height = lbltag.Height = lblkunde.Height = height; lblpro.Font = extra.Font = label.Font = lbltag.Font = lblkunde.Font = new Font("Microsoft Sans Serif", height / 3); lblkunde.Name = $"Kunde {fach}"; if (Kunde.GetKunde(string.Empty, ((Fach)lblkunde.Tag).KundeID, string.Empty).Suchtext == "?") lblkunde.Text = Auftrag.GetAuftrag(((Fach)lblkunde.Tag).AuftragID).ZusatzInfo; else lblkunde.Text = Kunde.GetKunde(string.Empty, ((Fach)lblkunde.Tag).KundeID, string.Empty).Suchtext; if (lblkunde.Text == string.Empty) lblkunde.Text = Kunde.GetKunde(string.Empty, ((Fach)lblkunde.Tag).KundeID, string.Empty).KundeName; lblkunde.TextAlign = ContentAlignment.MiddleCenter; if (width < 1500) lblkunde.Width = 400; else lblkunde.Width = 600; lbltag.Name = $"Tag {fach}"; if (((Fach)lbltag.Tag).Lieferdatum == null) lbltag.Text = Liefertag.SO.ToString(); else lbltag.Text = ((Liefertag)((DateTime)((Fach)lbltag.Tag).Lieferdatum).DayOfWeek).ToString(); if (lbltag.Text == string.Empty) lbltag.Text = "SO"; lbltag.TextAlign = ContentAlignment.MiddleLeft; label.Name = $"Fach {fach}"; label.TextAlign = ContentAlignment.MiddleRight; ///SchriftFarben für Fächer zuordnen. ///Unterschied zwischen Waschstrasse 1 & 2. int i = fach; if (maschine.Bezeichnung == "Waschstrasse 1") { if (i <= 4) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = beladeband; label.Text = $"F{i}"; } // Beladeband if (i >= 5 & i <= 13) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = waschstr; label.Text = $"W{i - 4}"; } // Waschstraße if (i == 14) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = presse; label.Text = $"P"; } // Presse if (i == 15) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = hubband; label.Text = $"H"; } // Hubband if(maschine.TrocknerKaputt == false) { if (i == 16 || i == 17) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = trockner; label.Text = $"T";//{i - 15}"; } // Trockner if (i == 18) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = entladeband; label.Text = $"S"; } // Entladeband } else { if (i == 16) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = trockner; label.Text = $"T"; // {i - 15}"; } // Trockner if (i == 17) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = entladeband; label.Text = $"S"; } // Entladeband } } if (maschine.Bezeichnung == "Waschstrasse 2") { if (i <= 5) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = beladeband; label.Text = $"F{i}"; } // Beladeband if (i >= 6 & i <= 17) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = waschstr; label.Text = $"W{i - 4}"; } // Waschstraße if (i == 18) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = presse; label.Text = $"P"; } // Presse if (i == 19) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = hubband; label.Text = $"H"; } // Hubband if(maschine.TrocknerKaputt == false) { if (i == 20 || i == 21) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = trockner; label.Text = $"T";// {i - 18}"; } // Trockner if (i == 22) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = entladeband; label.Text = $"S"; } // Entladeband } else { if (i == 20) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = trockner; label.Text = $"T";// {i - 18}"; } // Trockner if (i == 21) { lbltag.ForeColor = label.ForeColor = lblkunde.ForeColor = entladeband; label.Text = $"S"; } // Entladeband } } if (((Fach)extra.Tag).Extra != null) { extra.Text = Aufgabe.GetAufgabe(string.Empty, ((Fach)extra.Tag).Extra).Bezeichnung; if (extra.Text == "Extra Kunde") lblkunde.Text = "+" + Kunde.GetKunde(string.Empty, ((Fach)extra.Tag).ExtraKundeID, string.Empty).Suchtext; lblpro.BackColor = lblkunde.BackColor = lbltag.BackColor = label.BackColor = extra.BackColor = Aufgabe.GetAufgabe(string.Empty, ((Fach)extra.Tag).Extra).Farbe; lblkunde.ForeColor = lbltag.ForeColor = label.ForeColor = lblpro.ForeColor = Color.Black; extra.Visible = true; } else extra.Visible = false; lblkunde.Font = Get_Label_Font(lblkunde.Font, lblkunde.Text, lblkunde.Size); lbltag.Font = Get_Label_Font(lbltag.Font, lbltag.Text, lbltag.Size); label.Font = Get_Label_Font(label.Font, label.Text, label.Size); extra.Font = Get_Label_Font(extra.Font, extra.Text, extra.Size); lbltag.Width = TextRenderer.MeasureText(lbltag.Text, lbltag.Font).Width; label.Width = TextRenderer.MeasureText(label.Text, label.Font).Width; lblkunde.Location = new Point(loc.X, loc.Y + height * (i - 1)); lbltag.Location = new Point(lblkunde.Right, lblkunde.Location.Y); label.Location = new Point(lblkunde.Left - label.Width, lblkunde.Location.Y); extra.Location = new Point(10, lblkunde.Location.Y); lblpro.Location = new Point(lblkunde.Right + 100, lblkunde.Location.Y); extra.Name = $"Extra {maschine.MaschineID} {fach}"; if (width < 1500) extra.Width = width - 0; else extra.Width = width - 100; extra.ForeColor = Color.White; extra.TextAlign = ContentAlignment.MiddleRight; ///Waschprogramme bei Beladeband anzeigen. ///Unterscheidung durch Beladebandfächeranzahl. lblpro.Name = $"PR {fach}"; lblpro.TextAlign = ContentAlignment.MiddleRight; lblpro.Text = $"WP {((Fach)lblpro.Tag).WProgrammID}"; lblpro.Font = Get_Label_Font(lblpro.Font, lblpro.Text, lblpro.Size); lblpro.Width = TextRenderer.MeasureText(lblpro.Text, lblpro.Font).Width; labels[0] = label; labels[1] = lblkunde; labels[2] = lbltag; labels[3] = lblpro; labels[4] = extra; return labels; } public static Color Get_Color(Maschine maschine, int i) { Color color = new Color(); if (maschine.Bezeichnung == "Waschstrasse 1") { if (i <= 4) color = beladeband; // Beladeband if (i >= 5 & i <= 13) color = waschstr; // Waschstraße if (i == 14) color = presse; // Presse if (i == 15) color = hubband; // Hubband if (maschine.TrocknerKaputt == false) { if (i == 16 || i == 17) color = trockner; // Trockner if (i == 18) color = entladeband; // Entladeband } else { if (i == 16) color = trockner; // Trockner if (i == 17) color = entladeband; // Entladeband } } if (maschine.Bezeichnung == "Waschstrasse 2") { if (i <= 4) color = beladeband; // Beladeband if (i >= 5 & i <= 16) color = waschstr; // Waschstraße if (i == 17) color = presse; // Presse if (i == 18) color = hubband; // Hubband if (maschine.TrocknerKaputt == false) { if (i == 19 || i == 20) color = trockner; // Trockner if (i == 21) color = entladeband; // Entladeband } else { if (i == 19) color = trockner; // Trockner if (i == 20) color = entladeband; // Entladeband } } return color; } public static Label Label_Refresh(Label lbl, Maschine maschine, SPSDaten spsdaten, string screen) { int fach = 0; SPSDaten sps = spsdaten; if (lbl.Name.Contains("Kunde")) fach = int.Parse(lbl.Name.Substring(6)); if (lbl.Name.Contains("Fach")) fach = int.Parse(lbl.Name.Substring(5)); if (lbl.Name.Contains("Tag")) fach = int.Parse(lbl.Name.Substring(4)); if (lbl.Name.Contains("Extra")) fach = int.Parse(lbl.Name.Substring(8)); if (lbl.Name.Contains("PR")) fach = int.Parse(lbl.Name.Substring(3)); if (!lbl.Name.Contains("WP")) lbl.Tag = Fach.GetFach(maschine.MaschineID, fach); if (!sps.WS_2_Transport) { if (maschine.Bezeichnung == "Waschstrasse 2") { if (lbl.Name.Contains("17")) { if (sps.Presse2_Leer) lbl.Tag = null; else lbl.Tag = Fach.GetFach(maschine.MaschineID, 17); } if (lbl.Name.Contains("18")) { if (sps.Hubband2_Leer) lbl.Tag = null; else lbl.Tag = Fach.GetFach(maschine.MaschineID, 17); } if (lbl.Name.Contains("19")) { if (sps.Trockner21_Beladen || sps.Trockner22_Beladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 18); if (sps.Trockner21_Entladen || sps.Trockner22_Entladen) lbl.Tag = null; } if (lbl.Name.Contains("20") & !maschine.TrocknerKaputt) { if (sps.Trockner21_Beladen || sps.Trockner22_Beladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 19); if (sps.Trockner21_Entladen || sps.Trockner22_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 19); } if (lbl.Name.Contains("21")) { if (!maschine.TrocknerKaputt) { if (sps.Trockner21_Entladen || sps.Trockner22_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 20); } else { if (sps.Trockner21_Entladen || sps.Trockner22_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 19); } } } } if (!sps.WS_1_Transport) { if (maschine.Bezeichnung == "Waschstrasse 1") { if (lbl.Name.Contains("14")) { if (sps.Presse1_Leer) lbl.Tag = null; else lbl.Tag = Fach.GetFach(maschine.MaschineID, 14); } if (lbl.Name.Contains("15")) { if (sps.Hubband1_Leer) lbl.Tag = null; else lbl.Tag = Fach.GetFach(maschine.MaschineID, 14); } if (lbl.Name.Contains("16")) { if (sps.Trockner11_Beladen || sps.Trockner12_Beladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 15); if (sps.Trockner11_Entladen || sps.Trockner12_Entladen) lbl.Tag = null; } if (lbl.Name.Contains("17") & !maschine.TrocknerKaputt) { if (sps.Trockner11_Beladen || sps.Trockner12_Beladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 16); if (sps.Trockner11_Entladen || sps.Trockner12_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 16); } if (lbl.Name.Contains("18")) { if (!maschine.TrocknerKaputt) { if (sps.Trockner11_Entladen || sps.Trockner12_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 17); } else { if (sps.Trockner11_Entladen || sps.Trockner12_Entladen) lbl.Tag = Fach.GetFach(maschine.MaschineID, 16); } } } } if (lbl.Tag == null) { if (lbl.Name.Contains("Kunde")) lbl.Text = "LEER"; if (lbl.Name.Contains("Tag")) lbl.Text = " "; if (lbl.Name.Contains("Extra")) lbl.Visible = false; //BackColor wird wie Hintergrund und Schriftfarbe wird weiß wenn kein TAG (Extra). lbl.BackColor = Settings.Default.Wirlblau; lbl.ForeColor = Color.White; } else { if (lbl.Name.Contains("Kunde")) { if (Kunde.GetKunde(string.Empty, ((Fach)lbl.Tag).KundeID, string.Empty).Suchtext == "?") lbl.Text = Auftrag.GetAuftrag(((Fach)lbl.Tag).AuftragID).ZusatzInfo; else lbl.Text = Kunde.GetKunde(string.Empty, ((Fach)lbl.Tag).KundeID, string.Empty).Suchtext; if (lbl.Text == string.Empty) lbl.Text = Kunde.GetKunde(string.Empty, ((Fach)lbl.Tag).KundeID, string.Empty).KundeName; } if (lbl.Name.Contains("Tag")) { if (((Fach)lbl.Tag).Lieferdatum == null) lbl.Text = Liefertag.SO.ToString(); else lbl.Text = ((Liefertag)((DateTime)((Fach)lbl.Tag).Lieferdatum).DayOfWeek).ToString(); if (lbl.Text == string.Empty) lbl.Text = "SO"; lbl.Width = TextRenderer.MeasureText(lbl.Text, lbl.Font).Width; } if (lbl.Name.Contains("PR")) { lbl.Text = $"WP {((Fach)lbl.Tag).WProgrammID}"; if (fach == 3) sps.Waschprogramm = ((Fach)lbl.Tag).WProgrammID; //WASCHPROGRAMM FÜR ÜBERGABE IN SPS DATEN ÜBERGEBEN } if(((Fach)lbl.Tag).Extra != null) { Aufgabe extra = Aufgabe.GetAufgabe(string.Empty, ((Fach)lbl.Tag).Extra); if (lbl.Name.Contains("Extra")) { lbl.ForeColor = Color.White; lbl.Visible = true; lbl.Font = Get_Label_Font(lbl.Font, lbl.Text, lbl.Size); } else lbl.ForeColor = Color.Black; if (lbl.Name.Contains("Kunde")) { if (extra.Bezeichnung == "Extra Kunde") lbl.Text = "+" + Kunde.GetKunde(String.Empty, ((Fach)lbl.Tag).ExtraKundeID, string.Empty).Suchtext; } lbl.BackColor = Aufgabe.GetAufgabe(string.Empty, ((Fach)lbl.Tag).Extra).Farbe; } else { if (lbl.Name.Contains("Extra")) lbl.Visible = false; else { //if (!lbl.Name.Contains("PR")) lbl.ForeColor = Get_Color(maschine, fach); lbl.BackColor = Settings.Default.Wirlblau; } } } return lbl; } public static object SortimentLesen(string s) { StreamReader streamReader = null; bool ok = false; try { streamReader = new StreamReader(ConfigurationManager.AppSettings["SortimentPfad"], Encoding.GetEncoding("iso-8859-1")); } catch (Exception) { MessageBox.Show("Keine Sortiment-Datei gefunden, bitte kontrolliere Pfad und Dateiname!"); return ok; } int nr = 0; string row = string.Empty; Sortiment[] sortiment = new Sortiment[0]; List sortimentListe = new List(); int idx = 0; while (!streamReader.EndOfStream) { Array.Resize(ref sortiment, ++idx); row = streamReader.ReadLine(); sortiment[idx - 1] = new Sortiment(row, nr); sortimentListe.Add(new Sortiment(row, nr)); ++nr; } streamReader.Close(); ok = true; if (s == "Liste") return sortimentListe; else return ok; } public static Auftrag Kunde_unbekannt(int aID) { Auftrag auf = null; return auf; } /// /// QR-CODE FÜR ETIKETTEN /// public static Image Get_QR_Code(Kunde kunde, Auftrag auftrag) { Image img = null; BarcodeWriter code = new BarcodeWriter(); code.Format = BarcodeFormat.QR_CODE; if (auftrag != null) img = code.Write(auftrag.AuftragID.ToString() + "§"); else img = code.Write(kunde.KundeNummer.ToString() + "§"); //img = code.Write(auftrag.AuftragID + "," + kunde.KundeNummer + "," + auftrag.Liefertag.ToShortDateString()); return img; } /// /// DRUCKEN VON SCHMUTZWÄSCHESCHEINEN & ETIKETTEN /// public static Image SWS_Entwurf(Auftrag auftrag, Kunde adresse) { int ezl = 50; int handzeile = 33; float textsize = 10; float textsize2 = 20; int idx = 0; int idx1 = 0; int length = 0; Bitmap bitmap = new Bitmap(790, 1120); Graphics g = Graphics.FromImage(bitmap); Point adressblock = new Point(ezl, 50); Point tabelle = new Point(ezl, 330); SizeF textSize2 = g.MeasureString("Salzburg, am 26.08.1984", new Font("Arial", textsize, FontStyle.Regular)); SizeF textSize3 = g.MeasureString("MO", new Font("Arial", textsize2, FontStyle.Regular)); SizeF textSizePos = g.MeasureString("Bemerkung", new Font("Arial", textsize, FontStyle.Regular)); int zeile = (int)textSize2.Height + 20; //PIXEL int posTag = 145; if (adresse == null) adresse = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty); Image qrcode = Get_QR_Code(adresse, auftrag); string sortNr = string.Empty; //Innsbrucker Soziale Dienste Sortiment immer gleich. if (adresse.KundeNummer == "010069" | adresse.KundeNummer == "010071") sortNr = "010068"; else sortNr = adresse.KundeNummer; //result = sortimentListe.Find(Sortiment => Sortiment.KundeNummer == sortNr); List resultList = ((List)SortimentLesen("Liste")).FindAll(Sortiment => Sortiment.KundeNummer == sortNr); int qr = (int)textSize3.Height * 2 + (int)textSize2.Height * 3; g.FillRectangle(Brushes.White, 0, 0, bitmap.Width, bitmap.Height); //QR-Code g.DrawImage(qrcode, bitmap.Width - 50 - qr, 50, qr, qr); //Adressblock g.DrawString($"{adresse.KundeNummer} {adresse.Suchtext}", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock); g.DrawString($"{adresse.KundeName}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, adressblock.X, adressblock.Y + (int)textSize3.Height); g.DrawString($"{adresse.KundeName2}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, adressblock.X, adressblock.Y + (int)textSize3.Height + (int)textSize2.Height); // g.DrawString($"{adresse.Strasse}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, adressblock.X, adressblock.Y + (int)textSize3.Height + (int)textSize3.Height + (int)textSize2.Height); g.DrawString($"{adresse.PLZ} {adresse.Ort}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, adressblock.X, adressblock.Y + (int)textSize3.Height + (int)textSize3.Height + (int)textSize2.Height + (int)textSize2.Height); //TagAnzeige g.DrawString("MO", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock.X, adressblock.Y + posTag); g.DrawString("DI", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock.X + textSize3.Width + 10, adressblock.Y + posTag); g.DrawString("MI", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock.X + (textSize3.Width + 10) * 2, adressblock.Y + posTag); g.DrawString("DO", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock.X + (textSize3.Width + 10) * 3, adressblock.Y + posTag); g.DrawString("FR", new Font("Arial", textsize2, FontStyle.Regular), Brushes.Black, adressblock.X + (textSize3.Width + 10) * 4, adressblock.Y + posTag); //Datum g.DrawString("Datum:_______________", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, ezl, adressblock.Y + 200); if (adresse.Aufgabe != null) g.DrawString($"*{Aufgabe.GetAufgabe(string.Empty, adresse.Aufgabe).Bezeichnung}", new Font("Arial", textsize, FontStyle.Bold), Brushes.Black, tabelle.X + textSizePos.Width + 100, adressblock.Y + 200); //Tabelle Kopf g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X, tabelle.Y - zeile), new Point(bitmap.Width - 50, tabelle.Y - zeile)); g.DrawString("Bemerkung", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X, tabelle.Y - (int)textSize2.Height - 5); g.DrawString("Stück", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X + textSizePos.Width + 25, tabelle.Y - (int)textSize2.Height - 5); g.DrawString("Bezeichnung", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X + textSizePos.Width + 100, tabelle.Y - (int)textSize2.Height - 5); g.DrawString("Art.Nr.", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X + textSizePos.Width + 500, tabelle.Y - (int)textSize2.Height - 5); g.DrawLine(new Pen(Brushes.Black), tabelle, new Point(bitmap.Width - 50, tabelle.Y)); for (int i = 0; i < 19; i++) { ++idx; length = handzeile * idx; g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X, tabelle.Y - zeile), new Point(tabelle.X, tabelle.Y + length)); g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X + (int)textSizePos.Width + 5, tabelle.Y - zeile), new Point(tabelle.X + (int)textSizePos.Width + 5, tabelle.Y + length)); g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X + (int)textSizePos.Width + 90, tabelle.Y - zeile), new Point(tabelle.X + (int)textSizePos.Width + 90, tabelle.Y + length)); g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X + (int)textSizePos.Width + 495, tabelle.Y - zeile), new Point(tabelle.X + (int)textSizePos.Width + 495, tabelle.Y + length)); g.DrawLine(new Pen(Brushes.Black), new Point(bitmap.Width - 50, tabelle.Y - zeile), new Point(bitmap.Width - 50, tabelle.Y + length)); g.DrawLine(new Pen(Brushes.Black), new Point(tabelle.X, tabelle.Y + length), new Point(bitmap.Width - 50, tabelle.Y + length)); } foreach (Sortiment artikel in resultList) { ++idx1; length = handzeile * idx1; g.DrawString($"{artikel.ArtName}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X + textSizePos.Width + 100, tabelle.Y + length - 20); g.DrawString($"{artikel.ArtNr}", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, tabelle.X + textSizePos.Width + 500, tabelle.Y + length - 20); } //Bemerkung g.DrawString($"Bemerkung:", new Font("Arial", textsize, FontStyle.Regular), Brushes.Black, ezl, bitmap.Height - 130); //g.DrawString($"*{Aufgabe.GetAufgabe(string.Empty, adresse.Aufgabe).Bezeichnung}", new Font("Arial", textsize, FontStyle.Bold), Brushes.Black, ezl, bitmap.Height - 130 + handzeile); g.DrawRectangle(new Pen(Brushes.Black), ezl, bitmap.Height - 130 - textsize, bitmap.Width - 100, 100); Image img = bitmap; return img; } public static void SWS_Drucken(Auftrag auftrag, Kunde adresse) { if (auftrag != null) _auftrag = auftrag; if (adresse != null) _adresse = adresse; PrintDialog dialog = new PrintDialog(); PrintPreviewDialog preview = new PrintPreviewDialog(); preview.StartPosition = FormStartPosition.CenterScreen; preview.WindowState = FormWindowState.Maximized; foreach (string printer in PrinterSettings.InstalledPrinters) if (printer.Contains(ConfigurationManager.AppSettings["PrinterName"])) dialog.PrinterSettings.PrinterName = printer; //dialog.PrinterSettings.Copies = 10; if (dialog.ShowDialog() == DialogResult.OK) { PrintDocument printDocument = new PrintDocument(); printDocument.PrintPage += new PrintPageEventHandler(PrintDocument_PrintPage); printDocument.PrinterSettings = dialog.PrinterSettings; preview.Document = printDocument; preview.Document.DocumentName = "SWS-Schein"; preview.ShowDialog(); } } public static Image Etikett_Entwurf(Auftrag auftrag) { Kunde kunde = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty); if (kunde.Suchtext.StartsWith("?") | kunde.KundeNummer == "2320000") kunde.Suchtext = auftrag.ZusatzInfo; Image qr = Get_QR_Code(kunde, auftrag); Image qrweb = Image.FromFile(ConfigurationManager.AppSettings["QrPfad"]); qrweb.RotateFlip(RotateFlipType.Rotate270FlipNone); Bitmap bitmap = new Bitmap(1200, 350); //bitmap.SetResolution(100, 100); Graphics g = Graphics.FromImage(bitmap); Font font1 = new Font("Arial", 50, FontStyle.Bold); Font font2 = new Font("Arial", 30, FontStyle.Bold); Font font3 = new Font("Arial", 30, FontStyle.Regular); Font font4 = new Font("Arial", 150, FontStyle.Bold); float height_font1 = g.MeasureString($"{kunde.Suchtext}", font1).Height; float height_font2 = g.MeasureString($"{kunde.PLZ} {kunde.Ort})", font2).Height; SizeF size_container = g.MeasureString($"Container/Pakete:", font3); SizeF size_Liefertag = new SizeF(g.MeasureString("Liefertag:", font3)); float width_date_font1 = g.MeasureString("25.05.2023", font1).Width; Point startpoint = new Point(380, 50); g.FillRectangle(Brushes.White, 0, 0, bitmap.Width, bitmap.Height); //QR-Code g.DrawImage(qrweb, 15, 25, 350, 300); //Etikett-Text g.DrawString($"{kunde.Suchtext}", font1, Brushes.Black, startpoint); g.DrawString($"{kunde.PLZ} {kunde.Ort}", font2, Brushes.Black, startpoint.X, startpoint.Y + height_font1); g.DrawString("Liefertag:", font3, Brushes.Black, startpoint.X, startpoint.Y + height_font1 + 5 + height_font2 + 10); g.DrawString("Container/Pakete:", font3, Brushes.Black, startpoint.X + size_Liefertag.Width + 50, startpoint.Y + height_font1 + 5 + height_font2 + 10); g.DrawString($"{auftrag.Liefertag.ToShortDateString()}", font1, Brushes.Black, startpoint.X, startpoint.Y + height_font1 + 5 + height_font2 + 2 + size_Liefertag.Height + 2); g.DrawString($"{auftrag.ContainerClean}", font4, Brushes.Black, startpoint.X + size_Liefertag.Width + size_container.Width + 10, height_font1 + height_font2); Image img = bitmap; return img; } public static void Etikett_Drucken(Auftrag auftrag) { _auftrag = auftrag; int x = auftrag.ContainerClean; PrintDialog dialog = new PrintDialog(); PrintPreviewDialog preview = new PrintPreviewDialog(); PrintDocument printDocument = new PrintDocument(); foreach (string printer in PrinterSettings.InstalledPrinters) if (printer.Contains(ConfigurationManager.AppSettings["PrinterName"])) dialog.PrinterSettings.PrinterName = printer; dialog.PrinterSettings.Copies = (short)auftrag.ContainerClean; if (dialog.ShowDialog() == DialogResult.OK) { printDocument.PrinterSettings = dialog.PrinterSettings; printDocument.PrintPage += new PrintPageEventHandler(PrintDocument_PrintPage); dialog.Document = printDocument; dialog.Document.DocumentName = "Etikett"; printDocument.Print(); } } private static void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { if (sender.ToString().Contains("SWS-Schein")) { e.Graphics.DrawImage(Funktionen.SWS_Entwurf(_auftrag, _adresse), e.PageBounds); } if (sender.ToString().Contains("Etikett")) e.Graphics.DrawImage(Funktionen.Etikett_Entwurf(_auftrag), e.PageBounds); } /// /// HIDE AND SHOW CONTROLS WÄHREND LADEVORGANG /// public static Control.ControlCollection HideControls(Control.ControlCollection controls) { Control.ControlCollection cc = controls; foreach (Control c in cc) { c.Hide(); } return cc; } public static Control.ControlCollection ShowControls(Control.ControlCollection controls) { Control.ControlCollection cc = controls; foreach (Control c in cc) { c.Show(); } return cc; } /// /// LISTVIEW COLUMNSBREITE WIRD ANGEPASST UND DAS UMREIHEN ERMÖGLICHT /// public static ListView Columns_Resize(ListView lv) { int realwidth = lv.Width; int lvwWidth = 0; lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); ListView.ColumnHeaderCollection cc = lv.Columns; for (int i = 0; i < cc.Count; i++) { int colWidth = TextRenderer.MeasureText(cc[i].Text, lv.Font).Width + 30; if (colWidth > cc[i].Width) { lvwWidth += cc[i].Width = colWidth; } else lvwWidth += cc[i].Width; }//COLUMNS BREITE CONTENT ODER HEADER SIZE //BREITE DER LISTVIEW UNVERÄNDERT BEI NAMEN MIT... if (!lv.Name.Contains("Lieferungen") & !lv.Name.Contains("STH") & !lv.Name.Contains("Artikel")) lv.Width = lvwWidth; return lv; } public static ListView Columns_Reorder(ListView lv) { lv.AllowColumnReorder = true; return lv; } } }