using DatenDB; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Windows; using System.Windows.Forms; using Point = System.Drawing.Point; using Size = System.Drawing.Size; namespace Deckungsbeitrag { public partial class FormMain : Form { private Benutzer benutzer = null; public List sortimentListe; Kunde kunde = new Kunde(); Benutzer Benutzer; Aufgabe Aufgabe; Maschine Maschine; WProgramm Programm; Color Wirlblau; Thread t; bool listopen = false; public FormMain(Benutzer benutzer, Thread t1) : this(benutzer) { this.t = t1; } public FormMain() { InitializeComponent(); Wirlblau = Properties.Settings.Default.Wirlblau = Color.FromArgb(1, 53, 101); this.toolStripMenu.Size = new Size(toolStripButton1.Size.Width + 20, this.Height); this.flowPanelButtons.Location = new Point(toolStripMenu.Right + 10, 12); this.panelMain.Location = new Point(flowPanelButtons.Right + 10, 12); } public FormMain(Benutzer benutzer) : this() { this.benutzer = benutzer; //ANFANG //STATUS STRIP BEFÜLLEN if (((bool)Funktionen.SortimentLesen("Main")) == true) this.statusStripSortiment.Image = Properties.Resources.Checkmark_blue_16x; else this.statusStripSortiment.Image = Properties.Resources.Close_red_16x; this.toolStripStatusLabel2.ToolTipText = this.statusStripSortiment.ToolTipText = ConfigurationManager.AppSettings["SortimentPfad"]; this.statusStripDatum.Text = DateTime.Now.ToString(); this.statusStripUser.Text = this.benutzer.Vorname + " " + this.benutzer.Nachname; this.statusStrip1.ShowItemToolTips = true; //ENDE //STATUS STRIP BEFÜLLEN switch (benutzer.Rolle) { case BenutzerRolle.Verwaltung: this.toolStripDB.Enabled = this.toolStripButtonImport.Enabled = this.tSBWaschverlauf.Enabled = this.buttonBenutzerverwaltung.Enabled = false; this.toolStripDB.Visible = this.toolStripButtonImport.Visible = this.tSBWaschverlauf.Visible = this.buttonBenutzerverwaltung.Visible = false; break; case BenutzerRolle.Fahrer: this.buttonNeuerAuftrag.Enabled = this.buttonNeueAufgabe.Enabled = this.toolStripDB.Enabled = this.toolStripButtonImport.Enabled = this.tSBWaschverlauf.Enabled = this.tSBExpeditDrucken.Enabled = this.buttonBenutzerverwaltung.Enabled = false; this.buttonNeuerAuftrag.Visible = this.buttonNeueAufgabe.Enabled = this.toolStripDB.Visible = this.toolStripButtonImport.Visible = this.tSBWaschverlauf.Visible = this.tSBExpeditDrucken.Visible = this.buttonBenutzerverwaltung.Visible = false; break; case BenutzerRolle.Admin: this.buttonNeueMaschine.Enabled = this.tSBWaschverlauf.Enabled = false; this.buttonNeueMaschine.Visible = this.tSBWaschverlauf.Visible = false; break; case BenutzerRolle.Waschstrasse: this.buttonNeuerAuftrag.Enabled = this.buttonNeueAufgabe.Enabled = this.toolStripDB.Enabled = this.toolStripButtonImport.Enabled = this.buttonBenutzerverwaltung.Enabled = false; this.buttonNeuerAuftrag.Visible = this.buttonNeueAufgabe.Visible = this.toolStripDB.Visible = this.toolStripButtonImport.Visible = this.buttonBenutzerverwaltung.Visible = false; break; case BenutzerRolle.Master: break; default: break; } } private void FormMain_Load(object sender, EventArgs e) { //t.Abort(); this.WindowState = FormWindowState.Maximized; this.flowPanelButtons.Height = toolStripMenu.Height - statusStrip1.Height - 22; this.panelMain.Height = flowPanelButtons.Height; this.Activate(); } /// /// CLICK EVENTS TOOLSTRIP BUTTONS /// private void toolStripBeenden_Click(object sender, EventArgs e) { Application.Exit(); } private void toolStripZaehlscheine_Click(object sender, EventArgs e) { KundeDaten kundedaten = new KundeDaten(); if (kundedaten.ShowDialog() == DialogResult.OK) { } } private void toolStripDB_Click(object sender, EventArgs e) { FormNeuDeckungsbeitrag deckungsbeitrag = new FormNeuDeckungsbeitrag(this.benutzer, false); if (deckungsbeitrag.ShowDialog() == DialogResult.OK) { } } private void tSBFahrerAuftrag_Click(object sender, EventArgs e) { //NEUER SCREEN MIT LISTVIEW AUSPROBIEREN...SET OBJECT IN SCREEN AUSPROGRAMMIEREN FormFahrerScreen auftrag = new FormFahrerScreen(benutzer); auftrag.ShowDialog(); } private void tSBWaschstrasse1_Click(object sender, EventArgs e) { //FormWaschstrasse waschstrasse = new FormWaschstrasse(this.tSBWaschverlauf.Text); //waschstrasse.ShowDialog(); //LISTVIEW MIT GEWASCHTEN FÄCHERN ERSTELLEN (KOMMT WENN BENUTZER = ADMIN) } private void tSBWaschverlauf_Click(object sender, EventArgs e) { FormWaschverlauf verlauf = new FormWaschverlauf(); verlauf.ShowDialog(); } private void toolStripButtonImport_Click(object sender, EventArgs e) { Import import = new Import(); if (import.ShowDialog() == DialogResult.OK) { } } private void tSBWaschstrasse2_Click(object sender, EventArgs e) { } private void tSBKosten_Click(object sender, EventArgs e) { FormNeuDeckungsbeitrag deckungsbeitrag = new FormNeuDeckungsbeitrag(this.benutzer, true); if (deckungsbeitrag.ShowDialog() == DialogResult.OK) { } } private void tSBEinstellung_Click(object sender, EventArgs e) { FormEinstellung einstellung = new FormEinstellung(); einstellung.ShowDialog(); } private void toolStripStatusLabel2_DoubleClick(object sender, EventArgs e) { FormEinstellung einstellung = new FormEinstellung("Sortiment"); einstellung.ShowDialog(); } private void tSBExpedit_Click(object sender, EventArgs e) { FormExpedit exp = new FormExpedit(benutzer); exp.ShowDialog(); } /// /// TOOLSTRIP BUTTON DESIGN /// private void get_Border_Paint(object sender, PaintEventArgs e) { ToolStripItem item = (ToolStripItem)sender; ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 0, item.Width, item.Height), Color.White, ButtonBorderStyle.Solid); } private void toolStrip_MouseEnter(object sender, EventArgs e) { if (sender.GetType() == typeof(ToolStripButton)) { ToolStripButton tsb = (ToolStripButton)sender; tsb.ForeColor = Color.FromArgb(1, 53, 101); tsb.BackColor = Color.White; } } private void toolStrip_MouseLeave(object sender, EventArgs e) { if (sender.GetType() == typeof(ToolStripButton)) { ToolStripButton tsb = (ToolStripButton)sender; tsb.ForeColor = Color.White; tsb.BackColor = Color.FromArgb(1, 53, 101); } } private void textBox_Leave(object sender, EventArgs e) { this.textBoxBenutzername.Text = (this.textBoxVorname.Text + this.textBoxNachname.Text).ToLower(); } /// /// BUTTONS IN PANEL CLICK-EVENTS MIT SWITCH /// private void PanelButtons_Click(object sender, EventArgs e) { Button btn = (Button)sender; switch (btn.Text) { case var _ when btn.Name.Contains("NeueAufgabe"): { AutoCompleteStringCollection strings = new AutoCompleteStringCollection(); List aufgabenlist = Aufgabe.GetList(null); foreach (Aufgabe aufgabe in aufgabenlist) strings.Add(aufgabe.Bezeichnung); this.groupBoxNeueAufgabe.Location = new Point(this.buttonNeueAufgabe.Location.X, this.listView1.Bottom); this.comboBoxAufgabeKat.DataSource = Enum.GetValues(typeof(Kategorie)); this.textBoxBezeichnung.AutoCompleteCustomSource = strings; this.groupBoxNeueAufgabe.Width = 770; this.buttonFarbe.Visible = false; this.groupBoxNeueAufgabe.Visible = true; this.groupBoxNeueAufgabe.Parent = this.panelMain; } break; case var _ when btn.Name.Contains("Auftrag"): { FormNeuerAuftrag neuauftrag = new FormNeuerAuftrag(this.benutzer, null, false, null, null); if (neuauftrag.ShowDialog() == DialogResult.OK) { } } break; case var _ when btn.Name.Contains("NeuerBenutzer"): { this.groupBoxBenutzer.Height = 95; this.groupBoxBenutzer.Location = new Point(this.buttonNeuerBenutzer.Location.X, this.listView1.Bottom); this.groupBoxBenutzer.Text = "Benutzer anlegen"; this.comboBoxRolle.DataSource = Enum.GetValues(typeof(BenutzerRolle)); this.groupBoxBenutzer.Visible = true; } break; case var _ when btn.Name.Contains("Maschine"): { this.groupBoxMaschine.Location = this.buttonNeueMaschine.Location; this.groupBoxMaschine.Width = this.buttonNeueMaschine.Width; this.groupBoxMaschine.Height = this.buttonNeueMaschine.Height + 200; this.listViewMaschine.SuspendLayout(); this.listViewMaschine.Items.Clear(); this.listViewMaschine.Columns.Clear(); string columns = "Bezeichnung, Fächer, Trockner kaputt"; foreach (string s in columns.Split(',')) { ColumnHeader ch = new ColumnHeader(); ch.Width = 150; ch.Text = s; this.listViewMaschine.Columns.Add(ch); } ListViewItem item; foreach (Maschine maschine in Maschine.GetList()) { item = new ListViewItem(); item.Tag = maschine; item.Text = maschine.Bezeichnung; item.SubItems.Add(maschine.Faecher.ToString()); item.SubItems.Add(maschine.TrocknerKaputt.ToString()); this.listViewMaschine.Items.Add(item); } this.listViewMaschine = Funktionen.Columns_Resize(this.listViewMaschine); this.listViewMaschine.ResumeLayout(); this.groupBoxMaschine.Width = this.listViewMaschine.Width + 30; this.groupBoxMaschine.Visible = true; } break; case var _ when btn.Name.Contains("WPr"): { this.listViewProg.SuspendLayout(); this.listViewProg.Items.Clear(); this.listViewProg.Columns.Clear(); string col = "Nummer, Bezeichnung"; foreach (string s in col.Split(',')) { ColumnHeader ch = new ColumnHeader(); ch.Width = 150; ch.Text = s; this.listViewProg.Columns.Add(ch); } ListViewItem item1; foreach (WProgramm prog in WProgramm.GetList()) { item1 = new ListViewItem(); item1.Tag = prog; item1.Text = prog.Nummer.ToString(); item1.SubItems.Add(prog.Bezeichnung); this.listViewProg.Items.Add(item1); } this.listViewProg.ResumeLayout(); this.groupBoxWPr.Location = this.buttonWPr.Location; this.groupBoxWPr.Visible = true; } break; case var _ when btn.Name.Contains("Benutzerverwaltung"): { if (!listopen) { this.buttonNeuerBenutzer.Visible = true; this.listView1.Location = this.buttonBenutzerverwaltung.Location; string colname = "vorname, nachname, benutzer_name, rolle, schein, gueltig_bis, ist_aktiv"; List list = new List(Benutzer.GetList()); listView_Load(colname, list); this.pictureBoxBenutzerClose.Location = new Point(this.listView1.Right, this.listView1.Location.Y + 1); listopen = this.listView1.Visible = this.pictureBoxBenutzerClose.Visible = true; } } break; case var _ when btn.Name.Contains("Aufgabenverwaltung"): { if (!listopen) { this.buttonNeueAufgabe.Visible = true; this.listView1.Location = this.buttonAufgabenverwaltung.Location; string colname = "bezeichnung, beschreibung, kategorie, farbe"; List list = new List(Aufgabe.GetList(null)); listView_Load(colname, list); this.pictureBoxBenutzerClose.Location = new Point(this.listView1.Right, this.listView1.Location.Y + 1); listopen = this.listView1.Visible = this.pictureBoxBenutzerClose.Visible = true; } } break; default: break; } } //Panel Buttons Click Events /// /// BUTTONS SPEICHERN UND ABBRECHEN UND SCHLIESSEN IN GROUPBOX /// private void buttonAbbrechen_Click(object sender, EventArgs e) { Button btn = (Button)sender; switch (btn.Parent.Text) { case var _ when btn.Parent.Text.Contains("Benutzer"): this.Benutzer = null; this.groupBoxBenutzer.Visible = this.groupBoxBenutzer.Visible; this.buttonNeuerBenutzer.Visible = false; foreach (Control ctr in this.groupBoxBenutzer.Controls) clear_Controls(ctr); break; case var _ when btn.Parent.Text.Contains("Aufgabe"): this.Aufgabe = null; this.groupBoxNeueAufgabe.Visible = this.groupBoxBenutzer.Visible; this.buttonNeueAufgabe.Visible = this.buttonNeueAufgabe.Visible; this.buttonFarbe.Visible = false; foreach (Control ctr in this.groupBoxNeueAufgabe.Controls) clear_Controls(ctr); break; case var _ when btn.Parent.Text.Contains("Maschine"): this.Maschine = null; this.groupBoxMaschine.Visible = false; foreach (Control ctr in this.groupBoxMaschine.Controls) clear_Controls(ctr); break; case var _ when btn.Parent.Text.Contains("programm"): this.Programm = null; this.groupBoxWPr.Visible = false; foreach (Control ctr in this.groupBoxWPr.Controls) clear_Controls(ctr); break; default: break; } } //Über Switch können alle GroupBoxen geschlossen werden. private void groupBoxButtonSpeichern_CLick(object sender, EventArgs e) { Button btn = (Button)sender; switch (btn.Parent.Text) { case var _ when btn.Parent.Text.Contains("Benutzer"): if (Benutzer == null) Benutzer = new Benutzer(); this.Benutzer.Vorname = this.textBoxVorname.Text; this.Benutzer.Nachname = this.textBoxNachname.Text; this.Benutzer.Schein = int.TryParse(this.textBoxSchein.Text, out int tmp) ? tmp : (int?)null; this.Benutzer.GueltigBis = this.dTPGueltigBis.Value; this.Benutzer.BenutzerName = this.textBoxBenutzername.Text; this.Benutzer.Aktiv = this.checkBoxAktiv.Checked ? true : false; this.Benutzer.Rolle = (BenutzerRolle)this.comboBoxRolle.SelectedItem; if (this.Benutzer.Save() == 1) buttonAbbrechen_Click(btn, e); this.groupBoxBenutzer.Visible = false; break; case var _ when btn.Parent.Text.Contains("Aufgabe"): if (Aufgabe == null) Aufgabe = new Aufgabe(); else if (MessageBox.Show("Möchtest du die Änderungen speichern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; this.Aufgabe.Bezeichnung = this.textBoxBezeichnung.Text; this.Aufgabe.Beschreibung = this.textBoxBeschreibung.Text; this.Aufgabe.Kategorie = (Kategorie)this.comboBoxAufgabeKat.SelectedItem; if (this.buttonFarbe.Visible) { CancelEventArgs ex = new CancelEventArgs(); if (buttonFarbe_Validating(this, ex) == false) this.Aufgabe.Farbe = this.buttonFarbe.BackColor; } else this.Aufgabe.Farbe = DefaultBackColor; if (this.Aufgabe.Save() == 1) buttonAbbrechen_Click(btn, e); this.groupBoxNeueAufgabe.Visible = false; break; case var _ when btn.Parent.Text.Contains("Maschine"): if (Maschine == null) Maschine = new Maschine(); this.Maschine.Bezeichnung = this.textBoxMaschBezeich.Text; this.Maschine.Faecher = (int)this.numUpDownFaecher.Value; if (this.Maschine.Save() == 1) buttonAbbrechen_Click(btn, e); break; case var _ when btn.Parent.Text.Contains("programm"): if (Programm == null) Programm = new WProgramm(); this.Programm.Nummer = (int)this.numericUpDownWPr.Value; this.Programm.Bezeichnung = this.textBoxWPrBezeichnung.Text; if (this.Programm.Save() == 1) buttonAbbrechen_Click(btn, e); break; default: break; } } //Über Switch können alle GroupBoxen gespeichert werden. private void pictureBoxBenutzerClose_Click(object sender, EventArgs e) { this.listView1.Clear(); this.listView1.Visible = this.pictureBoxBenutzerClose.Visible = false; this.buttonBenutzerverwaltung.Visible = true; listopen = this.buttonNeuerBenutzer.Visible = this.groupBoxBenutzer.Visible = this.buttonNeueAufgabe.Visible = this.groupBoxNeueAufgabe.Visible = false; } //Benutzer ListView wird geschlossen. /// /// FUNKTIONEN IN GROUPBOXEN /// private void listView_Load(string colname, List objectlist) { this.listView1.SuspendLayout(); this.listView1.BeginUpdate(); Cursor.Current = Cursors.WaitCursor; ColumnHeader ch; foreach (string s in colname.Split(',')) { ch = new ColumnHeader(); ch.Name = s.Trim(); if (ch.Name == "vorname") ch.DisplayIndex = 0; if (ch.Name == "nachname") ch.DisplayIndex = 2; if (ch.Name == "benutzer_name") { ch.DisplayIndex = 3; ch.Name = "benutzername"; } if (ch.Name == "rolle") ch.DisplayIndex = 4; if (ch.Name == "schein") ch.DisplayIndex = 5; if (ch.Name == "gueltig_bis") { ch.DisplayIndex = 6; ch.Name = "gültig bis"; } if (ch.Name == "ist_aktiv") { ch.DisplayIndex = 7; ch.Name = "aktiv"; } if (ch.Name == "bezeichnung") ch.DisplayIndex = 0; if (ch.Name == "Beschreibung") ch.DisplayIndex = 1; if (ch.Name == "kategorie") ch.DisplayIndex = 3; if (ch.Name == "farbe") { ch.DisplayIndex = 4; } ch.Text = char.ToUpper(ch.Name[0]) + ch.Name.Substring(1); if (ch.Name != "benutzer_id" && ch.Name != "passwort") this.listView1.Columns.Add(ch); } this.listView1.Items.Clear(); var element = objectlist.FirstOrDefault(); switch (element.GetType().Name) { case ("Benutzer"): foreach (Benutzer ben in objectlist) { ListViewItem item; item = new ListViewItem(); item.Tag = ben; item.Text = ben.Vorname; item.SubItems.Add(ben.Nachname); item.SubItems.Add(ben.BenutzerName); item.SubItems.Add(ben.Rolle.ToString()); item.SubItems.Add(ben.Schein.ToString()); item.SubItems.Add(ben.GueltigBis.Value.ToShortDateString()); item.SubItems.Add(ben.Aktiv == true ? "JA" : "NEIN"); this.listView1.Items.Add(item); } break; case ("Aufgabe"): foreach (Aufgabe auf in objectlist) { ListViewItem item = new ListViewItem(); item.UseItemStyleForSubItems = false; item.Tag = auf; item.Text = auf.Bezeichnung; item.SubItems.Add(auf.Beschreibung); item.SubItems.Add(auf.Kategorie.ToString()); item.SubItems.Add(""); ColorConverter cc = new ColorConverter(); item.SubItems[3].BackColor = (Color)cc.ConvertFromString(auf.Farbe.ToArgb().ToString()); //COLUMN FARBE SUBITEM BACKCOLOR == FARBE. this.listView1.Items.Add(item); } break; default: break; } //RESIZE COLUMNS this.listView1 = Funktionen.Columns_Resize(this.listView1); this.listView1.Width = this.listView1.Width + 22; this.listView1.AllowColumnReorder = true; this.listView1.Height = 150; foreach (ListViewItem itm in this.listView1.Items) { if (itm.Index % 2 == 0) itm.BackColor = Color.LightSteelBlue; foreach (ListViewItem.ListViewSubItem subItem in itm.SubItems) if (!string.IsNullOrWhiteSpace(subItem.Text)) subItem.BackColor = itm.BackColor; }//BACKCOLOR FÜR JEDES ZWEITE ANDERE FARBE this.listView1.EndUpdate(); this.listView1.ResumeLayout(); Cursor.Current = Cursors.Default; } //Benutzer ListView laden. (KANN FÜR ANDERE AUCH VERWENDET WERDEN(Switch)) private void listView_MouseDoubleClick(object sender, MouseEventArgs e) { ListViewItem item = this.listView1.GetItemAt(e.X, e.Y); switch (item.Tag.GetType().Name) { case ("Benutzer"): Benutzer = (Benutzer)item.Tag; pictureBoxBenutzerClose_Click(this, e); this.groupBoxBenutzer.Location = this.listView1.Location; this.groupBoxBenutzer.Text = "Benutzer bearbeiten"; this.comboBoxRolle.DataSource = Enum.GetValues(typeof(BenutzerRolle)); this.groupBoxBenutzer.Visible = true; this.textBoxVorname.Text = Benutzer.Vorname; this.textBoxNachname.Text = Benutzer.Nachname; this.textBoxBenutzername.Text = Benutzer.BenutzerName; this.comboBoxRolle.SelectedItem = Benutzer.Rolle; comboBoxRolle_SelectedValueChanged(this, e); this.textBoxSchein.Text = Benutzer.Schein.ToString(); this.dTPGueltigBis.Value = Benutzer.GueltigBis.HasValue ? Benutzer.GueltigBis.Value : DateTime.Today.Date; this.checkBoxAktiv.Checked = Benutzer.Aktiv; break; case ("Aufgabe"): Aufgabe = (Aufgabe)item.Tag; pictureBoxBenutzerClose_Click(this, e); this.groupBoxNeueAufgabe.Location = this.listView1.Location; this.groupBoxNeueAufgabe.Text = "Aufgabe bearbeiten"; this.comboBoxAufgabeKat.DataSource = Enum.GetValues(typeof(Kategorie)); this.groupBoxNeueAufgabe.Visible = true; this.textBoxBeschreibung.Text = Aufgabe.Beschreibung; this.textBoxBezeichnung.Text = Aufgabe.Bezeichnung; this.buttonFarbe.BackColor = Aufgabe.Farbe; this.buttonFarbe.Visible = true; break; default: break; } } //Benutzer wird ausgewählt und kann bearbeitet werden. private void comboBoxRolle_SelectedValueChanged(object sender, EventArgs e) { if ((BenutzerRolle)this.comboBoxRolle.SelectedItem == BenutzerRolle.Fahrer) { this.groupBoxBenutzer.Height = 170; } else this.groupBoxBenutzer.Height = 95; } //Wenn Benutzerrolle ausgewählt wird. (Wenn Fahrer dann Groupbox vergrößern) private void comboBoxAufgabeKat_SelectedValueChanged(object sender, EventArgs e) { ComboBox cb = (ComboBox)sender; if (cb.SelectedValue.ToString() == "Waschstrasse") { groupBoxNeueAufgabe.Width = 880; this.buttonFarbe.Visible = true; } } //Wenn Aufgabenkategorie ausgewählt wird. (Wenn Kat=Waschstrasse kann Hintergrundfarbe ausgewählt werden) private bool buttonFarbe_Validating(object sender, CancelEventArgs e) { if (buttonFarbe.BackColor == Color.FromArgb(1, 53, 101)) { MessageBox.Show("Hallo"); buttonFarbe.ForeColor = buttonFarbe.FlatAppearance.BorderColor = Color.Red; e.Cancel = true; } return e.Cancel; } //Aufgabenkategorie Farbauswahl wird validiert. (Kat=Waschstrasse dann muss Farbe gewählt sein) private void buttonFarbe_Click(object sender, EventArgs e) { ColorDialog dialog = new ColorDialog(); if (dialog.ShowDialog() == DialogResult.OK) { this.buttonFarbe.BackColor = dialog.Color; } } //Aufgabenkategorie Farbauswahl. private void textBoxBezeichnung_Leave(object sender, EventArgs e) { TextBox tb = (TextBox)sender; if (!string.IsNullOrEmpty(tb.Text)) { tb.Text = tb.Text.Substring(0, 1).ToUpper() + tb.Text.Substring(1); if (Aufgabe.GetAufgabe(tb.Text, null) != null) { Aufgabe = Aufgabe.GetAufgabe(tb.Text, null); this.textBoxBeschreibung.Text = Aufgabe.Beschreibung; this.comboBoxAufgabeKat.SelectedItem = Aufgabe.Kategorie; this.buttonFarbe.BackColor = Aufgabe.Farbe; } } } //Aufgabe Bezeichnung wird kontrolliert ob bereits vorhanden und geladen. private void clear_Controls(Control ctr) { switch (ctr) { case TextBox tb: tb.Clear(); break; case CheckBox cb: cb.Checked = false; break; case ComboBox cobo: cobo.SelectedIndex = 0; break; case DateTimePicker dtp: dtp.Value = DateTime.Now; break; case NumericUpDown numupdown: numupdown.Value = 0; break; case ListView lv: lv.Items.Clear(); break; case Button btn: if (!btn.Name.Contains("Speichern") && !btn.Name.Contains("Abbrechen")) btn.BackColor = Properties.Settings.Default.Wirlblau; break; default: break; } } //Controls werden bereinigt. (Switchausführung) private void listViewMaschine_MouseDoubleClick(object sender, MouseEventArgs e) { ListViewItem item1 = this.listViewMaschine.GetItemAt(e.X, e.Y); Maschine = (Maschine)item1.Tag; if (Maschine.TrocknerKaputt == false) { if (MessageBox.Show($"Möchtest du bei der {Maschine.Bezeichnung} einen Trockner deaktivieren?", "Frage", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Maschine.TrocknerKaputt = true; Maschine.Save(); } } else { if (MessageBox.Show($"Möchtest du bei der {Maschine.Bezeichnung} den Trockner wieder aktivieren?", "Frage", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Maschine.TrocknerKaputt = false; Maschine.Save(); } } this.listViewMaschine.Items.Clear(); foreach (Maschine maschine in Maschine.GetList()) { ListViewItem item; item = new ListViewItem(); item.Tag = maschine; item.Text = maschine.Bezeichnung; item.SubItems.Add(maschine.Faecher.ToString()); item.SubItems.Add(maschine.TrocknerKaputt.ToString()); this.listViewMaschine.Items.Add(item); } } /// /// Hilfe Events /// private void buttonNeueMaschine_HelpRequested(object sender, HelpEventArgs hlpevent) { MessageBox.Show($"Hier kannst du eine neue Maschine anlegen.{Environment.NewLine}{Environment.NewLine}Wenn du bei einer Maschine einen Trockner aus- oder einschalten willst musst du die Maschine doppelt anklicken.", "Hilfe", MessageBoxButtons.OK, MessageBoxIcon.Information); } //Hilfe bei Maschine Button und Maschine Groupbox. //DIV FUNKTIONEN NICHT GEBRAUCHT private void Splash() { //Open a splash screen form FormLaden frm = new FormLaden(); Application.Run(frm); } //LADESCREEN WIRD GELADEN WENN BENÖTIGT. AKTIVIEREN } }