//
        // GET: /CuentaGastosDetalle/Create/1

        public ActionResult Create(int id)
        {
            if (id > 0)
            {
                CuentaGastos cg = new CuentaGastos()
                {
                    IdCuentaGastos = id
                };

                CuentaGastosDetalle cgd = new CuentaGastosDetalle();
                ViewBag.Model = cg.verCuentaGastos();
                ConceptosServiceModel        cs  = new ConceptosServiceModel();
                List <ConceptosServiceModel> lis = new List <ConceptosServiceModel>();
                //
                lis.Add(new ConceptosServiceModel
                {
                    IdConcepto = 0,
                    Nombre     = "Selecciona una opcion"
                });
                foreach (ConceptosServiceModel concepto in cs.GetListCuentaGastos())
                {
                    lis.Add(new ConceptosServiceModel {
                        IdConcepto = concepto.IdConcepto,
                        Nombre     = concepto.Nombre
                    });
                }
                SelectList lista = new SelectList(lis, "IdConcepto", "Nombre", 0);
                ViewBag.Lista = lista;
                return(View());
            }
            else
            {
                return(RedirectToAction("Index", new { id = id }));
            }
        }
        //
        // GET: /CuentaGasto/Delete/5

        public ActionResult Delete(int id)
        {
            CuentaGastos cg = new CuentaGastos()
            {
                IdCuentaGastos = id
            };

            return(View(cg.verCuentaGastos()));
        }
        //
        // GET: /CuentaGasto/

        public ActionResult Index()
        {
            CuentaGastos cg = new CuentaGastos();

            ViewBag.Model = cg.listCuentaGastos();
            var    jss = new JavaScriptSerializer();
            String js  = jss.Serialize(cg.listCuentaGastos());

            ViewBag.json = js;
            return(View());
        }
        //
        // GET: /CuentaGasto/Edit/5

        public ActionResult Edit(int id)
        {
            CuentaGastos cg = new CuentaGastos()
            {
                IdCuentaGastos = id
            };
            UserServiceModel us = new UserServiceModel();
            var        lis      = us.getUsersList();
            SelectList lista    = new SelectList(lis, "CodigoAcreditacion", "Nombre", 0);

            ViewBag.Lista = lista;
            return(View(cg.verCuentaGastos()));
        }
        //
        // GET: /CuentaGasto/Details/5

        public ActionResult Details(int id)
        {
            if (id > 0)
            {
                CuentaGastos        cg  = new CuentaGastos();
                CuentaGastosDetalle cgd = new CuentaGastosDetalle();
                cg.IdCuentaGastos = id;
                ViewBag.Model     = cg.verCuentaGastos();
                return(View());
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         CuentaGastos cg = new CuentaGastos()
         {
             IdCuentaGastos = id
         };
         cg.deleteCuentaCargo();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         CuentaGastos cg = new CuentaGastos()
         {
             FechaFinal     = DateTime.Parse(collection.Get("FechaFinal")),
             FechaInicial   = DateTime.Parse(collection.Get("FechaInicial")),
             NumeroAcreedor = collection.Get("NumeroAcreedor"),
             Descripcion    = collection.Get("Descripcion"),
             IdCuentaGastos = Int32.Parse(collection.Get("IdCuentaGastos"))
         };
         cg.modificarCuentaGasto();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                CuentaGastos cg = new CuentaGastos()
                {
                    FechaCreacion  = DateTime.Now,
                    FechaFinal     = DateTime.Parse(collection.Get("FechaFinal")),
                    FechaInicial   = DateTime.Parse(collection.Get("FechaInicial")),
                    NumeroAcreedor = collection.Get("NumeroAcreedor"),
                    Descripcion    = collection.Get("Descripcion")
                };
                cg.crearCuentaGasto();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public JsonResult IndexRest()
        {
            CuentaGastos cg = new CuentaGastos();

            return(Json(cg.listCuentaGastos(), JsonRequestBehavior.AllowGet));
        }