public ActionResult Consultar_Producto(string nombre, string categoria) { List <Producto> prod; List <Categoria> cat; Metodo_Producto mp = new Metodo_Producto(); Metodo_Categoria mc = new Metodo_Categoria(); Info datos = new Info(); //List<Object> todo = new List<Object>(); cat = mc.listar(); prod = mp.buscar(nombre, categoria); ViewBag.eliminar = TempData["Eliminar"]; ViewBag.modificar = TempData["Modificar"]; datos.Prod = prod; datos.Cat = cat; //todo.Add(prod); //todo.Add(cat); return(View(datos)); }
public ActionResult Registrar_Producto() { Metodo_Categoria mc = new Metodo_Categoria(); List <Categoria> cat = new List <Categoria>(); cat = mc.listar(); return(View(cat)); }
public ActionResult Consultar_Categoria() { List <Categoria> lista; Metodo_Categoria mc = new Metodo_Categoria(); lista = mc.listar(); ViewBag.eliminar = TempData["Eliminar"]; ViewBag.modificar = TempData["Modificar"]; return(View(lista)); }
public ActionResult Modificar_Categoria(int?id) { Categoria cat = new Categoria(); Metodo_Categoria mc = new Metodo_Categoria(); if (id != null) { cat = mc.obtener(id); return(View(cat)); } else { return(RedirectToAction("Consultar_Categoria")); } }
public ActionResult eliminar(int id) { Metodo_Categoria mc = new Metodo_Categoria(); if (mc.eliminar(id)) { TempData.Add("Eliminar", "Se eliminó Correctamente el Registro"); } else { TempData.Add("Eliminar", "No se eliminó Correctamente el Registro"); } return(RedirectToAction("Consultar_Categoria")); }
public ActionResult Modificar_Categoria(int?id, string nombre, string descripcion) { Metodo_Categoria mc = new Metodo_Categoria(); Categoria cat = new Categoria(); string message; SortedList <string, string> datos = new SortedList <string, string>(); if (id != null) { if (String.IsNullOrEmpty(nombre)) { datos.Add("sp_nombre", "Ingrese el nombre de la categoría"); } if (String.IsNullOrEmpty(descripcion)) { datos.Add("sp_descripcion", "Ingrese la descripción de la Categoría"); } if (datos.Count == 0) { cat.Id_categoria = id; cat.Nombre = nombre; cat.Descripcion = descripcion; if (mc.actualizar(cat)) { message = "Se actualizaron los datos correctamente"; } else { message = "No se pudo actualizar los datos"; } return(Json(new { message = message, success = true })); } else { return(Json(new { message = "Necesita completar los datos necesarios", success = false, datos })); } } return(RedirectToAction("Consultar_Categoria")); }
public ActionResult Modificar_Producto(int?id) { Metodo_Producto mp = new Metodo_Producto(); Metodo_Categoria mc = new Metodo_Categoria(); List <Categoria> cat = new List <Categoria>(); if (id != null) { cat = mc.listar(); pro = mp.obtener(id); Info datos = new Info(); datos.Cat = cat; datos.Obj_prod = pro; return(View(datos)); } else { return(RedirectToAction("Consultar_Producto")); } }
public ActionResult Registrar_Categoria(string nombre, string descripcion) { Categoria cat = new Categoria(); Metodo_Categoria mc = new Metodo_Categoria(); string message; SortedList <string, string> error = new SortedList <string, string>(); if (String.IsNullOrEmpty(nombre)) { error.Add("sp_nombre", "Ingrese el Nombre de la Categoría"); } if (String.IsNullOrEmpty(descripcion)) { error.Add("sp_descripcion", "Ingrese la Descripción"); } if (error.Count == 0) { cat.Nombre = nombre; cat.Descripcion = descripcion; if (mc.guardar(cat)) { message = "Se guardaron los datos correctamente"; } else { message = "No se Guardaron los datos"; } return(Json(new { message = message, success = true })); } else { return(Json(new { message = "Necesita completar los campos necesarios", success = false, datos = error })); } }
public ActionResult Registrar_Producto(string nombre, int?categoria, Double?precio, int?stock, string codigo, string descripcion, HttpPostedFileBase imagen) { Producto pro = new Producto(); Metodo_Producto mp = new Metodo_Producto(); Metodo_Categoria mc = new Metodo_Categoria(); List <Categoria> cat = new List <Categoria>(); string message, subir; SortedList <string, string> error = new SortedList <string, string>(); if (String.IsNullOrEmpty(nombre)) { error.Add("sp_nombre", "Ingrese el nombre del Producto"); } if (categoria == null) { error.Add("sp_categoria", "Seleccione la Categoria para el Producto"); } if (precio == null) { error.Add("sp_precio", "Ingrese el Precio del Producto"); } if (stock == null) { error.Add("sp_stock", "Ingrese el Stock del Producto"); } if (String.IsNullOrEmpty(codigo)) { error.Add("sp_codigo", "Ingrese el Codigo del Producto"); } if (String.IsNullOrEmpty(descripcion)) { error.Add("sp_descripcion", "Ingrese la Descripción del Producto"); } //cat = mc.listar(); if (error.Count == 0) { pro.Nombre = nombre; pro.Id_categoria = categoria; pro.Precio = precio; pro.Stock = stock; pro.Codigo = codigo; pro.Descripcion = descripcion; pro.Imagen = imagen.FileName; subir = Server.MapPath("~/Content/Imagenes/"); subir += imagen.FileName; if (mp.guardar(pro) && mp.subirArchivo(subir, imagen)) { message = "Se guardaron los datos correctamente"; } else { message = "No se Guardaron lo datos"; } return(Json(new { message = message, success = true })); } else { message = "Ingrese los datos necesarios"; return(Json(new { message = message, success = false, datos = error })); } }