Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Usuario"].ToString().Equals("Administrador"))
            {
                lblBienvenida.Text = "HOLA, " + Session["Nombre"].ToString();
                lblCargo.Text      = "USTED ES, " + Session["Usuario"].ToString().ToUpper();
            }
            else
            {
                Response.Redirect("LogIn.aspx");
            }

            if (!Page.IsPostBack)
            {
                Producto          p  = new Producto();
                DataSet           ds = p.ListarProductoSQL();
                CategoriaProducto cp = new CategoriaProducto();
                ddlCategoria.DataSource     = cp.ListarIdNombreSQL().Tables["CATEGORIA_PRODUCTO"].DefaultView;
                ddlCategoria.DataTextField  = "NOMBRE_CATEGORIAPRODUCTO";
                ddlCategoria.DataValueField = "ID_CATEGORIAPRODUCTO";
                ddlCategoria.DataBind();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    gvProducto.DataSource = ds;
                    gvProducto.DataBind();
                }
                else
                {
                    Response.Write(@"<script language='javascript'>alert('Sin registros de productos');</script>");
                }

                ddlCategoria.SelectedIndex = 0;
            }
        }
 /// <summary>
 /// Este método permite agregar o modificar un producto a la base de datos, pasando como parámetro un ProductoDTO
 /// Devuelve el Id del producto agregado/modificado
 /// Precondicion: El producto siempre tiene una categoria
 /// </summary>
 /// <param name="pIdProducto"></param>
 public int AgregarModificarProducto(ProductoDTO pProductoDTO)
 {
     using (var repo = new Repositorio())
     {
         Producto          pro         = repo.Productos.Find(pProductoDTO.Id);
         Producto          proAAgregar = this.DTOAProducto(pProductoDTO);
         CategoriaProducto cat         = repo.CategoriaProductos.Find(pProductoDTO.IdCategoria);
         proAAgregar.Categoria = cat;
         if (pro == null)
         {
             proAAgregar.Activo = true;
             repo.Productos.Add(proAAgregar);
             repo.SaveChanges();
             return(proAAgregar.Id);
         }
         else  /// Modificar producto
         {
             pro.Nombre               = proAAgregar.Nombre;
             pro.Descripcion          = proAAgregar.Descripcion;
             pro.StockMinimo          = proAAgregar.StockMinimo;
             pro.CantidadEnStock      = proAAgregar.CantidadEnStock;
             pro.PorcentajeDeGanancia = proAAgregar.PorcentajeDeGanancia;
             pro.PrecioDeCompra       = proAAgregar.PrecioDeCompra;
             pro.Activo               = proAAgregar.Activo;
             pro.Categoria            = proAAgregar.Categoria;
             repo.SaveChanges();
             return(pro.Id);
         }
     }
 }
Exemplo n.º 3
0
        public async Task <IEnumerable <CategoriaProducto> > GetAllAsync()
        {
            //throw new NotImplementedException();
            try
            {
                using (IDbConnection conexion = new SqlConnection(WebConnectionString))
                {
                    conexion.Open();
                    //var dynamicParameters = new DynamicParameters();
                    List <CategoriaProducto> Lista = new List <CategoriaProducto>();
                    CategoriaProducto        Item;
                    var dr = await conexion.ExecuteReaderAsync("[Catalogo].[SPCID_Get_CategoriaProducto]", /*param: dynamicParameters,*/ commandType : CommandType.StoredProcedure);

                    while (dr.Read())
                    {
                        Item = new CategoriaProducto();
                        Item.IdCategoriaProducto = dr.GetInt32(dr.GetOrdinal("IdCategoriaProducto"));
                        Item.Nombre      = dr.GetString(dr.GetOrdinal("Nombre"));
                        Item.Descripcion = dr.GetString(dr.GetOrdinal("Descripcion"));
                        Lista.Add(Item);
                    }
                    dr.Close();
                    return(Lista);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
 public Producto(string nombre, CategoriaProducto categoria, double precio, int cantidad)
 {
     this.nombre    = nombre;
     this.precio    = precio;
     this.cantidad  = cantidad;
     this.categoria = categoria;
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Usuario"].ToString().Equals("Administrador"))
            {
                lblBienvenida.Text = "HOLA, " + Session["Nombre"].ToString();
                lblCargo.Text      = "USTED ES, " + Session["Usuario"].ToString().ToUpper();
            }
            else
            {
                Response.Redirect("LogIn.aspx");
            }


            if (!Page.IsPostBack)
            {
                CategoriaProducto cp = new CategoriaProducto();
                DataSet           ds = cp.ListarCamposSQL();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    gvCategoriaProducto.DataSource = ds;
                    gvCategoriaProducto.DataBind();
                }
                else
                {
                    Response.Write(@"<script language='javascript'>alert('Sin registros de categorias de productos');</script>");
                }
            }
        }
        public async Task <JsonResult> PutCategoriaProducto(int id, CategoriaProducto categoriaProducto)
        {
            if (id != categoriaProducto.id)
            {
                return(new JsonResult(new { mensaje = "No coinciden los id." }));
            }

            _context.Entry(categoriaProducto).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoriaProductoExists(id))
                {
                    return(new JsonResult(new { mensaje = "No se encontro esa categoria" }));
                }
                else
                {
                    throw;
                }
            }

            return(new JsonResult(categoriaProducto));
        }
        public async Task <IActionResult> PutCategoriaProducto(long id, CategoriaProducto categoriaProducto)
        {
            if (id != categoriaProducto.Id)
            {
                return(BadRequest());
            }

            _context.Entry(categoriaProducto).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoriaProductoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// Busca CategoriaProducto por nombre
        /// </summary>
        /// <param name="nombreCategoria"></param>
        /// <returns> El id de la categoria </returns>
        public int BuscarCategoriaPorNombre(String nombreCategoria)
        {
            List <CategoriaProducto> listaCategoria = ListarCategorias();
            CategoriaProducto        categoria      = listaCategoria.Find(x => x.Nombre == nombreCategoria);

            return(categoria.Id);
        }
Exemplo n.º 9
0
        public CategoriaProducto obtenerCategoria(int codProdCat)
        {
            CategoriaProducto categoria = null;

            SqlCommand comando = new SqlCommand("usp_obtener_categoria", conexion);

            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@codProdCat", codProdCat);

            conexion.Open();
            SqlDataReader reader = comando.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    CategoriaProducto c = new CategoriaProducto();
                    c.codProdCat = int.Parse(reader["codProdCat"].ToString());
                    c.nomProdCat = reader["nomProdCat"].ToString();
                    categoria    = c;
                }
            }
            conexion.Close();

            return(categoria);
        }
Exemplo n.º 10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CategoriaProducto aux = new CategoriaProducto();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_baseurl);

                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage res = await client.GetAsync("api/CategoriaProducto/GetOneById/5?id=" + id);

                if (res.IsSuccessStatusCode)
                {
                    var auxRes = res.Content.ReadAsStringAsync().Result;

                    aux = JsonConvert.DeserializeObject <CategoriaProducto>(auxRes);
                }

                var myContent   = JsonConvert.SerializeObject(aux);
                var buffer      = Encoding.UTF8.GetBytes(myContent);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var postTask = client.PostAsync("api/CategoriaProducto/Delete", byteContent).Result;

                var result = postTask;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ModelState.AddModelError(string.Empty, "Server Error, Please contact administrator");
            return(View(aux));
        }
Exemplo n.º 11
0
        public List <CategoriaProducto> listarComboCategoriasProd()
        {
            List <CategoriaProducto> lstCatPro = null;
            SqlCommand comando = new SqlCommand("usp_listarCombo_categoria", conexion);

            conexion.Open();

            SqlDataReader reader = comando.ExecuteReader();

            if (reader.HasRows)
            {
                lstCatPro = new List <CategoriaProducto>();
                while (reader.Read())
                {
                    CategoriaProducto catPro = new CategoriaProducto();
                    catPro.codProdCat = int.Parse(reader["codProdCat"].ToString());
                    catPro.nomProdCat = reader["nomProdCat"].ToString();

                    lstCatPro.Add(catPro);
                }
            }

            conexion.Close();

            return(lstCatPro);
        }
Exemplo n.º 12
0
        public void ModificarCategoriaProducto(CategoriaProducto CategoriaProducto, string Conexion, ref int verificador)
        {
            try
            {
                CapaDatos.CD_Datos CapaDatos  = new CapaDatos.CD_Datos(Conexion);
                string[]           Parametros =
                {
                    "@Id_Emp",
                    "@Id_Cpr",
                    "@Id_Cpr_Ant",
                    "@Cpr_Descripcion",
                    "@Cpr_Activo"
                };
                object[] Valores =
                {
                    CategoriaProducto.Id_Emp,
                    CategoriaProducto.Id_Cpr,
                    CategoriaProducto.Id_Cpr_Ant,
                    CategoriaProducto.Cpr_Descripcion,
                    CategoriaProducto.Cpr_Activo
                };

                SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCatProductoCategoria_Modificar", ref verificador, Parametros, Valores);
                CapaDatos.LimpiarSqlcommand(ref sqlcmd);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
        public void ConsultaCategoriaProducto(CategoriaProducto CategoriaProducto, string Conexion, ref List <CategoriaProducto> List)
        {
            try
            {
                SqlDataReader      dr         = null;
                CapaDatos.CD_Datos CapaDatos  = new CapaDatos.CD_Datos(Conexion);
                string[]           Parametros = { "@Id_Emp" };
                object[]           Valores    = { CategoriaProducto.Id_Emp };
                SqlCommand         sqlcmd     = CapaDatos.GenerarSqlCommand("spCatProductoCategoria_Consulta", ref dr, Parametros, Valores);

                while (dr.Read())
                {
                    CategoriaProducto                 = new CategoriaProducto();
                    CategoriaProducto.Id_Emp          = (int)dr.GetValue(dr.GetOrdinal("Id_Emp"));
                    CategoriaProducto.Id_Cpr          = (int)dr.GetValue(dr.GetOrdinal("Id_Cpr"));
                    CategoriaProducto.Cpr_Descripcion = (string)dr.GetValue(dr.GetOrdinal("Cpr_Descripcion"));
                    CategoriaProducto.Cpr_Activo      = Convert.ToBoolean(dr.GetValue(dr.GetOrdinal("Cpr_Activo")));
                    if (Convert.ToBoolean(CategoriaProducto.Cpr_Activo))
                    {
                        CategoriaProducto.Cpr_ActivoStr = "Activo";
                    }
                    else
                    {
                        CategoriaProducto.Cpr_ActivoStr = "Inactivo";
                    }
                    List.Add(CategoriaProducto);
                }

                CapaDatos.LimpiarSqlcommand(ref sqlcmd);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
 private void dgvCategorias_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvCategorias.CurrentRow.DataBoundItem.GetType() == typeof(CategoriaProducto))
     {
         categoriaActual = (CategoriaProducto)dgvCategorias.CurrentRow.DataBoundItem;
     }
 }
        public async Task <ActionResult> Create([Bind(Include = "Id,CodigoCategoria,DescripcionCategoria,EstadoCategoria")] CategoriaProducto CategoriaProducto)
        {
            //BUSCAR QUE EXISTA UNA CATEGORIA CON ESA DESCRIPCION
            CategoriaProducto bod = db.CategoriasProducto.DefaultIfEmpty(null).FirstOrDefault(b => b.DescripcionCategoria.ToUpper().Trim() == CategoriaProducto.DescripcionCategoria.ToUpper().Trim());

            //SI EXISTE INGRESADO UNA CATEGORIA CON LA DESCRIPCION
            if (bod != null)
            {
                ModelState.AddModelError("DescripcionCategoria", "Utilice otro nombre");
                mensaje = "La descripción ya se encuentra registrada";
                return(Json(new { success = completado, message = mensaje }, JsonRequestBehavior.AllowGet));
            }

            using (var transact = db.Database.BeginTransaction()) {
                try {
                    //ESTADO DE LA CATEGORIA CUANDO SE CREA SIEMPRE ES TRUE
                    CategoriaProducto.EstadoCategoria = true;
                    if (ModelState.IsValid)
                    {
                        db.CategoriasProducto.Add(CategoriaProducto);
                        completado = await db.SaveChangesAsync() > 0 ? true : false;

                        mensaje = completado ? "Almacenado correctamente" : "Error al almacenar";
                    }
                    transact.Commit();
                } catch (Exception) {
                    mensaje = "Error al almacenar";
                    transact.Rollback();
                } //FIN TRY-CATCH
            }     //FIN USING

            return(Json(new { success = completado, message = mensaje }, JsonRequestBehavior.AllowGet));
        }
        public async Task <ServiceResultCategoriaProducto> SaveCategoria(CategoriaProductoServicesModel oCategoria)
        {
            ServiceResultCategoriaProducto result = new ServiceResultCategoriaProducto();

            try
            {
                if (await ValidateCategoria(oCategoria.Nombre))
                {
                    result.success = false;
                    result.message = $"Esta categoria: {oCategoria.Nombre} ya esta registrado";
                    return(result);
                }

                CategoriaProducto newCategoriaProducto = new CategoriaProducto()
                {
                    Nombre = oCategoria.Nombre
                };
                await _categoriaProductoRep.Add(newCategoriaProducto);

                result.message = await _categoriaProductoRep.SaveCategoria() ? "Categoria Agregada" : "Error agregando la categoria";

                oCategoria.Categoria_Producto_Id = newCategoriaProducto.Categoria_Producto_Id;

                result.Data = oCategoria;
            }
            catch (Exception e) { _logger.LogError($"Error: {e.Message}"); result.success = false; result.message = "Error agregando la informacion de la categoria"; }

            return(result.Data);
        }
Exemplo n.º 17
0
        // GET: CategoriaProducto
        public ActionResult CategoriaControler()
        {
            List <CategoriaProducto> lista = new List <CategoriaProducto>();

            CategoriaProducto categoria1 = new CategoriaProducto();

            categoria1.IdCategoria = new Guid();
            categoria1.Nombre      = "Renault";
            categoria1.Descripcion = "Categoria Francesa";
            lista.Add(categoria1);

            CategoriaProducto categoria2 = new CategoriaProducto();

            categoria2.IdCategoria = new Guid();
            categoria2.Nombre      = "Mazda";
            categoria2.Descripcion = "Categoria Japonesa";
            lista.Add(categoria2);

            CategoriaProducto categoria3 = new CategoriaProducto();

            categoria3.IdCategoria = new Guid();
            categoria3.Nombre      = "Chevrolet";
            categoria3.Descripcion = "Categoria Estadounidense";
            lista.Add(categoria3);



            return(View(lista));
        }
        public virtual JsonResult Crear(CategoriaProducto entidad)
        {
            var jsonResponse = new JsonResponse { Success = false };

            if (ModelState.IsValid)
            {
                try
                {
                    entidad.UsuarioCreacion = UsuarioActual.IdUsuario.ToString();
                    entidad.UsuarioModificacion = UsuarioActual.IdUsuario.ToString();

                    if (entidad.CAT_NombreIngles == null)
                        entidad.CAT_NombreIngles = "";
                    if (entidad.CAT_Descripcion == null)
                        entidad.CAT_Descripcion = "";
                    entidad.CAT_IndicadorArea = "A"; // cambiar 22/01/2013

                    CategoriaProductoBL.Instancia.Add(entidad);

                    jsonResponse.Success = true;
                    jsonResponse.Message = "Se Proceso con éxito";
                }
                catch (Exception ex)
                {
                    logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace));
                    jsonResponse.Message = "Ocurrio un error, por favor intente de nuevo o más tarde.";
                }
            }
            else
            {
                jsonResponse.Message = "Por favor ingrese todos los campos requeridos";
            }
            return Json(jsonResponse, JsonRequestBehavior.AllowGet);
        }
 public async Task<CategoriaProducto> GuardarCambios(Guid IdUsuario)
 {
     try
     {
         CategoriaProducto model = new CategoriaProducto
         {
             IdCategoriaProducto = IdCategoriaProducto,                    
             Nombre = Nombre,
             Descripcion = Descripcion                    
         };
         if (State == EntityState.Create)
         {
             return await Repository.AddAsync(model, IdUsuario);
         }
         else if (State == EntityState.Update)
         {
             return await Repository.UpdateAsync(model, IdUsuario);
         }
         return model;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Descripcion")] CategoriaProducto categoriaProducto)
        {
            if (id != categoriaProducto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoriaProducto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriaProductoExists(categoriaProducto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoriaProducto));
        }
Exemplo n.º 21
0
        public void ObtenerCategoriaNoExisteTest()
        {
            categoriadto.idCategoria = 8;
            CategoriaProducto categoria = categoriaService.Obtenercategoria(categoriadto);

            Assert.IsNull(categoria);
        }
        public async Task <ActionResult <CategoriaProducto> > PostCategoriaProducto(CategoriaProducto categoriaProducto)
        {
            _context.CategoriasProductos.Add(categoriaProducto);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoriaProducto", new { id = categoriaProducto.id }, categoriaProducto));
        }
Exemplo n.º 23
0
 public void EliminarCategoriaTest()
 {
     categoriadto.idCategoria = 2;
     categoriaService.Eliminarcategoria(categoriadto);
     cat = categoriaService.Obtenercategoria(categoriadto);
     Assert.IsNull(cat);
 }
Exemplo n.º 24
0
        public CategoriaProducto GetCategoriaProducto(int id)
        {
            CategoriaProducto categoriaProducto = new CategoriaProducto();

            try
            {
                using (conn.Connect())
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "GetCategoriaProducto";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("_id", id);
                    MySqlDataReader reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            categoriaProducto.Id          = Convert.ToInt16(reader["id"]);
                            categoriaProducto.Nombre      = reader["nombre"].ToString();
                            categoriaProducto.Descripcion = reader["descripcion"].ToString();
                            categoriaProducto.IsActive    = Convert.ToInt16(reader["isActive"]);
                        }
                    }
                }
            }
            catch (MySqlException mysqlEx)
            {
                logs.LogExceptionDB(conn.Connect(), mysqlEx, "GetcategoriaProveedor", UserSettings.User);
            }
            catch (Exception ex)
            {
                logs.LogExceptionDB(conn.Connect(), ex, "GetcategoriaProveedor", UserSettings.User);
            }
            return(categoriaProducto);
        }
Exemplo n.º 25
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            Producto          p  = new Producto();
            CategoriaProducto cp = new CategoriaProducto();
            bool   estatus       = false;
            string nom           = txtNombre.Text;
            int    cant          = int.Parse(txtCantidad.Text);
            string desc          = txtDescripcion.Text;

            if (rdoActivo.Checked == true)
            {
                estatus = true;
            }
            int  precio    = int.Parse(txtPrecio.Text);
            int  categ     = int.Parse(ddlCategoria.SelectedValue);
            bool resultado = p.CrearProductoSQL(nom, cant, desc, estatus, precio, categ);

            if (resultado == true)
            {
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                Response.Write(@"<script language='javascript'>alert('Problemas! producto no creado.');</script>");
            }
        }
Exemplo n.º 26
0
        private void Guardar()
        {
            try
            {
                Sesion session = new Sesion();
                session = (Sesion)Session["Sesion" + Session.SessionID];

                CategoriaProducto CategoriaProducto = new CategoriaProducto();
                CategoriaProducto.Id_Emp          = session.Id_Emp;
                CategoriaProducto.Id_Cpr          = Convert.ToInt32(txtClave.Text);
                CategoriaProducto.Cpr_Descripcion = txtDescripcion2.Text;
                CategoriaProducto.Cpr_Activo      = chkActivo.Checked;

                CN_CatProducto_Categoria clsCategoriaProducto = new CN_CatProducto_Categoria();
                int verificador = -1;
                if (HF_ID.Value == "")
                {
                    if (!_PermisoGuardar)
                    {
                        Alerta("No tiene permisos para grabar");
                        return;
                    }
                    clsCategoriaProducto.InsertarCategoriaProducto(CategoriaProducto, session.Emp_Cnx, ref verificador);
                    if (verificador == 1)
                    {
                        Nuevo();
                        Alerta("Los datos se guardaron correctamente");
                    }
                    else
                    {
                        Alerta("La clave ya existe");
                    }
                }
                else
                {
                    if (!_PermisoModificar)
                    {
                        Alerta("No tiene permisos para modificar");
                        return;
                    }
                    CategoriaProducto.Id_Cpr_Ant = Convert.ToInt32(HF_ID.Value);
                    clsCategoriaProducto.ModificarCategoriaProducto(CategoriaProducto, session.Emp_Cnx, ref verificador);
                    if (verificador == 1)
                    {
                        Nuevo();
                        Alerta("Los datos se modificaron correctamente");
                    }
                    else
                    {
                        Alerta("Ocurrió un error al intentar modificar los datos");
                    }
                }
                rgProducto.Rebind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 27
0
        public ActionResult DeleteConfirmed(int id)
        {
            CategoriaProducto categoriaProducto = db.CategoriaProductoes.Find(id);

            db.CategoriaProductoes.Remove(categoriaProducto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void AltaCategoria(int idCategoria)
 {
     using (Repositorio repo = new Repositorio())
     {
         CategoriaProducto cate = repo.CategoriaProductos.Find(idCategoria);
         cate.Activo = true;;
     }
 }
Exemplo n.º 29
0
        private async Task recargarRegistros()
        {
            CategoriaProducto categoriaP = await categoriaModel.categoriaProducto(currentIdProducto);

            categoriasTodas       = categoriaP.producto;
            categoriasDelProducto = categoriaP.todo;
            actualizarComboCategoria();
        }
 public Boolean VerificarSiCategoriaVence(int pProductoId)
 {
     using (var repo = new Repositorio())
     {
         CategoriaProducto catpro = repo.Productos.Include("Categoria").Where(p => p.Id == pProductoId).First().Categoria;
         return(catpro.Vence);
     }
 }
 public void BajaCategoria(int pIdCategoria)
 {
     using (Repositorio repo = new Repositorio())
     {
         CategoriaProducto cate = repo.CategoriaProductos.Find(pIdCategoria);
         cate.Activo = false;
     }
 }
 public virtual ActionResult Crear()
 {
     try
     {
         var entidad = new CategoriaProducto
         {
             CAT_Nombre = string.Empty
         };
         PrepararDatos(ref entidad, "Crear");
         return PartialView("Edit", entidad);
     }
     catch (Exception ex)
     {
         logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace));
         return new HttpNotFoundWithViewResult("Error");
     }
 }
        private void PrepararDatos(ref CategoriaProducto entidad, string accion)
        {
            entidad.Accion = accion;

            ViewData["idMenu"] = this.IdMenu;
            entidad.IdMenu = this.IdMenu;
            entidad.IdModulo = this.IdModulo;
            entidad.Estados = Utils.EnumToList<TipoEstado>();
        }