Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Mise a jour automatique du tableau dans "Gerer ses collections" quand…
Browse files Browse the repository at this point in the history
… on change de collection
  • Loading branch information
loic-vial committed Nov 19, 2012
1 parent 17dbd63 commit 35999d5
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 32 deletions.
16 changes: 2 additions & 14 deletions contenu/HobbyCartes/HobbyCartes/MembreGererCollections.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<table class="membreGererCollectionsTableCollections" >
<tr>
<td>Mes collections : </td>
<td><asp:DropDownList id="cboCollections" runat="server" /></td>
<td><asp:DropDownList id="cboCollections" runat="server" AutoPostBack="true" /></td>
<td><asp:Button id="btnSupprimerCollection" runat="server" text="Supprimer la collection" OnClientClick="javascript:return confirm('Voulez vous vraiment supprimer cette collection ?');" /></td>
</tr>
<tr>
Expand All @@ -19,19 +19,7 @@

<p>Liste des fiches pour la collection séléctionnée : </p>
<asp:table runat="server" id="tblListeFiches" cssclass="membreGererCollectionsTableListeFiches">
<asp:TableHeaderRow CssClass="membreGererCollectionsTableListeFichesHeader" >
<asp:TableCell>Nom</asp:TableCell>
<asp:TableCell>Prénom</asp:TableCell>
<asp:TableCell>Etat de la fiche</asp:TableCell>
<asp:TableCell>Numéro</asp:TableCell>
<asp:TableCell>Recrue</asp:TableCell>
<asp:TableCell>Valeur</asp:TableCell>
<asp:TableCell>Equipe</asp:TableCell>
<asp:TableCell>Editeur</asp:TableCell>
<asp:TableCell>Position</asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableHeaderRow>

</asp:table>

</div>
Expand Down
124 changes: 106 additions & 18 deletions contenu/HobbyCartes/HobbyCartes/MembreGererCollections.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,13 @@ Public Class MembreGererCollections
If Not connected Then Erreur.afficherErreur("Vous devez être connecté pour gérer vos collections.", Page)

majBoutons()

If cboCollections.Items.Count <> 0 Then
Dim type As Entites.Collection.Type = Entites.Collection.Type.Parse(GetType(Entites.Collection.Type), cboCollections.SelectedValue)
remplirListeFiches(Entites.Collection.getIdCollectionParTypeEtMembre(m_idMembre, type))
End If
' On click sur une carte, detail de la carte

majListeFiches()
End Sub

''' <summary>
''' Mise a jour des boutons pour "Supprimer" et "Ajouter" une collection
''' </summary>
''' <remarks></remarks>
Private Sub majBoutons()
If cboCollections.Items.Count = 0 Then
btnSupprimerCollection.Enabled = False
Expand Down Expand Up @@ -99,18 +97,35 @@ Public Class MembreGererCollections
End Sub

''' <summary>
''' Rempli le tableau de la liste des fiches avec une collection
''' Changement de selection dans la combobox des collections
''' </summary>
Private Sub remplirListeFiches(idCollection As Integer)
Dim dbCon As MySqlConnection = New MySqlConnection(My.Resources.StringConnexionBdd)
dbCon.Open()
Dim typeCol As Entites.Collection.Type = Entites.Collection.Type.Parse(GetType(Entites.Collection.Type), cboCollections.SelectedValue)
Dim Collection As Entites.Collection = New Entites.Collection(m_idMembre, typeCol, dbCon)
dbCon.Close()
For i As Integer = 0 To Collection.ListeFiches.Count - 1
tblListeFiches.Rows.Add(getFicheRow(Collection.ListeFiches.Item(i)))
Next
' Ajoute une ligne pour ajouter une fiche a la collection
Protected Sub cboCollections_SelectedIndexChanged() Handles cboCollections.SelectedIndexChanged
majListeFiches()
End Sub

''' <summary>
''' Met a jour le tableau de la liste des fiches en fonction de la collection selectionnee dans le combobox
''' </summary>
Private Sub majListeFiches()
' Vide d'abord le tableau
tblListeFiches.Rows.Clear()

' Ajoute l'entete du tableau
tblListeFiches.Rows.Add(getHeaderRow)

' Si une collection est selectionnee dans la combobox, on ajoute toutes les fiches de la collection
If cboCollections.Items.Count <> 0 Then
Dim dbCon As MySqlConnection = New MySqlConnection(My.Resources.StringConnexionBdd)
dbCon.Open()
Dim typeCol As Entites.Collection.Type = Entites.Collection.Type.Parse(GetType(Entites.Collection.Type), cboCollections.SelectedValue)
Dim Collection As Entites.Collection = New Entites.Collection(m_idMembre, typeCol, dbCon)
dbCon.Close()
For i As Integer = 0 To Collection.ListeFiches.Count - 1
tblListeFiches.Rows.Add(getFicheRow(Collection.ListeFiches.Item(i)))
Next
End If

' Ajoute une derniere ligne pour ajouter une nouvelle fiche a la collection
Dim rowBtnAjouter As TableRow = New TableRow
Dim cellBtnAjouter As TableCell = New TableCell
Dim btnAjouter As Button = New Button
Expand All @@ -121,6 +136,73 @@ Public Class MembreGererCollections
tblListeFiches.Rows.Add(rowBtnAjouter)
End Sub

''' <summary>
''' Retourne la ligne d'entete du tableau des fiches
''' </summary>
Private Function getHeaderRow() As TableHeaderRow
Dim rowEntete As TableHeaderRow = New TableHeaderRow
rowEntete.CssClass = "membreGererCollectionsTableListeFichesHeader"

Dim cellNomEntete As TableCell = New TableCell()
Dim lblNomEntete As Label = New Label()
lblNomEntete.Text = "Nom"
cellNomEntete.Controls.Add(lblNomEntete)
rowEntete.Cells.Add(cellNomEntete)

Dim cellPrenomEntete As TableCell = New TableCell()
Dim lblPrenomEntete As Label = New Label()
lblPrenomEntete.Text = "Prenom"
cellPrenomEntete.Controls.Add(lblPrenomEntete)
rowEntete.Cells.Add(cellPrenomEntete)

Dim cellEtatEntete As TableCell = New TableCell()
Dim lblEtatEntete As Label = New Label()
lblEtatEntete.Text = "Etat"
cellEtatEntete.Controls.Add(lblEtatEntete)
rowEntete.Cells.Add(cellEtatEntete)

Dim cellNumeroEntete As TableCell = New TableCell()
Dim lblNumeroEntete As Label = New Label()
lblNumeroEntete.Text = "Numero"
cellNumeroEntete.Controls.Add(lblNumeroEntete)
rowEntete.Cells.Add(cellNumeroEntete)

Dim cellRecrueEntete As TableCell = New TableCell()
Dim lblRecrueEntete As Label = New Label()
lblRecrueEntete.Text = "Recrue"
cellRecrueEntete.Controls.Add(lblRecrueEntete)
rowEntete.Cells.Add(cellRecrueEntete)

Dim cellValeurEntete As TableCell = New TableCell()
Dim lblValeurEntete As Label = New Label()
lblValeurEntete.Text = "Valeur"
cellValeurEntete.Controls.Add(lblValeurEntete)
rowEntete.Cells.Add(cellValeurEntete)

Dim cellEquipeEntete As TableCell = New TableCell()
Dim lblEquipeEntete As Label = New Label()
lblEquipeEntete.Text = "Equipe"
cellEquipeEntete.Controls.Add(lblEquipeEntete)
rowEntete.Cells.Add(cellEquipeEntete)

Dim cellEditeurEntete As TableCell = New TableCell()
Dim lblEditeurEntete As Label = New Label()
lblEditeurEntete.Text = "Editeur"
cellEditeurEntete.Controls.Add(lblEditeurEntete)
rowEntete.Cells.Add(cellEditeurEntete)

Dim cellPositionEntete As TableCell = New TableCell()
Dim lblPositionEntete As Label = New Label()
lblPositionEntete.Text = "Position"
cellPositionEntete.Controls.Add(lblPositionEntete)
rowEntete.Cells.Add(cellPositionEntete)

rowEntete.Cells.Add(New TableCell)
rowEntete.Cells.Add(New TableCell)

Return rowEntete
End Function

''' <summary>
''' Retourne une ligne de tableau representant la fiche passée en parametre
''' </summary>
Expand Down Expand Up @@ -201,13 +283,19 @@ Public Class MembreGererCollections
Return row
End Function

''' <summary>
''' Clic sur le bouton pour "Supprimer une fiche"
''' </summary>
Private Sub btnSuppr_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim btnSuppr As Button = DirectCast(sender, Button)
Dim idFiche As String = btnSuppr.ID.Substring(8)
Entites.Fiche.supprimer(idFiche)
Response.Redirect("MembreGererCollections.aspx")
End Sub

''' <summary>
''' Clic sur le bouton pour "Voir le détail d'une fiche"
''' </summary>
Private Sub btnVoir_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim btnVoir As Button = DirectCast(sender, Button)
Dim idFiche As String = btnVoir.ID.Substring(7)
Expand Down

0 comments on commit 35999d5

Please sign in to comment.