Ejemplo n.º 1
0
 public void Insert(ImportacaoEntity importacao)
 {
     try
     {
         OpenConnection();
         using (cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "imp.UP_IMPORTACAO_CADASTRAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@NOME_ARQUIVO", SqlDbType.VarChar, 300)).Value = importacao.NomeArquivo;
             cmd.Parameters.Add(new SqlParameter("@CAMINHO_ARQUIVO", SqlDbType.VarChar)).Value   = importacao.CaminhoArquivo;
             cmd.Parameters.Add(new SqlParameter("@ANTECIPACAO", SqlDbType.Bit)).Value           = importacao.Antecipacao;
             cmd.Parameters.Add(new SqlParameter("@SEGURADORA_ID", SqlDbType.Int)).Value         = importacao.Seguradora.Id;
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }
Ejemplo n.º 2
0
 public void Processar(int id)
 {
     try
     {
         ImportacaoBusiness business   = new ImportacaoBusiness();
         ImportacaoEntity   importacao = business.GetById(id);
         LerExcel(importacao);
         new ImportacaoRepository().Processar(id);
         importacao.Processada = true;
         business.Update(importacao);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void LerExcel(ImportacaoEntity importacao)
        {
            try
            {
                WorkBook              wb    = WorkBook.Load(importacao.CaminhoArquivo);
                WorkSheet             ws    = wb.WorkSheets.First();
                var                   table = ws.ToDataTable(true);
                DataRow[]             rows  = table.Select();
                IEnumerable <DataRow> ts    = from processo in table.AsEnumerable() select processo;

                foreach (DataRow row in table.Rows)
                {
                    new RegistroBusiness().Insert(new RegistroEntity
                    {
                        Importacao         = importacao,
                        NumeroSinistro     = row["Número Sinistro Zurich"].ToString(),
                        Companhia          = row["CIAS"].ToString(),
                        Processo           = row["Processo"].ToString(),
                        Bilhete            = row["Bilhete"].ToString(),
                        DataEmissaoVoucher = Convert.ToDateTime(row["Data de Emissão do Voucher"]),
                        Referencia         = row["Referência"].ToString(),
                        DataAtendimento    = Convert.ToDateTime(row["Data de Atendimento"]),
                        DataOcorrencia     = Convert.ToDateTime(row["Data de Ocorrência"]),
                        Nome            = row["Nome"].ToString(),
                        NumeroDocumento = row["Número do DOC"].ToString(),
                        Voucher         = row["VOUCHER "].ToString(),
                        Cobertura       = row["Cobertura Reclamada"].ToString(),
                        CustoOriginal   = Convert.ToDecimal(row["Custo na Moeda Original"]),
                        TipoMoeda       = row["Tipo de Moeda"].ToString(),
                        ValorFinal      = Convert.ToDecimal(row["Valor Final (US$)"]),
                        Fee             = Convert.ToDecimal(row["Fee"]),
                        TipoMoedaFee    = row["Tipo de Moeda Fee"].ToString(),
                        ValorDolar      = Convert.ToDecimal(row["Valor USD"]),
                        ValorReal       = Convert.ToDecimal(row["Valor ND R$"]),
                        Dolar           = Convert.ToDouble(row["Dólar"]),
                        NotaDebito      = row["ND/NC"].ToString(),
                        DataEmissaoND   = Convert.ToDateTime(row["Data de Emissão ND"]),
                        DataEnvio       = Convert.ToDateTime(row["Data de envio"]),
                        StatusPagamento = row["Status de Pgto PARCIAL/TOTAL"].ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 4
0
 public ImportacaoEntity GetById(int id)
 {
     try
     {
         OpenConnection();
         using (cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "imp.UP_IMPORTACAO_BUSCAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id;
             dr = cmd.ExecuteReader();
             ImportacaoEntity importacao = null;
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     importacao = new ImportacaoEntity()
                     {
                         Id             = Convert.ToInt32(dr["ID"]),
                         NomeArquivo    = dr["NOME_ARQUIVO"].ToString(),
                         CaminhoArquivo = dr["CAMINHO_ARQUIVO"].ToString(),
                         Antecipacao    = Convert.ToBoolean(dr["ANTECIPACAO"]),
                         Ativo          = Convert.ToBoolean(dr["ATIVO"]),
                         Seguradora     = new SeguradoraEntity()
                         {
                             Id   = Convert.ToInt32(dr["SEGURADORA_ID"]),
                             Nome = dr["SEGURADORA_NOME"].ToString(),
                             CNPJ = dr["SEGURADORA_CNPJ"].ToString()
                         },
                         DataImportacaoFormatada = dr["DATA_IMPORTACAO_FORMATADA"].ToString(),
                         Processada = Convert.ToBoolean(dr["BIT_PROCESSADA"])
                     };
                 }
             }
             return(importacao);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }
Ejemplo n.º 5
0
 public void Update(ImportacaoEntity importacao) => new ImportacaoRepository().Update(importacao);
Ejemplo n.º 6
0
 public void Insert(ImportacaoEntity importacao) => new ImportacaoRepository().Insert(importacao);