using DatenDB; using Deckungsbeitrag.AA_Klassen; using Deckungsbeitrag.Properties; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using System.Xml.Serialization; namespace Deckungsbeitrag { public partial class FormAusschlager : Form { private Meldungen meldung = new Meldungen(); private Auftrag auftrag; private WSFach fach; public Maschine maschine; public List fachliste; bool maximised = false; int height; Point loc; public bool ws1transport = false; public bool ws2transport = false; private string Userid { get; } public FormAusschlager() { InitializeComponent(); } public FormAusschlager(string userid) : this() { this.Userid = userid; if (userid.Contains("01")) this.maschine = Maschine.GetMaschine(null, "Waschstrasse 1"); if (userid.Contains("02")) this.maschine = Maschine.GetMaschine(null, "Waschstrasse 2"); } private void FormAusschlager_Load(object sender, EventArgs e) { // WaitCursor und Controls ausblenden. this.Cursor = Cursors.WaitCursor; Funktionen.HideControls(this.Controls); this.BackColor = Properties.Settings.Default.Wirlblau; this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; if (maschine.TrocknerKaputt) this.tableLayoutPanelWS.RowCount = maschine.Faecher - 1; else this.tableLayoutPanelWS.RowCount = maschine.Faecher; this.tableLayoutPanelWS.ColumnCount = 4; Get_TableLayoutPanel(this.tableLayoutPanelWS); Load_TableLayoutPanel(this.tableLayoutPanelWS); //DefaultCursor und Controls einblenden. Funktionen.ShowControls(this.Controls); this.Cursor = Cursors.Default; } private void Load_TableLayoutPanel(TableLayoutPanel tlp) { // Fachliste für Maschine holen. List fachliste = WSFach.GetFachliste(this.maschine); if (fachliste.Count > 0) { foreach (WSFach f in fachliste) { Auftrag auftrag = Auftrag.GetAuftrag(f.AuftragID); // Alle Zellen einer Spalte durchlaufen for (int col = 0; col < tableLayoutPanelWS.ColumnCount; col++) { if (col == 1 || col == 2 || col == 3) { for (int row = 0; row < tlp.RowCount; row++) { Control cellControl = tlp.GetControlFromPosition(col, row); if (cellControl != null && cellControl is Label lbl) { // Label in Zelle (col=2, row) bearbeiten if (col == 1) lbl.Text = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Suchtext; if (col == 2) lbl.Text = auftrag.Liefertag.DayOfWeek.ToString(); if (auftrag.AufgabeID != null) { if (col == 3) lbl.Text = Aufgabe.GetAufgabe(string.Empty, (int?)auftrag.AufgabeID).Bezeichnung; } } } } } } } else { meldung.MaschineIstLeer(null); } } /// /// Label in jede Zelle des Panels einfügen und mit Schriftfarben aus den Settings versehen. Fach Label hat auch Text erhalten. /// /// private void Get_TableLayoutPanel(TableLayoutPanel tlp) { int rows = tlp.RowCount; int cols = tlp.ColumnCount; // Alle Spalten und Zeilen Styles entfernen. tlp.ColumnStyles.Clear(); tlp.RowStyles.Clear(); // Labels in jeder Zelle erstellen for (int row = 0; row < rows; row++) { // Reihen gleichmäßig am Screen verteilen. tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 100F / rows)); for (int col = 0; col < cols; col++) { //tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute)); Label lbl = new Label(); lbl.Name = $"Zeile {row}, Spalte {col}"; lbl.Dock = DockStyle.Fill; lbl.Tag = Tuple.Create(row, col); lbl.BackColor = Color.Transparent; // Content Alignment pro Spalte festlegen. switch (col) { case 0: lbl.TextAlign = ContentAlignment.MiddleRight; lbl.Text = "Fach"; break; case 1: lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Text = "Kunde"; break; case 2: lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.Text = "Liefertag"; break; case 3: lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.Text = "Aufgabe"; break; default: break; } // Schriftfarbe nach Fachzahl zuordnen. if(this.maschine.Bezeichnung == "Waschstrasse 1") { switch (row) { case int n when (n <= 4): lbl.ForeColor = Config.FarbenConfig.Farben["Beladeband"]; if (lbl.Text == "Fach") lbl.Text = $"F"; break; case int n when (n >= 5 && n <= 13): lbl.ForeColor = Config.FarbenConfig.Farben["Waschstrasse"]; if (lbl.Text == "Fach") lbl.Text = $"W"; break; case int n when (n == 14): lbl.ForeColor = Config.FarbenConfig.Farben["Presse"]; if (lbl.Text == "Fach") lbl.Text = $"P"; break; case int n when (n == 15): lbl.ForeColor = Config.FarbenConfig.Farben["Hubband"]; if (lbl.Text == "Fach") lbl.Text = $"H"; break; case int n when (n == 16): lbl.ForeColor = Config.FarbenConfig.Farben["Trockner"]; if (lbl.Text == "Fach") lbl.Text = $"T"; break; case int n when (n == 17): if (maschine.TrocknerKaputt) { lbl.ForeColor = Config.FarbenConfig.Farben["Entladeband"]; if (lbl.Text == "Fach") lbl.Text = $"E"; } else { lbl.ForeColor = Config.FarbenConfig.Farben["Trockner"]; if (lbl.Text == "Fach") lbl.Text = $"T"; } break; case int n when (n == 18): lbl.ForeColor = Config.FarbenConfig.Farben["Entladeband"]; if (lbl.Text == "Fach") lbl.Text = $"E"; break; default: break; } } if(this.maschine.Bezeichnung == "Waschstrasse 2") { switch (row) { case int n when (n <= 5): lbl.ForeColor = Config.FarbenConfig.Farben["Beladeband"]; if (lbl.Text == "Fach") lbl.Text = $"F"; break; case int n when (n >= 6 && n <= 17): lbl.ForeColor = Config.FarbenConfig.Farben["Waschstrasse"]; if (lbl.Text == "Fach") lbl.Text = $"W"; break; case int n when (n == 18): lbl.ForeColor = Config.FarbenConfig.Farben["Presse"]; if (lbl.Text == "Fach") lbl.Text = $"P"; break; case int n when (n == 19): lbl.ForeColor = Config.FarbenConfig.Farben["Hubband"]; if (lbl.Text == "Fach") lbl.Text = $"H"; break; case int n when (n == 20): lbl.ForeColor = Config.FarbenConfig.Farben["Trockner"]; if (lbl.Text == "Fach") lbl.Text = $"T"; break; case int n when (n == 21): if (maschine.TrocknerKaputt) { lbl.ForeColor = Config.FarbenConfig.Farben["Entladeband"]; if (lbl.Text == "Fach") lbl.Text = $"E"; } else { lbl.ForeColor = Config.FarbenConfig.Farben["Trockner"]; if (lbl.Text == "Fach") lbl.Text = $"T"; } break; case int n when (n == 22): lbl.ForeColor = Config.FarbenConfig.Farben["Entladeband"]; if (lbl.Text == "Fach") lbl.Text = $"E"; break; default: break; } } // Schriftgröße an Zellenhöhe anpassen. lbl.Font = Funktionen.Get_Label_Font(lbl.Font, lbl.Text, GetCellSizeInPixels(tlp, cols, rows)); tlp.Controls.Add(lbl, col, row); } } } private void Fach_Laden() { fach = new WSFach(); fach.AuftragID = (int)this.auftrag.AufgabeID; fach.MaschineID = (int)this.maschine.MaschineID; fach.Gewaschen = DateTime.Now; fach.Gewicht = 0; } private void Fach_Speichern() { } public void Form_Refresh(Maschine ms, SPSDaten spsdaten) { } /// /// Umrechnen der Prozentgröße der Zeile in Pixelhöhe (int). /// /// /// /// /// public static Size GetCellSizeInPixels(TableLayoutPanel tlp, int column, int row) { float colPercent = 0; float rowPercent = tlp.RowStyles[0].Height; int pixelWidth = (int)colPercent; int pixelHeight = rowPercent == 0 ? 0 : (int)(tlp.Height * (rowPercent / 100f)); return new Size(pixelWidth, pixelHeight); } /// /// KEIN VERWEIS NOTWENDIG /// Wenn ESC gedrückt wird schließt sich das Fenster. /// /// /// protected override bool ProcessDialogKey(Keys keyData) { if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape) { this.Close(); return true; } if (Form.ModifierKeys == Keys.None && keyData == Keys.Insert) { Open_NeuerAuftrag(); return true; } return base.ProcessDialogKey(keyData); } private void Open_NeuerAuftrag() { FormNeuerAuftrag neuerAuftrag = new FormNeuerAuftrag(this.Userid); if (neuerAuftrag.ShowDialog() == DialogResult.OK) { this.auftrag = neuerAuftrag.Auftrag; Fach_Laden(); } } } } //DONE: Bei Transport wir ein Fach mit Aktuellem Auftrag erstellt. Das Alte wird bei Transport gespeichert. //DONE: Wenn NeuerAuftrag gewählt Fach ändern nicht vergessen. //DONE: Wenn NeuerAuftrag gewählt wie gehts weiter?