private bool ValidateForm() { bool isValid = true; if (!_validator.IsStringValid(FilmNameTextBox.Text)) { FindErrorProvider.SetError(FilmNameTextBox, "String must be russian and not contains special simbols"); FilmNameTextBox.Focus(); isValid = false; } if (!YearFromTextBox.IsYearValid()) { isValid = false; } if (!YearToTextBox.IsYearValid()) { isValid = false; } if (!_validator.IsStringValid(CountryTextBox.Text)) { FindErrorProvider.SetError(CountryTextBox, "String must be russian and not contains special simbols"); CountryTextBox.Focus(); isValid = false; } if (!_validator.IsStringValid(ProducerTextBox.Text)) { ProducerTextBox.Focus(); FindErrorProvider.SetError(ProducerTextBox, "String must be russian and not contains special simbols"); isValid = false; } if (!_validator.IsStringValid(MainActorsTextBox.Text)) { FindErrorProvider.SetError(MainActorsTextBox, "String must be russian and not contains special simbols"); MainActorsTextBox.Focus(); isValid = false; } else { FindErrorProvider.SetError(FilmNameTextBox, String.Empty); } return(isValid); }
private string TextBoxValidation() { string errorMessage = string.Empty; if (FirstNameTextBox.Text.Length > 0 && FirstNameTextBox.Text != null) { this.FirstName = FirstNameTextBox.Text; } else { errorMessage = "Invalid entry for first name. Please enter a valid first name"; FirstNameTextBox.Focus(); } if (MiddleNameTextBox.Text != null) { this.MiddleName = MiddleNameTextBox.Text; } else { errorMessage = "Invalid entry for middle name. Please enter a valid middle name"; MiddleNameTextBox.Focus(); } if (LastNameTextBox.Text.Length > 0 && LastNameTextBox.Text != null) { this.LastName = LastNameTextBox.Text; } else { errorMessage = "Invalid entry for last name. Please enter a valid last name"; LastNameTextBox.Focus(); } if (CityTextBox.Text.Length > 0 && CityTextBox.Text != null) { this.City = CityTextBox.Text; } else { errorMessage = "Invalid entry for city. Please enter a valid city"; CityTextBox.Focus(); } if (StateTextBox.Text.Length > 0 && StateTextBox.Text != null) { this.State = StateTextBox.Text; } else { errorMessage = "Invalid entry for state. Please enter a valid state"; StateTextBox.Focus(); } if (CountryTextBox.Text.Length > 0 && CountryTextBox.Text != null) { this.Country = CountryTextBox.Text; } else { errorMessage = "Invalid entry for Country. Please enter a valid country"; CountryTextBox.Focus(); } if (PhoneNumberTextBox.Text.Length > 0 && PhoneNumberTextBox.Text != null) { this.PhoneNumber = PhoneNumberTextBox.Text; } else { errorMessage = "Invalid entry for phone number. Please enter a valid phone number"; PhoneNumberTextBox.Focus(); } if (EmailAddressTextBox.Text.Length > 0 && EmailAddressTextBox.Text != null) { this.EmailAddress = EmailAddressTextBox.Text; } else { errorMessage = "Invalid entry for email address. Please enter a valid email address"; EmailAddressTextBox.Focus(); } return(errorMessage); }