Ejemplo n.º 1
0
        /// <summary>
        /// Insere na tabela vre_empresa
        /// </summary>
        /// <param name="reg"></param>
        /// <returns></returns>
        public Exception Insert_Empresa_Vre(Vre_empresa reg)
        {
            Empresa_Data obj = new Empresa_Data(_connection);
            Exception    ex  = obj.Incluir_Empresa_Vre(reg);

            return(ex);
        }
Ejemplo n.º 2
0
        private void Grava_Empresas_Vre(List <EmpresaStruct> Lista)
        {
            Empresa_bll empresa_Class = new Empresa_bll("GTIconnection");

            foreach (EmpresaStruct item in Lista)
            {
                if (empresa_Class.Existe_Empresa_Vre(Convert.ToInt32(item.id)))
                {
                    item.Already_inDB = true;
                }
                else
                {
                    try {
                        Vre_empresa reg = new Vre_empresa {
                            Nome_arquivo    = Path.GetFileName(FileUpload1.PostedFile.FileName),
                            Data_importacao = DateTime.Now,
                            Id                   = Convert.ToInt32(item.id),
                            Razao_social         = item.Nome.ToString().Replace("&amp;", "&"),
                            Cnpj                 = item.Cnpj,
                            Data_abertura        = item.DataAbertura,
                            Porte                = Convert.ToByte(item.Porte),
                            Numero_registro      = item.NumeroRegistro,
                            Tipo_registro        = Convert.ToByte(item.TipoRegistro),
                            Tipo_mei             = Convert.ToByte(item.TipoMei),
                            Cpf_responsavel      = item.CpfResponsavel,
                            Nome_responsavel     = item.NomeResponsavel,
                            Fone_contato1        = item.DDDContato1 + " " + item.FoneContato1,
                            Fone_contato2        = item.DDDContato2 + " " + item.FoneContato2,
                            Email_contato        = item.EmailContato,
                            Setor_quadra_lote    = item.Endereco.SetorQuadraLote,
                            Tipo_logradouro      = item.Endereco.TipoLogradouro.Length > 15 ? item.Endereco.TipoLogradouro.Substring(0, 15) : item.Endereco.TipoLogradouro,
                            Nome_logradouro      = item.Endereco.Logradouro,
                            Numero_imovel        = gtiCore.IsNumeric(item.Endereco.Numero.ToString()) ? Convert.ToInt32(gtiCore.RetornaNumero(item.Endereco.Numero)) : 0,
                            Complemento          = gtiCore.Truncate(item.Endereco.Complemento, 47, "...").ToString().TrimEnd(),
                            Bairro               = item.Endereco.Bairro,
                            Cidade               = item.Endereco.Cidade,
                            UF                   = item.Endereco.UF,
                            Cep                  = item.Endereco.Cep,
                            Area_estabelecimento = item.Licenciamento[0].Imovel == null ? 0 : Convert.ToSingle(item.Licenciamento[0].Imovel.AreaEstabelecimento),
                            Nome_proprietario    = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.NomeProprietario,
                            Email_proprietario   = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.EmailProprietario,
                            Fone_proprietario    = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.TelefoneProprietario
                        };
                        reg.Email_proprietario   = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.EmailProprietario;
                        reg.Nome_responsavel_uso = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.NomeResponsavelUso;
                        reg.Fone_responsavel_uso = item.Licenciamento[0].Imovel == null ? "" : item.Licenciamento[0].Imovel.TelefoneResponsavelUso;
                        reg.Area_total           = item.Licenciamento[0].Imovel == null ? 0 : Convert.ToSingle(item.Licenciamento[0].Imovel.AreaTotal);
                        reg.Pavimentos           = item.Licenciamento[0].Imovel == null?Convert.ToByte(0) : Convert.ToByte(item.Licenciamento[0].Imovel.Pavimentos);

                        reg.Contiguo = item.Licenciamento[0].Imovel == null?Convert.ToByte(0) : Convert.ToByte(item.Licenciamento[0].Imovel.Contiguo);

                        reg.Outros_usos = item.Licenciamento[0].Imovel == null?Convert.ToByte(0) : Convert.ToByte(item.Licenciamento[0].Imovel.OutrosUsos);

                        reg.Classif_CRC_PJ = item.ClassifCRCPJ == null?Convert.ToByte(0) : Convert.ToByte(item.ClassifCRCPJ);

                        reg.Classif_CRC_PF = item.ClassifCRCPF == null?Convert.ToByte(0) : Convert.ToByte(item.ClassifCRCPF);

                        reg.Numero_CRC_PJ = item.NumeroCRCPJ;
                        reg.Cnpj_contador = item.CNPJContador;
                        reg.Tipo_CRC_PF   = item.TipoCRCPF;
                        reg.Tipo_CRC_PJ   = item.TipoCRCPJ;
                        reg.Numero_CRC_PF = item.NumeroCRCPF;
                        reg.Uf_CRC_PF     = item.UFCRCPF;
                        reg.Uf_CRC_PJ     = item.UFCRCPJ;
                        reg.Cpf_contador  = item.CPFContador;

                        empresa_Class.Insert_Empresa_Vre(reg);
                    } catch (Exception ex) {
                        throw ex;
                    }

                    item.Already_inDB = false;

                    for (int i = 0; i < item.Atividade[0].Codigo.Count(); i++)
                    {
                        Vre_atividade regatv = new Vre_atividade();
                        regatv.Id        = Convert.ToInt32(item.id);
                        regatv.Cnae      = item.Atividade[0].Codigo[i].ToString();
                        regatv.Principal = Convert.ToBoolean(Convert.ToInt16(item.Atividade[0].Principal[i].ToString()));
                        regatv.Exercida  = Convert.ToBoolean(Convert.ToInt16(item.Atividade[0].Exercida[i].ToString()));

                        try {
                            empresa_Class.Insert_Atividade_Vre(regatv);
                        } catch (Exception ex) {
                            throw ex;
                        }
                    }
                    for (int i = 0; i < item.Sociedade[0].Socio.Count(); i++)
                    {
                        Vre_socio regsoc = new Vre_socio();
                        regsoc.Id     = Convert.ToInt32(item.id);
                        regsoc.Nome   = item.Sociedade[0].Socio[i].Nome.ToString();
                        regsoc.Numero = item.Sociedade[0].Socio[i].Numero.ToString();
                        try {
                            empresa_Class.Insert_Socio_Vre(regsoc);
                        } catch (Exception ex) {
                            throw ex;
                        }
                    }
                    for (int i = 0; i < item.Licenciamento.Count(); i++)
                    {
                        Vre_licenciamento reglic = new Vre_licenciamento();
                        reglic.Empresa_id      = Convert.ToInt32(item.id);
                        reglic.Solicitacao_id  = Convert.ToInt32(item.Licenciamento[i].Solicitacao);
                        reglic.Orgao_id        = Convert.ToInt32(item.Licenciamento[i].Orgao);
                        reglic.Status          = Convert.ToInt32(item.Licenciamento[i].Status);
                        reglic.Numero          = item.Licenciamento[i].Numero;
                        reglic.Risco           = Convert.ToBoolean(Convert.ToInt16(item.Licenciamento[i].Risco));
                        reglic.Data_emissao    = Convert.ToDateTime(item.Licenciamento[i].DataEmissao);
                        reglic.Data_vencimento = Convert.ToDateTime(item.Licenciamento[i].DataVencimento);

                        try {
                            empresa_Class.Insert_Licenciamento_Vre(reglic);
                        } catch (Exception ex) {
                            throw ex;
                        }
                    }
                }
            }
        }