예제 #1
0
        private bool validar()
        {
            if (String.IsNullOrWhiteSpace(txtEmail.Text) || !rg.IsMatch(txtEmail.Text))
            {
                MessageBox.Show("Preencha o campo Email adequadamente!");
                return(false);
            }
            if (String.IsNullOrWhiteSpace(txtNome.Text))
            {
                MessageBox.Show("Preencha o campo Nome!");
                return(false);
            }
            if (String.IsNullOrWhiteSpace(txtSenha.Text))
            {
                MessageBox.Show("Preencha o campo Senha!");
                return(false);
            }

            mskCPF.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            if (mskCPF.Text.Length >= 0 && mskCPF.Text.Length < 11)
            {
                MessageBox.Show("Preencha o campo CPF de modo correto!");
                return(false);
            }

            mskCPF.TextMaskFormat = MaskFormat.IncludeLiterals;

            if (!radFem.Checked && !radMasc.Checked)
            {
                MessageBox.Show("Selecione o campo Sexo!");
                return(false);
            }
            if (cmbCargo.SelectedIndex == 0)
            {
                MessageBox.Show("Preencha o campo Cargo!");
                return(false);
            }

            if (id == 0)
            {
                model = new ModelUsuario();

                DataTable dt = model.BuscaPorCampo("cpf", mskCPF.Text);
                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show("Usuario Já Cadastrado !\nProcure um CEO!");
                    Limpa();
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtConsulta.Text))
            {
                MessageBox.Show("Preencha o campo com termos a serem consultados");
                CarregaGrid();
                txtConsulta.Focus();
            }

            if (cmbCampo.SelectedText == "...")
            {
                MessageBox.Show("Escolha um campo a ser consultado");
                CarregaGrid();
                cmbCampo.Focus();
            }

            try
            {
                dgvDados.DataSource = up.BuscaPorCampo(cmbCampo.SelectedItem.ToString(), txtConsulta.Text.ToUpper());
            }
            catch (Exception exception)
            {
            }
        }