Esempio n. 1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var name = value as string;

            if (string.IsNullOrEmpty(name))
            {
                return(ValidationResult.Success);
            }
            return(RegExValidation.IsEmailValid(name) ? ValidationResult.Success : new ValidationResult(ErrorMessageString));
        }
        private bool ValidateSubmission()
        {
            try
            {
                //if (txtStationName.Text.Length < 5)
                //{
                //    MessageBox.Show(@"Station Name is required and must be more than 5 character long", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                //    return false;
                //}
                if (txtStationKey.Text == "")
                {
                    MessageBox.Show(@"Station ID is required", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                if (txtSurname.Text.Length < 3)
                {
                    MessageBox.Show(@"Kindly provide the Administrator's Surname", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }
                if (txtFirstName.Text.Length < 3)
                {
                    MessageBox.Show(@"Kindly provide the Administrator's First Name", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                if (txtUsername.Text.Length < 8)
                {
                    MessageBox.Show(@"Kindly provide the Administrator's Username", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }
                if (txtPassword.Text.Length != 8)
                {
                    MessageBox.Show(@"Invalid Administrator's login Password. Password must be exactly 8 character long: 6 number digits and 2 special characters", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                if (txtPassword.Text.Trim() != txtConfirmPassword.Text.Trim())
                {
                    MessageBox.Show(@"Password & Confirm Password must match", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                if (txtAdminAddress.Text.Length < 10)
                {
                    MessageBox.Show(@"Invalid / Admin Residential Address", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }
                if (txtAdminMobileNo.Text.Length < 7)
                {
                    MessageBox.Show(@"Kindly provide Admin's Mobile Number", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }
                //if (!GSMHelper.ValidateMobileNumber(txtAdminMobileNo.Text))
                //{
                //    MessageBox.Show(@"Invalid Admin Mobile Number", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                //    return false;
                //}
                //if (txtAdminMobileNo.Text.Length >= 7 && txtAdminMobileNo.Text.Length <= 15)
                //{
                //    MessageBox.Show(@"Invalid Administrator's Mobile Number", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                //    return false;
                //}
                if (txtEmail.Text == "")
                {
                    MessageBox.Show(@"Administrator's Email is required", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                if (RegExValidation.IsEmailValid(txtEmail.Text.Trim()))
                {
                    return(true);
                }
                MessageBox.Show(@"Invalid Administrator's Email", @"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                MessageBox.Show(@"Unable to validate your inputs. Please check all inputs and try again later", @"Process Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }
        }