Example #1
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                string valor = mskCPF.Text;
                if (ValidaCPF.IsCpf(valor))
                {
                    Funcionarios   func   = new Funcionarios();
                    FuncionariosBO funcBO = new FuncionariosBO();

                    func.Nome  = txtNome.Text;
                    func.Senha = txtSenha.Text;


                    if ((func.Nome == "") || (func.Nome == null) || (func.Senha == "") || (func.Senha == null))
                    {
                        MessageBox.Show("Preencha todos os campos");
                    }
                    else
                    {
                        func.Nome     = txtNome.Text.ToUpper();
                        func.Cpf      = Convert.ToInt64(mskCPF.Text);
                        func.Funcao   = cbbFuncao.SelectedItem.ToString();
                        func.Telefone = mskTelefone.Text;
                        func.Celular  = mskCelular.Text;
                        func.Senha    = txtSenha.Text;

                        funcBO.Gravar(func);
                        MessageBox.Show("Funcionário cadastrado com sucesso");

                        txtNome.Clear();
                        mskCPF.Clear();
                        cbbFuncao.SelectedIndex = -1;
                        mskTelefone.Clear();
                        mskCelular.Clear();
                        txtSenha.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("CPF Inválido!");
                    mskCPF.Clear();
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }