diff --git a/DataImport.cs b/DataImport.cs index 2806758..bfcd2b4 100644 --- a/DataImport.cs +++ b/DataImport.cs @@ -61,10 +61,10 @@ public class DataImport parts[7], parts[8], parts[9], - ParseInt(parts[10]), + parts[10], parts[11], parts[12], - ParseInt(parts[13]), + parts[13], parts[14], parts[15], parts[16], @@ -196,10 +196,10 @@ public class DataImport GetField("anredzus"), GetField("strasse"), GetField("strasse2"), - ParseInt(GetField("plz")), + GetField("plz"), GetField("ort"), GetField("land"), - ParseInt(GetField("pplz")), + GetField("pplz"), GetField("postfach"), GetField("name1"), GetField("name2"), diff --git a/DataStructures.cs b/DataStructures.cs index d4d8b38..171c746 100644 --- a/DataStructures.cs +++ b/DataStructures.cs @@ -70,10 +70,10 @@ public class KasPerson anredzus = ""; strasse = ""; strasse2 = ""; - plz = 0; + plz = ""; ort = ""; land = ""; - pplz = 0; + pplz = ""; postfach = ""; name1 = ""; name2 = ""; @@ -96,10 +96,10 @@ public class KasPerson string anredzus, string strasse, string strasse2, - int plz, + string plz, string ort, string land, - int pplz, + string pplz, string postfach, string name1, string name2, @@ -147,10 +147,10 @@ public class KasPerson public string anredzus { get; set; } public string strasse { get; set; } public string strasse2 { get; set; } - public int plz { get; set; } + public string plz { get; set; } public string ort { get; set; } public string land { get; set; } - public int pplz { get; set; } + public string pplz { get; set; } public string postfach { get; set; } public string name1 { get; set; } public string name2 { get; set; } diff --git a/Tasks/AddressCheck.cs b/Tasks/AddressCheck.cs index 3754c2b..0d4e3b6 100644 --- a/Tasks/AddressCheck.cs +++ b/Tasks/AddressCheck.cs @@ -9,10 +9,8 @@ public class AddressCheck { public enum ErrorTypes { - PlzTooShort, - PlzTooLong, - PPlzTooShort, - PPlzTooLong, + PlzNotUsable, + PPlzNotUsable, MayBeSameAddress, NoPLZorPPLZ } @@ -57,52 +55,64 @@ public class AddressCheck var address_component_count = 2; // cause anrede and name are first // PLZ-Prüfung - if (person.plz == 0 || person.plz == null) + if (person.plz == "" || person.plz == null) { hasFaults = true; warnings.Add(WarningTypes.NoPLZ); } else { - if ((person.plz < 10000 && string.IsNullOrWhiteSpace(person.land)) || - (person.plz < 10000 && person.land == "GER") || - (person.plz < 10000 && person.land == "DE")) + if (!AddressCreator.CheckPLZ(person.plz, person.land)) { hasFaults = true; - errors.Add(ErrorTypes.PlzTooShort); - } - else if ((person.plz > 99999 && string.IsNullOrWhiteSpace(person.land)) || - (person.plz > 99999 && person.land == "GER") || - (person.plz > 99999 && person.land == "DE")) - { - hasFaults = true; - errors.Add(ErrorTypes.PlzTooLong); + errors.Add(ErrorTypes.PlzNotUsable); } + // if ((person.plz < 10000 && string.IsNullOrWhiteSpace(person.land)) || + // (person.plz < 10000 && person.land == "GER") || + // (person.plz < 10000 && person.land == "DE")) + // { + // hasFaults = true; + // errors.Add(ErrorTypes.PlzTooShort); + // } + // else if ((person.plz > 99999 && string.IsNullOrWhiteSpace(person.land)) || + // (person.plz > 99999 && person.land == "GER") || + // (person.plz > 99999 && person.land == "DE")) + // { + // hasFaults = true; + // errors.Add(ErrorTypes.PlzTooLong); + // } } // PPLZ-Prüfung - if (person.pplz == 0 || person.pplz == null) + if (person.pplz == "" || person.pplz == null) { hasFaults = true; warnings.Add(WarningTypes.NoPPLZ); } else { - if ((person.pplz < 10000 && string.IsNullOrWhiteSpace(person.land)) || - (person.pplz < 10000 && person.land == "GER") || - (person.pplz < 10000 && person.land == "DE")) + + if (!AddressCreator.CheckPLZ(person.pplz, person.land)) { hasFaults = true; - errors.Add(ErrorTypes.PPlzTooShort); - } - else if ((person.pplz > 99999 && string.IsNullOrWhiteSpace(person.land)) || - (person.pplz > 99999 && person.land == "GER") || - (person.pplz > 99999 && person.land == "DE")) - { - hasFaults = true; - errors.Add(ErrorTypes.PPlzTooLong); + errors.Add(ErrorTypes.PPlzNotUsable); } + + // if ((person.pplz < 10000 && string.IsNullOrWhiteSpace(person.land)) || + // (person.pplz < 10000 && person.land == "GER") || + // (person.pplz < 10000 && person.land == "DE")) + // { + // hasFaults = true; + // errors.Add(ErrorTypes.PPlzTooShort); + // } + // else if ((person.pplz > 99999 && string.IsNullOrWhiteSpace(person.land)) || + // (person.pplz > 99999 && person.land == "GER") || + // (person.pplz > 99999 && person.land == "DE")) + // { + // hasFaults = true; + // errors.Add(ErrorTypes.PPlzTooLong); + // } } if (warnings.Contains(WarningTypes.NoPLZ) && warnings.Contains(WarningTypes.NoPPLZ))