Beispiel #1
0
        public string this[string columnName]
        {
            get
            {
                switch (columnName)
                {
                case "Wiek":
                    if (Wiek < 0)
                    {
                        return("wiek musi byc dodatni");
                    }
                    break;

                case "Kwota":
                    if (Kwota < 0)
                    {
                        return("kwota musi byc dodatnia");
                    }
                    break;

                case "Nazwisko":
                    if (string.IsNullOrEmpty(Nazwisko))
                    {
                        return("nazwisko nie moze byc puste");
                    }
                    break;

                case "Email":
                    if (!string.IsNullOrEmpty(Email))
                    {
                        try
                        {
                            MailAddress mail = new MailAddress(Email);
                            email = Email;
                        }
                        catch (FormatException)
                        {
                            email = null;
                            return("To nie jest poprawny formal adresu email");
                        }
                    }
                    break;

                case "Pesel":
                    long pesel;
                    if (long.TryParse(Pesel, out pesel))
                    {
                        if (Pesel.ToString().Length != 11)
                        {
                            return("pesel musi miec 11 znakow!");
                        }
                    }
                    else
                    {
                        return("pesel musi miec 11 znakow!");
                    }

                    break;

                default:
                    break;
                }
                return(null);
            }
        }
Beispiel #2
0
 public override string ToString()
 {
     return(FirstName.ToString() + " " + LastName.ToString() + " " + Pesel.ToString());
 }