Exemplo n.º 1
0
 void FrmCadContatosLoad(object sender, EventArgs e)
 {
     if (ReadOnly)
     {
         btnConfirma.Visible = false;
         btnCancela.Visible  = false;
         btnInclui.Visible   = false;
         btnExclui.Visible   = false;
         btnAltera.Visible   = false;
         //btnFecha.Text = "Seleciona";
         btnFecha.Top += 30;
     }
     contatos     = new cContatos();
     string where = "where COD_PARCEIRO='" + parceiro + "'";
     if (cod_contato != null)
     {
         where += " and COD_CONTATO = '" + cod_contato + "'";
     }
     this.Cursor = Cursors.WaitCursor;
     contatos.Carrega(dgvCadastro, where);
     this.Cursor = Cursors.Default;
     SetaEdicaoLocal(false);
     lblParceiro.Text = "Parceiro: " + parceiro + " - " + des_parceiro;
     if (juridica)
     {
         lblPapel.Text = "Papel";
     }
     else
     {
         lblPapel.Text = "Grau Afinidade";
     }
 }
Exemplo n.º 2
0
        void BtnConfirmaClick(object sender, EventArgs e)
        {
            string msg = "";
            bool   result;
            string codigo = edtCodigo.Text.Trim();

            if (acao == 'I')
            {
                acao = 'i';
                return;
            }
            if (acao == 'A')
            {
                acao = 'a';
                return;
            }
            string ativo = ckbAtivo.Checked ? "S" : "N";

            if (acao == 'i')
            {
                result = contatos.Inclui(parceiro, codigo,
                                         edtDescricao.Text,
                                         FONE.TiraEdicao(edtFone1.Text),
                                         FONE.TiraEdicao(edtFone2.Text),
                                         CELULAR.TiraEdicao(edtCelular.Text),
                                         edtEmail.Text,
                                         edtPapel.Text,
                                         dtpNascimento.Checked,
                                         dtpNascimento.Value,
                                         ativo,
                                         ref msg);
            }
            else
            {
                result = contatos.Altera(parceiro, codigo, edtDescricao.Text,
                                         FONE.TiraEdicao(edtFone1.Text),
                                         FONE.TiraEdicao(edtFone2.Text),
                                         CELULAR.TiraEdicao(edtCelular.Text),
                                         edtEmail.Text,
                                         edtPapel.Text,
                                         dtpNascimento.Checked,
                                         dtpNascimento.Value,
                                         ativo,
                                         ref msg);
            }
            if (!result)
            {
                if (acao == 'i')
                {
                    MessageBox.Show(codigo + "\n" + msg, "Erro na inclusão do contato", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(codigo + "\n" + msg, "Erro na alteração do contato", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            string where = "where COD_PARCEIRO='" + parceiro + "'";
            this.Cursor  = Cursors.WaitCursor;
            contatos.Carrega(dgvCadastro, where);
            this.Cursor = Cursors.Default;
            int selecionado = Procura(codigo, true);

            if (selecionado >= 0)
            {
                dgvCadastro.Rows[selecionado].Cells[0].Selected = true;
                AtualizaDados(selecionado);
                AtualizaDadosLocal(selecionado);
            }
            DesabilitaEdicao();
            SetaEdicaoLocal(false);
        }