/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package acces_aux_donnes;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;

/**
 *
 * @author emile.lalorcey
 */
public class familleMedocSQL {
    private Connection connexionTest;
    private Statement stmt = 	null;
    private ResultSet result = 	null;
    
    public familleMedocSQL(){
        connexionTest = connexionSQL.getConnect("10.121.38.69","bdgsb","appliGSB","(Uq1XV0Tr01s2H9Z");
    }
    
    public Vector<String> rechercheFamille(){
        Vector<String> famille = new Vector<String>();
        
        try {
            stmt = connexionTest.createStatement();
            // Accès à la table 
            result = stmt.executeQuery("SELECT fLibelle FROM FAMILLE;");
            while(result.next()) {   // Le praticien a été touvé
                famille.add(result.getString(1)); 
            }
            result.close();
            stmt.close();
        }catch (SQLException ex) {
              System.out.println("SQLException : " + ex.getMessage());
              System.out.println("SQLState : " + ex.getSQLState());
              System.out.println("Code erreur : " + ex.getErrorCode());  
        }      
        return famille;
    }
    
    public String rechercheCodeFamille(String libelle){
        String code = "";  
        try {
            stmt = connexionTest.createStatement();
            // Accès à la table 
            result = stmt.executeQuery("SELECT fCode FROM FAMILLE WHERE fLibelle ='"+ libelle +"';");
            while(result.next()) {   // Le praticien a été touvé
                code = result.getString(1); 
            }
            result.close();
            stmt.close();
        }catch (SQLException ex) {
              System.out.println("SQLException : " + ex.getMessage());
              System.out.println("SQLState : " + ex.getSQLState());
              System.out.println("Code erreur : " + ex.getErrorCode());  
        }
        return code;    
    }
    
    public Vector<String> rechercherMedocFamille(String libelle){
        Vector<String> famille = new Vector<String>();  
        try {
            stmt = connexionTest.createStatement();
            // Accès à la table 
            result = stmt.executeQuery("SELECT mNomCommercial FROM MEDICAMENT WHERE fCode ='"+ libelle +"';");
            while(result.next()) {   // Le praticien a été touvé
                famille.add(result.getString(1)); 
            }
            result.close();
            stmt.close();
        }catch (SQLException ex) {
              System.out.println("SQLException : " + ex.getMessage());
              System.out.println("SQLState : " + ex.getSQLState());
              System.out.println("Code erreur : " + ex.getErrorCode());  
        }
        return famille;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}
