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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
BindForm()
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
rptGrpAffecte.DataBind()
End Sub
''' <summary>
''' Remplissage du formulaire
''' </summary>
''' <remarks></remarks>
Private Sub BindForm()
Try
Dim ds As DataSet
Dim dtv As DataView
ds = Shp.GetGroupeAffectes
dtv = ds.Tables(0).DefaultView
rptGrpAffecte.DataSource = dtv
Catch ex As Exception
Me.Master.AfficheMessage("Erreur dans l'affichage du répéteur", False)
End Try
End Sub
''' <summary>
''' Remplir le répéteur
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub rptGrpAffecte_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptGrpAffecte.ItemDataBound
'Lignes répétées
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'Déclaration des variables de travail
Dim r As Data.DataRowView
Dim lblGrp, lblItem As Label
Dim btnSupp As ImageButton
Dim btnMaj As Button
'Association variables de travails aux objets de la fenêtre
r = CType(e.Item.DataItem, Data.DataRowView)
lblGrp = CType(e.Item.FindControl("lblGrp"), Label)
lblItem = CType(e.Item.FindControl("lblItem"), Label)
btnSupp = CType(e.Item.FindControl("btnSuppr"), ImageButton)
btnMaj = CType(e.Item.FindControl("btnMaj"), Button)
...
'Pied du répéteur
ElseIf e.Item.ItemType = ListItemType.Footer Then
'Déclaration des variables de travail
Dim lstGrp, lstItem As DropDownList
Dim btn As Button
'Association variables de travails aux objets de la fenêtre
lstGrp = CType(e.Item.FindControl("lstGrpAdd"), DropDownList)
lstItem = CType(e.Item.FindControl("lstItemAdd"), DropDownList)
btn = CType(e.Item.FindControl("btnAdd"), Button)
Dim ds As DataSet = Nothing
ds = GetDS_Groupes
lstGrp.DataSource = ds
lstGrp.DataTextField = "LibelleGrp"
lstGrp.DataValueField = "IdGrp"
lstGrp.DataBind()
lstGrp.Items.Insert(0, New ListItem("<--Choisir un Groupe-->", "-1"))
Dim lstIndexAdd As Integer = CInt(Request.Form(lstGrp.UniqueID))
If lstIndexAdd > 0 Then
lstGrp.SelectedValue = lstIndexAdd
ds = New Groupe(lstIndexAdd).GetDS_Items
lstItem.DataSource = ds
lstItem.DataTextField = "Libelle"
lstItem.DataValueField = "ID"
lstItem.DataBind()
End If
'Mettre en premier dans la liste des Items
If lstItem.Items.Count = 0 Then
btn.Enabled = False
lstItem.Items.Insert(0, New ListItem("<--Pas d'Item dans ce groupe-->", "-1"))
Else
btn.Enabled = True
lstItem.Items.Insert(0, New ListItem("<--Choisir un Item-->", "-1"))
End If
'Gestion du bouton insérer
btn.CommandName = "INS"
End If
End Sub
Protected Sub rptGrpAffecte_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptGrpAffecte.ItemCommand
If e.CommandName = "DEL" Then
Try
...
BindForm()
Catch ex As Exception
Me.Master.AfficheMessage("Erreur Affectation suppression", False)
End Try
ElseIf e.CommandName = "INS" Then
Try
'Déclaration des variables de travail
Dim lst As DropDownList
'Association variables de travails aux objets de la fenêtre
lst = CType(e.Item.FindControl("lstItemAdd"), DropDownList)
If lst.SelectedValue = -1 Then
AfficheMessage("Sélectionner un groupe puis un Item avant affecter")
Else
'Insert en Base
End If
BindForm()
Catch ex As Exception
Me.Master.AfficheMessage("Erreur Affichage Item Groupe", False)
End Try
End If
End Sub |
Partager