/*
 * CategoryList.java
 *
 */

package com.fenalco.entities;

import java.util.Vector;
import java.util.Hashtable;

import com.fenalco.utilities.database.SQLUtilities;
import com.fenalco.utilities.database.QueryException;

/**
 *
 * @author  Néstor Romero León
 */
public class CategoryList {
 
    private Vector categories;
    
    /** Creates a new instance of CategoryList */
    public CategoryList() {
        
        this.categories = new Vector();
        
        String sql = "SELECT cate_prod_codigo, cate_prod_nombre " +
                     "FROM categoria_producto " +
                     "ORDER BY cate_prod_nombre ASC;";
        
        Vector result = new Vector();
        Hashtable aux = new Hashtable();
        
        try{
            
            result = SQLUtilities.query( sql );
            if( result.size() > 0 ){
                for( int i=0;i<result.size();i++ ){
                    aux = (Hashtable)result.elementAt(i);
                    Vector row = new Vector();
                    row.addElement( (Integer)aux.get("cate_prod_codigo") );
                    row.addElement( (String)aux.get("cate_prod_nombre") );
                    
                    this.categories.addElement( row );
                    
                }
            }
        
        }catch( QueryException qe ){
            System.out.println( qe.getMessage() );
        }
        
    }
    
    /**
     * Getter for property categories.
     * @return Value of property categories.
     */
    public java.util.Vector getCategories() {
        return categories;
    }
    
    /**
     * Setter for property categories.
     * @param categories New value of property categories.
     */
    public void setCategories(java.util.Vector categories) {
        this.categories = categories;
    }
    
    
    /*
    public static void main( String[] args){
    
        CategoryList cl = new CategoryList();
        
        System.exit( 0 );
        
    }
    */
}
