void DossierEditeur::ajouterInscription() { try { QDialog* window = new QDialog(this); QGridLayout* lay = new QGridLayout; QPushButton* ok = new QPushButton("Ok"); QComboBox *ListeUV= new QComboBox(this); QComboBox *ListeCursus= new QComboBox(this); QComboBox *ListeResultat= new QComboBox(this); QComboBox *ListeSaison= new QComboBox(this); QLineEdit *Annee= new QLineEdit(this); QLabel* UVLabel= new QLabel("UV : ",this); QLabel* cursusLabel= new QLabel("Cursus : ",this); QLabel* resultatLabel= new QLabel("Note : ",this); QLabel* saisonLabel= new QLabel("Saison : ",this); QLabel* anneeLabel = new QLabel("Année : ",this); window->setFixedSize(300, 400); UV** uvs = UVManager::getInstance().getUVs(); for(unsigned int i=0;i<UVManager::getInstance().getNbUV(); i++) { ListeUV->addItem(uvs[i]->getCode()); } for(Note n = first; n <= last; n = Note(n+1)) ListeResultat->addItem(NoteToString(n)); for(int i = 0; i < FormationManager::getInstance().getTaille(); i++) ListeCursus->addItem(FormationManager::getInstance().getElement(i).getCode()); ListeSaison->addItem("Automne"); ListeSaison->addItem("Printemps"); lay->addWidget(UVLabel,0,0); lay->addWidget(cursusLabel,1,0); lay->addWidget(resultatLabel,2,0); lay->addWidget(saisonLabel,3,0); lay->addWidget(anneeLabel,4,0); lay->addWidget(ListeUV,0,1); lay->addWidget(ListeCursus,1,1); lay->addWidget(ListeResultat,2,1); lay->addWidget(ListeSaison,3,1); lay->addWidget(Annee,4,1); lay->addWidget(ok,5,1,Qt::AlignHCenter); window->setLayout(lay); connect(ok,SIGNAL(clicked()),window,SLOT(accept())); window->exec(); if(window->result()) { if(Annee->text().isEmpty()) throw UTProfilerException("Ne laissez pas l'année vide !"); UV& uv = UVManager::getInstance().getUV(ListeUV->currentText()); Semestre s(StringToSaison(ListeSaison->currentText()),Annee->text().toUInt()); Dossier::getInstance().ajouterInscription(uv,StringToNote(ListeResultat->currentText()),s,ListeCursus->currentText()); QMessageBox::information(this,"Ajout d'une inscription", QString("Ajout de la catégorie ")+ListeUV->currentText()+" réussie."); dossier->setRowCount(Dossier::getInstance().getTaille()); QTableWidgetItem *monItem = new QTableWidgetItem(ListeUV->currentText()); dossier->setItem(Dossier::getInstance().getTaille() -1,0,monItem); monItem = new QTableWidgetItem(s.FormeContracte()); dossier->setItem(Dossier::getInstance().getTaille() -1,1,monItem); monItem = new QTableWidgetItem(ListeResultat->currentText()); dossier->setItem(Dossier::getInstance().getTaille() -1,2,monItem); monItem = new QTableWidgetItem(ListeCursus->currentText()); dossier->setItem(Dossier::getInstance().getTaille() -1,3,monItem); } } catch(UTProfilerException& e) { QMessageBox::warning(this, "Ajout d'inscription", e.getInfo()); } }
void Database::SaverLoader::load() { tUV.clear(); tEtudiant.clear(); tFormation.clear(); tCategorie.clear(); tNote.clear(); tSaison.clear(); tSemestre.clear(); //load Notes string q="SELECT note, description, rang, eliminatoire FROM Note;"; QSqlQuery res=db.query(q); while(res.next()) { Note note(res.value(0).toString(),res.value(1).toString(),res.value(2).toUInt(),res.value(3).toUInt()); } //load Saisons q="SELECT nom, description FROM Saison;"; res=db.query(q); while(res.next()) { Saison Sais(res.value(0).toString(),res.value(1).toString()); } //load Semestres q="SELECT code, saison, year FROM Semestre;"; res=db.query(q); while(res.next()) { Semestre sem(tSaison.getElement(res.value(1).toString()),res.value(2).toInt()); } qDebug()<<"test"; //load Catégories q="SELECT code, description FROM Categorie;"; res=db.query(q); while(res.next()) { Categorie cat(res.value(0).toString(),res.value(1).toString()); } qDebug()<<"test"; //Mise en place des sous Catégories for(std::vector<Categorie>::iterator it_cat=tCategorie.getIterator();it_cat!=tCategorie.end();it_cat++) { q="SELECT codeParent, codeFille FROM SousCategorie where codeParent='"+it_cat->getCode().toStdString()+"';"; res=db.query(q); while(res.next()) { tCategorie.getElement(res.value(0).toString()).addSousCategorie(tCategorie.getElement(res.value(1).toString())); } } qDebug()<<"test"; //load UVS q="SELECT code, titre, automne, printemps FROM UV;"; res=db.query(q); while(res.next()) { map<Categorie, unsigned int> uvcre=map<Categorie, unsigned int>(); string q1="SELECT code, categorie, nbCredits FROM CreditsUV WHERE code='"+res.value(0).toString().toStdString()+"';"; QSqlQuery res1=db.query(q1); while(res1.next()) { uvcre[StringToCategorie(res1.value(1).toString())]=res1.value(2).toInt(); } UV(res.value(0).toString().toStdString(), res.value(1).toString().toStdString(), uvcre, res.value(2).toBool(), res.value(3).toBool()); } //load Formation q="SELECT nom, description FROM Formation;"; res=db.query(q); while(res.next()) { map<UV*, bool> uvs=map<UV*, bool>(); string q1="SELECT formation, uv, obligatoire FROM FormationUV where formation='"+res.value(0).toString().toStdString()+"';"; QSqlQuery res1=db.query(q1); while(res1.next()) { UV& uv=tUV.getElement(res1.value(1).toString().toStdString()); uvs[&uv]=res1.value(2).toBool(); } map<Categorie, unsigned int> Cat=map<Categorie, unsigned int>(); q1="SELECT formation, categorie, nbCredits FROM CreditsFormation where formation='"+res.value(0).toString().toStdString()+"';"; res1=db.query(q1); while(res1.next()) { Cat[StringToCategorie(res1.value(1).toString())]=res1.value(2).toInt(); } std::vector<Condition> conds; q1="SELECT formation, condition FROM conditionsFormation where formation='"+res.value(0).toString().toStdString()+"';"; res1=db.query(q1); while(res1.next()) { conds.push_back(Condition(res1.value(1).toString())); } Formation(res.value(0).toString(), res.value(1).toString(), uvs, Cat,conds); } //load Etudiants q="SELECT ine, login, nom, prenom, dateNaissance from Etudiant;"; res=db.query(q); while(res.next()) { vector<Inscription> insc= vector<Inscription>(); string q1="SELECT login, code, saison, annee, resultat FROM Inscription WHERE login='******';"; QSqlQuery res1=db.query(q1); while(res1.next()) { //Semestre s=Semestre(StringToSaison(res1.value(2).toString()), res1.value(3).toInt()); string code=res1.value(1).toString().toStdString(); const UV& uv=tUV.getElement(code); Inscription inscription=Inscription(uv, tSemestre.getElement(res1.value(2).toString()+res1.value(3).toString()), StringToNote(res1.value(4).toString())); insc.push_back(inscription); } vector<Formation*> form= vector<Formation*>(); q1="SELECT login, formation FROM FormationEtudiant WHERE login='******';"; res1=db.query(q1); while(res1.next()) { Formation& F=tFormation.getElement(res1.value(1).toString().toStdString()); form.push_back(&F); } Dossier dos=Dossier(insc, form); Etudiant etu=Etudiant(dos, res.value(0).toInt(), res.value(2).toString(), res.value(3).toString(), res.value(4).toDate(), res.value(1).toString()); qDebug()<<"fin load"; } }