diff --git a/Base.xlsx b/Base.xlsx new file mode 100644 index 0000000..6dd8f97 Binary files /dev/null and b/Base.xlsx differ diff --git a/GestionDesInscriptions.jar b/GestionDesInscriptions.jar deleted file mode 100644 index b6f8475..0000000 Binary files a/GestionDesInscriptions.jar and /dev/null differ diff --git a/GestionDesInscriptions_2.jar b/GestionDesInscriptions_2.jar deleted file mode 100644 index 7d92a74..0000000 Binary files a/GestionDesInscriptions_2.jar and /dev/null differ diff --git a/GestionDesInscriptions_3.jar b/GestionDesInscriptions_3.jar deleted file mode 100644 index 62e1555..0000000 Binary files a/GestionDesInscriptions_3.jar and /dev/null differ diff --git a/GestionDesInscriptions_1.jar b/Gestion_des_inscriptions_groupes_etudiant.jar similarity index 90% rename from GestionDesInscriptions_1.jar rename to Gestion_des_inscriptions_groupes_etudiant.jar index 4f2f07d..9c491b0 100644 Binary files a/GestionDesInscriptions_1.jar and b/Gestion_des_inscriptions_groupes_etudiant.jar differ diff --git a/base.xml b/base.xml deleted file mode 100644 index ef8cb66..0000000 --- a/base.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/base/base.xml b/base/base.xml new file mode 100644 index 0000000..d8898af --- /dev/null +++ b/base/base.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/base/base_sauvegarde.xml b/base/base_sauvegarde.xml new file mode 100644 index 0000000..d8898af --- /dev/null +++ b/base/base_sauvegarde.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/base_sauvegarde.xml b/base_sauvegarde.xml deleted file mode 100644 index ef8cb66..0000000 --- a/base_sauvegarde.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/baseUFRHG/CreateCalcWorkbook.java b/src/baseUFRHG/CreateCalcWorkbook.java index b36b278..3ec505c 100644 --- a/src/baseUFRHG/CreateCalcWorkbook.java +++ b/src/baseUFRHG/CreateCalcWorkbook.java @@ -150,9 +150,8 @@ public class CreateCalcWorkbook extends JFrame{ JOptionPane.showMessageDialog(null, "Le classeur a été créé avec succès."); }catch (IOException e) { - System.out.println(e.toString()); -// e.printStackTrace(); - JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class CreateCalcWorkbook", JOptionPane.ERROR_MESSAGE); + System.out.println(e.toString()); + JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class CreateCalcWorkbook", JOptionPane.ERROR_MESSAGE); } return null; } diff --git a/src/baseUFRHG/ExempleMAJ.java b/src/baseUFRHG/ExempleMAJ.java index 812f117..ad57e52 100644 --- a/src/baseUFRHG/ExempleMAJ.java +++ b/src/baseUFRHG/ExempleMAJ.java @@ -23,12 +23,12 @@ public class ExempleMAJ extends JFrame{ public void init() { frame = new JFrame(); frame.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée"); - frame.setBounds(100, 100, 1000, 600); + frame.setBounds(0, 0, 1300, 100); int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth(); int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight(); - frame.setLocation(( (screenWidth) - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2); - +// frame.setLocation(( (screenWidth) - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2); + frame.setSize(screenWidth, screenHeight); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); diff --git a/src/baseUFRHG/FileSaveXLSX.java b/src/baseUFRHG/FileSaveXLSX.java index df9d138..d72ade2 100644 --- a/src/baseUFRHG/FileSaveXLSX.java +++ b/src/baseUFRHG/FileSaveXLSX.java @@ -10,38 +10,7 @@ public class FileSaveXLSX { String Formation = ""; JFrame frame = new JFrame("Enregistrer le classeur Ms Excel"); -// public void chooseDestination2(Object[][] data, String Formation, exportBaseToExcel.exportType type) { -// this.data = data; -// this.Formation = Formation; -// -// // Créer une boîte de dialogue de sélection de fichier -// JFileChooser fileChooser = new JFileChooser(); -// -// // Afficher uniquement les dossiers (et non les fichiers) -// fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); -// -// // Afficher la boîte de dialogue de sélection de fichier -// int result = fileChooser.showSaveDialog(null); -// -// // Vérifier si l'utilisateur a sélectionné un dossier de destination -// if (result == JFileChooser.APPROVE_OPTION) { -// // Récupérer le dossier sélectionné par l'utilisateur -// File selectedFolder = fileChooser.getSelectedFile(); -// -// // Récupérer le nom du fichier à partir d'une boîte de dialogue -// String fileName = JOptionPane.showInputDialog(null, "Nom du fichier :", Formation); -// -// // Créer le chemin complet du fichier en combinant le dossier et le nom du fichier -// String filePath = selectedFolder.getAbsolutePath() + File.separator + fileName + ".xlsx"; -// -// if(type.equals(exportBaseToExcel.exportType.TABLE)) new CreateCalcWorkbook(data,filePath); -// if(type.equals(exportBaseToExcel.exportType.EMARGEMENT)) new createEmargement(data, filePath); -// } -// -// -// -// -// } + public void save(Object[][] data, String Formation, exportBaseToExcel.exportType type) { @@ -55,8 +24,10 @@ public class FileSaveXLSX { // Spécifiez le nom de fichier par défaut if(type == exportBaseToExcel.exportType.EMARGEMENT) { nameFile = "emargement_" + Formation + ".xlsx"; - }else { + }else if(type == exportBaseToExcel.exportType.TABLE){ nameFile = "table_" + Formation + ".xlsx"; + }else { + nameFile = "base" + Formation + ".xlsx"; } fileChooser.setSelectedFile(new File(nameFile)); @@ -72,10 +43,9 @@ public class FileSaveXLSX { new CreateCalcWorkbook(data, selectedFile.getAbsolutePath()); if (type.equals(exportBaseToExcel.exportType.EMARGEMENT)) new createEmargement(data, selectedFile.getAbsolutePath()); + if (type.equals(exportBaseToExcel.exportType.BASE)) + new CreateCalcWorkbook(data, selectedFile.getAbsolutePath()); } - - - - + } } diff --git a/src/baseUFRHG/base.java b/src/baseUFRHG/base.java index 896ad12..4dd3a02 100644 --- a/src/baseUFRHG/base.java +++ b/src/baseUFRHG/base.java @@ -1,21 +1,17 @@ package baseUFRHG; -import java.io.BufferedWriter; import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; +import baseUFRHG.sauvegardeXMLBase.saveType; + public class base { /** @@ -33,12 +29,6 @@ public class base { String defaultValue = "2022-2023"; String userInput = JOptionPane.showInputDialog("Quelle est l'année universitaire ? ",defaultValue); - - - - - - String regex = "(\\d{4})-(\\d{4})"; Pattern pattern = Pattern.compile(regex); @@ -54,23 +44,9 @@ public class base { userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput); nBase.addChild(new noeud(userInput)); nBase.setAttribut("defaut_Year", userInput); - - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; - Path outputFilePath = Paths.get(directoryName); - try { - BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8); - fichier.write(nBase.toWrite()); - fichier.close(); - - JFrame frame = new JFrame(); - JLabel texte = new JLabel("

La base de données a été créée.

"); - JOptionPane.showMessageDialog(frame, texte); - - } catch (IOException e) { - e.printStackTrace(); - } - return nBase; - + sauvegardeXMLBase.save(nBase, saveType.WITH_MESSAGE); + commandes.nBase = nBase; + return commandes.nBase; } @@ -93,13 +69,7 @@ public class base { } - - - - return null; - - } diff --git a/src/baseUFRHG/demarre.java b/src/baseUFRHG/demarre.java index e469b91..935e1cb 100644 --- a/src/baseUFRHG/demarre.java +++ b/src/baseUFRHG/demarre.java @@ -84,7 +84,7 @@ public class demarre extends JFrame { frmEvalwriter.setResizable(false); - btnCreate = new JButton("Exporter toute la base dans
un classeur MS Excel (base.xlsx)"); + btnCreate = new JButton("Exporter toute la base dans
un classeur MS Excel"); btnCreate.setHorizontalAlignment(SwingConstants.LEFT); btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png"))); btnCreate.addActionListener(new ActionListener() { @@ -119,10 +119,10 @@ public class demarre extends JFrame { // lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueilanalysecalc.png"))); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); lblNewLabel.setFont(new Font("Pacifico", Font.PLAIN, 26)); - lblNewLabel.setBounds(10, 82, 753, 106); + lblNewLabel.setBounds(10, 104, 753, 106); frmEvalwriter.getContentPane().add(lblNewLabel); - JButton btnNewButton = new JButton("Mise à jour de la base
depuis classeur MS Excel"); + JButton btnNewButton = new JButton("Mise à jour de la base depuis
un classeur Ms Excel"); btnNewButton.setHorizontalAlignment(SwingConstants.LEFT); btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/majInscriptionToBase.png"))); btnNewButton.addActionListener(new ActionListener() { @@ -154,9 +154,9 @@ public class demarre extends JFrame { btnTutoriels.setBounds(397, 394, 366, 175); frmEvalwriter.getContentPane().add(btnTutoriels); - JButton btnimporterDesInscriptionsdepuis = new JButton("Importer des inscriptions
depuis tableur MS Excel"); + JButton btnimporterDesInscriptionsdepuis = new JButton("Importer des inscriptions
depuis un classeur Ms Excel"); btnimporterDesInscriptionsdepuis.setHorizontalAlignment(SwingConstants.LEFT); - btnimporterDesInscriptionsdepuis.setIcon(new ImageIcon(demarre.class.getResource("/resources/importationexcel.png"))); + btnimporterDesInscriptionsdepuis.setIcon(new ImageIcon(demarre.class.getResource("/resources/bouton_inscription_excel.png"))); btnimporterDesInscriptionsdepuis.setFont(new Font("Arial", Font.BOLD, 16)); btnimporterDesInscriptionsdepuis.setBounds(397, 323, 366, 60); btnimporterDesInscriptionsdepuis.addActionListener(new ActionListener() { @@ -172,7 +172,7 @@ public class demarre extends JFrame { JLabel lblNewLabel_3 = new JLabel("pablo rodriguez - 2023
Version 1.0.1"); lblNewLabel_3.setVerticalAlignment(SwingConstants.TOP); lblNewLabel_3.setHorizontalAlignment(SwingConstants.LEFT); - lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 14)); + lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 15)); lblNewLabel_3.setForeground(new Color(255, 255, 255)); lblNewLabel_3.setBounds(22, 11, 265, 40); frmEvalwriter.getContentPane().add(lblNewLabel_3); diff --git a/src/baseUFRHG/exportBaseToExcel.java b/src/baseUFRHG/exportBaseToExcel.java index a0ef4b7..b54a04f 100644 --- a/src/baseUFRHG/exportBaseToExcel.java +++ b/src/baseUFRHG/exportBaseToExcel.java @@ -1,6 +1,5 @@ package baseUFRHG; -import java.nio.file.Paths; import java.util.Arrays; import java.util.Comparator; @@ -13,6 +12,7 @@ public class exportBaseToExcel { public static enum exportType { TABLE, EMARGEMENT, + BASE } @@ -102,7 +102,12 @@ public class exportBaseToExcel { } if(data.length>0) { - new CreateCalcWorkbook(data, Paths.get("").toAbsolutePath().toString()+ "/Base.xlsx"); + + + FileSaveXLSX s = new FileSaveXLSX(); + s.save(data, "", exportType.BASE); + +// new CreateCalcWorkbook(data, Paths.get("").toAbsolutePath().toString()+ "/Base.xlsx"); }else { JPanel panel = new JPanel(); JLabel message = new JLabel("

La base de données est nulle.

"); diff --git a/src/baseUFRHG/gestionnaire.java b/src/baseUFRHG/gestionnaire.java index 5b8469f..2598d6d 100644 --- a/src/baseUFRHG/gestionnaire.java +++ b/src/baseUFRHG/gestionnaire.java @@ -335,7 +335,7 @@ public class gestionnaire extends JFrame { } }); - JMenu menuExport = new JMenu("Export"); + JMenu menuExport = new JMenu("Exportation"); menuExport.setFont(new Font("Tahoma", Font.BOLD, 14)); JMenuItem exportItem = menuExport.add(new exportTable(this)); menuExport.add(exportItem); @@ -1126,7 +1126,7 @@ public class gestionnaire extends JFrame { } } - lblInformation.setText("Informations : Nombre d'étudaint = " + compteur); + lblInformation.setText("Informations : Nombre d'étudiant = " + compteur); // Obtenir les entrées du dictionnaire sous forme de liste List> entryList = new ArrayList<>(dictionary.entrySet()); diff --git a/src/baseUFRHG/importInscriptionXLS.java b/src/baseUFRHG/importInscriptionXLS.java index 4c429c3..abf8856 100644 --- a/src/baseUFRHG/importInscriptionXLS.java +++ b/src/baseUFRHG/importInscriptionXLS.java @@ -100,6 +100,7 @@ public class importInscriptionXLS { nStudent = new noeud(nameNoeudStudent); nFormation.addChild(nStudent); } + for (Map.Entry entry : Student.entrySet()) { if(entry.getKey().equals("Individu - Nom") || entry.getKey().equals("Individu - Prénom") @@ -113,6 +114,7 @@ public class importInscriptionXLS { nStudent.setAttribut(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(entry.getKey()), entry.getValue()); } } + if(nStudent.getAttributes("Groupe_Principal")==null) nStudent.setAttribut("Groupe_Principal",""); if(nStudent.getAttributes("Groupe_Informatique")==null) nStudent.setAttribut("Groupe_Informatique",""); if(nStudent.getAttributes("Groupe_TD")==null) nStudent.setAttribut("Groupe_TD",""); @@ -144,7 +146,6 @@ public class importInscriptionXLS { } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/baseUFRHG/recupeBases.java b/src/baseUFRHG/recupeBases.java index 60613ce..584edc9 100644 --- a/src/baseUFRHG/recupeBases.java +++ b/src/baseUFRHG/recupeBases.java @@ -13,14 +13,16 @@ public class recupeBases { * Récupère la base des évaluations qui se trouve indiqué par commandes.PathBaseEvaluationDefaut ou commandes.PathBaseEvaluations. */ public static noeud recupeLaBase() { - String filePath = "base.xml"; + String filePath = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml"; File file = new File(filePath); noeud nBase = null; + + if (file.exists()) { //lecture du fichier base.xml - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; + String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml"; String xmlString = lectureFileToString.lecture(directoryName); nBase = lectureXML.lectureStringToNoeud(xmlString); diff --git a/src/baseUFRHG/sauvegardeXMLBase.java b/src/baseUFRHG/sauvegardeXMLBase.java index ca63f64..a2b6e1e 100644 --- a/src/baseUFRHG/sauvegardeXMLBase.java +++ b/src/baseUFRHG/sauvegardeXMLBase.java @@ -1,11 +1,13 @@ package baseUFRHG; import java.io.BufferedWriter; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; +import java.util.Date; import javax.swing.JOptionPane; @@ -20,9 +22,23 @@ public class sauvegardeXMLBase { public static void save(noeud nBase, saveType type) { // Sauvegarde de la base - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { + String pathToFile = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml"; + + String PathToDirector = Paths.get("").toAbsolutePath() + "/base"; + File directory11 = new File(PathToDirector); + + if (!directory11.exists()) { + boolean created = directory11.mkdirs(); + if (created) { + System.out.println("Répertoire base créé avec succès"); + } else { + System.out.println("Échec de la création du répertoire base"); + } + } + + + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(pathToFile), StandardCharsets.UTF_8))) { writer.write(nBase.toWrite()); if(type==saveType.WITH_MESSAGE) JOptionPane.showMessageDialog(null, "La base a été sauvegardée.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); } catch (IOException e) { @@ -34,10 +50,29 @@ public class sauvegardeXMLBase { public static void saveSauvegarde(noeud nBase) { + + + String PathToDirector = Paths.get("").toAbsolutePath() + "/base"; + File directory11 = new File(PathToDirector); + + if (!directory11.exists()) { + boolean created = directory11.mkdirs(); + if (created) { + System.out.println("Répertoire base créé avec succès"); + } else { + System.out.println("Échec de la création du répertoire base"); + } + } + + // Sauvegarde de la base - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base_sauvegarde.xml"; + String pathToFile = Paths.get("").toAbsolutePath().toString()+ "/base/base_sauvegarde.xml"; try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { + new FileOutputStream(pathToFile), StandardCharsets.UTF_8))) { + + Date aujourdhui = new Date(); + nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui)); + writer.write(nBase.toWrite()); } catch (IOException e) { e.printStackTrace(); @@ -54,6 +89,9 @@ public class sauvegardeXMLBase { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(path), StandardCharsets.UTF_8))) { + Date aujourdhui = new Date(); + nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui)); + writer.write(nBase.toWrite()); JOptionPane.showMessageDialog(null, "Sauvegarde réussi.","Message",JOptionPane.OK_OPTION); } catch (IOException e) { @@ -66,13 +104,17 @@ public class sauvegardeXMLBase { public static void saveModif(noeud nBase, Integer nbreModif) { + + // Sauvegarde de la base - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; + String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml"; try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { + + Date aujourdhui = new Date(); + nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui)); writer.write(nBase.toWrite()); - - + if(nbreModif>0) { JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); }else { diff --git a/src/resources/Exemple de mise à jour.png b/src/resources/Exemple de mise à jour.png index 1032646..fbeca9a 100644 Binary files a/src/resources/Exemple de mise à jour.png and b/src/resources/Exemple de mise à jour.png differ diff --git a/src/resources/bouton_inscription_excel.png b/src/resources/bouton_inscription_excel.png new file mode 100644 index 0000000..a41296d Binary files /dev/null and b/src/resources/bouton_inscription_excel.png differ