using DatenDB; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Deckungsbeitrag { public partial class FormNeueAufgabe : Form { private Aufgabe aufgabe; private Meldungen meldung = new Meldungen(); public FormNeueAufgabe() { InitializeComponent(); } private void FormNeueAufgabe_Load(object sender, EventArgs e) { this.buttonFarbe.Enabled = false; this.buttonFarbe.Tag = false; Load_comboBoxAufgabeKat(); } private void Load_comboBoxAufgabeKat() { this.comboBoxAufgabeKat.DataSource = Enum.GetValues(typeof(Kategorie)); this.comboBoxAufgabeKat.SelectedIndex = -1; } private void buttonSpeichern_Click(object sender, EventArgs e) { Aufgabe aufgabe = new Aufgabe(); aufgabe.Bezeichnung = textBoxBezeichnung.Text; aufgabe.Beschreibung = textBoxBeschreibung.Text; aufgabe.Kategorie = (Kategorie)comboBoxAufgabeKat.SelectedItem; aufgabe.Aktiv = true; if (buttonFarbe.Enabled) { if ((bool)buttonFarbe.Tag == true) aufgabe.Farbe = buttonFarbe.FlatAppearance.BorderColor; else { switch (meldung.GetFrage(this, $"Du hast keine Farbe für die Aufgabe gewählt. Möchtest du die Farbe jetzt wählen? {Environment.NewLine}Wenn du die Aufgabekategorie ändern möchtest drücke Abbrechen.", true)) { case DialogResult.Cancel: return; case DialogResult.Yes: buttonFarbe_Click(this, null); break; case DialogResult.No: break; default: break; } } } aufgabe.Save(); } private void buttonAbbrechen_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void buttonFarbe_Click(object sender, EventArgs e) { ColorDialog color = new ColorDialog(); if(color.ShowDialog() == DialogResult.OK) { buttonFarbe.FlatAppearance.BorderColor = buttonFarbe.ForeColor = color.Color; buttonFarbe.Tag = true; } } private void comboBoxAufgabeKat_Validating(object sender, CancelEventArgs e) { if ((Kategorie)comboBoxAufgabeKat.SelectedItem == Kategorie.Waschstrasse) this.buttonFarbe.Enabled = true; } } } //TODO: Neue Aufgabe Screen erstellen.