new file: bd.properties
new file: bd.script new file: bin/CtrlAccesListe.class new file: bin/CtrlLogin.class new file: bin/modele/Disciplines.class new file: bin/modele/Evenements.class new file: bin/modele/Membres.class new file: bin/modele/Participer.class new file: bin/test.class new file: bin/vue/Planning$1.class new file: bin/vue/Planning$2.class new file: bin/vue/Planning$3.class new file: bin/vue/Planning.class new file: lib/hsqldb.jar new file: lib/servlet-2_3-fcs-classfiles.zip new file: lib/sqltool.jar new file: src/CtrlAccesListe.java new file: src/CtrlLogin.java new file: src/modele/Disciplines.java new file: src/modele/Evenements.java new file: src/modele/Membres.java new file: src/modele/Participer.java new file: src/test.java new file: src/vue/Planning.java
This commit is contained in:
parent
44c1a9ac42
commit
3fdf7aae3a
4
bd.properties
Normal file
4
bd.properties
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#HSQL Database Engine 2.3.0
|
||||||
|
#Wed Dec 04 11:32:45 CET 2013
|
||||||
|
version=2.3.0
|
||||||
|
modified=no
|
60
bd.script
Normal file
60
bd.script
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
SET DATABASE UNIQUE NAME HSQLDB42BD230C27
|
||||||
|
SET DATABASE GC 0
|
||||||
|
SET DATABASE DEFAULT RESULT MEMORY ROWS 0
|
||||||
|
SET DATABASE EVENT LOG LEVEL 0
|
||||||
|
SET DATABASE SQL NAMES FALSE
|
||||||
|
SET DATABASE SQL REFERENCES FALSE
|
||||||
|
SET DATABASE SQL SIZE TRUE
|
||||||
|
SET DATABASE SQL TYPES FALSE
|
||||||
|
SET DATABASE SQL TDC DELETE TRUE
|
||||||
|
SET DATABASE SQL TDC UPDATE TRUE
|
||||||
|
SET DATABASE SQL TRANSLATE TTI TYPES TRUE
|
||||||
|
SET DATABASE SQL CONCAT NULLS TRUE
|
||||||
|
SET DATABASE SQL UNIQUE NULLS TRUE
|
||||||
|
SET DATABASE SQL CONVERT TRUNCATE TRUE
|
||||||
|
SET DATABASE SQL AVG SCALE 0
|
||||||
|
SET DATABASE SQL DOUBLE NAN TRUE
|
||||||
|
SET DATABASE TRANSACTION CONTROL LOCKS
|
||||||
|
SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED
|
||||||
|
SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE
|
||||||
|
SET DATABASE TEXT TABLE DEFAULTS ''
|
||||||
|
SET FILES WRITE DELAY 500 MILLIS
|
||||||
|
SET FILES BACKUP INCREMENT TRUE
|
||||||
|
SET FILES CACHE SIZE 10000
|
||||||
|
SET FILES CACHE ROWS 50000
|
||||||
|
SET FILES SCALE 32
|
||||||
|
SET FILES LOB SCALE 32
|
||||||
|
SET FILES DEFRAG 0
|
||||||
|
SET FILES NIO TRUE
|
||||||
|
SET FILES NIO SIZE 256
|
||||||
|
SET FILES LOG TRUE
|
||||||
|
SET FILES LOG SIZE 50
|
||||||
|
CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e'
|
||||||
|
ALTER USER SA SET LOCAL TRUE
|
||||||
|
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
|
||||||
|
SET SCHEMA PUBLIC
|
||||||
|
CREATE MEMORY TABLE PUBLIC.MEMBRES(IDMEMBRE INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NOM VARCHAR(20),PRENOM VARCHAR(20),ADRESSE VARCHAR(50),DTN DATE,NUMTEL VARCHAR(20),DROIT INTEGER,DATEADHESION DATE,PASSWORD VARCHAR(20))
|
||||||
|
ALTER TABLE PUBLIC.MEMBRES ALTER COLUMN IDMEMBRE RESTART WITH 0
|
||||||
|
CREATE MEMORY TABLE PUBLIC.EVENEMENTS(IDEVENEMENT INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,TYPE INTEGER,DATEE DATE,LIEU VARCHAR(20))
|
||||||
|
ALTER TABLE PUBLIC.EVENEMENTS ALTER COLUMN IDEVENEMENT RESTART WITH 8
|
||||||
|
CREATE MEMORY TABLE PUBLIC.PARTICIPER(IDEVENEMENT INTEGER,IDMEMBRE INTEGER,ROLE INTEGER,PRIMARY KEY(IDMEMBRE,IDEVENEMENT),FOREIGN KEY(IDMEMBRE) REFERENCES PUBLIC.MEMBRES(IDMEMBRE),FOREIGN KEY(IDEVENEMENT) REFERENCES PUBLIC.EVENEMENTS(IDEVENEMENT))
|
||||||
|
CREATE MEMORY TABLE PUBLIC.DISCIPLINES(NOMDISIPLINE VARCHAR(20) PRIMARY KEY,IDEVENEMENT INTEGER,FOREIGN KEY(IDEVENEMENT) REFERENCES PUBLIC.EVENEMENTS(IDEVENEMENT))
|
||||||
|
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1
|
||||||
|
SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC
|
||||||
|
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC
|
||||||
|
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC
|
||||||
|
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC
|
||||||
|
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC
|
||||||
|
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC
|
||||||
|
GRANT DBA TO SA
|
||||||
|
SET SCHEMA SYSTEM_LOBS
|
||||||
|
INSERT INTO BLOCKS VALUES(0,2147483647,0)
|
||||||
|
SET SCHEMA PUBLIC
|
||||||
|
INSERT INTO EVENEMENTS VALUES(0,0,'2013-10-12','lol')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(1,0,'2013-10-12','lol')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(2,0,'2013-10-12','lol')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(3,0,'2013-10-12','lol')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(4,1,'2012-11-20','toulouse')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(5,0,'2013-10-12','lol')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(6,1,'2012-11-20','toulouse')
|
||||||
|
INSERT INTO EVENEMENTS VALUES(7,1,'2012-11-20','toulouse')
|
BIN
bin/CtrlAccesListe.class
Normal file
BIN
bin/CtrlAccesListe.class
Normal file
Binary file not shown.
BIN
bin/CtrlLogin.class
Normal file
BIN
bin/CtrlLogin.class
Normal file
Binary file not shown.
BIN
bin/modele/Disciplines.class
Normal file
BIN
bin/modele/Disciplines.class
Normal file
Binary file not shown.
BIN
bin/modele/Evenements.class
Normal file
BIN
bin/modele/Evenements.class
Normal file
Binary file not shown.
BIN
bin/modele/Membres.class
Normal file
BIN
bin/modele/Membres.class
Normal file
Binary file not shown.
BIN
bin/modele/Participer.class
Normal file
BIN
bin/modele/Participer.class
Normal file
Binary file not shown.
BIN
bin/test.class
Normal file
BIN
bin/test.class
Normal file
Binary file not shown.
BIN
bin/vue/Planning$1.class
Normal file
BIN
bin/vue/Planning$1.class
Normal file
Binary file not shown.
BIN
bin/vue/Planning$2.class
Normal file
BIN
bin/vue/Planning$2.class
Normal file
Binary file not shown.
BIN
bin/vue/Planning$3.class
Normal file
BIN
bin/vue/Planning$3.class
Normal file
Binary file not shown.
BIN
bin/vue/Planning.class
Normal file
BIN
bin/vue/Planning.class
Normal file
Binary file not shown.
BIN
lib/hsqldb.jar
Normal file
BIN
lib/hsqldb.jar
Normal file
Binary file not shown.
BIN
lib/servlet-2_3-fcs-classfiles.zip
Normal file
BIN
lib/servlet-2_3-fcs-classfiles.zip
Normal file
Binary file not shown.
BIN
lib/sqltool.jar
Normal file
BIN
lib/sqltool.jar
Normal file
Binary file not shown.
62
src/CtrlAccesListe.java
Normal file
62
src/CtrlAccesListe.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import vue.Planning;
|
||||||
|
|
||||||
|
import modele.Evenements;
|
||||||
|
|
||||||
|
|
||||||
|
public class CtrlAccesListe {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException{
|
||||||
|
Evenements e;
|
||||||
|
ResultSet r;
|
||||||
|
|
||||||
|
JFrame f_planning ;
|
||||||
|
Planning p ;
|
||||||
|
|
||||||
|
f_planning = new JFrame("Planning") ;
|
||||||
|
p = new Planning() ;
|
||||||
|
|
||||||
|
Container c = f_planning.getContentPane();
|
||||||
|
c.setLayout(new FlowLayout());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// cr<EFBFBD>e le planning <EFBFBD> la date actuelle
|
||||||
|
c.add(p);
|
||||||
|
/*
|
||||||
|
// c.add(new Planning(2012, 4, 20)) ;
|
||||||
|
p.color_date(11) ;
|
||||||
|
p.color_date(20) ;*/
|
||||||
|
|
||||||
|
f_planning.pack();
|
||||||
|
// f_planning.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
f_planning.setVisible(true);
|
||||||
|
f_planning.setResizable(false) ;
|
||||||
|
|
||||||
|
|
||||||
|
e = new Evenements();
|
||||||
|
|
||||||
|
e.setEvenement("2012-11-20", 1, "toulouse");
|
||||||
|
r = e.getEvenement(-1);
|
||||||
|
|
||||||
|
while(r.next())
|
||||||
|
{
|
||||||
|
String str[]=r.getString("dateE").split("-");
|
||||||
|
|
||||||
|
p.color_date(Integer.decode( str[2]));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/CtrlLogin.java
Normal file
10
src/CtrlLogin.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
public class CtrlLogin {
|
||||||
|
//attributs
|
||||||
|
|
||||||
|
//Constructeurs
|
||||||
|
|
||||||
|
//méthodes
|
||||||
|
|
||||||
|
|
||||||
|
}
|
80
src/modele/Disciplines.java
Normal file
80
src/modele/Disciplines.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package modele;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class Disciplines {
|
||||||
|
//attributs
|
||||||
|
|
||||||
|
//constructueurs
|
||||||
|
public Disciplines(){}
|
||||||
|
|
||||||
|
//methodes
|
||||||
|
/**
|
||||||
|
* permet de saisir une discipline pour un entrainement donné
|
||||||
|
* @param pIdEntrainement
|
||||||
|
* @param pNomDiscipline
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void setDiscipline(int pIdEntrainement, String pNomDiscipline) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//insertion nouveau membres
|
||||||
|
Statement statement = connexion.createStatement() ;
|
||||||
|
statement.executeUpdate("INSERT INTO Disciplines (nomDiscipline, idEntrainement)"
|
||||||
|
+ "VALUES ('"+ pIdEntrainement +"', '"+ pIdEntrainement );
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
connexion.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet d'obtenir la discipline pour un entrainement donnée
|
||||||
|
* @param pIdEntrainement
|
||||||
|
* @return
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getDiscipline (int pIdEntrainement) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT nomDiscipline FROM membres WHERE" +
|
||||||
|
"idEvenement =" + pIdEntrainement);
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat.getString("nomDiscipline");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
src/modele/Evenements.java
Normal file
76
src/modele/Evenements.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package modele;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class Evenements {
|
||||||
|
|
||||||
|
//attributs
|
||||||
|
|
||||||
|
|
||||||
|
//Constuctueurs
|
||||||
|
public Evenements(){};
|
||||||
|
|
||||||
|
//méthodes
|
||||||
|
public void setEvenement(String pDate, int pType, String pLieu) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//insertion nouveau membres
|
||||||
|
Statement statement = connexion.createStatement() ;
|
||||||
|
statement.executeUpdate("INSERT INTO Evenements (type, dateE, lieu)"
|
||||||
|
+ "VALUES ('"+ pType +"', '"+ pDate +"', '"+ pLieu +"')" );
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
connexion.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param pIdEvenement
|
||||||
|
* @return un resultSet contenant le ou les infos evenements
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public ResultSet getEvenement(int pIdEvenement) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
if(pIdEvenement == -1)
|
||||||
|
{
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT * FROM evenements ");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT * FROM evenements WHERE idEvenement =" + pIdEvenement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
}
|
126
src/modele/Membres.java
Normal file
126
src/modele/Membres.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package modele;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Membres {
|
||||||
|
|
||||||
|
//attributs
|
||||||
|
/* private String nom;
|
||||||
|
private String prenom;
|
||||||
|
private String adresse;
|
||||||
|
private String dtn;
|
||||||
|
private String numTel;
|
||||||
|
private String droit;
|
||||||
|
private String dateAdhesion;
|
||||||
|
private String password;*/
|
||||||
|
|
||||||
|
//Constructeurs
|
||||||
|
public Membres() {}
|
||||||
|
|
||||||
|
//méthode
|
||||||
|
/**
|
||||||
|
* Insere dans la base un nouveau membres
|
||||||
|
* @param pNom
|
||||||
|
* @param pPrenom
|
||||||
|
* @param pDtn
|
||||||
|
* @param pNumTel
|
||||||
|
* @param pAdresse
|
||||||
|
* @param pDroit
|
||||||
|
* @param pDateAdhesion
|
||||||
|
* @param pPassword
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void setInfo(String pNom, String pPrenom, String pDtn, String pNumTel, String pAdresse,
|
||||||
|
int pDroit, String pDateAdhesion,String pPassword) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//insertion nouveau membres
|
||||||
|
Statement statement = connexion.createStatement() ;
|
||||||
|
statement.executeUpdate("INSERT INTO membres (nom, prenom, adresse,"
|
||||||
|
+" numTel, droit, password, dtn, dateAdhesion )"
|
||||||
|
+ "VALUES ('"+ pNom +"', '"+ pPrenom +"', '"+ pAdresse +"',"
|
||||||
|
+"'"+ pNumTel +"', '"+ pDroit +"', '"+ pPassword +"', "
|
||||||
|
+"'"+ pDtn +"', '"+ pDateAdhesion +"')");
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
connexion.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* idMembres les infos du membre ou si -1 alors retourne les infos de tout les membres
|
||||||
|
* @param pIdMembres
|
||||||
|
* @return un resultSet contenant le ou les infos membres
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public ResultSet getInfo(int pIdMembre) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
if(pIdMembre == -1)
|
||||||
|
{
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT * FROM membres ");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT * FROM membres WHERE idMembre =" + pIdMembre);
|
||||||
|
}
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void supprimer(int pIdMembre) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeUpdate("DROP * WHERE idMembre= " + pIdMembre) ;
|
||||||
|
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
163
src/modele/Participer.java
Normal file
163
src/modele/Participer.java
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
package modele;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class Participer {
|
||||||
|
//attributs
|
||||||
|
|
||||||
|
//constructeurs
|
||||||
|
public Participer(){};
|
||||||
|
|
||||||
|
|
||||||
|
//méthodes
|
||||||
|
/**
|
||||||
|
* permet de saisir le role d'un membre lors d'un evenement
|
||||||
|
* @param pIdEvenement
|
||||||
|
* @param pIdMembre
|
||||||
|
* @param role
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void setRole(int pIdEvenement, int pIdMembre, int role ) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//insertion nouveau membres
|
||||||
|
Statement statement = connexion.createStatement() ;
|
||||||
|
statement.executeUpdate("INSERT INTO participer (idEvenement, idMembre, role)"
|
||||||
|
+ "VALUES ('"+ pIdEvenement +"', '"+ pIdMembre +"', '"+ role +"')" );
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
connexion.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet d'avoir le role d'un membre lors d'un evenement
|
||||||
|
* @param pIdEvenement
|
||||||
|
* @param pIdMembre
|
||||||
|
* @return
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getRole(int pIdEvenement, int pIdMembre) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT role FROM evenements WHERE idEvenement = " +
|
||||||
|
pIdEvenement + " AND idMembre = " + pIdMembre);
|
||||||
|
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat.getInt("role");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet de se désincrire un membre d'un evenelement
|
||||||
|
* @param pIdEvenement
|
||||||
|
* @param pIdMembre
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void setAnnuler(int pIdEvenement, int pIdMembre) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeUpdate("DROP * WHERE idEvenement = " +
|
||||||
|
pIdEvenement + " AND idMembre = " + pIdMembre);
|
||||||
|
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getListeParticipants(int pIdEvenement) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT idMembre FROM evenements WHERE idEvenement = " +
|
||||||
|
pIdEvenement );
|
||||||
|
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultSet getListeParticipation (int pIdMembre) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
|
||||||
|
{
|
||||||
|
Statement statement;
|
||||||
|
ResultSet resultat;
|
||||||
|
//connexion à la base
|
||||||
|
Connection connexion = null;
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver" ).newInstance();
|
||||||
|
connexion = DriverManager.getConnection("jdbc:hsqldb:file:bd", "sa", "" );
|
||||||
|
|
||||||
|
//récupération infos dans la bases
|
||||||
|
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
resultat = statement.executeQuery("SELECT idEvenement FROM evenements WHERE idMembre = " +
|
||||||
|
pIdMembre );
|
||||||
|
|
||||||
|
|
||||||
|
//fermeture base
|
||||||
|
statement = connexion.createStatement();
|
||||||
|
statement.executeQuery("SHUTDOWN");
|
||||||
|
statement.close();
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
42
src/test.java
Normal file
42
src/test.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
|
||||||
|
import modele.Evenements;
|
||||||
|
import modele.Membres;
|
||||||
|
|
||||||
|
public class test {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
|
||||||
|
|
||||||
|
Membres m;
|
||||||
|
Evenements e;
|
||||||
|
ResultSet r;
|
||||||
|
|
||||||
|
m = new Membres();
|
||||||
|
e = new Evenements();
|
||||||
|
|
||||||
|
e.setEvenement("2013-10-12", 0, "lol");
|
||||||
|
|
||||||
|
//m.setInfo("g", "lo", "2000-05-08", "0568025855", "lol", 1, "2013-05-20", "pp");
|
||||||
|
r = e.getEvenement(-1);
|
||||||
|
|
||||||
|
|
||||||
|
while(r.next())
|
||||||
|
{
|
||||||
|
String str[]=r.getString("dateE").split("-");
|
||||||
|
System.out.println(str[0]);
|
||||||
|
System.out.println(str[1]);
|
||||||
|
System.out.println(str[2]);
|
||||||
|
System.out.println(r.getDate("dateE"));
|
||||||
|
}
|
||||||
|
System.out.println("fin");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
296
src/vue/Planning.java
Normal file
296
src/vue/Planning.java
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
package vue;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class Planning extends JPanel {
|
||||||
|
|
||||||
|
protected int yy;
|
||||||
|
protected int mm, dd;
|
||||||
|
protected JButton labs[][];
|
||||||
|
protected int leadGap = 0;
|
||||||
|
|
||||||
|
Calendar calendar = new GregorianCalendar();
|
||||||
|
|
||||||
|
|
||||||
|
protected final int thisYear = calendar.get(Calendar.YEAR);
|
||||||
|
protected final int thisMonth = calendar.get(Calendar.MONTH);
|
||||||
|
private JButton b0;
|
||||||
|
|
||||||
|
private JComboBox monthChoice;
|
||||||
|
private JComboBox yearChoice;
|
||||||
|
|
||||||
|
private JButton b_inscrire ;
|
||||||
|
private JButton b_desinscrire ;
|
||||||
|
private JPanel p_button, p_grille, p_south ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construit un calendrier commencant <EFBFBD> la date actuelle
|
||||||
|
*/
|
||||||
|
public Planning() {
|
||||||
|
super();
|
||||||
|
setYYMMDD(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
|
||||||
|
calendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
buildGUI();
|
||||||
|
recompute();
|
||||||
|
print_button() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construit un calendrier, en donnant le jour, mois, ann<EFBFBD>e
|
||||||
|
*
|
||||||
|
* @exception IllegalArgumentException
|
||||||
|
* Si l'ann<EFBFBD>e n'est pas correcte
|
||||||
|
*/
|
||||||
|
public Planning(int year, int month, int today) {
|
||||||
|
super();
|
||||||
|
setYYMMDD(year, month, today);
|
||||||
|
buildGUI();
|
||||||
|
recompute();
|
||||||
|
print_button() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setYYMMDD(int year, int month, int today) {
|
||||||
|
yy = year;
|
||||||
|
mm = month;
|
||||||
|
dd = today;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] months = { "Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin",
|
||||||
|
"Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre" };
|
||||||
|
|
||||||
|
/** Build the GUI. Assumes that setYYMMDD has been called. */
|
||||||
|
private void buildGUI() {
|
||||||
|
getAccessibleContext().setAccessibleDescription(
|
||||||
|
"Calendrier non disponible, desole");
|
||||||
|
setBorder(BorderFactory.createEtchedBorder());
|
||||||
|
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
JPanel tp = new JPanel();
|
||||||
|
tp.add(monthChoice = new JComboBox());
|
||||||
|
|
||||||
|
for (int i = 0; i < months.length; i++)
|
||||||
|
monthChoice.addItem(months[i]);
|
||||||
|
|
||||||
|
monthChoice.setSelectedItem(months[mm]) ;
|
||||||
|
|
||||||
|
monthChoice.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent ae) {
|
||||||
|
int i = monthChoice.getSelectedIndex();
|
||||||
|
if (i >= 0) {
|
||||||
|
mm = i;
|
||||||
|
recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
monthChoice.getAccessibleContext().setAccessibleName("Mois");
|
||||||
|
monthChoice.getAccessibleContext().setAccessibleDescription(
|
||||||
|
"Choisir mois");
|
||||||
|
|
||||||
|
tp.add(yearChoice = new JComboBox());
|
||||||
|
yearChoice.setEditable(true);
|
||||||
|
|
||||||
|
for (int i = yy - 5; i < yy + 5; i++)
|
||||||
|
yearChoice.addItem(Integer.toString(i));
|
||||||
|
|
||||||
|
yearChoice.setSelectedItem(Integer.toString(yy));
|
||||||
|
|
||||||
|
yearChoice.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent ae) {
|
||||||
|
int i = yearChoice.getSelectedIndex();
|
||||||
|
if (i >= 0) {
|
||||||
|
yy = Integer.parseInt(yearChoice.getSelectedItem()
|
||||||
|
.toString());
|
||||||
|
recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(BorderLayout.NORTH, tp);
|
||||||
|
|
||||||
|
JPanel bp = new JPanel();
|
||||||
|
bp.setLayout(new GridLayout(7, 7));
|
||||||
|
labs = new JButton[6][7];
|
||||||
|
|
||||||
|
bp.add(b0 = new JButton("Dimanche"));
|
||||||
|
bp.add(new JButton("Lundi"));
|
||||||
|
bp.add(new JButton("Mardi"));
|
||||||
|
bp.add(new JButton("Mercredi"));
|
||||||
|
bp.add(new JButton("Jeudi"));
|
||||||
|
bp.add(new JButton("Vendredi"));
|
||||||
|
bp.add(new JButton("Samedi"));
|
||||||
|
|
||||||
|
ActionListener dateSetter = new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String num = e.getActionCommand();
|
||||||
|
|
||||||
|
if (!num.equals("")) {
|
||||||
|
// met le jour actuel d'une couleur
|
||||||
|
setDayActive(Integer.parseInt(num));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Ajout des boutons
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
for (int j = 0; j < 7; j++) {
|
||||||
|
bp.add(labs[i][j] = new JButton(""));
|
||||||
|
labs[i][j].addActionListener(dateSetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(BorderLayout.CENTER, bp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static int dom[] = { 31, 28, 31, 30, /* jan fev mar avr */
|
||||||
|
31, 30, 31, 31, /* mai juin juil aout */
|
||||||
|
30, 31, 30, 31 /* sep oct nov dec */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Compute which days to put where, in the Cal panel */
|
||||||
|
protected void recompute() {
|
||||||
|
if (mm < 0 || mm > 11)
|
||||||
|
throw new IllegalArgumentException("Mois " + mm
|
||||||
|
+ " bad, must be 0-11");
|
||||||
|
clearDayActive();
|
||||||
|
calendar = new GregorianCalendar(yy, mm, dd);
|
||||||
|
|
||||||
|
leadGap = new GregorianCalendar(yy, mm, 1).get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
|
||||||
|
int daysInMonth = dom[mm];
|
||||||
|
if (isLeap(calendar.get(Calendar.YEAR)) && mm == 1)
|
||||||
|
++daysInMonth;
|
||||||
|
|
||||||
|
// R<EFBFBD>initialise le label
|
||||||
|
for (int i = 0; i < leadGap; i++) {
|
||||||
|
labs[0][i].setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= daysInMonth; i++) {
|
||||||
|
JButton b = labs[(leadGap + i - 1) / 7][(leadGap + i - 1) % 7];
|
||||||
|
b.setText(Integer.toString(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = leadGap + 1 + daysInMonth; i < 6 * 7; i++) {
|
||||||
|
labs[(i) / 7][(i) % 7].setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shade current day, only if current month
|
||||||
|
if (thisYear == yy && mm == thisMonth)
|
||||||
|
setDayActive(dd);
|
||||||
|
|
||||||
|
// Recharge l'<EFBFBD>cran
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isLeap() returns true if the given year is a Leap Year.
|
||||||
|
*
|
||||||
|
* "a year is a leap year if it is divisible by 4 but not by 100, except
|
||||||
|
* that years divisible by 400 *are* leap years." -- Kernighan & Ritchie,
|
||||||
|
* _The C Programming Language_, p 37.
|
||||||
|
*/
|
||||||
|
public boolean isLeap(int year) {
|
||||||
|
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set l'ann<6E>e, le mois et le jour */
|
||||||
|
public void setDate(int yy, int mm, int dd) {
|
||||||
|
this.yy = yy;
|
||||||
|
this.mm = mm; // starts at 0, like Date
|
||||||
|
this.dd = dd;
|
||||||
|
recompute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Met <20> jour le jour actuel */
|
||||||
|
private void clearDayActive() {
|
||||||
|
JButton b;
|
||||||
|
|
||||||
|
if (activeDay > 0) {
|
||||||
|
b = labs[(leadGap + activeDay - 1) / 7][(leadGap + activeDay - 1) % 7];
|
||||||
|
b.setBackground(b0.getBackground());
|
||||||
|
b.repaint();
|
||||||
|
activeDay = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int activeDay = -1;
|
||||||
|
|
||||||
|
/** Set just the day, on the current month */
|
||||||
|
public void setDayActive(int newDay) {
|
||||||
|
|
||||||
|
clearDayActive();
|
||||||
|
|
||||||
|
// Entre le nouveau
|
||||||
|
if (newDay <= 0)
|
||||||
|
dd = new GregorianCalendar().get(Calendar.DAY_OF_MONTH);
|
||||||
|
else
|
||||||
|
dd = newDay;
|
||||||
|
|
||||||
|
Component square = labs[(leadGap + newDay - 1) / 7][(leadGap + newDay - 1) % 7];
|
||||||
|
square.setBackground(Color.red);
|
||||||
|
square.repaint();
|
||||||
|
activeDay = newDay;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskDay(int newDay){
|
||||||
|
|
||||||
|
Component square = labs[(leadGap + newDay - 1) / 7][(leadGap + newDay - 1) % 7];
|
||||||
|
|
||||||
|
square.setBackground(Color.yellow);
|
||||||
|
square.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void print_button() {
|
||||||
|
// rajouter bouton inscrire / d<EFBFBD>sinscrire, si jour dispo ou non
|
||||||
|
|
||||||
|
this.b_inscrire = new JButton("S'inscrire") ;
|
||||||
|
this.b_desinscrire = new JButton("Se desinscrire") ;
|
||||||
|
|
||||||
|
b_inscrire.setEnabled(true) ;
|
||||||
|
b_desinscrire.setEnabled(false) ;
|
||||||
|
|
||||||
|
this.p_grille = new JPanel() ;
|
||||||
|
this.p_button = new JPanel() ;
|
||||||
|
this.p_south = new JPanel() ;
|
||||||
|
|
||||||
|
p_button.setLayout(new FlowLayout()) ;
|
||||||
|
p_grille.setLayout(new GridLayout(1, 2));
|
||||||
|
|
||||||
|
p_button.add(p_grille) ;
|
||||||
|
p_grille.add(b_inscrire);
|
||||||
|
p_grille.add(b_desinscrire) ;
|
||||||
|
|
||||||
|
p_south.add(p_button) ;
|
||||||
|
this.add(p_south, BorderLayout.SOUTH) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void color_date(int day) {
|
||||||
|
setTaskDay(day) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user