コード例 #1
0
ファイル: fClienteBasico.cs プロジェクト: ricardo-xavier/soft
        void BtnConfirmaClick(object sender, EventArgs e)
        {
            if (btnConfirma.Text.CompareTo("Seleciona") == 0)
            {
                result = true;
                Close();
                return;
            }
            if (edtCodigo.Text.Trim().Length == 0)
            {
                MessageBox.Show("Código", "Campo obrigatório",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                edtCodigo.Focus();
                return;
            }
            if (edtRazao.Text.Trim().Length == 0)
            {
                MessageBox.Show("Código", "Campo obrigatório",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                edtCodigo.Focus();
                return;
            }
            string     msg       = "";
            cParceiros parceiros = new cParceiros();

            result = parceiros.IncluiRapido(edtCodigo.Text,
                                            edtRazao.Text,
                                            FONE.TiraEdicao(edtFone1.Text),
                                            FONE.TiraEdicao(edtFone2.Text),
                                            FONE.TiraEdicao(edtCelular.Text),
                                            FONE.TiraEdicao(edtFAX.Text),
                                            edtEmail.Text,
                                            ref msg);
            if (!result)
            {
                MessageBox.Show(edtCodigo.Text + "\n" + msg, "Erro na inclusão do cliente", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (edtContato.Text.Trim().Length == 0)
            {
                cContatos contatos = new cContatos();
                result = contatos.Inclui(edtCodigo.Text,
                                         edtContato.Text,
                                         edtNome.Text,
                                         FONE.TiraEdicao(edtFoneContato1.Text),
                                         FONE.TiraEdicao(edtFoneContato2.Text),
                                         FONE.TiraEdicao(edtCelularContato.Text),
                                         FONE.TiraEdicao(edtEmailContato.Text),
                                         edtPapel.Text, false, DateTime.Now,
                                         "S", ref msg);
                if (!result)
                {
                    MessageBox.Show(edtContato.Text + "\n" + msg, "Erro na inclusão do contato", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            result = true;
            Close();
        }
コード例 #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);
        }