Exemplo n.º 1
0
        /// <summary>
        ///  Prüfen der Felder auf Korrektheit, ggfs. Fehlermeldung
        ///  Author: Antonios Fesenmeier
        /// </summary>
        /// <returns></returns>
        private bool CheckForm()
        {
            _IsValid = false;

            // Zunächst muss geprüft werden ob alle Pflichtfelder erfüllt sind!
            // Wenn nicht muss eine passende Fehlermeldung hinzugefügt werden.

            // Noch recht unschön für Anregungen wäre ich dankbar!
            #region checkMandatoryFields

            if (chBIsCompany.IsChecked == true)
            {
                if (_Validator.IsNullOrEmpty(txtCompanyName.Text) == false)
                {
                    this._IsValid = false;
                    _Validator.addError("Firmenname", "Bitte geben Sie den Firmennamen an!");
                }
            }

            if (_Validator.IsNullOrEmpty(txtFirstName.Text) == false)
            {
                _IsValid = false;
                _Validator.addError("Vorname", "Bitte geben Sie einen Vornamen an!");
            }


            if (_Validator.IsNullOrEmpty(txtLastName.Text) == false)
            {
                _IsValid = false;
                _Validator.addError("Nachname", "Bitte geben Sie einen Nachnamen an!");
            }

            if (_Validator.IsNullOrEmpty(txtStreet.Text) == false)
            {
                _IsValid = false;
                _Validator.addError("Straße", "Bitte geben Sie eine Straße an!");
            }
            else
            {
                _IsValid = true;
            }
            if (_Validator.IsNullOrEmpty(txtZipCode.Text) == false)
            {
                _IsValid = false;
                _Validator.addError("PLZ", "Bitte geben Sie eine Postleitzahl an!");
            }
            else
            {
                _IsValid = true;
            }
            if (_Validator.IsNullOrEmpty(txtCity.Text) == false)
            {
                _IsValid = false;
                _Validator.addError("Stadt", "Bitte geben Sie eine Stadt an!");
            }

            #endregion

            // Nachdem alle Pflichtfelder ausgefüllt wurden, wird auf deren korrekten Inhalt geprüft.
            if (_IsValid == true)
            {
                if (_Validator.IsName("Vorname", txtFirstName.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsName("Nachname", txtLastName.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsPLZ("PLZ", txtZipCode.Text) == false)
                {
                    this._IsValid = false;
                }
            }

            // Nachdem alle Pflichtfelder korrekt ausgefüllt wurden, ist es nötig weitere Felder auf Inhalte
            // und deren korrektheit zu testen!
            #region checkOptionalFields

            if (_IsValid == true)
            {
                if (_Validator.IsNullOrEmpty(txtTelNo.Text) == true &&
                    _Validator.IsPhoneNumber("Telefonnummer ", txtTelNo.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsNullOrEmpty(txtFax.Text) == true &&
                    _Validator.IsPhoneNumber("Fax-Nr.", txtFax.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsNullOrEmpty(txtMobileNo.Text) == true &&
                    _Validator.IsMobileNumber("Mobilnummer ", txtMobileNo.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsNullOrEmpty(txtEMail.Text) == true &&
                    _Validator.IsEMail("E-Mail ", txtEMail.Text) == false)
                {
                    this._IsValid = false;
                }
            }

            #endregion

            return(_IsValid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Überprüft die Eingaben im Formular
        /// </summary>
        /// <returns>Boolean, ob die Eingaben valide sind</returns>
        private bool CheckForm()
        {
            this._IsValid = true;

            // Zunächst muss geprüft werden ob alle Pflichtfelder erfüllt sind!
            // Wenn nicht muss eine passende Fehlermeldung hinzugefügt werden.

            #region checkMandatoryFields


            if (_Validator.IsNullOrEmpty(txtFirstName.Text) == false)
            {
                this._IsValid = false;
                _Validator.addError(IniParser.GetSetting("TEAM", "surname"), IniParser.GetSetting("TEAM", "surnameError"));
            }

            if (_Validator.IsNullOrEmpty(txtLastName.Text) == false)
            {
                this._IsValid = false;
                _Validator.addError(IniParser.GetSetting("TEAM", "name"), IniParser.GetSetting("TEAM", "nameError"));
            }


            if (_Validator.IsNullOrEmpty(txtStreet.Text) == false)
            {
                this._IsValid = false;
                _Validator.addError(IniParser.GetSetting("TEAM", "streat"), IniParser.GetSetting("TEAM", "streetError"));
            }

            if (_Validator.IsNullOrEmpty(txtZipCode.Text) == false)
            {
                this._IsValid = false;
                _Validator.addError(IniParser.GetSetting("TEAM", "zip"), IniParser.GetSetting("TEAM", "zipError"));
            }


            if (_Validator.IsNullOrEmpty(txtCity.Text) == false)
            {
                this._IsValid = false;
                _Validator.addError(IniParser.GetSetting("TEAM", "city"), IniParser.GetSetting("TEAM", "cityError"));
            }

            #endregion

            // Nachdem alle Pflichtfelder ausgefüllt wurden, wird auf deren korrekten Inhalt geprüft.
            if (this._IsValid == true)
            {
                if (_Validator.IsName(IniParser.GetSetting("TEAM", "surname"), txtFirstName.Text) == false)
                {
                    this._IsValid = false;
                }
                if (_Validator.IsName(IniParser.GetSetting("TEAM", "name"), txtLastName.Text) == false)
                {
                    this._IsValid = false;
                }
                if (_Validator.IsPLZ(IniParser.GetSetting("TEAM", "zip"), txtZipCode.Text) == false)
                {
                    this._IsValid = false;
                }
            }

            // Nachdem alle Pflichtfelder korrekt ausgefüllt wurden, ist es nötig weitere Felder auf Inhalte
            // und deren korrektheit zu testen!
            #region checkOptionalFields

            if (this._IsValid == true)
            {
                if (_Validator.IsNullOrEmpty(txtTelNo1.Text) == true &&
                    _Validator.IsPhoneNumber(IniParser.GetSetting("TEAM", "phone"), txtTelNo1.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsNullOrEmpty(txtMobileNo1.Text) == true &&
                    _Validator.IsMobileNumber(IniParser.GetSetting("TEAM", "mobile"), txtMobileNo1.Text) == false)
                {
                    this._IsValid = false;
                }

                if (_Validator.IsNullOrEmpty(txtEMail1.Text) == true &&
                    _Validator.IsEMail(IniParser.GetSetting("TEAM", "email"), txtEMail1.Text) == false)
                {
                    this._IsValid = false;
                }
            }

            #endregion

            return(this._IsValid);
        }
        private bool CheckChildDataGrid()
        {
            int count = 1;

            if (_ValidChilds.Count > 0)
            {
                _ValidChilds.Clear();
            }

            //Datenbestand aus Datagrid sichern
            IList <ChildModel> tempChilds = _Childs.ToList();


            //Letztes (leeres) Child entfernen
            if (_Childs.Count > 0)
            {
                _Childs.Remove(_Childs.Last());
            }
            dtgChildren.ItemsSource = _Childs;
            // Durch die Kinder itterieren
            //for (int rowIdx = 0; rowIdx < dtgChildren.Items.Count; rowIdx++)

            foreach (ChildModel actualChild in dtgChildren.ItemsSource)
            {
                if (_PartnerChildValidator.IsNullOrEmpty(actualChild.FirstName) == false)
                {
                    this._PartnerChildIsValid = false;
                    _PartnerChildValidator.addError("Vorname Kind" + count, "Bitte geben Sie den Vornamen von Kind " + count + " an!");
                }

                if (_PartnerChildValidator.IsNullOrEmpty(actualChild.FirstName) == true)
                {
                    if (_PartnerChildValidator.IsName("Vorname Kind" + count, actualChild.FirstName, "Bitte geben Sie den Vornamen von Kind " + count + " an!") == false)
                    {
                        this._PartnerChildIsValid = false;
                    }
                }

                if (_PartnerChildValidator.IsNullOrEmpty(actualChild.LastName) == false)
                {
                    this._PartnerChildIsValid = false;
                    _PartnerChildValidator.addError("Nachname Kind" + count, "Bitte geben Sie den Nachnamen von Kind " + count + " an!");
                }

                if (_PartnerChildValidator.IsNullOrEmpty(actualChild.FirstName) == true)
                {
                    if (_PartnerChildValidator.IsName("Nachname Kind" + count, actualChild.LastName, "Bitte geben Sie den Nachnamen von Kind " + count + " an!") == false)
                    {
                        this._PartnerChildIsValid = false;
                    }
                }

                DateTime date = actualChild.Birthday;
                TimeSpan ts   = System.DateTime.Now.Subtract(date);

                if (date > System.DateTime.Now || ts.TotalDays >= (365 * 120))
                {
                    MessageBox.Show("Bitte geben Sie ein korrektes Geburtsdatum an!", "Fehlerhaftes Datum", MessageBoxButton.OK, MessageBoxImage.Error);
                    this._PartnerChildIsValid = false;
                }

                count++;

                //Hinzufügen zur Liste
                if (this._PartnerChildIsValid == true)
                {
                    _ValidChilds.Add(actualChild);
                }
            }

            //löschen des letzten leeren kindes rückgängig machen
            if (this._PartnerChildIsValid == false)
            {
                _Childs = tempChilds;
                dtgChildren.ItemsSource = _Childs;
            }

            return(this._PartnerChildIsValid);
        }
Exemplo n.º 4
0
        public bool checkRevenuesTab()
        {
            clearErrorMsg();
            int count = 1;

            if (_ValidRevenues.Count > 0)
            {
                _ValidRevenues.Clear();
            }

            // Durch die Revenues itterieren
            for (int rowIdx = 0; rowIdx < dtgRevenue2.Items.Count; rowIdx++)
            {
                var currentRow = dtgRevenue2.GetRow(rowIdx);
                if (currentRow == null)
                {
                    continue;
                }
                var actualRevenue = (RevenueModel)currentRow.Item;
                if (actualRevenue.isAdded == false && actualRevenue.revAmount == "0")
                {
                    continue;
                }


                // Revenue Typ
                ContentPresenter cpRevenueType = dtgRevenue2.Columns[0].GetCellContent(currentRow) as ContentPresenter;
                var combobox = DataGridHelper.GetVisualChild <ComboBox>(cpRevenueType);
                if (combobox.SelectedItem == null)
                {
                    this._RevenuesIsValid = false;
                    _RevenuesValidator.addError("Einkommen Nr. " + count, "Bitte geben Sie den Einkommenstyp von Einkommen Nr. " + count);
                }

                //StartDatum muss gesetzt sein
                ContentPresenter cpStartDate = dtgRevenue2.Columns[2].GetCellContent(currentRow) as ContentPresenter;
                var datepickerStart          = DataGridHelper.GetVisualChild <DatePicker>(cpStartDate);
                if (datepickerStart.SelectedDate.HasValue)
                {
                    actualRevenue.revStartDate = datepickerStart.SelectedDate.Value;
                }
                else
                {
                    this._RevenuesIsValid = false;
                    _RevenuesValidator.addError("Startdatum Einkunft" + count, "Bitte geben Sie das Startdatum von Einkunft " + count + " an!");
                }

                //Enddatum muss nicht gesetzt sein, wenn aber dann nach Startdatum
                ContentPresenter cpEndDate = dtgRevenue2.Columns[3].GetCellContent(currentRow) as ContentPresenter;
                var datepickerEnd          = DataGridHelper.GetVisualChild <DatePicker>(cpEndDate);
                if (datepickerEnd.SelectedDate.HasValue && datepickerStart.SelectedDate.HasValue)
                {
                    DateTime dateEnd   = datepickerEnd.SelectedDate.GetValueOrDefault(System.DateTime.Today);
                    DateTime dateStart = datepickerStart.SelectedDate.GetValueOrDefault(System.DateTime.Today);
                    TimeSpan ts        = dateEnd.Subtract(dateStart);

                    if (ts.TotalDays < (0))
                    {
                        MessageBox.Show("Bitte geben Sie ein korrektes Enddatum an!", "Fehlerhaftes Datum", MessageBoxButton.OK, MessageBoxImage.Error);
                        datepickerEnd.SelectedDate = System.DateTime.Now;
                        this._RevenuesIsValid      = false;
                    }
                    else
                    {
                        actualRevenue.revEndDate = datepickerEnd.SelectedDate.Value;
                    }
                }
                else
                {
                    this._RevenuesIsValid = false;
                    _RevenuesValidator.addError("Enddatum Einkunft" + count, "Bitte geben Sie das Enddatum von Einkunft " + count + " an!");
                }


                //Noch ein kleines Problem beim Wert überprüfen
                //Des mit isDouble geht noch nicht
                if (_RevenuesValidator.IsNullOrEmpty(actualRevenue.revAmount) == true)
                {
                    if (_RevenuesValidator.IsDouble("Betrag Einkunft" + count, actualRevenue.revAmount, "Bitte geben Sie den Betrag der Einkunft " + count + " an!") == false)
                    {
                        this._RevenuesIsValid = false;
                    }
                }


                //Hinzufügen zur Liste
                if (this._RevenuesIsValid == true)
                {
                    _ValidRevenues.Add(actualRevenue);
                }

                count++;
            }
            return(this._RevenuesIsValid);
        }