コード例 #1
0
ファイル: MovimentoCaixaBll.cs プロジェクト: n-bam/pizza_byte
        /// <summary>
        /// Obtem o total de entrega por profissional
        /// </summary>
        /// <param name="requisicaoDto"></param>
        /// <param name="retornoDto"></param>
        /// <returns></returns>
        public bool ObterTotalEntregaPorProfissional(RequisicaoDataDto requisicaoDto, ref RetornoObterTotalEntregaPorProfissionalDto retornoDto)
        {
            string mensagemErro = "";

            if (!UtilitarioBll.ValidarIdentificacao(requisicaoDto.Identificacao, requisicaoDto.IdUsuario, ref mensagemErro))
            {
                retornoDto.Retorno  = false;
                retornoDto.Mensagem = mensagemErro;
                logBll.ResgistrarLog(requisicaoDto, LogRecursos.ObterTotalEntregaPorProfissional, Guid.Empty, mensagemErro);
                return(false);
            }

            List <SqlParameter> listaFiltros = new List <SqlParameter>();

            listaFiltros.Add(new SqlParameter("dataCaixa", requisicaoDto.Data.Date));

            string query = "SELECT CAST(ISNULL(SUM(TaxaEntrega), 0) AS float) AS TotalEntregas," +
                           " f.Nome AS NomeProfissional" +
                           " FROM PizzaByte.PedidosEntregas AS e" +
                           " INNER JOIN PizzaByte.Pedidos AS p ON e.IdPedido = p.Id" +
                           " INNER JOIN PizzaByte.Funcionarios AS f ON e.IdFuncionario = f.Id AND f.Inativo = 0" +
                           " AND f.Excluido = 0" +
                           " WHERE CAST(e.DataInclusao AS Date) = @dataCaixa AND e.Inativo = 0 AND e.Excluido = 0" +
                           " AND e.IdFuncionario IS NOT NULL" +
                           " GROUP BY f.Nome" +
                           " ORDER BY f.Nome";

            try
            {
                PizzaByteContexto contexto = new PizzaByteContexto();
                retornoDto.ListaTotais = contexto.Database.SqlQuery <TotalPorProfissional>(query, listaFiltros.ToArray()).ToList();

                retornoDto.Retorno  = true;
                retornoDto.Mensagem = "Ok";
                return(true);
            }
            catch (Exception ex)
            {
                retornoDto.Retorno  = false;
                retornoDto.Mensagem = "Falha ao obter os dados: " + ex.Message;

                logBll.ResgistrarLog(requisicaoDto, LogRecursos.ObterTotalEntregaPorProfissional, Guid.Empty, mensagemErro);
                return(false);
            }
        }
コード例 #2
0
ファイル: MovimentoCaixaBll.cs プロジェクト: n-bam/pizza_byte
        /// <summary>
        /// Obtem os dados necessários para popular a tela de caixa
        /// </summary>
        /// <param name="requisicaoDto"></param>
        /// <param name="retornoDto"></param>
        /// <returns></returns>
        public bool ObterFormasPagamentoDia(RequisicaoDataDto requisicaoDto, ref RetornoObterResumoCaixaDto retornoDto)
        {
            string mensagemErro = "";

            if (!UtilitarioBll.ValidarIdentificacao(requisicaoDto.Identificacao, requisicaoDto.IdUsuario, ref mensagemErro))
            {
                retornoDto.Retorno  = false;
                retornoDto.Mensagem = mensagemErro;
                logBll.ResgistrarLog(requisicaoDto, LogRecursos.ObterInformacoesDashboard, Guid.Empty, mensagemErro);
                return(false);
            }

            List <SqlParameter> listaFiltros = new List <SqlParameter>();
            string query = "SELECT CAST(ISNULL(SUM(RecebidoDinheiro), 0) AS float) AS RecebidoDinheiro," +
                           " CAST(ISNULL(SUM(RecebidoCredito), 0) AS float) AS RecebidoCredito," +
                           " CAST(ISNULL(SUM(RecebidoDebito), 0) AS float) AS RecebidoDebito," +
                           " CAST(ISNULL(SUM(Troco), 0) AS float) AS Troco," +
                           " CAST(ISNULL(SUM(TaxaEntrega), 0) AS float) AS TaxaEntrega" +
                           " FROM PizzaByte.Pedidos" +
                           " WHERE CAST(DataInclusao AS Date) = @dataCaixa AND Inativo = 0 AND Excluido = 0";

            listaFiltros.Add(new SqlParameter("dataCaixa", requisicaoDto.Data.Date));

            try
            {
                PizzaByteContexto contexto = new PizzaByteContexto();
                retornoDto             = contexto.Database.SqlQuery <RetornoObterResumoCaixaDto>(query, listaFiltros.ToArray()).FirstOrDefault();
                retornoDto.TotalVendas = (retornoDto.RecebidoDinheiro - retornoDto.Troco) + retornoDto.RecebidoCredito + retornoDto.RecebidoDebito;

                retornoDto.Retorno  = true;
                retornoDto.Mensagem = "Ok";
                return(true);
            }
            catch (Exception ex)
            {
                retornoDto.Retorno  = false;
                retornoDto.Mensagem = "Falha ao obter os dados: " + ex.Message;

                logBll.ResgistrarLog(requisicaoDto, LogRecursos.ObterInformacoesDashboard, Guid.Empty, mensagemErro);
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// Obtem os valores de entrega para cada profissional
        /// </summary>
        /// <param name="id"></param>
        /// <param name="model"></param>
        /// <param name="mensagemErro"></param>
        /// <returns></returns>
        public string ObterTotalProfissionais(DateTime dataCaixa)
        {
            //Preparar a requisição e o retorno
            RetornoObterTotalEntregaPorProfissionalDto retornoDto = new RetornoObterTotalEntregaPorProfissionalDto();
            RequisicaoDataDto requisicaoDto = new RequisicaoDataDto()
            {
                Data          = dataCaixa.Date,
                Identificacao = SessaoUsuario.SessaoLogin.Identificacao,
                IdUsuario     = SessaoUsuario.SessaoLogin.IdUsuario
            };

            //Consumir o serviço
            MovimentoCaixaBll movimentoCaixaBll = new MovimentoCaixaBll(true);

            movimentoCaixaBll.ObterTotalEntregaPorProfissional(requisicaoDto, ref retornoDto);

            //Tratar o retorno
            string retorno = new JavaScriptSerializer().Serialize(retornoDto);

            return(retorno);
        }
コード例 #4
0
        /// <summary>
        /// Obtem o resumo do caixa
        /// </summary>
        /// <param name="id"></param>
        /// <param name="model"></param>
        /// <param name="mensagemErro"></param>
        /// <returns></returns>
        public string ObterFormasPagamento(DateTime dataCaixa)
        {
            //Preparar a requisição e o retorno
            RetornoObterResumoCaixaDto retornoDto    = new RetornoObterResumoCaixaDto();
            RequisicaoDataDto          requisicaoDto = new RequisicaoDataDto()
            {
                Data          = dataCaixa,
                Identificacao = SessaoUsuario.SessaoLogin.Identificacao,
                IdUsuario     = SessaoUsuario.SessaoLogin.IdUsuario
            };

            //Consumir o serviço
            MovimentoCaixaBll movimentoCaixaBll = new MovimentoCaixaBll(true);

            movimentoCaixaBll.ObterFormasPagamentoDia(requisicaoDto, ref retornoDto);

            //Tratar o retorno
            string retorno = new JavaScriptSerializer().Serialize(retornoDto);

            return(retorno);
        }