Ejemplo n.º 1
0
        public static string Actualizar(int Id, string NombreAnt, string Nombre, string Descripcion)
        {
            DCategoria Datos = new DCategoria();
            Categoria  Obj   = new Categoria();

            if (NombreAnt.Equals(Nombre))
            {
                Obj.IdCategoria = Id;
                Obj.Nombre      = Nombre;
                Obj.Descripcion = Descripcion;
                return(Datos.Actualizar(Obj));
            }
            else
            {
                string Existe = Datos.Existe(Nombre);
                if (Existe.Equals("1"))
                {
                    return("La categoría ya existe");
                }
                else
                {
                    Obj.IdCategoria = Id;
                    Obj.Nombre      = Nombre;
                    Obj.Descripcion = Descripcion;
                    return(Datos.Actualizar(Obj));
                }
            }
        }
Ejemplo n.º 2
0
        public static string Insertar(string Nombre, string Descripcion)
        {
            DCategoria Datos  = new DCategoria();
            string     Existe = Datos.Existe(Nombre);

            if (Existe.Equals("1"))
            {
                return("La categoría ya existe");
            }
            else
            {
                Categoria nuevaCategoria = new Categoria();
                nuevaCategoria.Nombre      = Nombre;
                nuevaCategoria.Descripcion = Descripcion;
                return(Datos.Insertar(nuevaCategoria));
            }
        }
Ejemplo n.º 3
0
        public static string Insertar(string nombre, string descripcion)
        {
            DCategoria Datos  = new DCategoria();
            string     existe = Datos.Existe(nombre);

            if (existe.Equals("1"))
            {
                return("la Categoria ya existe");
            }
            else
            {
                Categoria obj = new Categoria();
                obj.Nombre      = nombre;
                obj.Descripcion = descripcion;
                return(Datos.Insertar(obj));
            }
        }