public void textBoxEmail_Validating(object sender, CancelEventArgs e)
        {
            string mySQL = string.Empty;

            mySQL += "SELECT  * FROM [AccountDB].[dbo].[User] WHERE[AccountDB].[dbo].[User].Email = '" + txtEmail.Text.Trim() + "'";
            DataTable userData = Server_connection.executeSQL(mySQL);

            if (userData.Rows.Count > 0)
            {
                e.Cancel = true;
                errorProviderEmail.SetError(txtEmail, "User with this email already exists ");
            }
            Valid_func_delegate delegate_func = Helpers.Valid_email;

            if (validation(delegate_func, model.Email, txtEmail.Text.Trim()))
            {
                e.Cancel = false;
                errorProviderEmail.SetError(txtEmail, "");
            }
            else
            {
                e.Cancel = true;
                errorProviderEmail.SetError(txtEmail, "Email should match to template [email protected] ");
            }
        }
 private bool validation(Valid_func_delegate func, string what, string to)
 {
     if (func(to))
     {
         what = to;
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private void textBoxLastName_Validating(object sender, CancelEventArgs e)
        {
            Valid_func_delegate delegate_func = Helpers.Valid_surname_name;

            if (validation(delegate_func, model.Lastname, txtLastname.Text.Trim()))
            {
                e.Cancel = false;
                errorProviderLastName.SetError(txtLastname, "");
            }
            else
            {
                e.Cancel = true;
                errorProviderLastName.SetError(txtLastname, "Last name should consist only of letters");
            }
        }
        private void textBoxPassword_Validating(object sender, CancelEventArgs e)
        {
            Valid_func_delegate delegate_func = Helpers.Valid_password;

            if (validation(delegate_func, model.Pasword, txtPassword.Text.Trim()))
            {
                if (txtPassword.Text.Trim() == txtConfirmPassword.Text.Trim())
                {
                    e.Cancel = false;
                    errorProviderPassword.SetError(txtPassword, "");
                }
                else
                {
                    e.Cancel = true;
                    errorProviderPassword.SetError(txtPassword, "Two passwords does not matches");
                }
            }
            else
            {
                e.Cancel = true;
                errorProviderPassword.SetError(txtPassword, "Password should consist of more than 8 symbols(Upper letter, lower letter, number, special symbol  )");
            }
        }