示例#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 Retorno VerificarExistencia(TipoFrete Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("SELECT 1 FROM TB_TIPO_FRETE ");
         CommandSQL.AppendLine("WHERE TB_TIPO_FRETE.DESCRICAO = @DESCRICAO ");
         CommandSQL.AppendLine("AND TB_TIPO_FRETE.CODIGO <> @CODIGO ");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Abrir();
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Reader = Command.ExecuteReader();
         while (Reader.Read())
         {
             return(new Retorno(false, String.Format(Mensagens.MSG_04, "TipoFrete", "Descricao")));
         }
         return(new Retorno(true));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
示例#3
0
        public Retorno Consultar(TipoFrete Entity)
        {
            try
            {
                TipoFrete TipoFrete = new TipoFrete();
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_FRETE.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_FRETE.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_FRETE ");

                CommandSQL.AppendLine("WHERE TB_TIPO_FRETE.CODIGO = @CODIGO ");
                Command = CriaComandoSQL(CommandSQL.ToString());
                Abrir();
                Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    TipoFrete = FillEntity(Reader);
                }
                return(new Retorno(TipoFrete));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
示例#4
0
        public Retorno Pesquisar(TipoFrete Entity, int Pagina, int QntPagina)
        {
            try
            {
                List <TipoFrete> TipoFretes = new List <TipoFrete>();
                int Limite = (Pagina - 1) * QntPagina;
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_FRETE.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_FRETE.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_FRETE ");

                CommandSQL.AppendLine("WHERE (TB_TIPO_FRETE.DESCRICAO LIKE '%" + Entity.Descricao + "%' )");
                CommandSQL.AppendLine("LIMIT @QNT_PAGINA OFFSET @LIMITE");
                Command = CriaComandoSQL(CommandSQL.ToString());
                Abrir();
                Command.Parameters.AddWithValue("@QNT_PAGINA", QntPagina);
                Command.Parameters.AddWithValue("@LIMITE", Limite);
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    TipoFretes.Add(FillEntity(Reader));
                }
                return(new Retorno(TipoFretes));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
示例#5
0
        public Retorno PreenchimentoObrigatorio(TipoFrete Entity)
        {
            if (String.IsNullOrEmpty(Entity.Descricao))
            {
                return(new Retorno(false, String.Format(Mensagens.MSG_01, "Descricao")));
            }

            return(new Retorno(true));
        }
示例#6
0
 private Retorno VerificarExistencia(TipoFrete Entity)
 {
     try
     {
         return(new DataTipoFrete().VerificarExistencia(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
示例#7
0
 public Retorno Consultar(TipoFrete Entity)
 {
     try
     {
         return(new DataTipoFrete().Consultar(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
示例#8
0
 public Retorno Pesquisar(TipoFrete Entity, int Pagina, int QntPagina)
 {
     try
     {
         return(new DataTipoFrete().Pesquisar(Entity, Pagina, QntPagina));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
示例#9
0
        private TipoFrete FillEntity(IDataReader reader)
        {
            TipoFrete TipoFrete = new TipoFrete();

            try
            {
                TipoFrete.Codigo    = ConverterValorReader(reader, "CODIGO", 0);
                TipoFrete.Descricao = ConverterValorReader(reader, "DESCRICAO", String.Empty);
            }
            catch (Exception ex) { throw ex; }
            return(TipoFrete);
        }
        public decimal ObterCusto(TipoFrete tipo)
        {
            if (tipo == TipoFrete.Pac)
            {
                return(distancia * 1.25m);
            }
            if (tipo == TipoFrete.Sedex)
            {
                return(distancia * 2m);
            }
            if (tipo == TipoFrete.Transportadora)
            {
                return(distancia * 1.75m);
            }
            if (tipo == TipoFrete.RetiradaNoLocal)
            {
                return(0m);
            }

            throw new Exception("Tipo de frete inválido");
        }
示例#11
0
 public Retorno Incluir(TipoFrete Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("INSERT INTO TB_TIPO_FRETE( ");
         CommandSQL.AppendLine("DESCRICAO) ");
         CommandSQL.AppendLine("VALUES (");
         CommandSQL.AppendLine("@DESCRICAO) ");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Salvo")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
示例#12
0
 public Retorno Alterar(TipoFrete Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("UPDATE TB_TIPO_FRETE SET ");
         CommandSQL.AppendLine("DESCRICAO = @DESCRICAO ");
         CommandSQL.AppendLine("WHERE CODIGO = @CODIGO");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Alterado ")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
示例#13
0
 public Retorno Excluir(TipoFrete Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("DELETE FROM TB_TIPO_FRETE WHERE CODIGO = @CODIGO");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Excluido ")));
     }
     catch (Exception ex)
     {
         if (((MySqlException)ex).Number == 1451)
         {
             return(new Retorno(false, Mensagens.MSG_16));
         }
         throw ex;
     }
     finally { Fechar(); }
 }
示例#14
0
 public Retorno Salvar(TipoFrete Entity)
 {
     try
     {
         Retorno retorno = PreenchimentoObrigatorio(Entity);
         if (retorno.IsValido)
         {
             if (Entity.Codigo == 0)
             {
                 retorno = new DataTipoFrete().Incluir(Entity);
             }
             else
             {
                 retorno = new DataTipoFrete().Alterar(Entity);
             }
         }
         return(retorno);
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
示例#15
0
 public void ObterFrete(TipoFrete Frete)
 {
 }
 public IFrete ObterFrete(TipoFrete tipo)
 {
     return(tiposFrete[tipo]);
 }
 public decimal ObterCusto(TipoFrete tipo)
 {
     return(factoryFrete.ObterFrete(tipo).CalcularCusto(distancia));
 }