示例#1
0
        /// <summary>
        /// Retorna o texto do registro do tipo 70 para uso do SIntegra.
        /// </summary>
        /// <returns>Uma string com os dados formatados para uso do SIntegra.</returns>
        public override string ToString()
        {
            // Formata os dados para o retorno do método
            string n01 = Tipo.ToString().PadLeft(2, '0');
            string n02 = Cnpj.PadLeft(14, '0');
            string n03 = InscEst.PadRight(14);
            string n04 = FormatData(DataEmissao);
            string n05 = UfEmit.PadRight(2);
            string n06 = Modelo.ToString().PadLeft(2, '0');
            string n07 = Serie;
            string n08 = Subserie.ToString().PadLeft(2, '0');
            string n09 = Numero.ToString().PadLeft(6, '0');
            string n10 = CFOP.ToString().PadLeft(4, '0');
            string n11 = ValorTotal.ToString("0##########.#0").Remove(11, 1);
            string n12 = BcIcms.ToString("0###########.#0").Remove(12, 1);
            string n13 = ValorIcms.ToString("0###########.#0").Remove(12, 1);
            string n14 = Isenta.ToString("0###########.#0").Remove(12, 1);
            string n15 = Outras.ToString("0###########.#0").Remove(12, 1);
            string n16 = TipoFrete.ToString();
            string n17 = Situacao == TipoSituacao.Normal ? "N" : "S";

            // Retorna os dados formatados
            return(n01 + n02 + n03 + n04 + n05 + n06 + n07 + n08 + n09 + n10 +
                   n11 + n12 + n13 + n14 + n15 + n16 + n17);
        }
示例#2
0
        public void SalvarSubserie(Subserie _subserie)
        {
            try
            {
                _subserie.Subserie_pai = _subserie.Subserie_pai == 0 ? null : _subserie.Subserie_pai;

                _subserie.Id_subserie = TratarIdSubSerie(_subserie);

                if (_subserie.Registro == 0)
                {
                    _DAO.Add(_subserie);
                    _DAO.SaveChanges();
                }
                else
                {
                    _DAO.Atualizar(_subserie, _subserie.Registro);
                }
            }
            catch (DbEntityValidationException dbex)
            {
                throw new Erros.ErroDeValidacao(dbex);
            }
            catch (DbUpdateException dbuex)
            {
                throw new Erros.ErroGeral("Não foi possível concluir a operação. Verifique se o item não foi cadastrado previamente.");
            }
            catch (Exception ex)
            {
                throw new Erros.ErroGeral("Erro inesperado. " + ex.Message);
            }
        }
示例#3
0
        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);
        }
示例#4
0
 private int buscaPosicao(List <Subserie> list, Subserie k)
 {
     try { return(list.FindIndex(o => o.Equals(k))); }
     catch
     {
         return(-1);
     }
 }
示例#5
0
 public ActionResult Excluir(string Id)
 {
     try
     {
         Subserie _subserie = _DAO.GetByRegistro(int.Parse(Id));
         _DAO.ExcluirSubserie(_subserie);
         Logador.LogEntidade(Logador.LogAcoes.Excluir, _subserie);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index").ComMensagemDeErro(ex.Message));
     }
 }
示例#6
0
 public void ExcluirSubserie(Subserie _subserie)
 {
     try
     {
         _DAO.Delete(_subserie);
     }
     catch (DbUpdateException)
     {
         throw new Erros.ErroGeral("Não foi possível excluir a Subsérie " + _subserie.Rotulo_subserie + " pois a mesma está em uso.");
     }
     catch (Exception ex)
     {
         throw new Erros.ErroGeral("Não foi possível concluir a operação. " + ex.Message);
     }
 }
示例#7
0
        public string TratarIdSubSerie(Subserie _subSerie)
        {
            //string IDAux = _subSerie.Id_subserie.Replace('.', ' ').Substring(0, _subSerie.Id_subserie.Length - 1).Trim();
            string[] stSplit = _subSerie.Id_subserie.Split('.');
            string   IDAux   = stSplit[0];
            Serie    serie   = new SerieBO().GetByRegistro(_subSerie.Serie);

            if (SubserieFilha(_subSerie))
            {
                IDAux = _subSerie.Id_subserie.Replace('.', ' ');
                string idPai = new SubserieBO().GetByRegistro(_subSerie.Subserie_pai.Value).Id_subserie.Replace('.', ' ');
                if (!IDAux.StartsWith(idPai))
                {
                    throw new Erros.ErroGeral("ID da Subsérie inválido. Consulte as regras de identificação de Subséries.");
                }
                else
                {
                    if (DigitosValidos(_subSerie.Id_subserie))
                    {
                        return(_subSerie.Id_subserie);
                    }
                    else
                    {
                        throw new Erros.ErroGeral("O ID da Subsérie possui caracteres inválidos");
                    }
                }
            }
            else
            {
                if (IDAux != serie.Id_serie)
                {
                    throw new Erros.ErroGeral("ID da Subsérie inválido. Consulte as regras de identificação de Subséries.");
                }
                else
                {
                    if (DigitosValidos(_subSerie.Id_subserie))
                    {
                        return(_subSerie.Id_subserie);
                    }
                    else
                    {
                        throw new Erros.ErroGeral("O ID da Subsérie possui caracteres inválidos");
                    }
                }
            }
        }
示例#8
0
 public ActionResult CadastrarSubserie(Subserie _novaSerie)
 {
     if (!ModelState.IsValid)
     {
         return(View("Cadastrar", _novaSerie));
     }
     {
         try
         {
             if (Session["id"] != null)
             {
                 _novaSerie.Registro = int.Parse(Session["id"].ToString());
             }
             _DAO.SalvarSubserie(_novaSerie);
             Logador.LogEntidade(Logador.LogAcoes.Salvar, _novaSerie);
             return(RedirectToAction("Index").ComMensagemDeSucesso("Subsérie salva com sucesso!"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Cadastrar", _novaSerie).ComMensagemDeErro(ex.Message));
         }
     }
 }
示例#9
0
        /// <summary>
        /// Retorna o texto do registro do tipo 61 para uso do SIntegra.
        /// </summary>
        /// <returns>Uma string com os dados formatados para uso do SIntegra.</returns>
        public override string ToString()
        {
            // Formata os dados para o retorno do método
            string n01 = Tipo.ToString();
            string n02 = "".PadRight(14);
            string n03 = "".PadRight(14);
            string n04 = FormatData(DataEmissao);
            string n05 = Modelo.PadLeft(2, '0');
            string n06 = Serie.ToString().PadRight(3);
            string n07 = Subserie.ToString().PadRight(2);
            string n08 = NumeroInicialOrdem.ToString().PadLeft(6, '0');
            string n09 = NumeroFinalOrdem.ToString().PadLeft(6, '0');
            string n10 = ValorTotal.ToString("0##########.#0").Remove(11, 1);
            string n11 = BaseCalcICMS.ToString("0##########.#0").Remove(11, 1);
            string n12 = ValorICMS.ToString("0#########.#0").Remove(10, 1);
            string n13 = ValorIsencao.ToString("0##########.#0").Remove(11, 1);
            string n14 = ValorOutras.ToString("0##########.#0").Remove(11, 1);
            string n15 = AliquotaICMS.ToString("0#.#0").Remove(2, 1);
            string n16 = "".PadRight(1);

            // Retorna os dados formatados
            return(n01 + n02 + n03 + n04 + n05 + n06 + n07 + n08 + n09 + n10 +
                   n11 + n12 + n13 + n14 + n15 + n16);
        }
示例#10
0
 public bool SubserieFilha(Subserie _subSerie)
 {
     return(_subSerie.Subserie_pai != 0 && _subSerie.Subserie_pai != null);
 }
示例#11
0
 public ActionResult Cadastrar(Subserie _subserie)
 {
     return(View(_subserie));
 }