예제 #1
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);
            }
        }
예제 #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 || nudPrec.Value == 0 || fileName.Equals(string.Empty)))
            {
                AdvogadoDAO   adao = new AdvogadoDAO();
                frmPedirSenha frm  = new frmPedirSenha();
                frm.ShowDialog();
                Advogado na = new Advogado()
                {
                    Nome           = txtNome.Text,
                    Endereco       = txtEnd.Text,
                    CPF            = txtCPF.Text,
                    Telefone       = txtTel.Text,
                    Email          = txtEmail.Text,
                    Nascimento     = dateNasci.Text,
                    Especializacao = cboArea.Text,
                    Foto           = copyImgToFolder(),
                    PrecoPorHR     = Convert.ToInt32(nudPrec.Value),
                    QtdCasos       = Convert.ToInt32(nudQtdC.Value),
                    User           = frm.txtUser.Text,
                    Pass           = frm.txtPass.Text
                };

                if (adao.Confirmar(na.User))
                {
                    CustomMB.Show("Já existe um advogado com esse nome de usuario cadastrado!", CustomMB.CorFundo.Vermelho);
                }
                else
                {
                    adao.Salvar(na);
                    CustomMB.Show("Advogado cadastrado com sucesso!", CustomMB.CorFundo.Verde);
                    btnClear_Click(sender, e);
                    na = null;
                }
            }
            else
            {
                CustomMB.Show("Alguns campos estão vazios!", CustomMB.CorFundo.Amarelo);
            }
        }