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
| Protected Sub fvCmde_DataBound( _
ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles fvCmde.DataBound
Dim canImprim, canValidSrv, canValid1, canValid2, canEdit, canFact, canAnnul, canSolder As Boolean
Dim rowView As DataRowView = CType(fvCmde.DataItem, DataRowView)
' Paramétrage de l'affichage des boutons Modif, Annul, Edition, ...
If rowView("ETAT_CMD") = 1 Then
canValidSrv = (AchatUsr.NiveauService(rowView("SRV_CMD")) > 0)
Else
canValidSrv = False
End If
canValid1 = False
If rowView("ETAT_CMD") = 2 Then
If rowView("TOTAL_CMD").ToString <> "" Then
If rowView("TOTAL_CMD") >= CType(ConfigurationManager.AppSettings("Plafond1"), Double) Then
canValid1 = User.IsInRole("AchatsValid1")
End If
End If
End If
canValid2 = False
If rowView("ETAT_CMD") = 3 Then
If rowView("TOTAL_CMD").ToString <> "" Then
If rowView("TOTAL_CMD") >= CType(ConfigurationManager.AppSettings("Plafond2"), Double) Then
canValid1 = User.IsInRole("AchatsValid2")
End If
End If
End If
canImprim = False
Select Case CType(rowView("ETAT_CMD"), Integer)
Case 2
If rowView("TOTAL_CMD").ToString <> "" Then
canImprim = rowView("TOTAL_CMD") < CType(ConfigurationManager.AppSettings("Plafond1"), Double)
End If
Case 3
If rowView("TOTAL_CMD").ToString <> "" Then
canImprim = rowView("TOTAL_CMD") < CType(ConfigurationManager.AppSettings("Plafond2"), Double)
Else
canImprim = True
End If
Case 4 'Validé 2
canImprim = True
Case 5
canImprim = True
Case 6
canImprim = True
End Select
If rowView("TYPE_CMD") = 1 Then
canEdit = (rowView("ETAT_CMD") = 1)
Else
canEdit = (rowView("ETAT_CMD") >= 1 And rowView("ETAT_CMD") <= 5)
End If
canFact = (CType(rowView("ETAT_CMD"), Int16) = 5) And (rowView("TYPE_CMD").ToString <> "3")
canSolder = (CType(rowView("ETAT_CMD"), Int16) = 5) And (CType(rowView("NBF"), Integer) > 0)
canAnnul = (CType(rowView("ETAT_CMD"), Int16) < 6) And (CType(rowView("NBF"), Integer) < 0)
PanelFact.Visible = (CType(rowView("ETAT_CMD"), Int16) = 5) Or (CType(rowView("ETAT_CMD"), Int16) = 6)
...
Case FormViewMode.ReadOnly
'Valid
fvCmde.FindControl("imgBtnValid").Visible = canValidSrv Or canValid1 Or canValid2
fvCmde.FindControl("lnkBtnValid").Visible = canValidSrv Or canValid1 Or canValid2
'Edit
fvCmde.FindControl("imgBtnImprim").Visible = canImprim
fvCmde.FindControl("lnkBtnImprim").Visible = canImprim
'Modif
fvCmde.FindControl("imgBtnEdit").Visible = canEdit
fvCmde.FindControl("lnkBtnEdit").Visible = canEdit
'Fact
fvCmde.FindControl("imgBtnFact").Visible = canFact
fvCmde.FindControl("lnkBtnFact").Visible = canFact
'solder
fvCmde.FindControl("imgBtnSold").Visible = canSolder
fvCmde.FindControl("lnkBtnSold").Visible = canSolder
'annul
fvCmde.FindControl("imgBtnAnnul").Visible = canAnnul
fvCmde.FindControl("lnkBtnAnnul").Visible = canAnnul |
Partager