1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| import java.util.ArrayList;
import java.util.Hashtable;
import ldap.ldap;
import my_sql.Mysql;
public class NbTotalDispo {
public static int nbService(String titre,Mysql m) throws Exception {
int nbS = 0;
String requete = "SELECT st_nbHeuresService FROM statut WHERE st_id like '"+ titre +"'";
ResultSet rs = m.query(requete);
if (rs.next())
nbS = rs.getInt("st_nbHeuresService");
rs.close();
return nbS;
}
public static int nbComp(String titre,Mysql m) throws Exception {
int nbC = 0;
String requete = "SELECT st_maxHeuresComp FROM statut WHERE st_id like '"+ titre +"'";
ResultSet rs = m.query(requete);
if (rs.next())
nbC = rs.getInt("st_maxHeuresComp");
rs.close();
return nbC;
}
public void InfoLdap()
{
ArrayList nomprof ;
Mysql m=new Mysql();
ldap objldap = new ldap( "login", "password" ) ;
objldap.connectldap() ;
Hashtable info_inter = new Hashtable() ;
Hashtable res = new Hashtable() ;
nomprof = m.NomProf() ;
String[] attrIDs = {"statut","quantitetempstravail"};
for( int i = 0 ; i < nomprof.size() ; i++ )
{
res = objldap.reseach( "uid", nomprof.get(i).toString(), attrIDs ) ;
info_inter.put( nomprof.get(i ).toString(), res ) ;
}
}
public static int nbEffectue(String Enseignant,String Module,Mysql m) throws Exception
{
int nbE = 0;
String requete = "SELECT NbHeuresEffectuees FROM services " +
"WHERE NomEnseignant= '"+Enseignant+"' and Module='"+Module+"'";
ResultSet rs = m.query(requete);
if (rs.next())
nbE = rs.getInt("NbHeuresEffectuees");
rs.close();
return nbE;
}
public int nbTotalDispo(int nbE,int nbC,int nbS,Hashtable info_inter) throws Exception
{
int nbToD = 0;
int nb = 0;
int qntr ;
qntr = (((Hashtable) info_inter.get("denis")).get( "quantitetempstravail" )).toInt() ;
nb = (nbS+nbC)* qntr;
nbToD = nb - nbE;
if (rs.next())
nbE = rs.getInt("nbTotalDispo");
rs.close();
return nbToD;
}
public static void main(String[] args)throws Exception {
Mysql mysql = new Mysql();
mysql.Connect("services");
System.out.println(NbTotalDispo.nbService("Moniteur",mysql));
System.out.println(NbTotalDispo.nbComp("Moniteur",mysql));
mysql.Deconnect();
}
} |
Partager