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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
Private Sub ChargeDatas()
Dim tmp As Integer
Dim dtsConst As DataSet = UtilsPS.PS_GetInfosConstructeurs(tmp)
If dtsConst IsNot Nothing AndAlso dtsConst.Tables.Count > 0 AndAlso dtsConst.Tables(0).DefaultView.Count > 0 Then
dtvConstruct = dtsConst.Tables(0).DefaultView
dtvConstructV2 = dtsConst.Tables(1).DefaultView
dtvGrossiste = dtsConst.Tables(2).DefaultView
End If
HelperCache.SetObjectToCache(dtvConstructId, dtvConstruct)
HelperCache.SetObjectToCache(dtvConstructIdV2, dtvConstructV2)
HelperCache.SetObjectToCache(dtvGrossisteId, dtvGrossiste)
End Sub
''' <summary>
''' Pagination de la liste des constructeurs
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub grdConstInternes_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdConstInternes.PageIndexChanging
Try
BindConst(False)
grdConstInternes.EditIndex = -1
grdConstInternes.PageIndex = e.NewPageIndex
grdConstInternes.DataBind()
Catch ex As Exception
My.Log.WriteException(ex)
End Try
End Sub
Private Sub grdConstInternes_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdConstInternes.RowEditing
grdConstInternes.EditIndex = e.NewEditIndex
BindConst(False)
End Sub
Private Sub grdConstInternes_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles grdConstInternes.RowCancelingEdit
grdConstInternes.EditIndex = -1
BindConst(False)
End Sub
Private Sub grdConstInternes_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles grdConstInternes.RowUpdating
grdConstInternes.EditIndex = -1
BindConst(False)
End Sub
Protected Sub grdConstInternes_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdConstInternes.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
'Mettre flèche dans le sens du tri
If ViewState("SortExp") IsNot Nothing Then
Dim ImgSort As Image = New Image()
If ViewState("SortOrder").ToString() = "ASC" Then
ImgSort.ImageUrl = "~/Images/up.png"
Else
ImgSort.ImageUrl = "~/Images/down.png"
End If
Dim pH As PlaceHolder = Nothing
Select Case ViewState("SortExp")
Case "EstActif"
pH = e.Row.FindControl("placeholderActif")
Case "Libelle"
pH = e.Row.FindControl("placeholderConst")
Case "ID_EDB_V2"
pH = e.Row.FindControl("placeholderConstV2")
End Select
If pH IsNot Nothing Then pH.Controls.Add(ImgSort)
End If
Dim lstActif As DropDownList = e.Row.FindControl("rdlstActif")
If lstActif IsNot Nothing Then lstActif.SelectedValue = FiltreActif
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
Dim Macolumn As DataRowView = e.Row.DataItem()
'Actif
Dim act As Web.UI.HtmlControls.HtmlGenericControl = CType(e.Row.FindControl("ConstAct"), Web.UI.HtmlControls.HtmlGenericControl)
If act IsNot Nothing Then
If Not IsDBNull(Macolumn("EstActif")) AndAlso CBool(Macolumn("EstActif")) Then
act.Attributes.Add("class", "actif")
Else
act.Attributes.Add("class", "inactif")
End If
End If
'Mode édition
Dim chk As CheckBox = CType(e.Row.FindControl("chkConstActifUpdate"), CheckBox)
If chk IsNot Nothing Then
chk.Checked = (Not IsDBNull(Macolumn("EstActif")) AndAlso CBool(Macolumn("EstActif")))
Dim lst As DropDownList = CType(e.Row.FindControl("lstConstV2Update"), DropDownList)
LstConstV2(lst)
lst.SelectedValue = Macolumn("ID_EDB_V2").ToString
End If
ElseIf e.Row.RowType = DataControlRowType.Footer Then
Dim lst As DropDownList = CType(e.Row.FindControl("lstConstV2Insert"), DropDownList)
LstConstV2(lst)
ElseIf e.Row.RowType = DataControlRowType.Pager Then
Dim btnFirst, btnPrevious, btnNext, btnLast As LinkButton
btnFirst = e.Row.FindControl("btnFirst")
If btnFirst IsNot Nothing Then
If grdConstInternes.PageIndex = 0 Then
btnFirst.Visible = False
Else
btnFirst.Visible = True
End If
End If
btnPrevious = e.Row.FindControl("btnPrevious")
If btnPrevious IsNot Nothing Then
If grdConstInternes.PageIndex = 0 Then
btnPrevious.Visible = False
Else
btnPrevious.Visible = True
End If
End If
btnNext = e.Row.FindControl("btnNext")
If btnNext IsNot Nothing Then
If grdConstInternes.PageIndex = grdConstInternes.PageCount - 1 Then
btnNext.Visible = False
Else
btnNext.Visible = True
End If
End If
btnLast = e.Row.FindControl("btnLast")
If btnLast IsNot Nothing Then
If grdConstInternes.PageIndex = grdConstInternes.PageCount - 1 Then
btnLast.Visible = False
Else
btnLast.Visible = True
End If
End If
Dim lblPagination, lblConstGrd As Label
lblPagination = e.Row.FindControl("lblPagination")
If lblPagination IsNot Nothing Then
lblPagination.Text = grdConstInternes.PageIndex + 1 & " sur " & grdConstInternes.PageCount
End If
lblConstGrd = e.Row.FindControl("lblConstGrd")
If lblConstGrd IsNot Nothing Then
If dtvConstruct.Count > 1 Then
lblConstGrd.Text = dtvConstruct.Count & " constructeurs affichés sur " & dtvConstruct.Table.Rows.Count
Else
lblConstGrd.Text = dtvConstruct.Count & " constructeurs affiché sur " & dtvConstruct.Table.Rows.Count
End If
End If
End If
End Sub
Private Sub LstConstV2(ByRef lst As DropDownList)
lst.DataSource = dtvConstructV2
lst.DataBind()
lst.Items.Insert(0, New ListItem("Aucun", "NULL"))
End Sub
Protected Sub grdConstInternes_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdConstInternes.RowCommand
Select Case e.CommandName
Case "Previous"
If grdConstInternes.PageIndex > 0 Then
BindConst(False)
grdConstInternes.EditIndex = -1
grdConstInternes.PageIndex = grdConstInternes.PageIndex - 1
grdConstInternes.DataBind()
End If
Case "First"
BindConst(False)
grdConstInternes.EditIndex = -1
grdConstInternes.PageIndex = 0
grdConstInternes.DataBind()
Case "Next"
If grdConstInternes.PageIndex < grdConstInternes.PageCount Then
BindConst(False)
grdConstInternes.EditIndex = -1
grdConstInternes.PageIndex = grdConstInternes.PageIndex + 1
grdConstInternes.DataBind()
End If
Case "Last"
BindConst(False)
grdConstInternes.EditIndex = -1
grdConstInternes.PageIndex = grdConstInternes.PageCount
grdConstInternes.DataBind()
Case "Trier"
grdConstInternes.EditIndex = -1
If ViewState("SortExp") Is Nothing Then
ViewState("SortExp") = e.CommandArgument.ToString()
ViewState("SortOrder") = "ASC"
Else
If ViewState("SortExp").ToString() = e.CommandArgument.ToString() Then
If ViewState("SortOrder").ToString() = "ASC" Then
ViewState("SortOrder") = "DESC"
Else
ViewState("SortOrder") = "ASC"
End If
Else
ViewState("SortOrder") = "ASC"
ViewState("SortExp") = e.CommandArgument.ToString()
End If
End If
BindConst()
Case "Ajouter"
Dim txtLibConst As TextBox = grdConstInternes.FooterRow.FindControl("txtLibConstInsert")
Dim chkActif As CheckBox = grdConstInternes.FooterRow.FindControl("chkConstActifInsert")
Dim lstConstV2 As DropDownList = grdConstInternes.FooterRow.FindControl("lstConstV2Insert")
If txtLibConst IsNot Nothing AndAlso chkActif IsNot Nothing AndAlso lstConstV2 IsNot Nothing Then UpdateConstructeur(-1, txtLibConst.Text.Trim, chkActif.Checked, lstConstV2.SelectedValue, True)
Case "Supprimer"
Constructeur.Delete(CInt(e.CommandArgument))
ChargeDatas()
BindConst()
Case "Update"
Dim txtLibConst As TextBox = e.CommandSource.FindControl("txtLibConstUpdate")
Dim chkActif As CheckBox = e.CommandSource.FindControl("chkConstActifUpdate")
Dim lstConstV2 As DropDownList = e.CommandSource.FindControl("lstConstV2Update")
If txtLibConst IsNot Nothing AndAlso chkActif IsNot Nothing AndAlso lstConstV2 IsNot Nothing Then UpdateConstructeur(CInt(e.CommandArgument), txtLibConst.Text.Trim, chkActif.Checked, lstConstV2.SelectedValue, False)
End Select
End Sub
Protected Sub SelActifChanged(ByVal sender As Object, ByVal e As System.EventArgs)
FiltreActif = sender.selectedValue
HelperCache.SetObjectToCache(FiltreActifId, FiltreActif)
grdConstInternes.EditIndex = -1
BindConst()
End Sub
Private Sub BindConst(Optional ByVal AvecRazPage As Boolean = True)
grdConstInternes.EnableViewState = True
Dim dtvTmp As DataView = dtvConstruct.Table.DataSet.Copy().Tables(0).DefaultView
If dtvTmp IsNot Nothing Then
'Gestion des filtres
Dim strFiltre As String = Nothing
If FiltreActif <> Nothing AndAlso FiltreActif <> "-1" Then
strFiltre = "EstActif = " & FiltreActif
End If
dtvTmp.RowFilter = strFiltre
'Gestion du tri
If ViewState("SortExp") IsNot Nothing Then
dtvTmp.Sort = ViewState("SortExp").ToString() & " " & ViewState("SortOrder").ToString()
Else
dtvTmp.Sort = ""
End If
End If
If dtvTmp Is Nothing OrElse dtvTmp.Count > 0 Then
grdConstInternes.DataSource = dtvTmp
If AvecRazPage Then
grdConstInternes.AllowPaging = True
grdConstInternes.PageSize = 23
grdConstInternes.PageIndex = 0
grdConstInternes.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast
End If
grdConstInternes.DataBind()
Else
'Add a blank row to the dataset
dtvTmp.AddNew()
'Bind the DataSet to the GridView
grdConstInternes.DataSource = dtvTmp
grdConstInternes.DataBind()
'Get the number of columns to know what the Column Span should be
Dim columnCount As Integer = grdConstInternes.Rows(0).Cells.Count
'Call the clear method to clear out any controls that you use in the columns. I use a dropdown list in one of the column so this was necessary.
grdConstInternes.Rows(0).Cells.Clear()
grdConstInternes.Rows(0).Cells.Add(New TableCell)
grdConstInternes.Rows(0).Cells(0).ColumnSpan = columnCount
grdConstInternes.Rows(0).Cells(0).Text = "Pas de constructeur"
End If
End Sub |
Partager