示例#1
0
        public Object ExecutarOpBD(char _c, Advogado _o)
        {
            try
            {
                AdvogadoDAO dao = new AdvogadoDAO();
                switch (_c)
                {
                case 'i':
                    return(dao.Inserir(_o));

                case 'd':
                    return(dao.Deletar(_o.Id_adv));

                case 'a':
                    return(dao.Atualizar(_o));

                case 't':
                    return(dao.ListarTodos());

                case 'o':
                    return(dao.BuscarPorID(_o.Id_adv));

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!(txtNome.Text.Equals(string.Empty) || txtEnd.Text.Equals(string.Empty) || txtCPF.Text.Length != 14 || txtTel.Text.Length != 15 || txtEmail.Text.Equals(string.Empty) || !txtEmail.Text.Contains("@") || cboArea.SelectedIndex == -1 || txtUser.Text.Equals(string.Empty) || txtPass.Text.Equals(string.Empty) || nudPrec.Value == 0))
            {
                a.Nome           = txtNome.Text;
                a.Endereco       = txtEnd.Text;
                a.CPF            = txtCPF.Text;
                a.Telefone       = txtTel.Text;
                a.Email          = txtEmail.Text;
                a.Nascimento     = dateNasci.Text;
                a.Especializacao = cboArea.Text;
                try
                {
                    a.Foto = copyImgToFolder();
                }
                catch (Exception)
                { }
                a.PrecoPorHR = Convert.ToInt32(nudPrec.Value);
                a.QtdCasos   = Convert.ToInt32(nudQtdC.Value);
                a.Pass       = txtPass.Text;

                if (a.User.Equals(txtUser))
                {
                    a.User = txtUser.Text;
                    if (adao.Confirmar(a.User))
                    {
                        CustomMB.Show("Já existe um advogado com esse nome de usuario cadastrado!", CustomMB.CorFundo.Vermelho);
                    }
                    else
                    {
                        adao.Atualizar();
                        CustomMB.Show("Advogado atualizado com sucesso!", CustomMB.CorFundo.Verde);
                        this.Dispose();
                    }
                }
                else
                {
                    adao.Atualizar();
                    CustomMB.Show("Advogado atualizado com sucesso!", CustomMB.CorFundo.Verde);
                }
            }
            else
            {
                CustomMB.Show("Alguns campos estão vazios!", CustomMB.CorFundo.Amarelo);
            }
        }