IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

classe PlaceHolder l'affichage de l'ordre voulu [Débutant]


Sujet :

C#

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    316
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2010
    Messages : 316
    Par défaut classe PlaceHolder l'affichage de l'ordre voulu
    Bonjour,

    Je récupère les informations sous le format XML d'un service Web...

    Je mets les informations dans un " Generic List<type>" et les affiche par la "classe PlaceHolder".

    Affichage c'est en ordre de l'information venue par le service WEB donc par "Id".
    Comment peux-je changer l'affichage de cet ordre : par exemple selon "BwEtatId"

    ---Pour clarifier la situation : -----
    Voici mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    List<ConstructIdent> monListSansAnnulation = new List<ConstructIdent>();
                    int etatId;
                    foreach (ConstructIdent inscription in monInscription)
                    {
                        etatId = inscription.BwEtatId;
     
                        if (!etatId.Equals(3))
                        {
                            monListSansAnnulation.Add(inscription);
                        }
                    }
     
     
                    int i = 1;
                    PlaceHolder1.Controls.Add(new LiteralControl("<table id = resultat>"));
                    PlaceHolder1.Controls.Add(new LiteralControl("<tr><td><b>Inscription No.</b></td><td class= paire><b>Description</b></td><td><b>Etat</b></td><td class= paire><b>Debut</b></td><td><b>Fin</b></td><td class= paire><b>changement</b></td></tr>"));
     
                    tVisualiserPageState.Inscriptions = new ConstructIdent[monListSansAnnulation.Count];
     
                    foreach (ConstructIdent inscription in monListSansAnnulation)
                    {
                        etatId = inscription.BwEtatId;
     
                        string etats;
     
     
     
                        switch (etatId)
                        {
                            case 0:
                                etats = "Pas encore";
                                break;
                            case 1:
                                etats = "Actif";
                                break;
                            case 2:
                                etats = "Suspendu";
                                break;
                            case 3:
                                etats = "Annulé";
                                break;
                            case 4:
                                etats = "Expiré";
                                break;
                            default:
                                etats = "non identifié";
                                break;
                        }
     
                        PlaceHolder1.Controls.Add(new LiteralControl("<tr>"));
     
                        // inscription id
                        PlaceHolder1.Controls.Add(new LiteralControl("<td>"));
                        Label inscriptionIdLabel = new Label();
                        inscriptionIdLabel.ID = "inscriptionIdLabel" + i.ToString();
                        inscriptionIdLabel.Text = inscription.Id.ToString();
                        PlaceHolder1.Controls.Add(inscriptionIdLabel);
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
     
                        // descriptionData
                        PlaceHolder1.Controls.Add(new LiteralControl("<td class= paire>"));
                        Label descriptionDataLabel = new Label();
                        descriptionDataLabel.ID = "descriptionDataLabel" + i.ToString();
                        descriptionDataLabel.Text = GetDescriptionData(inscription.BaseId);
                        PlaceHolder1.Controls.Add(descriptionDataLabel);
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
                        PlaceHolder1.Controls.Add(new LiteralControl("<td>"));
     
     
                        // etats
                        Label etatsLabel = new Label();
                        etatsLabel.ID = "etatsLabel" + i.ToString();
                        etatsLabel.Text = etats;
                        PlaceHolder1.Controls.Add(etatsLabel);
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
                        PlaceHolder1.Controls.Add(new LiteralControl("<td class= paire>"));
     
                        // Debut etat
                        Label DepartDebutLabel = new Label();
                        DepartDebutLabel.ID = "DepartDebutLabel" + i.ToString();
                        DepartDebutLabel.Text = GetDepartDescription(inscription.BaseId, inscription.IdDepart);
                        PlaceHolder1.Controls.Add(DepartDebutLabel);
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
                        PlaceHolder1.Controls.Add(new LiteralControl("<td>"));
     
                        // Fin etat
                        Label FinDebutLabel = new Label();
                        FinDebutLabel.ID = "FinDebutLabel" + i.ToString();
                        FinDebutLabel.Text = GetDepartDescription(inscription.BaseId, inscription.IdFin);
                        PlaceHolder1.Controls.Add(FinDebutLabel);
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
     
                        // bouton changement
                        PlaceHolder1.Controls.Add(new LiteralControl("<td class= paire>"));
                        Button changementBouton = new Button();
                        changementBouton.ID = "changementBouton_" + i.ToString();
                        changementBouton.Text = "Rectifier";
                        if ((inscription.BwEtatId == 3))
                            changementBouton.Enabled = false;
     
                        changementBouton.Click += new System.EventHandler(this.changementBouton_Click);
                        PlaceHolder1.Controls.Add(changementBouton);
     
                        PlaceHolder1.Controls.Add(new LiteralControl("</td>"));
                        PlaceHolder1.Controls.Add(new LiteralControl("</tr>"));
     
                        tVisualiserPageState.Inscriptions[i - 1] = inscription;
                        i++;
     
                    }
     
                    PlaceHolder1.Controls.Add(new LiteralControl("</table>"));
     
     
     
                    SavePageState();
    ---Pour clarifier la situation : -----
    voici exemple des informatiosn venu par Web service :
    <?xml version="1.0" encoding="utf-8" ?>
    <ArrayConstructIdent xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlnssd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.toto.com/DataBase/BW">
    <ConstructIdent>
    <Id>5</Id>
    <BaseId>1a1</BaseId>
    <BwEtatId>4</BwEtatId>
    <IdDepart>4408R</IdDepart>
    <IdFin>4410R</IdFin>
    </ConstructIdent>

    <ConstructIdent>
    <Id>9</Id>
    <BaseId>1a1</BaseId>
    <BwEtatId>0</BwEtatId>
    <IdDepart>4408R</IdDepart>
    <IdFin>4410R</IdFin>
    </ConstructIdent>


    <ConstructIdent>
    <Id>18</Id>
    <BaseId>1a1</BaseId>
    <BwEtatId>1</BwEtatId>
    <IdDepart>4408R</IdDepart>
    <IdFin>4410R</IdFin>
    </ConstructIdent>
    </ArrayConstructIdent>
    Merci....

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    316
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2010
    Messages : 316
    Par défaut
    Comme ConstructIdent, c'est dans webService, en format XML, je ne peux pas donc changer le web service...
    Alors je ne peux pas implémenter Icomparable dans ma classe ConstructIdent, n'est-ce pas ?
    Est-ce que je peux utiliser "Enumerable.OrderBy" pour trier les informations dans List<type> Comment ?

    ---Pour clarifier la situation : -----
    Voici mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    //demande info par nameId sur les inscriptions
                  ConstructIdent[] myInscriptions = InscriptionsWP.GetInscriptions(nameId);
     
                    // declaration Generic List<type>
                  List<ConstructIdent> monListSansAnnulation = new List<ConstructIdent>();

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    316
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2010
    Messages : 316
    Par défaut
    Bonjour, voila la solution plus simple dix jours après...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    	//(...... etc)
     
    					//demande info par nameId sur les inscriptions
                  ConstructIdent[] myInscriptions = InscriptionsWP.GetInscriptions(nameId);
     
                    // declaration Generic List<type>
                  List<ConstructIdent> monListSansAnnulation = new List<ConstructIdent>();
                    int etatId;
     
     
    			int localisation;    //// Pour garder la position ou insérer l'élément en cours 
    			bool repere;     	//Un booléen (aura la valeur True lorsque l'élément est trouvé) ainsi on ne vais pas le re-traiter après la boucle foreach.
     
     
                foreach (ConstructIdent inscription in monInscription)
                {
                    etatId = inscription.BwetatId;
     
                    if (!etatId.Equals(3))
                    {
                        localisation = 0;
                        repere = false;   //affecté/ assignée false (rien trouvé)
     
                        foreach (ConstructIdent InsertInscription in monListSansAnnulation)  //La fonction Insert permet d'ajouter un élément donné à une liste dans une position précise (la variable localisation)  
                        {
                            if (inscription.BwetatId < InsertInscription.BwetatId)    //comparaison les valeurs du membre que l'on veut trie
                            {
     
     
                                monListSansAnnulation.Insert(localisation, inscription);
                                repere = true; //affecté/ assignée true (donc trouvé)
                                break;    // mettre un  break qui permet de quitter la boucle foreach parce que l'élément a été déjà inséré ]
                            }
     
                            localisation++;         //affectée/assignée à 1  donc il faut se déplacer pour insérer le prochain élément]
                        }
     
     
     
                        if (!repere)   // la variable repere est à True veut dire que l'élément actuel est plus grand que tous ceux qui se trouvent dans la liste monListSansAnnulation, alors il faut ajouter à la fin]          
                        {
     
                            monListSansAnnulation.Add(inscription);   //la fonction Add ajoute l'élément à la fin de la liste.
                        }
                    }
                }
     
     
    			int i = 1;
    			//(...... etc)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [PHP 5.2] Problème de classe et d'affichage
    Par ETVigan dans le forum Langage
    Réponses: 34
    Dernier message: 12/11/2010, 08h37
  2. Comment remplacer un affichage aléatoire par un affichage dans l'ordre
    Par PierreR75 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 23/04/2010, 17h48
  3. Affichage liste dans ordre croissant
    Par nymus7 dans le forum Langage
    Réponses: 2
    Dernier message: 08/02/2010, 10h46
  4. VBO dans une class : pas d'affichage
    Par Naelhem dans le forum OpenGL
    Réponses: 1
    Dernier message: 23/09/2008, 15h09
  5. Réponses: 4
    Dernier message: 19/10/2005, 17h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo