diff --git a/Base.xlsx b/Base.xlsx deleted file mode 100644 index 74b067e..0000000 Binary files a/Base.xlsx and /dev/null differ diff --git a/GestionDesInscriptions_1.jar b/GestionDesInscriptions_1.jar index bf093f9..e28f045 100644 Binary files a/GestionDesInscriptions_1.jar and b/GestionDesInscriptions_1.jar differ diff --git a/GestionDesInscriptions_2.jar b/GestionDesInscriptions_2.jar index 91e500c..19eb97f 100644 Binary files a/GestionDesInscriptions_2.jar and b/GestionDesInscriptions_2.jar differ diff --git a/GestionDesInscriptions_3.jar b/GestionDesInscriptions_3.jar index 90d1af2..575e645 100644 Binary files a/GestionDesInscriptions_3.jar and b/GestionDesInscriptions_3.jar differ diff --git a/base.xml b/base.xml index 5f1bb47..820195b 100644 --- a/base.xml +++ b/base.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/baseUFRHG/demarre.java b/src/baseUFRHG/demarre.java index b6e3eab..73f083c 100644 --- a/src/baseUFRHG/demarre.java +++ b/src/baseUFRHG/demarre.java @@ -83,7 +83,7 @@ public class demarre extends JFrame { actCharge = new JButton("Importer des inscriptions
depuis CSV (UTF-8, point-virgule)"); actCharge.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - lecture.lect(); + importInscriptionCSV.importe(); } }); actCharge.setHorizontalAlignment(SwingConstants.LEFT); @@ -154,6 +154,14 @@ public class demarre extends JFrame { btnimporterDesInscriptionsdepuis.setHorizontalAlignment(SwingConstants.LEFT); btnimporterDesInscriptionsdepuis.setFont(new Font("Arial", Font.BOLD, 16)); btnimporterDesInscriptionsdepuis.setBounds(376, 109, 356, 60); + btnimporterDesInscriptionsdepuis.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + File f = FileChooserXLSX.retourneFileXLSX(); + if(f!=null) { + importInscriptionXLS.importe(f); + } + } + }); frmEvalwriter.getContentPane().add(btnimporterDesInscriptionsdepuis); JLabel lblNewLabel_2 = new JLabel("version 1.0.1"); @@ -164,15 +172,15 @@ public class demarre extends JFrame { lblNewLabel_3.setBounds(10, 426, 151, 14); frmEvalwriter.getContentPane().add(lblNewLabel_3); - JButton btnNewButton_1 = new JButton("Aide à la mise en jour"); - btnNewButton_1.addActionListener(new ActionListener() { + JButton btnNAideMiseAJour = new JButton("Aide à la mise en jour"); + btnNAideMiseAJour.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); - btnNewButton_1.setFont(new Font("Tahoma", Font.BOLD, 12)); - btnNewButton_1.setBounds(10, 378, 356, 30); - frmEvalwriter.getContentPane().add(btnNewButton_1); + btnNAideMiseAJour.setFont(new Font("Tahoma", Font.BOLD, 12)); + btnNAideMiseAJour.setBounds(10, 378, 356, 30); + frmEvalwriter.getContentPane().add(btnNAideMiseAJour); } diff --git a/src/baseUFRHG/importAllBaseToExcel.java b/src/baseUFRHG/importAllBaseToExcel.java index 63d815f..7d86a18 100644 --- a/src/baseUFRHG/importAllBaseToExcel.java +++ b/src/baseUFRHG/importAllBaseToExcel.java @@ -16,11 +16,27 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class importAllBaseToExcel { public static void lecture(File file) { + if(commandes.nBase==null) { commandes.nBase = recupeBases.recupeLaBase(); } - int compteur = 0 ; + noeud nYear = null; + if(commandes.nBase.getAttributes("defaut_Year")!=null) { + String defautYear = commandes.nBase.getAttributes("defaut_Year"); + if(commandes.nBase.getChild(defautYear)!=null) { + nYear = commandes.nBase.getChild(defautYear); + }else { + JOptionPane.showMessageDialog(null, "Il n'y a pas d'année universitaire par défaut.", "Erreur", JOptionPane.ERROR_MESSAGE); + return; + } + }else { + JOptionPane.showMessageDialog(null, "Il n'y a pas d'année universitaire par défaut.", "Erreur", JOptionPane.ERROR_MESSAGE); + return; + } + + + int compteur = 0 ; try (FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath()); Workbook workbook = new XSSFWorkbook(fileInputStream)) { @@ -41,7 +57,7 @@ public class importAllBaseToExcel { if(indexCol==0) { // Colonne formation if(cell.getCellType() == CellType.STRING) { - nBF = commandes.nBase.getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(cell.getStringCellValue())); + nBF = nYear.getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(cell.getStringCellValue())); } } diff --git a/src/baseUFRHG/lecture.java b/src/baseUFRHG/importInscriptionCSV.java similarity index 89% rename from src/baseUFRHG/lecture.java rename to src/baseUFRHG/importInscriptionCSV.java index cf75cf5..7af0ae6 100644 --- a/src/baseUFRHG/lecture.java +++ b/src/baseUFRHG/importInscriptionCSV.java @@ -6,10 +6,10 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; -public class lecture { +public class importInscriptionCSV { - public static void lect() { + public static void importe() { noeud noeudCSV = null; diff --git a/src/baseUFRHG/importInscriptionXLS.java b/src/baseUFRHG/importInscriptionXLS.java new file mode 100644 index 0000000..6e99fd8 --- /dev/null +++ b/src/baseUFRHG/importInscriptionXLS.java @@ -0,0 +1,146 @@ +package baseUFRHG; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JOptionPane; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class importInscriptionXLS { + + public static void importe(File file) { + if(commandes.nBase==null) { + commandes.nBase = recupeBases.recupeLaBase(); + } + + noeud nYear = null; + if(commandes.nBase.getAttributes("defaut_Year")!=null) { + String defautYear = commandes.nBase.getAttributes("defaut_Year"); + if(commandes.nBase.getChild(defautYear)!=null) { + nYear = commandes.nBase.getChild(defautYear); + }else { + JOptionPane.showMessageDialog(null, "Il n'y a pas d'année universitaire par défaut.", "Erreur", JOptionPane.ERROR_MESSAGE); + return; + } + }else { + JOptionPane.showMessageDialog(null, "Il n'y a pas d'année universitaire par défaut.", "Erreur", JOptionPane.ERROR_MESSAGE); + return; + } + + + + try (FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath()); + Workbook workbook = new XSSFWorkbook(fileInputStream)) { + +// int numSheets = workbook.getNumberOfSheets(); + + + Sheet sheet = workbook.getSheetAt(0); + + if(!sheet.getSheetName().equals("Inscrits détail")) { + JOptionPane.showMessageDialog(null, "Ce n'est pas une feuille d'inscription de luniversité d'Artois."); + return; + } + + Map Head = new HashMap(); + + + for (Row row : sheet) { + + Map Student = new HashMap(); + for (Cell cell : row) { + if(row.getRowNum()==0) { + Head.put(cell.getColumnIndex(),cell.getStringCellValue()); + }else { + if(cell.getCellType()== CellType.STRING) { + Student.put(Head.get(cell.getColumnIndex()), String.valueOf(cell.getStringCellValue())); + }if (cell.getCellType()== CellType.NUMERIC) { + Student.put(Head.get(cell.getColumnIndex()), String.valueOf(Integer.valueOf((int) cell.getNumericCellValue()))); + } else { + + } + + } + } + if(Student.get("IAE - Etape (lib.)")!=null) { + String nameFormation = supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(Student.get("IAE - Etape (lib.)")); + noeud nFormation = null; + if(nYear.getChild(nameFormation)!=null) { + nFormation = nYear.getChild(nameFormation); + }else { + nFormation = new noeud(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nameFormation)); + nYear.addChild(nFormation); + } + String nameNoeudStudent = "n"+String.valueOf(Student.get("Individu - Code Etudiant")); + noeud nStudent = null; + if(nFormation.getChild(nameNoeudStudent)!=null) { + nStudent = nFormation.getChild(nameNoeudStudent); + } else { + 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") + || entry.getKey().equals("Individu - Code Etudiant") + || entry.getKey().equals("IAE - Etape (lib.)") + || entry.getKey().equals("Profil étudiant (lib.)") + || entry.getKey().equals("Bac ou équivalence (lib.)") + || entry.getKey().equals("Individu - Email personnel") + || entry.getKey().equals("Individu - Email") + || entry.getKey().equals("Individu - Tél. portable")) { + 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",""); + if(nStudent.getAttributes("Groupe_Langue")==null) nStudent.setAttribut("Groupe_Langue",""); + if(nStudent.getAttributes("Groupe_Doc")==null) nStudent.setAttribut("Groupe_Doc",""); + if(nStudent.getAttributes("Groupe_Projet")==null) nStudent.setAttribut("Groupe_Projet",""); + if(nStudent.getAttributes("Covoiturage")==null) nStudent.setAttribut("Covoiturage","non"); + if(nStudent.getAttributes("Etudiant_Covoiturage")==null) nStudent.setAttribut("Etudiant_Covoiturage",""); + if(nStudent.getAttributes("LV1")==null) nStudent.setAttribut("LV1",""); + if(nStudent.getAttributes("LV2")==null) nStudent.setAttribut("LV2",""); + if(nStudent.getAttributes("UE_Libre")==null) nStudent.setAttribut("UE_Libre",""); + if(nStudent.getAttributes("Option")==null) nStudent.setAttribut("Option",""); + if(nStudent.getAttributes("Stage_1")==null) nStudent.setAttribut("Stage_1",""); + if(nStudent.getAttributes("Num_convention_1")==null) nStudent.setAttribut("Num_convention_1",""); + if(nStudent.getAttributes("Periode_1")==null) nStudent.setAttribut("Periode_1",""); + if(nStudent.getAttributes("Stage_2")==null) nStudent.setAttribut("Stage_2",""); + if(nStudent.getAttributes("Num_convention_2")==null) nStudent.setAttribut("Num_convention_2",""); + if(nStudent.getAttributes("Periode_2")==null) nStudent.setAttribut("Periode_2",""); + if(nStudent.getAttributes("Information")==null) nStudent.setAttribut("Information",""); + if(nStudent.getAttributes("Atelier-rentree_horaire")==null) nStudent.setAttribut("Atelier-rentree_horaire",""); + if(nStudent.getAttributes("Atelier_pre-rentree_enseignant")==null) nStudent.setAttribut("Atelier_pre-rentree_enseignant",""); + if(nStudent.getAttributes("Atelier_pre-rentree_salle")==null) nStudent.setAttribut("Atelier_pre-rentree_salle",""); + + + System.out.println( nStudent.toWrite()); // Nouvelle ligne après chaque ligne du tableau + } + } + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + sauvegardeXMLBase.save(commandes.nBase,sauvegardeXMLBase.saveType.SANS_MESSAGE); + JOptionPane.showMessageDialog(null, "Importation des inscription et les mises à jour sont réussies."); + + + } + + + +}