예제 #1
0
        public static IEnumerable <PlanoDeVendas> GetListaPlanoDeVendas(long idconta, long dt_ini, long dt_fim, int?idmarca, int?idcolecao, int?idcliente, int?idcidade, int?idgrupo)
        {
            var    u      = new PlanoDeVendas();
            var    f      = new Filtros(u);
            string filtro = "";

            f.Add(() => u.id_conta, idconta, FiltroExpressao.Igual);
            // f.Add(() => u.dt_agenda, new DateTime(dt_ini), FiltroExpressao.MaiorIgual);

            /* if (dt_fim != 0)
             * {
             *   f.Add(() => u.dt_agenda, new DateTime(dt_fim), FiltroExpressao.MenorIgual);
             * } */
            if ((idmarca ?? 0) != 0)
            {
                f.Add(() => u.marca, idmarca, FiltroExpressao.Igual);
            }
            if ((idcliente ?? 0) != 0)
            {
                f.Add(() => u.cliente, idcliente, FiltroExpressao.Igual);
            }
            if ((idcolecao ?? 0) != 0)
            {
                f.Add(() => u.colecao, idcolecao, FiltroExpressao.Igual);
            }

            /*  if ((idgrupo ?? 0) != 0)
             * {
             *    filtro = string.Format(" and id_servico in (select s.id from cadastro_servico s where s.id_grupo={0})", idgrupo);
             * }*/

            return(DAL.ListarObjetos <PlanoDeVendas>(f.ToString() + filtro, "id desc"));
        }
예제 #2
0
        public ActionResult Deletar(int id = 0)
        {
            var model = new PlanoDeVendas();

            if (id > 0)
            {
                model = DAL.GetObjeto <PlanoDeVendas>(string.Format("id={0}", id));
                DAL.Excluir(model);
            }
            return(RedirectToAction("Consultar"));
        }
예제 #3
0
 public ActionResult Cadastrar(int id = 0)
 {
     if (Settings.hasPermission(Settings.MENU_PLANODEVENDAS_CADASTRAR, UsuarioLogado))
     {
         var model = new PlanoDeVendas();
         if (id > 0)
         {
             model = DAL.GetObjetoById <PlanoDeVendas>(id);
         }
         return(View(model));
     }
     else
     {
         return(View("~/views/Shared/error.cshtml"));
     }
 }
예제 #4
0
        public ActionResult Cadastrar(PlanoDeVendas model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            model.id_usuario = Convert.ToInt64(UsuarioLogado.IdUsuario);
            model.id_conta   = Convert.ToInt64(UsuarioLogado.IdConta);
            try
            {
                if (model.id == 0)
                {
                    var existe1 = DAL.GetObjeto <PlanoDeVendas>(string.Format("id_colecao={0} and id_marca={1} and id_cliente={2}", model.colecao, model.marca, model.cliente)) ?? new PlanoDeVendas();
                    if (existe1.id > 0)
                    {
                        this.AddNotification("Plano de vendas já existe!", "Alerta");
                        return(View(model));
                    }
                }

                long id = DAL.Gravar(model);

                if (model.id > 0 && id == 0)
                {
                    this.AddNotification("Plano de vendas alterado!", "Sucesso");
                }
                else
                {
                    this.AddNotification("Plano de vendas cadastrado!", "Sucesso");
                }
            }
            catch (Exception e)
            {
                this.AddNotification("Erro:" + e.Message, "Erro");
            }

            var obj = new PlanoDeVendas();

            obj.marca             = model.marca;
            obj.nm_marca          = model.nm_marca;
            obj.colecao           = model.colecao;
            obj.nm_colecao        = model.nm_colecao;
            obj.valorcolecaoatual = model.valorcolecaoatual;
            return(View(obj));
        }