public bool altaCategoria(Categoria reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("insert into CATEGORIAS values ('" + reg.descripcion + "');");
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() >= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
        public bool bajaCategoría(Categoria reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("delete from CATEGORIAS where Id = '" + reg.codigo + "' and Descripcion = '" + reg.descripcion + "';");
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
Esempio n. 3
0
 public bool altaNuevoArticulo(Articulo articulo)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareStatement("insert into ARTICULOS values (@codigo, @nombre, @descripcion, @idMarca, @idCategoria, @imagen, @precio);");
         data.addParameter("@codigo", articulo.codigo);
         data.addParameter("@nombre", articulo.nombre);
         data.addParameter("@descripcion", articulo.descripcion);
         data.addParameter("@idMarca", articulo.marca.id);
         data.addParameter("@idCategoria", articulo.categoria.id);
         data.addParameter("@imagen", articulo.imagen);
         data.addParameter("@precio", articulo.precio);
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool modificarCategoria(Categoria reg, string newDesc)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                Validator.validate(reg, newDesc);

                ddbbData.prepareStatement("update CATEGORIAS set Descripcion = '" + newDesc + "' where Id = '" + reg.codigo + "' and Descripcion = '" + reg.descripcion + "';");
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
Esempio n. 5
0
 public bool modificarArticulo(Articulo articulo)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareStatement("update ARTICULOS set ARTICULOS.Nombre = @nombre, " +
                               "ARTICULOS.Descripcion = @descripcion, ARTICULOS.IdMarca = @idMarca, ARTICULOS.IdCategoria = @idCategoria, " +
                               "ARTICULOS.ImagenUrl = @imagenUrl, ARTICULOS.Precio = @precio where ARTICULOS.Codigo = @codigo");
         data.addParameter("@nombre", articulo.nombre);
         data.addParameter("@descripcion", articulo.descripcion);
         data.addParameter("@idMarca", articulo.marca.id);
         data.addParameter("@idCategoria", articulo.categoria.id);
         data.addParameter("@imagenUrl", articulo.imagen);
         data.addParameter("@precio", articulo.precio);
         data.addParameter("@codigo", articulo.codigo);
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
        public bool modificarMarca(Marca reg, string newDesc)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("update MARCAS set Descripcion = '" + newDesc + "' where Id = '" + reg.codigo + "';");
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData = null;
            }
        }
Esempio n. 7
0
        public bool bajaMarca(Marca reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("delete from MARCAS where Id = '" + reg.codigo + "' and Descripcion = '" + reg.descripcion + "';");
                ddbbData.sendStatement();

                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData = null;
            }
        }
Esempio n. 8
0
        public bool altaMarcaDB(Marca reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                Validator.validate(reg);
                ddbbData.prepareStatement("insert into MARCAS values(@Descripcion)");
                ddbbData.addParameter("@Descripcion", reg.descripcion);
                ddbbData.sendStatement();

                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData = null;
            }
        }
        public bool bajaArticulo(Articulo reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("delete from ARTICULOS where Id = '" + reg.id +
                                          "' and Codigo = '" + reg.codigo + "' and Nombre = '" + reg.nombre + "';");
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
        public bool altaArticulo(Articulo reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("insert into ARTICULOS VALUES ( @cod, @nom, @desc, @idMar, @idCat, @ima, @pre);");
                ddbbData.addParameter("@cod", reg.codigo);
                ddbbData.addParameter("@nom", reg.nombre);
                ddbbData.addParameter("@desc", reg.descripcion);
                ddbbData.addParameter("@idMar", reg.marca.codigo);
                ddbbData.addParameter("@idCat", reg.categoria.codigo);
                ddbbData.addParameter("@ima", reg.imagen);
                ddbbData.addParameter("@pre", reg.precio);
                ddbbData.sendStatement();

                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
        public bool modificarArticulo(Articulo reg)
        {
            DDBBGateway ddbbData = new DDBBGateway();

            try
            {
                ddbbData.prepareStatement("update ARTICULOS set " +
                                          "Codigo = @Cod, " +
                                          "Nombre = @Nom, " +
                                          "Descripcion = @Desc, " +
                                          "IdMarca = @IdMar, " +
                                          "IdCategoria = @IdCat, " +
                                          "Imagen = @Img, " +
                                          "Precio = @Pre " +
                                          "where Id = @IdArt;");

                ddbbData.addParameter("@Cod", reg.codigo);
                ddbbData.addParameter("@Nom", reg.nombre);
                ddbbData.addParameter("@Desc", reg.descripcion);
                ddbbData.addParameter("@IdMar", reg.marca.codigo.ToString());
                ddbbData.addParameter("@IdCat", reg.categoria.codigo.ToString());
                ddbbData.addParameter("@Img", reg.imagen);
                ddbbData.addParameter("@Pre", reg.precio.ToString());
                ddbbData.addParameter("@IdArt", reg.id.ToString());
                ddbbData.sendStatement();
                if (ddbbData.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddbbData.closeConnection();
            }
        }
Esempio n. 12
0
 public bool updateVoucher(Voucher aux)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareStatement("update Vouchers set IdCliente = '" + aux.IdCliente + "', IdProducto = '" + aux.IdProducto + "', Estado = 1, FechaRegistro = '" + DateTime.Now + "' where Id = '" + aux.ID + "'");
         data.sendStatement();
         if (data.getAffectedRows() >= 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 13
0
 public bool eliminaciónFisicaArticulo(Articulo aBorrar)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery("delete from ARTICULOS where Codigo = @codigo");
         data.addParameter("@codigo", aBorrar.codigo);
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 14
0
        public bool modificarCliente(Cliente aux)
        {
            try
            {
                DDBBGateway data = new DDBBGateway();
                data.prepareStatement("update Clientes set Nombre = '" + aux.Nombre + "', Apellido = '" + aux.Apellido + "', Email = '" + aux.Email + "', Direccion = '" + aux.Direccion + "', Ciudad = '" + aux.Ciudad + "', CodigoPostal = '" + aux.CodigoPostal + "' where DNI = '" + aux.DNI + "'");
                data.sendStatement();
                data.closeConnection();

                if (data.getAffectedRows() >= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 15
0
        public bool altaCliente(Cliente aux)
        {
            try
            {
                DDBBGateway data = new DDBBGateway();
                data.prepareStatement("" +
                                      "INSERT INTO Clientes VALUES ('" + aux.DNI + "', '" + aux.Nombre + "', '" + aux.Apellido + "', '" + aux.Email + "', '" + aux.Direccion + "', '" + aux.Ciudad + "', '" + aux.CodigoPostal + "', '" + DateTime.Now + "')");
                data.sendStatement();
                data.closeConnection();

                if (data.getAffectedRows() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }