Exemplo n.º 1
0
        public string this[string name]
        {
            get
            {
                string result = null;

                if (name == "_Name")
                {
                    if (nameChanged)
                    {
                        if (string.IsNullOrEmpty(_Name))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.NameValidate(_Name))
                        {
                            result = "Name can contain only letters";
                        }
                    }
                }
                if (name == "Surename")
                {
                    if (surenameChanged)
                    {
                        if (string.IsNullOrEmpty(Surename))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.NameValidate(Surename))
                        {
                            result = "Name can contain only letters";
                        }
                    }
                }

                if (name == "IDCardNumber")
                {
                    if (idCardNumberChanged)
                    {
                        if (string.IsNullOrWhiteSpace(IDCardNumber.ToString()))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.EGNValidate(IDCardNumber.ToString()))
                        {
                            result = "ID Card number must be 10 digit number";
                        }

                        //else if(this["IDCardNumber"]==)
                    }
                }
                if (name == "EGN")
                {
                    if (egnChanged)
                    {
                        if (string.IsNullOrWhiteSpace(EGN.ToString()))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.EGNValidate(EGN.ToString()))
                        {
                            result = "EGN number must be 10 digit number";
                        }
                    }
                }
                if (name == "Country")
                {
                    if (countryChanged)
                    {
                        if (string.IsNullOrWhiteSpace(Country))
                        {
                            result = "Field is empty";
                        }
                    }
                }
                if (name == "City")
                {
                    if (cityChanged)
                    {
                        if (string.IsNullOrWhiteSpace(City))
                        {
                            result = "Field is empty";
                        }
                    }
                }
                if (name == "Street")
                {
                    if (streetChanged)
                    {
                        if (string.IsNullOrWhiteSpace(Street))
                        {
                            result = "Field is empty";
                        }
                    }
                }

                if (name == "Phone")
                {
                    if (phoneChanged)
                    {
                        if (string.IsNullOrWhiteSpace(Phone))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.PhoneNumberValidate(Phone))
                        {
                            result = "Wrong input";
                        }
                    }
                }
                if (name == "Email")
                {
                    if (emailChanged)
                    {
                        if (string.IsNullOrWhiteSpace(Email))
                        {
                            result = "Field is empty";
                        }
                        else if (!CarSystemGUI.Validate.EmailValidate(Email))
                        {
                            result = "Wrong input";
                        }
                    }
                }

                return(result);
            }
        }