public zapatos findById(int id_zapatos)
    {
        zapatos zapato    = new zapatos();
        String  sqlString = "SELECT * FROM zapatos WHERE id_zapatos = @id_zapatos";

        conn = new conexion();
        SqlCommand command = new SqlCommand(sqlString, conn.getConn());

        command.Parameters.Add("@id_zapatos", SqlDbType.Int);
        command.Parameters["@id_zapatos"].Value = id_zapatos;
        SqlDataReader rd = command.ExecuteReader();

        while (rd.Read())
        {
            zapato.Id_zapatos          = rd.GetInt32(0);
            zapato.NomGaZapato1        = rd.GetString(1);
            zapato.Estilos             = rd.GetInt32(2);
            zapato.Marcas              = rd.GetInt32(3);
            zapato.TallasDisponibles1  = rd.GetString(4);
            zapato.CantidadDisponible1 = rd.GetInt32(5);
            zapato.ColoresGama1        = rd.GetString(6);
            zapato.Viajeros            = rd.GetInt32(7);
        }
        rd.Close();
        conn.cerrar();
        return(zapato);
    }
 public int remove(zapatos zapato)
 {
     {
         int    a     = 0;
         String query = "DELETE FROM zapatos WHERE id_zapatos = @id_zapatos";
         conn = new conexion();
         SqlCommand     command = conn.getConn().CreateCommand();
         SqlTransaction trans   = conn.getConn().BeginTransaction("simpleTrans");
         try
         {
             command.Connection  = conn.getConn();
             command.CommandText = query;
             command.Transaction = trans;
             command.Parameters.Add("@id_zapatos", SqlDbType.Int);
             command.Parameters["@id_zapatos"].Value = zapato.Id_zapatos;
             command.ExecuteNonQuery();
             trans.Commit();
             a = 1;
         }
         catch (Exception e)
         {
             trans.Rollback();
         }
         finally
         {
             conn.cerrar();
         }
         return(a);
     }
 }
    public List <zapatos> findAll()
    {
        List <zapatos> lista = new List <zapatos>(0);

        conn = new conexion();
        SqlCommand    command = new SqlCommand("SELECT * FROM zapatos", conn.getConn());
        SqlDataReader rd      = command.ExecuteReader();

        while (rd.Read())
        {
            zapatos zapato = new zapatos();
            zapato.Id_zapatos          = rd.GetInt32(0);
            zapato.NomGaZapato1        = rd.GetString(1);
            zapato.Estilos             = rd.GetInt32(2);
            zapato.Marcas              = rd.GetInt32(3);
            zapato.TallasDisponibles1  = rd.GetString(4);
            zapato.CantidadDisponible1 = rd.GetInt32(5);
            zapato.ColoresGama1        = rd.GetString(6);
            zapato.Viajeros            = rd.GetInt32(7);
            lista.Add(zapato);
        }
        rd.Close();
        conn.cerrar();
        return(lista);
    }
    public int deleteZapato(int id_zapatos)
    {
        zapatos zapato = new zapatos();

        zapato.Id_zapatos = id_zapatos;
        ZapatoService dao = new ZapatoServiceImpl();

        return((int)dao.remove(zapato));
    }
    public int agregarZapato(String nombre, Int32 estilo, Int32 marca, String tallas, Int32 cantidad, String colores, Int32 viajeros)
    {
        zapatos zapato = new zapatos();

        zapato.NomGaZapato1        = nombre;
        zapato.Estilos             = estilo;
        zapato.Marcas              = marca;
        zapato.TallasDisponibles1  = tallas;
        zapato.CantidadDisponible1 = cantidad;
        zapato.ColoresGama1        = colores;
        zapato.Viajeros            = viajeros;
        ZapatoService dao = new ZapatoServiceImpl();

        return((int)dao.add(zapato));
    }
    public int update(zapatos zapato)
    {
        int    a     = 0;
        String query = "UPDATE zapatos SET NomGaZapato = @NomGaZapato, estilos = @estilos, marcas = @marcas, TallasDisponibles = @TallasDisponibles, CantidadDisponible = @CantidadDisponible, ColoresGama = @ColoresGama, viajeros = @viajeros WHERE id_zapatos = @id_zapatos";

        conn = new conexion();
        SqlCommand     command = conn.getConn().CreateCommand();
        SqlTransaction trans   = conn.getConn().BeginTransaction("simpleTrans");

        try
        {
            command.Connection  = conn.getConn();
            command.CommandText = query;
            command.Transaction = trans;
            command.Parameters.Add("@id_zapatos", SqlDbType.Int);
            command.Parameters["@id_zapatos"].Value = zapato.Id_zapatos;
            command.Parameters.Add("@NomGaZapato", SqlDbType.VarChar, 50);
            command.Parameters.Add("@estilos", SqlDbType.Int);
            command.Parameters.Add("@marcas", SqlDbType.Int);
            command.Parameters.Add("@TallasDisponibles", SqlDbType.VarChar, 100);
            command.Parameters.Add("@CantidadDisponible", SqlDbType.Int);
            command.Parameters.Add("@ColoresGama", SqlDbType.VarChar, 100);
            command.Parameters.Add("@viajeros", SqlDbType.Int);
            command.Parameters["@NomGaZapato"].Value        = zapato.NomGaZapato1;
            command.Parameters["@estilos"].Value            = zapato.Estilos;
            command.Parameters["@marcas"].Value             = zapato.Marcas;
            command.Parameters["@TallasDisponibles"].Value  = zapato.TallasDisponibles1;
            command.Parameters["@CantidadDisponible"].Value = zapato.CantidadDisponible1;
            command.Parameters["@ColoresGama"].Value        = zapato.ColoresGama1;
            command.Parameters["@viajeros"].Value           = zapato.Viajeros;
            command.ExecuteNonQuery();
            trans.Commit();
            a = 1;
        }
        catch (Exception e)
        {
            trans.Rollback();
        }
        finally
        {
            conn.cerrar();
        }
        return(a);
    }
    public int add(zapatos zapato)
    {
        int a = 0;

        conn = new conexion();
        SqlTransaction tran;
        SqlCommand     command = conn.getConn().CreateCommand();

        tran = conn.getConn().BeginTransaction("simpleTransicion");
        try
        {
            command.Connection  = conn.getConn();
            command.Transaction = tran;
            command.CommandText = "INSERT INTO zapatos(NomGaZapato,estilos,marcas,TallasDisponibles,CantidadDisponible,ColoresGama,viajeros) VALUES(@NomGaZapato,@estilos,@marcas,@TallasDisponibles,@CantidadDisponible,@ColoresGama,@viajeros)";
            command.Parameters.Add("@NomGaZapato", SqlDbType.VarChar, 50);
            command.Parameters.Add("@estilos", SqlDbType.Int);
            command.Parameters.Add("@marcas", SqlDbType.Int);
            command.Parameters.Add("@TallasDisponibles", SqlDbType.VarChar, 100);
            command.Parameters.Add("@CantidadDisponible", SqlDbType.Int);
            command.Parameters.Add("@ColoresGama", SqlDbType.VarChar, 100);
            command.Parameters.Add("@viajeros", SqlDbType.Int);
            command.Parameters["@NomGaZapato"].Value        = zapato.NomGaZapato1;
            command.Parameters["@estilos"].Value            = zapato.Estilos;
            command.Parameters["@marcas"].Value             = zapato.Marcas;
            command.Parameters["@TallasDisponibles"].Value  = zapato.TallasDisponibles1;
            command.Parameters["@CantidadDisponible"].Value = zapato.CantidadDisponible1;
            command.Parameters["@ColoresGama"].Value        = zapato.ColoresGama1;
            command.Parameters["@viajeros"].Value           = zapato.Viajeros;
            command.ExecuteNonQuery();
            tran.Commit();
            a = 1;
        }
        catch (Exception e)
        {
            tran.Rollback();
        }
        finally
        {
            conn.cerrar();
        }
        return(a);
    }
Exemple #8
0
        private void btnBuscar_Click(object sender, RoutedEventArgs e)
        {
            Int32 id = Convert.ToInt32(cmbProducto.SelectedValue);

            List <zapatos> lista = new List <zapatos>(0);

            zapatos zapato = new zapatos();

            zapato.Id_zapatos          = ws.getZapatoById(id).Id_zapatos;
            zapato.NomGaZapato1        = ws.getZapatoById(id).NomGaZapato1;
            zapato.Estilos             = ws.getZapatoById(id).Estilos;
            zapato.Marcas              = ws.getZapatoById(id).Marcas;
            zapato.TallasDisponibles1  = ws.getZapatoById(id).TallasDisponibles1;
            zapato.CantidadDisponible1 = ws.getZapatoById(id).CantidadDisponible1;
            zapato.ColoresGama1        = ws.getZapatoById(id).ColoresGama1;
            zapato.Viajeros            = ws.getZapatoById(id).Viajeros;
            lista.Add(zapato);

            dtgZapatos.ItemsSource = lista;
        }