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
   |  
void eparticipants::sltEdit()
{
    Participant *e;
    e = new Participant;
    QString qspart = ui->LineEP->text();
    char * argnom;
    char * argprenom;
    char * argpseudo;
    char * argnomteam;
    QString qsnom = ui->LineENom->text();
    QString qsprenom =ui->LineEPrenom->text();
    QString qspseudo = ui->LineEPseudo->text();
    QString qsteam = ui->LineETeam->text();
 
    if(ui->LineENom->text().isEmpty())
        argnom = e->getNom();
    if(ui->LineEPrenom->text().isEmpty())
        argprenom = e->getPrenom();
    if(ui->LineEPseudo->text().isEmpty())
        argpseudo = e->getPseudo();
    if(ui->LineETeam->text().isEmpty())
        argnomteam = e->getNomTeam();
    ifstream FILE_1("participants",ios::binary|ios::in);
    ofstream FILE_2("P2",ios::binary|ios::out);
    FILE_1.read((char *)e, sizeof(Participant));
    while (e->getPrenom()!=qspart && e->getPseudo() != qspart && e->getNom() != qspart && !(FILE_1.eof()))
       {
         FILE_2.write((char *)e, sizeof(Participant));
         FILE_1.read((char *)e, sizeof(Participant));
       }
    FILE_1.read((char *)e, sizeof(Participant));
    while (!FILE_1.eof())
          {
                FILE_2.write((char *)e, sizeof(Participant));
                FILE_1.read((char *)e, sizeof(Participant));
          }
    FILE_2.close();
    FILE_1.close();
 
    ifstream FILE_3("P2",ios::binary|ios::in);
    ofstream FILE_4("participants",ios::binary|ios::out);
     FILE_3.read((char *)e, sizeof(Participant));
        while(!FILE_3.eof())
        {
             FILE_4.write((char *)e, sizeof(Participant));
             FILE_3.read((char *)e, sizeof(Participant));
        }
        FILE_3.close();
        FILE_4.close();
 
        if(!(qsnom.isEmpty()))
        {
            strncpy (argnom, qsnom.toUtf8().data(),qsnom.length());
            argnom[qsnom.length()]='\0';
        }
        if(!(qsprenom.isEmpty()))
        {
            strncpy (argprenom, qsprenom.toUtf8().data(),qsprenom.length());
            argprenom[qsprenom.length()]='\0';
        }
        if(!(qspseudo.isEmpty()))
        {
            strncpy (argpseudo, qspseudo.toUtf8().data(),qspseudo.length());
            argpseudo[qspseudo.length()]='\0';
        }
        if(!(qsteam.isEmpty()))
        {
            strncpy (argnomteam, qsteam.toUtf8().data(),qsteam.length());
            argnomteam[qsteam.length()]='\0';
        }
        Participant *a;
       a = new Participant;
    ofstream FILE_ECRI("participants",ios::binary|ios::app);
    if(!a->enregParticipant(argnom, argprenom, argpseudo, argnomteam))
          QMessageBox::critical(this, "Edition", "Erreur de modification du participant");
     if(FILE_ECRI.write((char *)a, sizeof(Participant)))
        QMessageBox::information(this,"Edition","participant modifié avec succès!");
     FILE_ECRI.close();
     remove("P2");
     QDialog::hide() ;
} | 
Partager