コード例 #1
0
        // Add New Person Event
        public void Add_ClickEvent(string fullname, string age, string country)
        {
            int age_result = 0;

            try
            {
                Int32.TryParse(age, out age_result);
            }
            catch (System.Exception ex)
            {
                _logger.AddNewEntryDialogBox(ExceptionsDetails.FieldInputException.AgeField);
            }

            if (!Regex.IsMatch(fullname, @"^[a-zA-Z'./s]{1,40}$"))
            {
                _logger.AddNewEntryDialogBox(ExceptionsDetails.FieldInputException.NameField);
            }
            if (!Regex.IsMatch(country, @"^[a-zA-Z'./s]{1,40}$"))
            {
                _logger.AddNewEntryDialogBox(ExceptionsDetails.FieldInputException.CountryField);
            }

            //Get Data from Fields
            Person personFromField = new Person()
            {
                FullName = fullname, Age = age_result, Country = country
            };

            if (personFromField.FullName == String.Empty && (personFromField.Age < 0 || personFromField.Age >= 140) && personFromField.Country == String.Empty)
            {
                _logger.AddNewEntryDialogBox(ExceptionsDetails.FieldInputException.NotingToUpdate);
            }

            _personManager.AddPerson(new Person());
        }