115 lines
3.5 KiB
C#
115 lines
3.5 KiB
C#
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;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Deckungsbeitrag
|
|
{
|
|
public partial class FormAufgabeVW : Form
|
|
{
|
|
Aufgabe aufgabe;
|
|
public FormAufgabeVW()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void FormAufgabeVW_Load(object sender, EventArgs e)
|
|
{
|
|
GroupBox_Visibility_State(this.groupBoxNeueAufgabe);
|
|
List<object> list = new List<object>(Aufgabe.GetList(null));
|
|
this.listViewAufgabeVW = Funktionen.ListView_Load(this.listViewAufgabeVW, Aufgabe.COLUMNS, list);
|
|
|
|
}
|
|
private void Clear_controls()
|
|
{
|
|
foreach (Control ctr in this.groupBoxNeueAufgabe.Controls)
|
|
{
|
|
if (ctr.GetType() == typeof(TextBox))
|
|
{
|
|
TextBox tb = (TextBox)ctr;
|
|
tb.Clear();
|
|
}
|
|
if (ctr.GetType() == typeof(CheckBox))
|
|
{
|
|
CheckBox cb = (CheckBox)ctr;
|
|
cb.Checked = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
private void Load_comboBoxAufgabeKat()
|
|
{
|
|
this.comboBoxAufgabeKat.DataSource = Enum.GetValues(typeof(Kategorie));
|
|
}
|
|
private void listViewAufgabeVW_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
ListViewItem item = this.listViewAufgabeVW.GetItemAt(e.X, e.Y);
|
|
if (item != null)
|
|
{
|
|
this.aufgabe = (Aufgabe)item.Tag;
|
|
this.groupBoxNeueAufgabe.Text = "Aufgabe bearbeiten";
|
|
this.textBoxBezeichnung.Text = this.aufgabe.Bezeichnung;
|
|
this.textBoxBeschreibung.Text = this.aufgabe.Beschreibung;
|
|
Load_comboBoxAufgabeKat();
|
|
this.comboBoxAufgabeKat.SelectedItem = this.aufgabe.Kategorie;
|
|
comboBoxAufgabeKat_SelectedValueChanged(this, EventArgs.Empty);
|
|
if (this.aufgabe.Kategorie == Kategorie.Waschstrasse)
|
|
{
|
|
this.buttonFarbe.BackColor = this.aufgabe.Farbe;
|
|
this.buttonFarbe.Visible = true;
|
|
}
|
|
}
|
|
if(!this.groupBoxNeueAufgabe.Visible) GroupBox_Visibility_State(this.groupBoxNeueAufgabe);
|
|
}
|
|
private void comboBoxAufgabeKat_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (comboBoxAufgabeKat.SelectedValue.ToString() == "Waschstrasse")
|
|
{
|
|
this.buttonFarbe.Visible = true;
|
|
}
|
|
else this.buttonFarbe.Visible = false;
|
|
|
|
}
|
|
private void GroupBox_Visibility_State(GroupBox gb)
|
|
{
|
|
if(gb.Visible) gb.Visible = false;
|
|
else gb.Visible = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// BUTTON CLICK EVENTS
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void buttonNewUser_Click(object sender, EventArgs e)
|
|
{
|
|
GroupBox_Visibility_State(this.groupBoxNeueAufgabe);
|
|
this.buttonNewUser.BackColor = Color.Gray;
|
|
this.groupBoxNeueAufgabe.Text = "Neue Aufgabe";
|
|
Load_comboBoxAufgabeKat();
|
|
Clear_controls();
|
|
}
|
|
private void buttonSpeichern_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.aufgabe == null) this.aufgabe = new Aufgabe();
|
|
this.aufgabe.Bezeichnung = this.textBoxBezeichnung.Text;
|
|
this.aufgabe.Beschreibung = this.textBoxBeschreibung.Text;
|
|
this.aufgabe.Kategorie = (Kategorie)this.comboBoxAufgabeKat.SelectedItem;
|
|
this.aufgabe.Farbe = this.buttonFarbe.BackColor;
|
|
|
|
if (this.aufgabe.Save() == 1) { Clear_controls(); FormAufgabeVW_Load(this, e); }
|
|
}
|
|
private void buttonAbbrechenAufgabe_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|