/// <summary>
        /// Creates a new Ausgangsrechnung with the provided parameters
        /// </summary>
        /// <param name="sender">The sending button</param>
        /// <param name="e">The EventArgs</param>
        private void CreateAusgangsrechnung(object sender, EventArgs e)
        {
            // reset message label
            this.ausgangsrechnungMsgLabel.Visible = false;
            this.ausgangsrechnungMsgLabel.Text = string.Empty;

            // check if a projekt is selected
            if (this.projekteComboBox.SelectedIndex < 1)
            {
                this.ausgangsrechnungMsgLabel.Visible = true;
                this.ausgangsrechnungMsgLabel.Text = "Kein Projekt ausgewählt";
                this.ausgangsrechnungMsgLabel.ForeColor = Color.Red;
                return;
            }

            AusgangsrechnungTable table = new AusgangsrechnungTable();

            // Get values
            int projektID = GlobalActions.GetIdFromCombobox(this.projekteComboBox.SelectedValue.ToString(), this.ausgangsrechnungMsgLabel);
            string unpaidBalanceString = this.unpaidBalanceTextBox.Text;
            string rechnungstitelString = this.rechnungstitelTextBox.Text;

            double unpaidBalance;

            // Validate values
            IRule posintval = new PositiveIntValidator();
            IRule posdoubval = new PositiveDoubleValidator();
            IRule lnhsv = new LettersNumbersHyphenSpaceValidator();
            IRule slv = new StringLength150Validator();

            DataBindingFramework.BindFromInt(projektID.ToString(), "ProjektID", this.ausgangsrechnungMsgLabel, false, posintval);
            unpaidBalance = DataBindingFramework.BindFromDouble(unpaidBalanceString, "Offener Betrag", this.ausgangsrechnungMsgLabel, false, posdoubval);
            DataBindingFramework.BindFromString(rechnungstitelString, "Rechnungstitel", this.ausgangsrechnungMsgLabel, false, lnhsv, slv);

            // return if errors occured
            if (this.ausgangsrechnungMsgLabel.Visible)
            {
                return;
            }

            // no errors, send values to business layer
            RechnungsManager saver = new RechnungsManager();

            try
            {
                saver.CreateAusgangsrechnung(projektID, unpaidBalance, rechnungstitelString);
            }
            catch (InvalidInputException)
            {
                this.logger.Log(Logger.Level.Error, "The business layer returned the provided values for saving a new Ausgangsrechnung with an error.");
            }
            catch (DataBaseException ex)
            {
                this.logger.Log(Logger.Level.Error, "A serious problem with the database occured while trying to save a new Ausgangsrechnung.");
                this.logger.Log(Logger.Level.Error, ex.Message);
                this.ausgangsrechnungMsgLabel.Text = ex.Message;
                this.ausgangsrechnungMsgLabel.ForeColor = Color.Red;
                this.ausgangsrechnungMsgLabel.Show();
            }

            // show success message label (only if saving has been successful)
            if (!this.ausgangsrechnungMsgLabel.Visible)
            {
                GlobalActions.ShowSuccessLabel(this.ausgangsrechnungMsgLabel);
            }
        }
        // If NE tab visible, create Eingangsrechnung AND Buchungszeile. Otherwise, only create Buchungszeile to current Eingangsrechnung
        private void AddBuchungszeile(object sender, EventArgs e)
        {
            this.eingangsrechnungMsgLabel.Text = string.Empty;
            this.eingangsrechnungMsgLabel.Hide();

            // in case of new Eingangsrechnung, the input fields are not locked
            if (!this.eingangsrechnungBezeichnungTextBox.ReadOnly == true)
            {
                this.logger.Log(Logger.Level.Info, "Beginning with new Eingangsrechnung");

                // create new Eingangsrechnung
                this.eingangsrechnung = new EingangsrechnungTable();

                // check Eingangsrechnungs input fields
                if (this.existingKontakteComboBox.SelectedIndex < 1)
                {
                    this.eingangsrechnungMsgLabel.Text = "Keine KundenID gewählt!";
                    this.eingangsrechnungMsgLabel.ForeColor = Color.Red;
                    this.eingangsrechnungMsgLabel.Show();
                    return;
                }

                // get KontaktID out of Combobox
                string kontaktID = this.existingKontakteComboBox.SelectedItem.ToString();
                this.eingangsrechnung.KontaktID = -1;

                try
                {
                    this.eingangsrechnung.KontaktID = GlobalActions.GetIdFromCombobox(kontaktID, this.eingangsrechnungMsgLabel);
                }
                catch (InvalidInputException)
                {
                    logger.Log(Logger.Level.Error, "Unknown Exception while getting ID from Projekte from AngeboteTab!");
                }

                // check for valid KontaktID
                IRule posint = new PositiveIntValidator();
                DataBindingFramework.BindFromInt(this.eingangsrechnung.KontaktID.ToString(), "KontaktID", this.eingangsrechnungMsgLabel, false, posint);

                // check other vals
                eingangsrechnung.Rechnungsdatum = this.eingangsrechnungDatePicker.Value.ToShortDateString();
                eingangsrechnung.Bezeichnung = this.eingangsrechnungBezeichnungTextBox.Text;

                // check date
                IRule dateval = new DateValidator();
                DataBindingFramework.BindFromString(eingangsrechnung.Rechnungsdatum, "Datum", this.eingangsrechnungMsgLabel, false, dateval);

                // check description
                IRule lnhsv = new LettersNumbersHyphenSpaceValidator();
                IRule slv = new StringLength150Validator();
                DataBindingFramework.BindFromString(eingangsrechnung.Bezeichnung, "Bez. Eingangsrechnung", this.eingangsrechnungMsgLabel, false, lnhsv, slv);

                // add Archivierungspfad
                // Year/Month/Date/KontaktID/Bezeichnung
                eingangsrechnung.Archivierungspfad = DateTime.Now.Year.ToString() + '/' + DateTime.Now.Month.ToString() + '/' + DateTime.Now.ToShortDateString() + '-' + this.eingangsrechnung.KontaktID + '-' + this.eingangsrechnung.Bezeichnung;

                // check for errors
                if (this.eingangsrechnungMsgLabel.Visible)
                { return; }
            }

            // save Buchungszeile
            this.AddBuchungszeileToDataGridView();

            // lock Eingangsrechnungs elements, if not already done
            if (!this.eingangsrechnungBezeichnungTextBox.ReadOnly == true)
            {
                this.existingKontakteComboBox.Enabled = false;
                this.eingangsrechnungDatePicker.Enabled = false;
                this.eingangsrechnungBezeichnungTextBox.ReadOnly = true;
                this.logger.Log(Logger.Level.Info, "Locked Eingangsrechnungs-elements");
            }
        }
        // add Buchungszeile
        private void AddBuchungszeileToDataGridView()
        {
            string betrag = this.eingangsrechnungBetragTextBox.Text;
            string bezeichnung = this.buchungszeileBezeichnungTextBox.Text;

            IRule pdv = new PositiveDoubleValidator();
            IRule lnhsv = new LettersNumbersHyphenSpaceValidator();
            IRule slv = new StringLength150Validator();

            // Create Buchungszeilen business object
            BuchungszeilenTable buchungszeile = new BuchungszeilenTable();
            buchungszeile.Bezeichnung = DataBindingFramework.BindFromString(bezeichnung, "Bezeichnung", this.eingangsrechnungMsgLabel, false, lnhsv, slv);
            buchungszeile.BetragNetto = DataBindingFramework.BindFromDouble(betrag, "Betrag", this.eingangsrechnungMsgLabel, false, pdv);
            buchungszeile.KategorieID = this.kategorieComboBox.SelectedIndex+1;
            buchungszeile.Buchungsdatum = DateTime.Now.ToShortDateString();

            // in case of errors, do not continue with saving new Eingangsrechnung
            if (this.eingangsrechnungMsgLabel.Visible)
            { return; }

            // add to DataGridView
            this.buchungszeilenBindingSource.Add(buchungszeile);
            GlobalActions.ShowSuccessLabel(this.eingangsrechnungMsgLabel);
        }