Exemple #1
0
 public void Inserir(SPC_CPF spc)
 {
     try
     {
         string         cone  = Cript_Decript.DeCifra(ConfigurationManager.AppSettings["Conexao"]);
         SqlParameter[] param = new SqlParameter[0x15];
         param[0]          = new SqlParameter("@CPF", SqlDbType.VarChar);
         param[0].Value    = spc.CPF;
         param[1]          = new SqlParameter("@NOME", SqlDbType.VarChar);
         param[1].Value    = spc.Nome == null ? String.Empty : spc.Nome;
         param[2]          = new SqlParameter("@NOMEMAE", SqlDbType.VarChar);
         param[2].Value    = spc.NomeMae == null ? String.Empty : spc.NomeMae;
         param[3]          = new SqlParameter("@NOMEPAI", SqlDbType.VarChar);
         param[3].Value    = spc.NomePai == null ? String.Empty : spc.NomePai;
         param[4]          = new SqlParameter("@DTNASC", SqlDbType.DateTime);
         param[4].Value    = spc.Nasc.ToShortDateString().Equals("01/01/0001") ? null : spc.Nasc.ToShortDateString();
         param[5]          = new SqlParameter("@ENDERECO", SqlDbType.VarChar);
         param[5].Value    = spc.Ende == null ? String.Empty : spc.Ende;
         param[6]          = new SqlParameter("@ESTCIV", SqlDbType.VarChar);
         param[6].Value    = spc.EstCiv == null ? String.Empty : spc.EstCiv;
         param[7]          = new SqlParameter("@UF", SqlDbType.VarChar);
         param[7].Value    = spc.UF == null ? String.Empty : spc.UF;
         param[8]          = new SqlParameter("@IDADE", SqlDbType.Int);
         param[8].Value    = Versioned.IsNumeric(spc.Idade) ? Convert.ToInt32(spc.Idade) : 0;
         param[9]          = new SqlParameter("@TituloEleitor", SqlDbType.VarChar);
         param[9].Value    = spc.TitEleitor == null ? String.Empty : spc.TitEleitor;
         param[10]         = new SqlParameter("@SEXO", SqlDbType.VarChar);
         param[10].Value   = spc.Sexo == null ? String.Empty : spc.Sexo;
         param[11]         = new SqlParameter("@SIGNO", SqlDbType.VarChar);
         param[11].Value   = spc.Signo == null ? String.Empty : spc.Signo;
         param[12]         = new SqlParameter("@DTSITUACAO", SqlDbType.DateTime);
         param[12].Value   = spc.DtSituacao.ToShortDateString().Equals("01/01/0001") ? null : spc.DtSituacao.ToShortDateString();
         param[13]         = new SqlParameter("@DSCSITUACAO", SqlDbType.VarChar);
         param[13].Value   = spc.DscSituacao == null ? String.Empty : spc.DscSituacao;
         param[14]         = new SqlParameter("@UFSITUACAO", SqlDbType.VarChar);
         param[14].Value   = spc.UfSituacao == null ? String.Empty : spc.UfSituacao;
         param[15]         = new SqlParameter("@DDDCEL", SqlDbType.VarChar);
         param[15].Value   = spc.DDDCel == null ? String.Empty : spc.DDDCel;
         param[0x10]       = new SqlParameter("@TELCEL", SqlDbType.VarChar);
         param[0x10].Value = spc.TelCel == null ? String.Empty : spc.TelCel;
         param[0x11]       = new SqlParameter("@DDDCOM", SqlDbType.VarChar);
         param[0x11].Value = spc.DDDCom == null ? String.Empty : spc.DDDCom;
         param[0x12]       = new SqlParameter("@TELCOM", SqlDbType.VarChar);
         param[0x12].Value = spc.TelCom == null ? String.Empty : spc.TelCom;
         param[0x13]       = new SqlParameter("@DDDRES", SqlDbType.VarChar);
         param[0x13].Value = spc.DDDRes == null ? String.Empty : spc.DDDRes;
         param[20]         = new SqlParameter("@TELRES", SqlDbType.VarChar);
         param[20].Value   = spc.TelRes == null ? String.Empty : spc.TelRes;
         long resultConsulta = Convert.ToInt32(SqlHelper.ExecuteScalar(cone, CommandType.StoredProcedure, "intouch..prc_SPC_Inserir_Consulta", param));
         if ((spc.Cheque != null) && (spc.Cheque.Count > 0))
         {
             param = new SqlParameter[13];
             foreach (SPC_CPF_CHEQUE item in spc.Cheque)
             {
                 param[0]        = new SqlParameter("@ID", SqlDbType.BigInt);
                 param[0].Value  = resultConsulta;
                 param[1]        = new SqlParameter("@ID_TP_CONSULTA", SqlDbType.Int);
                 param[1].Value  = spc.TipoConsulta;
                 param[2]        = new SqlParameter("@CODALINEA", SqlDbType.BigInt);
                 param[2].Value  = DBNull.Value.Equals(item.CodAlinea) ? String.Empty : item.CodAlinea.ToString();
                 param[3]        = new SqlParameter("@DSCALINEA", SqlDbType.VarChar);
                 param[3].Value  = item.DscAlinea.ToString() != "" ? item.DscAlinea : String.Empty;
                 param[4]        = new SqlParameter("@BANCO", SqlDbType.VarChar);
                 param[4].Value  = item.Banco.ToString() != "" ? item.Banco.ToString() : String.Empty;
                 param[5]        = new SqlParameter("@NUMAGENCIA", SqlDbType.VarChar);
                 param[5].Value  = item.NumAgencia.ToString() != "" ? item.NumAgencia.ToString() : String.Empty;
                 param[6]        = new SqlParameter("@NUMCTACORRENTE", SqlDbType.VarChar);
                 param[6].Value  = item.NumCC != "" ? item.NumCC : String.Empty;
                 param[7]        = new SqlParameter("@DTEMISSAO", SqlDbType.DateTime);
                 param[7].Value  = item.DtEmissao.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DtEmissao.ToShortDateString();
                 param[8]        = new SqlParameter("@NUMCHEQUE", SqlDbType.VarChar);
                 param[8].Value  = item.NumCheque.ToString() != "" ? item.NumCheque.ToString() : String.Empty;
                 param[9]        = new SqlParameter("@VLCHEQUE", SqlDbType.Decimal);
                 param[9].Value  = item.VlCheque.ToString() != "" ? item.VlCheque.ToString() : String.Empty;
                 param[10]       = new SqlParameter("@NOMEASSOCIADOCHEQUE", SqlDbType.VarChar);
                 param[10].Value = item.NmAssociado != "" ? item.NmAssociado : String.Empty;
                 param[11]       = new SqlParameter("@NOMEENTIDADECHEQUE", SqlDbType.VarChar);
                 param[11].Value = item.NmEntidade != "" ? item.NmEntidade : String.Empty;
                 param[12]       = new SqlParameter("@ORIGEMCHEQUE", SqlDbType.VarChar);
                 param[12].Value = item.Origem != "" ? item.Origem : String.Empty;
                 SqlHelper.ExecuteNonQuery(cone, CommandType.StoredProcedure, "intouch..prc_SPC_Inserir_Cheque", param);
             }
         }
         if ((spc.ConsultaRealizada != null) && (spc.ConsultaRealizada.Count > 0))
         {
             param = new SqlParameter[8];
             foreach (SPC_CPF_ConsultaRealizada item in spc.ConsultaRealizada)
             {
                 param[0]       = new SqlParameter("@ID", SqlDbType.BigInt);
                 param[0].Value = resultConsulta;
                 param[1]       = new SqlParameter("@ID_TP_CONSULTA", SqlDbType.Int);
                 param[1].Value = spc.TipoConsulta;
                 param[2]       = new SqlParameter("@QUANTIDADEDIASCONSULTADOS", SqlDbType.BigInt);
                 param[2].Value = !Versioned.IsNumeric(item.QuantidadeDiasConsultados) ? 0 : item.QuantidadeDiasConsultados;
                 param[3]       = new SqlParameter("@DataUltimaOcorrencia", SqlDbType.DateTime);
                 param[3].Value = item.DataUltimaOcorrencia.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DataUltimaOcorrencia.ToShortDateString();
                 param[4]       = new SqlParameter("@DataConsulta", SqlDbType.DateTime);
                 param[4].Value = item.DataConsulta.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DataConsulta.ToShortDateString();
                 param[5]       = new SqlParameter("@NomeAssociado", SqlDbType.VarChar);
                 param[5].Value = item.NomeAssociado == null ? String.Empty : item.NomeAssociado;
                 param[6]       = new SqlParameter("@NomeEntidade", SqlDbType.VarChar);
                 param[6].Value = item.NomeEntidade == null ? String.Empty : item.NomeEntidade;
                 param[7]       = new SqlParameter("@Origem", SqlDbType.VarChar);
                 param[7].Value = item.Origem == null ? String.Empty : item.Origem;
             }
             SqlHelper.ExecuteNonQuery(cone, CommandType.StoredProcedure, "intouch..prc_SPC_Inserir_ConsultaRealizada", param);
         }
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         Exception ex = exception1;
         ProjectData.ClearProjectError();
     }
 }
Exemple #2
0
        public void Inserir_Empresa(SPC_CNPJ pj)
        {
            string cone = Cript_Decript.DeCifra(ConfigurationManager.AppSettings["Conexao"]);

            SqlParameter[] param = new SqlParameter[0x13];
            try
            {
                SPC_CNPJ cnpjXPTO = pj;
                param[0]          = new SqlParameter("@CNPJ", SqlDbType.VarChar);
                param[0].Value    = cnpjXPTO.CNPJ == null ? String.Empty : cnpjXPTO.CNPJ.ToString();
                param[1]          = new SqlParameter("@Razao", SqlDbType.VarChar);
                param[1].Value    = cnpjXPTO.Razao == null ? String.Empty : cnpjXPTO.Razao.ToString();
                param[2]          = new SqlParameter("@Razao_Anterior", SqlDbType.VarChar);
                param[2].Value    = cnpjXPTO.RazaoAnterior == null ? String.Empty : cnpjXPTO.RazaoAnterior.ToString();
                param[3]          = new SqlParameter("@Bairro", SqlDbType.VarChar);
                param[3].Value    = cnpjXPTO.Endereco.Bairro == null ? String.Empty : cnpjXPTO.Endereco.Bairro.ToString();
                param[4]          = new SqlParameter("@Cidade", SqlDbType.VarChar);
                param[4].Value    = cnpjXPTO.Endereco.Cidade == null ? String.Empty : cnpjXPTO.Endereco.Cidade.ToString();
                param[5]          = new SqlParameter("@UF", SqlDbType.VarChar);
                param[5].Value    = cnpjXPTO.Endereco.UF == null ? String.Empty : cnpjXPTO.Endereco.UF.ToString();
                param[6]          = new SqlParameter("@Complemento", SqlDbType.VarChar);
                param[6].Value    = cnpjXPTO.Endereco.Complemento == null ? String.Empty : cnpjXPTO.Endereco.Complemento.ToString();
                param[7]          = new SqlParameter("@Logradouro", SqlDbType.VarChar);
                param[7].Value    = cnpjXPTO.Endereco.Logradouro == null ? String.Empty : cnpjXPTO.Endereco.Logradouro.ToString();
                param[8]          = new SqlParameter("@Numero", SqlDbType.VarChar);
                param[8].Value    = cnpjXPTO.Endereco.Numero == null ? String.Empty : cnpjXPTO.Endereco.Numero.ToString();
                param[9]          = new SqlParameter("@DDDFax", SqlDbType.VarChar);
                param[9].Value    = cnpjXPTO.DDDFax == null ? String.Empty : cnpjXPTO.DDDFax.ToString();
                param[10]         = new SqlParameter("@FoneFax", SqlDbType.VarChar);
                param[10].Value   = cnpjXPTO.Fax == null ? String.Empty : cnpjXPTO.Fax.ToString();
                param[11]         = new SqlParameter("@InscrEstadual", SqlDbType.VarChar);
                param[11].Value   = cnpjXPTO.InscrEstadual == null ? String.Empty : cnpjXPTO.InscrEstadual.ToString();
                param[12]         = new SqlParameter("@CodNatJur", SqlDbType.VarChar);
                param[12].Value   = cnpjXPTO.NatJuridica == null ? String.Empty : cnpjXPTO.NatJuridica.ToString();
                param[13]         = new SqlParameter("@DescNatJur", SqlDbType.VarChar);
                param[13].Value   = cnpjXPTO.NatJurDescricao == null ? String.Empty : cnpjXPTO.NatJurDescricao.ToString();
                param[14]         = new SqlParameter("@NmComercial", SqlDbType.VarChar);
                param[14].Value   = cnpjXPTO.NmComercial == null ? String.Empty : cnpjXPTO.NmComercial.ToString();
                param[15]         = new SqlParameter("@Situacao", SqlDbType.VarChar);
                param[15].Value   = cnpjXPTO.Situacao == null ? String.Empty : cnpjXPTO.Situacao.ToString();
                param[0x10]       = new SqlParameter("@DDD", SqlDbType.Int);
                param[0x10].Value = cnpjXPTO.DDD == null ? String.Empty : cnpjXPTO.DDD.ToString();
                param[0x11]       = new SqlParameter("@Fone", SqlDbType.VarChar);
                param[0x11].Value = cnpjXPTO.Telefone == null ? String.Empty : cnpjXPTO.Telefone.ToString();
                param[0x12]       = new SqlParameter("@VlCapital", SqlDbType.VarChar);
                param[0x12].Value = !Versioned.IsNumeric(cnpjXPTO.VlCapital) ? String.Empty : cnpjXPTO.VlCapital.ToString();
                long ID_SPC_CNPJ = (long)(SqlHelper.ExecuteScalar(cone, CommandType.StoredProcedure, "INTOUCH..prc_Inserir_CNPJ", param));
                param = new SqlParameter[4];
                foreach (SPC_CNPJ_CNAE_PRINCIPAL Cnae in cnpjXPTO.Cnae)
                {
                    param[0]       = new SqlParameter("@ID_SPC_CNPJ", SqlDbType.BigInt);
                    param[0].Value = ID_SPC_CNPJ;
                    param[1]       = new SqlParameter("@Cnae", SqlDbType.BigInt);
                    param[1].Value = !Versioned.IsNumeric(Cnae.Codigo) ? 0 : Cnae.Codigo;
                    param[2]       = new SqlParameter("@DESCRICAO", SqlDbType.VarChar);
                    param[2].Value = Cnae.Descricao == null ? String.Empty : Cnae.Descricao;
                    param[3]       = new SqlParameter("@TIPO", SqlDbType.VarChar);
                    param[3].Value = Cnae.Tipo == null ? String.Empty : Cnae.Tipo;
                    SqlHelper.ExecuteScalar(cone, CommandType.StoredProcedure, "INTOUCH..prc_Inserir_CNPJ_CNAE", param);
                }
                if ((cnpjXPTO.Cheque != null) && (cnpjXPTO.Cheque.Count > 0))
                {
                    param = new SqlParameter[13];
                    foreach (SPC_CPF_CHEQUE item in cnpjXPTO.Cheque)
                    {
                        param[0]        = new SqlParameter("@ID", SqlDbType.BigInt);
                        param[0].Value  = ID_SPC_CNPJ;
                        param[1]        = new SqlParameter("@ID_TP_CONSULTA", SqlDbType.Int);
                        param[1].Value  = pj.TipoConsulta;
                        param[2]        = new SqlParameter("@CODALINEA", SqlDbType.BigInt);
                        param[2].Value  = DBNull.Value.Equals(item.CodAlinea) ? String.Empty : item.CodAlinea.ToString();
                        param[3]        = new SqlParameter("@DSCALINEA", SqlDbType.VarChar);
                        param[3].Value  = item.DscAlinea.ToString() != "" ? item.DscAlinea : String.Empty;
                        param[4]        = new SqlParameter("@BANCO", SqlDbType.VarChar);
                        param[4].Value  = item.Banco.ToString() != "" ? item.Banco.ToString() : String.Empty;
                        param[5]        = new SqlParameter("@NUMAGENCIA", SqlDbType.VarChar);
                        param[5].Value  = item.NumAgencia.ToString() != "" ? item.NumAgencia.ToString() : String.Empty;
                        param[6]        = new SqlParameter("@NUMCTACORRENTE", SqlDbType.VarChar);
                        param[6].Value  = item.NumCC != "" ? item.NumCC : String.Empty;
                        param[7]        = new SqlParameter("@DTEMISSAO", SqlDbType.DateTime);
                        param[7].Value  = item.DtEmissao.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DtEmissao.ToShortDateString();
                        param[8]        = new SqlParameter("@NUMCHEQUE", SqlDbType.VarChar);
                        param[8].Value  = item.NumCheque.ToString() != "" ? item.NumCheque.ToString() : String.Empty;
                        param[9]        = new SqlParameter("@VLCHEQUE", SqlDbType.Decimal);
                        param[9].Value  = item.VlCheque.ToString() != "" ? item.VlCheque.ToString() : String.Empty;
                        param[10]       = new SqlParameter("@NOMEASSOCIADOCHEQUE", SqlDbType.VarChar);
                        param[10].Value = item.NmAssociado != "" ? item.NmAssociado: String.Empty;
                        param[11]       = new SqlParameter("@NOMEENTIDADECHEQUE", SqlDbType.VarChar);
                        param[11].Value = item.NmEntidade != "" ? item.NmEntidade: String.Empty;
                        param[12]       = new SqlParameter("@ORIGEMCHEQUE", SqlDbType.VarChar);
                        param[12].Value = item.Origem != "" ? item.Origem: String.Empty;
                        SqlHelper.ExecuteNonQuery(cone, CommandType.StoredProcedure, "intouch..prc_SPC_Inserir_Cheque", param);
                    }
                }
                if ((cnpjXPTO.ConsultaRealizada != null) && (cnpjXPTO.ConsultaRealizada.Count > 0))
                {
                    param = new SqlParameter[8];
                    foreach (SPC_CPF_ConsultaRealizada item in cnpjXPTO.ConsultaRealizada)
                    {
                        param[0]       = new SqlParameter("@ID", SqlDbType.BigInt);
                        param[0].Value = ID_SPC_CNPJ;
                        param[1]       = new SqlParameter("@ID_TP_CONSULTA", SqlDbType.Int);
                        param[1].Value = pj.TipoConsulta;
                        param[2]       = new SqlParameter("@QUANTIDADEDIASCONSULTADOS", SqlDbType.BigInt);
                        param[2].Value = !Versioned.IsNumeric(item.QuantidadeDiasConsultados) ? 0 : item.QuantidadeDiasConsultados;
                        param[3]       = new SqlParameter("@DataUltimaOcorrencia", SqlDbType.DateTime);
                        param[3].Value = item.DataUltimaOcorrencia.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DataUltimaOcorrencia.ToShortDateString();
                        param[4]       = new SqlParameter("@DataConsulta", SqlDbType.DateTime);
                        param[4].Value = item.DataConsulta.ToShortDateString().Equals("01/01/0001") ? String.Empty : item.DataConsulta.ToShortDateString();
                        param[5]       = new SqlParameter("@NomeAssociado", SqlDbType.VarChar);
                        param[5].Value = item.NomeAssociado == null ? String.Empty :  item.NomeAssociado;
                        param[6]       = new SqlParameter("@NomeEntidade", SqlDbType.VarChar);
                        param[6].Value = item.NomeEntidade == null ? String.Empty : item.NomeEntidade;
                        param[7]       = new SqlParameter("@Origem", SqlDbType.VarChar);
                        param[7].Value = item.Origem == null ? String.Empty : item.Origem;
                    }
                    SqlHelper.ExecuteNonQuery(cone, CommandType.StoredProcedure, "intouch..prc_SPC_Inserir_ConsultaRealizada", param);
                }
                cnpjXPTO = null;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception ex = exception1;
                ProjectData.ClearProjectError();
            }
        }