public int Insert_Integrativa_CdaDebito(Cdadebitos Reg) { int _id = 0; using (Integrativa_Context db = new Integrativa_Context(_connection)) { object[] Parametros = new object[14]; Parametros[0] = new SqlParameter { ParameterName = "@idcda", SqlDbType = SqlDbType.Int, SqlValue = Reg.Idcda }; Parametros[1] = new SqlParameter { ParameterName = "@codtributo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Codtributo }; Parametros[2] = new SqlParameter { ParameterName = "@tributo", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Tributo }; Parametros[3] = new SqlParameter { ParameterName = "@exercicio", SqlDbType = SqlDbType.Int, SqlValue = Reg.Exercicio }; Parametros[4] = new SqlParameter { ParameterName = "@lancamento", SqlDbType = SqlDbType.Int, SqlValue = Reg.Lancamento }; Parametros[5] = new SqlParameter { ParameterName = "@seq", SqlDbType = SqlDbType.Int, SqlValue = Reg.Seq }; Parametros[6] = new SqlParameter { ParameterName = "@nroparcela", SqlDbType = SqlDbType.Int, SqlValue = Reg.Nroparcela }; Parametros[7] = new SqlParameter { ParameterName = "@complparcela", SqlDbType = SqlDbType.Int, SqlValue = Reg.Complparcela }; Parametros[8] = new SqlParameter { ParameterName = "@dtvencimento", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Dtvencimento }; Parametros[9] = new SqlParameter { ParameterName = "@vlroriginal", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Vlroriginal }; Parametros[10] = new SqlParameter { ParameterName = "@vlrmultas", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Vlrmultas }; Parametros[11] = new SqlParameter { ParameterName = "@vlrjuros", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Vlrjuros }; Parametros[12] = new SqlParameter { ParameterName = "@vlrcorrecao", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Vlrcorrecao }; Parametros[13] = new SqlParameter { ParameterName = "@dtgeracao", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Dtgeracao }; try { db.Database.ExecuteSqlCommand("INSERT INTO cdadebitos(idcda,codtributo,tributo,exercicio,lancamento,seq,nroparcela,complparcela,dtvencimento," + "vlroriginal,vlrmultas,vlrjuros,vlrcorrecao,dtgeracao) VALUES(@idcda,@codtributo,@tributo,@exercicio,@lancamento,@seq,@nroparcela," + "@complparcela,@dtvencimento,@vlroriginal,@vlrmultas,@vlrjuros,@vlrcorrecao,@dtgeracao)", Parametros); _id = Reg.Idcdadebitos; } catch { } return(_id); } }
/// <summary> /// Insere um registro na tabela CdaDebitos (Integrativa) /// </summary> /// <param name="Reg"></param> /// <returns></returns> public int Insert_Integrativa_CdaDebito(Cdadebitos Reg) { Integrativa_Data obj = new Integrativa_Data(_connection); return(obj.Insert_Integrativa_CdaDebito(Reg)); }
private void Grava_Dados() { Sistema_bll sistema_Class = new Sistema_bll(_connection); Tributario_bll tributario_Class = new Tributario_bll(_connection); GTI_Models.modelCore.TipoCadastro _tipo_cadastro = sistema_Class.Tipo_Cadastro(_codigo); Contribuinte_Header_Struct _header = sistema_Class.Contribuinte_Header(_codigo); string _tipo_divida = _tipo_cadastro == GTI_Models.modelCore.TipoCadastro.Imovel ? "Imobiliário" : _tipo_cadastro == GTI_Models.modelCore.TipoCadastro.Cidadao ? "Taxas Diversas" : "Mobiliário"; int _certidao = tributario_Class.Retorna_Ultima_Certidao_Livro(_numero_livro); int _pagina = _certidao; Cdas regCda = new Cdas() { Iddevedor = _codigo.ToString(), Setordevedor = _tipo_divida, Dtinscricao = Convert.ToDateTime(DataInscricaoText.Text), Nrocertidao = _certidao, Nrolivro = _numero_livro, Nrofolha = _pagina, Dtgeracao = DateTime.Now }; Integrativa_bll integrativa_Class = new Integrativa_bll(_connection_integrativa); int _idCda = integrativa_Class.Insert_Integrativa_Cda(regCda); if (_tipo_cadastro != GTI_Models.modelCore.TipoCadastro.Cidadao) { Cadastro regCadastro = new Cadastro() { Idcda = _idCda, Setordevedor = _tipo_divida, Crc = _codigo, Nome = _header.Nome, Inscricao = _header.Inscricao, Cpfcnpj = _header.Cpf_cnpj, Rginscrestadual = _header.Rg, Localcep = _header.Cep, Localendereco = _header.Endereco, Localnumero = _header.Numero, Localcomplemento = _header.Complemento, Localbairro = _header.Nome_bairro, Localcidade = _header.Nome_cidade, LocalEstado = _header.Nome_uf, Quadra = _header.Quadra_original, Lote = _header.Lote_original, Entregacep = _header.Cep_entrega, Entregaendereco = _header.Endereco_entrega, Entreganumero = _header.Numero_entrega, Entregabairro = _header.Nome_bairro_entrega, Entregacomplemento = _header.Complemento_entrega, Entregacidade = _header.Nome_cidade_entrega, Entregaestado = _header.Nome_uf_entrega, Dtgeracao = DateTime.Now }; integrativa_Class = new Integrativa_bll(_connection_integrativa); int _idCadastro = integrativa_Class.Insert_Integrativa_Cadastro(regCadastro); } else { Partes regPartes = new Partes() { Idcda = _idCda, Tipo = "Principal", Crc = _codigo, Nome = _header.Nome, Cpfcnpj = _header.Cpf_cnpj, Rginscrestadual = _header.Rg, Cep = _header.Cep, Endereco = _header.Endereco, Numero = _header.Numero, Complemento = _header.Complemento, Bairro = _header.Nome_bairro, Cidade = _header.Nome_cidade, Estado = _header.Nome_uf, Dtgeracao = DateTime.Now }; integrativa_Class = new Integrativa_bll(_connection_integrativa); int _idPartes = integrativa_Class.Insert_Integrativa_Partes(regPartes); } Imovel_bll imovel_Class = new Imovel_bll(_connection); Cidadao_bll cidadao_Class = new Cidadao_bll(_connection); Empresa_bll empresa_class = new Empresa_bll(_connection); if (_tipo_cadastro == GTI_Models.modelCore.TipoCadastro.Imovel) { List <ProprietarioStruct> ListaPropImovel = imovel_Class.Lista_Proprietario(_codigo); foreach (ProprietarioStruct item in ListaPropImovel) { CidadaoStruct _cidadao = cidadao_Class.Dados_Cidadao(item.Codigo); Partes regPartes = new Partes() { Idcda = _idCda, Tipo = item.Principal ? "Principal" : "Compromissário", Crc = _codigo, Nome = _cidadao.Nome, Cpfcnpj = string.IsNullOrWhiteSpace(_cidadao.Cnpj) ? _cidadao.Cpf : _cidadao.Cnpj, Rginscrestadual = _cidadao.Rg, Dtgeracao = DateTime.Now }; if (_cidadao.EtiquetaR == "C") { regPartes.Cep = _cidadao.CepC.ToString(); regPartes.Endereco = _cidadao.EnderecoC; regPartes.Numero = _cidadao.NumeroC; regPartes.Complemento = _cidadao.ComplementoC; regPartes.Bairro = _cidadao.NomeBairroC; regPartes.Cidade = _cidadao.NomeCidadeC; regPartes.Estado = _cidadao.UfC; } else { regPartes.Cep = _cidadao.CepR.ToString(); regPartes.Endereco = _cidadao.EnderecoR; regPartes.Numero = _cidadao.NumeroR; regPartes.Complemento = _cidadao.ComplementoR; regPartes.Bairro = _cidadao.NomeBairroR; regPartes.Cidade = _cidadao.NomeCidadeR; regPartes.Estado = _cidadao.UfR; } integrativa_Class = new Integrativa_bll(_connection_integrativa); int _idPartes = integrativa_Class.Insert_Integrativa_Partes(regPartes); } } else { if (_tipo_cadastro == GTI_Models.modelCore.TipoCadastro.Empresa) { List <CidadaoStruct> ListaSocio = empresa_class.ListaSocio(_codigo); foreach (CidadaoStruct item in ListaSocio) { CidadaoStruct _cidadao = cidadao_Class.Dados_Cidadao(item.Codigo); Partes regPartes = new Partes() { Idcda = _idCda, Tipo = "Sócio", Crc = _codigo, Nome = _cidadao.Nome, Cpfcnpj = string.IsNullOrWhiteSpace(_cidadao.Cnpj) ? _cidadao.Cpf : _cidadao.Cnpj, Rginscrestadual = _cidadao.Rg, Dtgeracao = DateTime.Now }; if (_cidadao.EtiquetaR == "C") { regPartes.Cep = _cidadao.CepC.ToString(); regPartes.Endereco = _cidadao.EnderecoC; regPartes.Numero = _cidadao.NumeroC; regPartes.Complemento = _cidadao.ComplementoC; regPartes.Bairro = _cidadao.NomeBairroC; regPartes.Cidade = _cidadao.NomeCidadeC; regPartes.Estado = _cidadao.UfC; } else { regPartes.Cep = _cidadao.CepR.ToString(); regPartes.Endereco = _cidadao.EnderecoR; regPartes.Numero = _cidadao.NumeroR; regPartes.Complemento = _cidadao.ComplementoR; regPartes.Bairro = _cidadao.NomeBairroR; regPartes.Cidade = _cidadao.NomeCidadeR; regPartes.Estado = _cidadao.UfR; } integrativa_Class = new Integrativa_bll(_connection_integrativa); int _idPartes = integrativa_Class.Insert_Integrativa_Partes(regPartes); } } } foreach (ListViewItem linha in MainListView.Items) { short _ano = Convert.ToInt16(linha.Text); short _lanc = Convert.ToInt16(linha.SubItems[1].Text.Substring(0, 2)); short _seq = Convert.ToInt16(linha.SubItems[2].Text); byte _parc = Convert.ToByte(linha.SubItems[3].Text); byte _compl = Convert.ToByte(linha.SubItems[4].Text); Exception ex = tributario_Class.Inscrever_Divida_Ativa(_codigo, _ano, _lanc, _seq, _parc, _compl, _numero_livro, _pagina, _certidao, Convert.ToDateTime(DataInscricaoText.Text)); foreach (SpExtrato item in _listaTributo) { if (item.Anoexercicio == _ano && item.Codlancamento == _lanc && item.Seqlancamento == _seq && item.Numparcela == _parc && item.Codcomplemento == _compl) { Cdadebitos regCdaDebito = new Cdadebitos() { Idcda = _idCda, Codtributo = item.Codtributo, Tributo = item.Abrevtributo, Exercicio = _ano, Lancamento = _lanc, Seq = _seq, Nroparcela = _parc, Complparcela = _compl, Dtvencimento = item.Datavencimento, Vlroriginal = item.Valortributo, Vlrmultas = item.Valormulta, Vlrjuros = item.Valorjuros, Vlrcorrecao = item.Valorcorrecao, Dtgeracao = DateTime.Now }; int _IdCdaDebito = integrativa_Class.Insert_Integrativa_CdaDebito(regCdaDebito); } } } }