コード例 #1
0
        public void Excluir(int pId, out int retval)
        {
            if (pId < 1)
            {
                throw new Exception("Selecione antes de excluir.");
            }

            TelefoneDAL obj = new TelefoneDAL();

            obj.DELETE(pId, conStr, out retval);
        }
コード例 #2
0
        public void Alterar(Telefone telefone, out int retval)
        {
            if (telefone.Tel.Trim().Length == 0)
            {
                throw new Exception("O Telefone do Contato é Obrigatório");
            }

            if (telefone.IdContato > 1)
            {
                throw new Exception("O Nome do Contato é Obrigatório");
            }

            TelefoneDAL obj = new TelefoneDAL();

            obj.Alterar(telefone, conStr, out retval);
        }
コード例 #3
0
        public void Excluir(int pId, out int retval)
        {
            if (pId < 1)
            {
                throw new Exception("Selecione antes de excluir.");
            }

            ContatosDAL obj = new ContatosDAL();

            obj.DELETE(pId, conStr, out retval);

            if (retval > 0)
            {
                EmailDAL objEmail = new EmailDAL();
                objEmail.DELETE(pId, conStr, out retval);

                TelefoneDAL objTel = new TelefoneDAL();
                objTel.DELETE(pId, conStr, out retval);
            }
        }
コード例 #4
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            if (!validaFormulario())
            {
                Session.Add("danger", "Preencha os campos corretamente!" + erro);
                return;
            }

            Pessoa objPessoa = new Pessoa();

            objPessoa.IdPessoa = (string.IsNullOrEmpty(txtCodigo.Text)) ? 0 : Convert.ToInt32(txtCodigo.Text);

            objPessoa.CNPJ         = Convert.ToInt64(txtCNPJ.Text);
            objPessoa.NomePessoa   = txtNomeFantasia.Text;
            objPessoa.NomeFantasia = txtNomeFantasia.Text;
            objPessoa.RazaoSocial  = txtRazao.Text;
            objPessoa.Email        = txtEmail.Text;
            objPessoa.TipoPessoa   = "J";

            Telefone objTelefone = new Telefone();

            objTelefone.Numero         = txtTelefone.Text;
            objTelefone.DDD            = Convert.ToInt32(txtDd.Text);
            objTelefone.IdPessoa       = objPessoa.IdPessoa;
            objTelefone.IdTipoTelefone = Convert.ToInt32(rbTipoTelefone.SelectedValue);

            Endereco objEndereco = new Endereco();

            objEndereco.Logradouro  = txtEndereco.Text;
            objEndereco.Numero      = txtNumero.Text;
            objEndereco.CEP         = txtCEP.Text;
            objEndereco.Complemento = txtComplemento.Text;
            objEndereco.IdMunicipio = ddlMunicipio.SelectedIndex;
            objEndereco.IdEstado    = ddlEstado.SelectedIndex;
            objEndereco.IdPessoa    = objPessoa.IdPessoa;

            PessoaDAL dbPessoa = new PessoaDAL();

            if (objPessoa.IdPessoa == 0)
            {
                if (dbPessoa.InserirPessoa(objPessoa, objEndereco, objTelefone, ref erro))
                {
                    Session.Add("success", "Cadastro Efetuado com Sucesso!");
                }
                else
                {
                    Session.Add("danger", "Não foi possível efetuar o cadastro!" + erro);
                }
            }
            else
            {
                if (!dbPessoa.AtualizarPessoa(objPessoa, ref erro))
                {
                    Session.Add("danger", "Não foi possível Atualizar o cadastro!" + erro);
                    return;
                }
                FornecedorDAL dbFornecedor = new FornecedorDAL();

                if (!dbFornecedor.AtualizaFornecedor(objPessoa, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não foi possível Atualizar o cadastro!" + erro);
                    return;
                }
                TelefoneDAL dbTelefone = new TelefoneDAL();

                if (!dbTelefone.AtualizarTelefone(objTelefone, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não foi possível Atualizar o cadastro!" + erro);
                    return;
                }
                EnderecoDAL dbEndereco = new EnderecoDAL();

                if (!dbEndereco.AtualizaEndereco(objEndereco, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não foi possível Atualizar o cadastro!" + erro);
                    return;
                }
                Session.Add("success", "Cadastro Atualizado com Sucesso!");
                carregaGvFornecedor();
                limpar();
            }
        }
コード例 #5
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            validaFormulario();

            Pessoa objPessoa = new Pessoa();

            objPessoa.CNPJ         = Convert.ToInt64(txtCNPJ.Text);
            objPessoa.RazaoSocial  = txtRazao.Text;
            objPessoa.NomeFantasia = txtNomeFantasia.Text;
            objPessoa.Email        = txtEmail.Text;
            objPessoa.IdPessoa     = Convert.ToInt32(hfCodigoEmpresa.Value);

            objPessoa.telefone = new Telefone();

            objPessoa.telefone.Numero = txtNumero.Text;
            objPessoa.telefone.DDD    = Convert.ToInt32(txtDd.Text);

            objPessoa.endereco = new Endereco();

            objPessoa.endereco.Logradouro  = txtEndereco.Text;
            objPessoa.endereco.Numero      = txtNumero.Text;
            objPessoa.endereco.CEP         = txtCEP.Text;
            objPessoa.endereco.Complemento = txtComplemento.Text;
            objPessoa.endereco.IdMunicipio = ddlMunicipio.SelectedIndex;
            objPessoa.endereco.IdEstado    = ddlEstado.SelectedIndex;

            EmpresaDAL  dbEmpresa  = new EmpresaDAL();
            PessoaDAL   dbPessoa   = new PessoaDAL();
            EnderecoDAL dbEndereco = new EnderecoDAL();
            TelefoneDAL dbTelefone = new TelefoneDAL();

            if (string.IsNullOrEmpty(hfCodigoEmpresa.Value))
            {
                if (!dbPessoa.InserirPessoa(objPessoa, objPessoa.endereco, objPessoa.telefone, ref erro))
                {
                    Session.Add("danger", "Não possível efetuar o cadastro! " + erro);
                }
                Session.Add("success", "Cadastro efetuado com sucesso!");
                BindEmpresa();
            }
            else
            {
                if (!dbEmpresa.AtualizarEmpresa(objPessoa, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não possível efetuar o cadastro! " + erro);
                    return;
                }
                if (!dbEndereco.AtualizaEndereco(objPessoa.endereco, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não possível atualizar o endereço! " + erro);
                    return;
                }
                if (!dbTelefone.AtualizarTelefone(objPessoa.telefone, ref erro) && erro != "")
                {
                    Session.Add("danger", "Não possível atualizar o telefone! " + erro);
                    return;
                }
                Session.Add("success", "Cadastro atualizado com Sucesso! ");
                BindEmpresa();
            }
        }