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
| Private Sub UserForm_Initialize()
Sheets("ficheresponsableachat").Activate
For i = 2 To 100
ComboBox1.AddItem Sheets("ficheresponsableachat").Cells(i, 2)
Next
For i = 2 To 15
Next
Sheets("commandetraitee").Activate
Dim VarDerLigne As Integer
Dim VarPlageList As String
VarDerLigne = Sheets("etatdustock").Range("A65536").End(xlUp).Row
VarPlageList = Sheets("etatdustock").Range("B2:B" & VarDerLigne).Address
llselectionarticle.RowSource = "etatdustock!" & VarPlageList
End Sub
Private Sub llselectionarticle_Click()
VarSelectedArticle = UserForm1.llselectionarticle.ListIndex + 2
llstock = Sheets("etatdustock").Range("D" & VarSelectedArticle).Value
If llstock = 0 Then
llreference = "Article non Dispo"
llprix.Visible = False
llquantite.Visible = False
llprixtotal.Visible = False
Else
llprix.Visible = True
llquantite.Visible = True
llprixtotal.Visible = True
llreference = Sheets("etatdustock").Range("A" & VarSelectedArticle).Value
llprix = Format(Sheets("etatdustock").Range("C" & VarSelectedArticle).Value, "#,##0.00")
llprixtotal = ""
llquantite = ""
llquantite.SetFocus
End If
End Sub
Private Sub llquantite_change()
Dim Chiffre As Integer
If llquantite = "" Then Exit Sub
On Error GoTo Sortie
Chiffre = llquantite
llprixtotal = Format(llprix * llquantite, 0#)
ajouterarticleboutton.Visible = True
Exit Sub
Sortie:
MsgBox "Saisir Uniquement un Entier Numérique"
CacheCache
End Sub
Private Sub ajouterarticleboutton_Click()
Dim VarDerL As Integer
Dim Quantite As Integer
Dim Stock As Integer
VarDerL = Sheets("commandetraitee").Range("B42").End(xlUp).Row + 1
If llquantite = "" Then
MsgBox "Vous Devez Saisir Une Quantité", vbCritical, "Erreur => Invalide"
llquantite.Visible = True
llquantite.SetFocus
Exit Sub
End If
If llquantite <= 0 Then
MsgBox "Vous Devez Saisir Une Valeur Positive ", vbCritical, "Invalide"
llquantite.Visible = True
llquantite = ""
llquantite.SetFocus
Exit Sub
End If
On Error GoTo Sortie
Quantite = llquantite
Stock = llstock
If Quantite > Stock Then
MsgBox "La quantité demandée " & llquantite & " est supérieur au stock " _
& llstock, vbCritical, "Aie=> Stock Insuffisant"
llquantite.Visible = True
llquantite = llstock
llquantite.SetFocus
Exit Sub
End If
If VarDerL = 40 Then
MsgBox "Vous êtes arrivé à la dernière ligne de cette facture", vbCritical, "Thierry's Démo => Fin de Facture"
CacheCache
Exit Sub
End If
With Sheets("commandetraitee")
.Range("A" & VarDerL) = ComboBox1
.Range("B" & VarDerL) = llreference
.Range("C" & VarDerL) = llselectionarticle
.Range("D" & VarDerL) = Format(llprix, 0#)
.Range("E" & VarDerL) = llquantite
.Range("F" & VarDerL) = Format(llprixtotal, 0#)
End With
Sheets("etatdustock").Range("D" & VarSelectedetatdustock).Value = _
Sheets("etatdustock").Range("D" & VarSelectedetatdustock).Value - llstock
CacheCache
Exit Sub
Sortie:
MsgBox "Article mis dans le panier !", vbOKOnly, "Parfait"
CacheCache
End Sub
Private Sub finalisercomande_Click()
Dim Montant As Currency
Dim VarDerLi As Integer
VarDerLi = Sheets("commandetraitee").Range("B42").End(xlUp).Row + 1
Montant = Sheets("commandetraitee").Range("F42")
If Montant = 0 Then
MsgBox "Vous n'avez entré aucun article dans la facture ! " _
& vbCrLf & "Vous devez avoir au moins 1 article pour procéder au traitement", _
vbCritical, "Erreur => Invalide"
Exit Sub
Sheets("commandetraitee").Range("D3") = "XLCity le " & Format(Now, "DD/MM/YYYY")
Sheets("commandetraitee").Range("B45") = "Dans l'attente de recevoir la somme de " _
& Format(Montant, "0.00") & " Euro"
Unload UserForm1
Sheets("ficheresponsableachat").Activate
Sheets("commandetraitee").PrintPreview
End Sub
Private Sub CacheCache()
ajouterarticleboutton.Visible = True
llquantite.Visible = False
llquantite = ""
llstock = ""
llreference = ""
llprix = ""
llprixtotal = ""
llselectionarticle = ""
llselectionarticle.SetFocus
End Sub
Private Sub CommandButton1_Click()
Unload UserForm1
userformparametrage.Show
End Sub
Private Sub retourparametrageee_Click()
UserForm1.Hide
userformparametrage.Show
End Sub |
Partager