Example #1
0
        /// <summary>
        /// Wandelt ein FilterSet der Datenbank in eine Instanz von FilterSetModel um
        /// </summary>
        /// <param name="filterSet">DataModel.FilterSet</param>
        /// <returns>FilterSetModel</returns>
        public static FilterSetModel getFilterSetModelFromFilterSet(FilterSet filterSet)
        {
            if (filterSet == null)
                return null;

            IEnumerable<Filter> filters = Filter.GetFilters(null, filterSet.FilterSetID);

            // Name des FilterSets
            FilterSetModel filterSetModel = new FilterSetModel(filterSet.Linking);
            filterSetModel.name = filterSet.Name;

            // füge diesem filterSet alle filter hinzu
            foreach (var filter in filters)
            {
                FilterModel filterModel = new FilterModel();
                // konvertiere die strings aus der datenbank in enums
                filterModel.group = (FilterModel.Groups)Enum.Parse(typeof(FilterModel.Groups), filter.Table);
                filterModel.criterion = (FilterModel.Criterions)Enum.Parse(typeof(FilterModel.Criterions), filter.Type);
                filterModel.operation = (FilterModel.Operations)Enum.Parse(typeof(FilterModel.Operations), filter.Operation);
                filterModel.value = SafeStringParser.safeParseToStr(filter.Value);
                filterSetModel.filterList.Add(filterModel);
            }
            return filterSetModel;
        }
Example #2
0
        /// <summary>
        /// Erzeugt neues Filter-Datenbankobjekt anhand einer formletter_pattern-ID
        /// </summary>
        /// <param name="patternID"></param>
        public FormletterPatternModelDB(int patternID)
        {
            filterSetModels = new List <FilterSetModel>();
            //formletterTableAssignments = new List<FormletterTableAssignment>();
            formletterColumnCsvDocumentAssignments = new List <FormletterColumnCsvDocumentAssignment>();

            // Lese zurück
            IList <FormletterPattern> patterns = FormletterPattern.GetFormletterPatterns(patternID).ToList <FormletterPattern>();

            // Es gibt genau einen formletterPattern
            FormletterPattern pattern = patterns[0];

            // Strings füllen
            this.name                = SafeStringParser.safeParseToStr(pattern.Name);
            this.saluation_m         = SafeStringParser.safeParseToStr(pattern.SaluationM);
            this.saluation_f         = SafeStringParser.safeParseToStr(pattern.SaluationF);
            this.saluation_n         = SafeStringParser.safeParseToStr(pattern.SaluationNT);
            this.formletter_filename = SafeStringParser.safeParseToStr(pattern.FileName);
            this.csv_filename        = SafeStringParser.safeParseToStr(pattern.FileName).Replace(".odt", ".csv");
            this.letterText          = SafeStringParser.safeParseToStr(pattern.Text);

            // pattern ID
            pID = pattern.FormletterPatternID;

            // füge diesem formletterPattern alle filterSets hinzu
            IEnumerable <FilterSet> filterSets = FilterSet.GetFilterSets(null, pID);

            foreach (var set in filterSets)
            {
                // Hole die IDs alle Filter dieses FilterSets
                int fsID = set.FilterSetID;
                IEnumerable <Filter> filters = Filter.GetFilters(null, fsID);

                // Name des FilterSets
                FilterSetModel filterSetModel = new FilterSetModel(set.Linking);
                filterSetModel.name = set.Name;

                // füge diesem filterSet alle filter hinzu
                foreach (var filter in filters)
                {
                    FilterModel filterModel = new FilterModel();
                    // konvertiere die strings aus der datenbank in enums
                    filterModel.group     = (FilterModel.Groups)Enum.Parse(typeof(FilterModel.Groups), filter.Table);
                    filterModel.criterion = (FilterModel.Criterions)Enum.Parse(typeof(FilterModel.Criterions), filter.Type);
                    filterModel.operation = (FilterModel.Operations)Enum.Parse(typeof(FilterModel.Operations), filter.Operation);
                    filterModel.value     = SafeStringParser.safeParseToStr(filter.Value);
                    filterSetModel.filterList.Add(filterModel);
                }

                filterSetModels.Add(filterSetModel);
            }

            // Füge alle Spaltenverknüpfungen hinzu
            IEnumerable <ColumnAssignment> assignments = ColumnAssignment.GetColumnAssignments(null, pID);

            foreach (var assignment in assignments)
            {
                string csvCol  = SafeStringParser.safeParseToStr(assignment.CsvColumn);
                string dbTable = SafeStringParser.safeParseToStr(assignment.DatabaseTable);
                string dbCol   = SafeStringParser.safeParseToStr(assignment.DatabaseColumn);

                // parse diese strings in ihre Enum-Äquivalente
                FormletterTableAssignment.Groups eDbTable = (FormletterTableAssignment.Groups)Enum.Parse(typeof(FormletterTableAssignment.Groups), dbTable);
                FormletterTableAssignment.Fields eDbCol   = (FormletterTableAssignment.Fields)Enum.Parse(typeof(FormletterTableAssignment.Fields), dbCol);

                // erstelle eine enum-basierte tabellen-spalten-verknüpfung damit
                FormletterTableAssignment fta = new FormletterTableAssignment(eDbTable, eDbCol);

                // jetzt haben wir ein komplettes csv-datenbank-spaltenverknüpfungs-objekt
                FormletterColumnCsvDocumentAssignment colAssignment = new FormletterColumnCsvDocumentAssignment(csvCol, fta);

                this.formletterColumnCsvDocumentAssignments.Add(colAssignment);
            }
        }
        /// <summary>
        /// Erzeugt neues Filter-Datenbankobjekt anhand einer formletter_pattern-ID
        /// </summary>
        /// <param name="patternID"></param>
        public FormletterPatternModelDB(int patternID)
        {
            filterSetModels = new List<FilterSetModel>();
            //formletterTableAssignments = new List<FormletterTableAssignment>();
            formletterColumnCsvDocumentAssignments = new List<FormletterColumnCsvDocumentAssignment>();

            // Lese zurück
            IList<FormletterPattern> patterns = FormletterPattern.GetFormletterPatterns(patternID).ToList<FormletterPattern>();

            // Es gibt genau einen formletterPattern
            FormletterPattern pattern = patterns[0];

            // Strings füllen
            this.name = SafeStringParser.safeParseToStr(pattern.Name);
            this.saluation_m = SafeStringParser.safeParseToStr(pattern.SaluationM);
            this.saluation_f = SafeStringParser.safeParseToStr(pattern.SaluationF);
            this.saluation_n = SafeStringParser.safeParseToStr(pattern.SaluationNT);
            this.formletter_filename = SafeStringParser.safeParseToStr(pattern.FileName);
            this.csv_filename = SafeStringParser.safeParseToStr(pattern.FileName).Replace(".odt", ".csv");
            this.letterText = SafeStringParser.safeParseToStr(pattern.Text);

            // pattern ID
            pID = pattern.FormletterPatternID;

            // füge diesem formletterPattern alle filterSets hinzu
            IEnumerable<FilterSet> filterSets = FilterSet.GetFilterSets(null, pID);
            foreach (var set in filterSets)
            {
                // Hole die IDs alle Filter dieses FilterSets
                int fsID = set.FilterSetID;
                IEnumerable<Filter> filters = Filter.GetFilters(null, fsID);

                // Name des FilterSets
                FilterSetModel filterSetModel = new FilterSetModel(set.Linking);
                filterSetModel.name = set.Name;

                // füge diesem filterSet alle filter hinzu
                foreach (var filter in filters)
                {
                    FilterModel filterModel = new FilterModel();
                    // konvertiere die strings aus der datenbank in enums
                    filterModel.group = (FilterModel.Groups)Enum.Parse(typeof(FilterModel.Groups), filter.Table);
                    filterModel.criterion = (FilterModel.Criterions)Enum.Parse(typeof(FilterModel.Criterions), filter.Type);
                    filterModel.operation = (FilterModel.Operations)Enum.Parse(typeof(FilterModel.Operations), filter.Operation);
                    filterModel.value = SafeStringParser.safeParseToStr(filter.Value);
                    filterSetModel.filterList.Add(filterModel);
                }

                filterSetModels.Add(filterSetModel);
            }

            // Füge alle Spaltenverknüpfungen hinzu
            IEnumerable<ColumnAssignment> assignments = ColumnAssignment.GetColumnAssignments(null, pID);
            foreach (var assignment in assignments)
            {
                string csvCol = SafeStringParser.safeParseToStr(assignment.CsvColumn);
                string dbTable = SafeStringParser.safeParseToStr(assignment.DatabaseTable);
                string dbCol = SafeStringParser.safeParseToStr(assignment.DatabaseColumn);

                // parse diese strings in ihre Enum-Äquivalente
                FormletterTableAssignment.Groups eDbTable = (FormletterTableAssignment.Groups)Enum.Parse(typeof(FormletterTableAssignment.Groups), dbTable);
                FormletterTableAssignment.Fields eDbCol = (FormletterTableAssignment.Fields)Enum.Parse(typeof(FormletterTableAssignment.Fields), dbCol);

                // erstelle eine enum-basierte tabellen-spalten-verknüpfung damit
                FormletterTableAssignment fta = new FormletterTableAssignment(eDbTable, eDbCol);

                // jetzt haben wir ein komplettes csv-datenbank-spaltenverknüpfungs-objekt
                FormletterColumnCsvDocumentAssignment colAssignment = new FormletterColumnCsvDocumentAssignment(csvCol, fta);

                this.formletterColumnCsvDocumentAssignments.Add(colAssignment);
            }
        }
Example #4
0
        /// <summary>
        /// Filtere Teammitglieder anhand Filter
        /// </summary>
        /// <param name="filter">Filter-Objekt</param>
        /// <param name="teamMembers">Liste von Teammitgliedern</param>
        /// <returns></returns>
        private IEnumerable<Team> filterTeamMember(FilterModel filter, IEnumerable<Team> teamMembers)
        {
            FilterModel.Criterions criterion = filter.criterion;
            FilterModel.Operations operation = filter.operation;

            // dupliziere teamMembers
            IEnumerable<Team> editTeamMembers = teamMembers.ToList<Team>();

            int value_int;
            DateTime value_date;

            #region Kriterien und Operationen Switch-Cases
            switch (filter.criterion)
            {
                case FilterModel.Criterions.Vorname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => isStringGreaterThanString(t.FirstName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => isStringSmallerThanString(t.FirstName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Nachname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => isStringGreaterThanString(t.LastName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => isStringSmallerThanString(t.LastName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Straße_Hsnr:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => isStringGreaterThanString(t.Street, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => isStringSmallerThanString(t.Street, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.PLZ:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => t.ZipCode > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => t.ZipCode < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Wohnort:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => isStringGreaterThanString(t.City, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => isStringSmallerThanString(t.City, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Geburtsdatum:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.DateOfBirth.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.DateOfBirth.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => t.DateOfBirth > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => t.DateOfBirth < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Alter:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.Age.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.Age.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => t.Age > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => t.Age < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Aktiv:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.IsActive == parseTextBoxValueToBoolean(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !(t.IsActive == parseTextBoxValueToBoolean(filter.value)));
                            break;
                    } break;

                case FilterModel.Criterions.Teamfunktion:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editTeamMembers = editTeamMembers.Where(t => t.TeamFunction.Name.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editTeamMembers = editTeamMembers.Where(t => !t.TeamFunction.Name.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editTeamMembers = editTeamMembers.Where(t => isStringGreaterThanString(t.TeamFunction.Name, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editTeamMembers = editTeamMembers.Where(t => isStringSmallerThanString(t.TeamFunction.Name, filter.value));
                            break;
                    } break;

            #endregion

            }
            return editTeamMembers;
        }
Example #5
0
        /// <summary>
        /// Filtere Sponsoren anhand Filter
        /// </summary>
        /// <param name="filter">Filter-Objekt</param>
        /// <param name="sponsors">Liste von Sponsoren</param>
        /// <returns></returns>
        private IEnumerable<Sponsor> filterSponsor(FilterModel filter, IEnumerable<Sponsor> sponsors)
        {
            FilterModel.Criterions criterion = filter.criterion;
            FilterModel.Operations operation = filter.operation;

            // dupliziere sponsors
            IEnumerable<Sponsor> editSponsors = sponsors.ToList<Sponsor>();

            int value_int;

            #region Kriterien und Operationen Switch-Cases
            switch (filter.criterion)
            {
                case FilterModel.Criterions.Vorname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => isStringGreaterThanString(s.FirstName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => isStringSmallerThanString(s.FirstName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Nachname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => isStringGreaterThanString(s.LastName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => isStringSmallerThanString(s.LastName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Kontaktperson:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.ContactPerson.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.ContactPerson.Equals(filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Straße_Hsnr:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => isStringGreaterThanString(s.Street, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => isStringSmallerThanString(s.Street, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.PLZ:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => s.ZipCode > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => s.ZipCode < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Wohnort:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => isStringGreaterThanString(s.City, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => isStringSmallerThanString(s.City, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Firma:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.CompanyName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !s.CompanyName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editSponsors = editSponsors.Where(s => isStringGreaterThanString(s.CompanyName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editSponsors = editSponsors.Where(s => isStringSmallerThanString(s.CompanyName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Aktiv:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.IsActive == parseTextBoxValueToBoolean(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !(s.IsActive == parseTextBoxValueToBoolean(filter.value)));
                            break;
                    } break;

                case FilterModel.Criterions.Serienbrief_erlaubt:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editSponsors = editSponsors.Where(s => s.IsFormLetterAllowed == parseTextBoxValueToBoolean(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editSponsors = editSponsors.Where(s => !(s.IsFormLetterAllowed == parseTextBoxValueToBoolean(filter.value)));
                            break;
                    } break;
            }
            #endregion

            return editSponsors;
        }
Example #6
0
        /// <summary>
        /// Filtere Kunden anhand Filter
        /// </summary>
        /// <param name="filter">Filter-Objekt</param>
        /// <param name="persons">Liste von Personen</param>
        /// <returns></returns>
        private IEnumerable<Person> filterCustomer(FilterModel filter, IEnumerable<Person> persons)
        {
            FilterModel.Criterions criterion = filter.criterion;
            FilterModel.Operations operation = filter.operation;

            // dupliziere persons
            IEnumerable<Person> editPersons = persons.ToList<Person>();

            int value_int;
            DateTime value_date;

            #region Kriterien und Operationen Switch-Cases
            switch (filter.criterion)
            {
                case FilterModel.Criterions.Vorname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.FirstName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.FirstName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.FirstName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Nachname:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.LastName.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.LastName, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.LastName, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Straße_Hsnr:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.Street.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.Street, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.Street, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.PLZ:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.ZipCode.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.ZipCode > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.ZipCode < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Wohnort:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.City.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.City, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.City, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Geburtsdatum:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.DateOfBirth.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.DateOfBirth.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.DateOfBirth > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.DateOfBirth < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Alter:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.Age.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.Age.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.Age > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.Age < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Letzter_Einkauf:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.LastPurchase.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.LastPurchase.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.LastPurchase > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.LastPurchase < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Anzahl_Kinder:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.NumberOfChildren.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.NumberOfChildren.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.NumberOfChildren > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.NumberOfChildren < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Anzahl_Personen:
                    if (!(int.TryParse(filter.value, out value_int)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.NumberOfPersonInHousholdInteger.Equals(value_int));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.NumberOfPersonInHousholdInteger.Equals(value_int));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.NumberOfPersonInHousholdInteger > value_int);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.NumberOfPersonInHousholdInteger < value_int);
                            break;
                    } break;

                case FilterModel.Criterions.Nationalität:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.Nationality.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.Nationality.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.Nationality, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.Nationality, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Geburtsland:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.CountryOfBirth.Equals(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.CountryOfBirth.Equals(filter.value));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => isStringGreaterThanString(p.CountryOfBirth, filter.value));
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => isStringSmallerThanString(p.CountryOfBirth, filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Gültigkeitsbeginn:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.ValidityStart.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.ValidityStart.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.ValidityStart > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.ValidityStart < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Gültigkeitsende:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.ValidityEnd.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.ValidityEnd.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.ValidityEnd > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.ValidityEnd < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Erfassungsdatum:
                    if (!(DateTime.TryParseExact(filter.value, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out value_date)))
                        break;
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.CreationDate.Equals(value_date));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.CreationDate.Equals(value_date));
                            break;
                        case FilterModel.Operations.größer:
                            editPersons = editPersons.Where(p => p.CreationDate > value_date);
                            break;
                        case FilterModel.Operations.kleiner:
                            editPersons = editPersons.Where(p => p.CreationDate < value_date);
                            break;
                    } break;

                case FilterModel.Criterions.Verheiratet:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.IsMarried == parseTextBoxValueToBoolean(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !p.IsMarried == parseTextBoxValueToBoolean(filter.value));
                            break;
                    } break;

                case FilterModel.Criterions.Aktiv:
                    switch (filter.operation)
                    {
                        case FilterModel.Operations.gleich:
                            editPersons = editPersons.Where(p => p.IsActive == parseTextBoxValueToBoolean(filter.value));
                            break;
                        case FilterModel.Operations.ungleich:
                            editPersons = editPersons.Where(p => !(p.IsActive == parseTextBoxValueToBoolean(filter.value)));
                            break;
                    } break;
            }
            #endregion

            return editPersons;
        }
Example #7
0
 /// <summary>
 /// Fügt Filter anhand FilterModel hinzu
 /// </summary>
 /// <param name="filter">FilterModel</param>
 public void addFilter(FilterModel filter)
 {
     if (filter != null)
         this.filterList.Add(filter);
 }
 /// <summary>
 /// Prüfe ob ein gleicher Filter bereits existiert
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 private bool checkForDuplicateFilters(FilterModel filter)
 {
     foreach (var subitem in listBox1.Items)
     {
         if (subitem.ToString() == filter.ToString())
             return true;
     }
     return false;
 }
        /// <summary>
        /// Filter hinzufügen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addFilter_Click(object sender, RoutedEventArgs e)
        {
            if ((cbGroup.SelectionBoxItem.ToString() == "" ||
                 cbCriterion.SelectionBoxItem.ToString() == "" ||
                 cbOperation.SelectionBoxItem.ToString() == "" ||
                 //tbValue.Text.ToString() == "" || // Text darf leer sein für z.B. Phone != ""
                 false ))
            {
                return;
            }
            listBox1.IsEnabled = true;
            saveFilterSet.IsEnabled = true;

            FilterModel filter = new FilterModel();
            filter.group = (FilterModel.Groups)((cbGroup.SelectedItem as ComboBoxItems).enumVal);
            filter.criterion = (FilterModel.Criterions)((cbCriterion.SelectedItem as ComboBoxItems).enumVal);
            filter.operation = (FilterModel.Operations)((cbOperation.SelectedItem as ComboBoxItems).enumVal);
            filter.value = tbValue.Text;

            if (!checkForDuplicateFilters(filter))
            {
                listBox1.Items.Add(filter);
                btDeleteButton.IsEnabled = true;
                tbValue.Text = "";
            }
        }