Example #1
0
        private void CarregaComboFabricante()
        {
            Veiculos.Ioc.Service.Service <Ioc.Core.Data.Fabricante> service = new Ioc.Service.Service <Ioc.Core.Data.Fabricante>();

            ViewBag.IdFabricante = new SelectList
                                   (
                service.BuscarTodos(),
                "Id",
                "Descricao"
                                   );
        }
Example #2
0
        private void CarregaComboModelo()
        {
            Veiculos.Ioc.Service.Service <Ioc.Core.Data.Modelo> service = new Ioc.Service.Service <Ioc.Core.Data.Modelo>();

            ViewBag.IdModelo = new SelectList
                               (
                service.BuscarTodos(),
                "Id",
                "Descricao"
                               );
        }
Example #3
0
        private void FormaPagamento()
        {
            Veiculos.Ioc.Service.Service <Ioc.Core.Data.FormaPagamento> service = new Ioc.Service.Service <Ioc.Core.Data.FormaPagamento>();

            ViewBag.IdFormaPagamento = new SelectList
                                       (
                service.BuscarTodos(),
                "Id",
                "Descricao",
                1
                                       );
        }
Example #4
0
        public JsonResult Placa(string placa, string veiculo)
        {
            Veiculos.Ioc.Service.Service <Ioc.Core.Data.Compra> service = new Ioc.Service.Service <Ioc.Core.Data.Compra>();

            var result = (from c in service.BuscarTodos(g => g.Veiculo.IdStatusVeiculo == 3 && (g.Veiculo.Placa.StartsWith(placa) && !g.Veiculo.Placa.Equals(veiculo)))
                          select new
            {
                Id = c.Veiculo.Id,
                Veiculo = c.Veiculo.Placa + "/" + c.Veiculo.Modelo.Descricao + "/" + c.Veiculo.Modelo.Fabricante.Descricao + "/" + c.Veiculo.AnoFabricacao.ToString(),
                c.Preco,
                IdCompra = c.Id
            }
                          );

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public JsonResult CarregarVendas(int? IdStatusVenda)
        {
            var draw = Request.Form.GetValues("draw").FirstOrDefault();
            var start = Request.Form.GetValues("start").FirstOrDefault();
            var length = Request.Form.GetValues("length").FirstOrDefault();
            var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            var searchValue = Request.Form.GetValues("search[value]").FirstOrDefault();

            int pageSize = length != null ? Convert.ToInt32(length) : 0;
            int skip = start != null ? Convert.ToInt32(start) : 0;

            Veiculos.Ioc.Service.Service<Ioc.Core.Data.Venda> servico = new Ioc.Service.Service<Ioc.Core.Data.Venda>();

            Expression<Func<Ioc.Core.Data.Venda, bool>> _where = null;

            if(IdStatusVenda != null)
                _where= a => a.IdStatusVenda == IdStatusVenda;

            if (!string.IsNullOrEmpty(searchValue))
            {
                _where = a => a.IdStatusVenda == IdStatusVenda && (a.Veiculo.Placa.StartsWith(searchValue) || a.Veiculo.Modelo.Descricao.StartsWith(searchValue) || a.Veiculo.Modelo.Fabricante.Descricao.StartsWith(searchValue));
            }

            var result = from v in servico.BuscarTodos(_where).ToList()
                         select new
                         {
                             v.Id,
                             Data = v.Data.ToString("dd/MM/yyyy"),
                             v.Veiculo.Placa,
                             Fabricante = v.Veiculo.Modelo.Fabricante.Descricao,
                             Modelo = v.Veiculo.Modelo.Descricao,
                             Valor = v.ValorTotal,
                             Vendedor = v.Usuario.Nome
                         };

            int recordsTotal = result.Count();

            var data = result.OrderByDescending(o => o.Id).Skip(skip).Take(pageSize).ToList();

            if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir)))
            {
                if (sortColumnDir.Equals("asc", StringComparison.OrdinalIgnoreCase))
                {
                    if (sortColumn.Equals("Fabricante", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Fabricante).ToList();
                    if (sortColumn.Equals("Data", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Data).ToList();
                    if (sortColumn.Equals("Modelo", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Modelo).ToList();
                    if (sortColumn.Equals("Placa", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Placa).ToList();
                    if (sortColumn.Equals("Valor", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Valor).ToList();
                    if (sortColumn.Equals("Vendedor", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderBy(f => f.Vendedor).ToList();
                }
                else
                {
                    if (sortColumn.Equals("Fabricante", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Fabricante).ToList();
                    if (sortColumn.Equals("Data", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Data).ToList();
                    if (sortColumn.Equals("Modelo", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Modelo).ToList();
                    if (sortColumn.Equals("Placa", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Placa).ToList();
                    if (sortColumn.Equals("Valor", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Valor).ToList();
                    if (sortColumn.Equals("Vendedor", StringComparison.OrdinalIgnoreCase))
                        data = data.OrderByDescending(f => f.Vendedor).ToList();
                }
            }

            return Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data }, JsonRequestBehavior.AllowGet);
        }