public DateTime RecuperaProximoDiaUtil(DateTime data, string siglaUF) { bool achouProximoDiaUtil = false; DateTime dataUtil = data.AddDays(-1); while (!achouProximoDiaUtil) { dataUtil = dataUtil.AddDays(1); UnidadeFederacao unidadeFederacao = unidadeFederacaoRepository.ListarPeloFiltro(l => l.Sigla == siglaUF, l => l.ListaFeriado).FirstOrDefault(); Feriado feriado = null; if (unidadeFederacao != null) { feriado = unidadeFederacao.ListaFeriado.Where(l => l.Data.Value.Date == dataUtil.Date).FirstOrDefault(); } if (feriado == null) { if ((dataUtil.DayOfWeek != DayOfWeek.Saturday) && (dataUtil.DayOfWeek != DayOfWeek.Sunday)) { achouProximoDiaUtil = true; } } } return(dataUtil); }
public string gerarLinhaTexto() { string retorno = ""; retorno += Funcoes.Formatar(tipo.ToString(), 2, true, '0'); retorno += Funcoes.Formatar(cnpj, 14, false, '0'); retorno += Funcoes.Formatar(inscricaoEstadual, 14, true, ' '); retorno += Funcoes.Formatar(dataEmissao.ToString("yyyyMMdd"), 8, true, '0'); retorno += Funcoes.Formatar(UnidadeFederacao.ToString(), 2, true, '0'); retorno += Funcoes.Formatar(Modelo.ToString(), 2, true, '0'); retorno += Funcoes.Formatar(Serie.ToString(), 1, true, '0'); retorno += Funcoes.Formatar(Subserie.ToString(), 2, true, '0'); retorno += Funcoes.Formatar(Numero.ToString(), 6, true, '0'); retorno += Funcoes.Formatar(CFOP.ToString(), 4, true, '0'); retorno += Funcoes.Formatar(valorTotal.ToString("n2"), 13, false, '0'); retorno += Funcoes.Formatar(BaseCalculo.ToString("n2"), 14, false, '0'); retorno += Funcoes.Formatar(ValorICMS.ToString("n2"), 14, false, '0'); retorno += Funcoes.Formatar(Isenta_nao_tributada.ToString("n2"), 14, false, '0'); retorno += Funcoes.Formatar(Outras.ToString("n2"), 14, false, '0'); retorno += Funcoes.Formatar(Modalidade.ToString(), 1, true, '0'); retorno += Funcoes.Formatar(Situacao.ToString(), 1, true, '0'); return(retorno); }
public void Salvar(TUnidadeFederacao tUnidadeFederacao) { if (tUnidadeFederacao.Sigla.Count() == 0) { throw new BusinessException("A placa do veículo deve possuir 7 caracteres."); } var tUF = FabricaDeRepositorios <IUnidadeFederacaoRepositorio> .Instancia.BuscarPelaSigla(tUnidadeFederacao.Sigla); if (tUF != null) { tUnidadeFederacao.Id = tUF.Id; } UnidadeFederacao uf = Mapper.Map <UnidadeFederacao>(tUnidadeFederacao); //TVeiculoParaVeiculo(tVeiculo); try { FabricaDeRepositorios <IUnidadeFederacaoRepositorio> .Instancia.SalvarOuAtualizar(uf); } catch (Exception ex) { ExceptionHandler.Handle(ex); } }
private static void InsereUFs() { var repUF = new Repository <UnidadeFederacao>(); var uf = new UnidadeFederacao { Id = 11, Nome = "Rondônia", Sigla = "RO" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 12, Nome = "Acre", Sigla = "AC" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 13, Nome = "Amazonas", Sigla = "AM" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 14, Nome = "Roraima", Sigla = "RR" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 15, Nome = "Pará", Sigla = "PA" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 16, Nome = "Amapá", Sigla = "AP" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 17, Nome = "Tocantins", Sigla = "TO" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 21, Nome = "Maranhão", Sigla = "MA" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 22, Nome = "Piauí", Sigla = "PI" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 23, Nome = "Ceará", Sigla = "CE" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 24, Nome = "Rio Grande do Norte", Sigla = "RN" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 25, Nome = "Paraíba", Sigla = "PB" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 26, Nome = "Pernambuco", Sigla = "PE" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 27, Nome = "Alagoas", Sigla = "AL" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 28, Nome = "Sergipe", Sigla = "SE" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 29, Nome = "Bahia", Sigla = "BA" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 31, Nome = "Minas Gerais", Sigla = "MG" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 32, Nome = "Espírito Santo", Sigla = "ES" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 33, Nome = "Rio de Janeiro", Sigla = "RJ" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 35, Nome = "São Paulo", Sigla = "SP" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 41, Nome = "Paraná", Sigla = "PR" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 42, Nome = "Santa Catarina", Sigla = "SC" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 43, Nome = "Rio Grande do Sul", Sigla = "RS" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 50, Nome = "Mato Grosso do Sul", Sigla = "MS" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 51, Nome = "Mato Grosso", Sigla = "MT" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 52, Nome = "Goiás", Sigla = "GO" }; repUF.Insert(uf); uf = new UnidadeFederacao { Id = 53, Nome = "Distrito Federal", Sigla = "DF" }; repUF.Insert(uf); }