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
| Public i, j, Délai, Lot, Qté_sto, Seuil, RefFrn, RefProd, Taille As Integer
Public PUV As Double
Private Sub CommandButton1_Click()
Dim newLig As Long
Dim result As String, OuEcrire() As String
OuEcrire = Split(LigneSuivante, ",")
newLig = CLng(OuEcrire(1))
With Sheets(OuEcrire(0))
.Range("C" & newLig).Value = TextBox1.Value ' designation
.Range("I" & newLig).Value = TextBox2.Value ' prix
.Range("J" & newLig).Value = TextBox5.Value ' unite
.Range("K" & newLig).Value = TextBox4.Value ' qte
.Range("L" & newLig).Value = .Range("K" & newLig).Value * .Range("I" & newLig).Value
.Range("M" & newLig).Value = IIf(Me.OptionButton1, 1, 2)
.Range("O" & newLig).Value = IIf(Me.OptionButton1, 0.055 * .Range("L" & newLig).Value, "")
.Range("P" & newLig).Value = IIf(Me.OptionButton2, 0.196 * .Range("L" & newLig).Value, "")
'.....
End With
TextBox1.Value = ""
TextBox2.Value = ""
TextBox5.Value = ""
TextBox4.Value = ""
Me.OptionButton7.Value = False
End Sub
Private Sub UserForm_Initialize()
'Pour afficher la dernière saisie
i = 2
While Feuil11.Cells(i, 1) <> ""
i = i + 1
Wend
i = i - 1
SpinButton1.Value = i
Frame2.Visible = False
Frame3.Visible = False
Me.OptionButton1.Value = True
End Sub
Private Sub SpinButton1_Change()
i = SpinButton1.Value
'Empêche de trop remonter
If i < 2 Then
i = 2
SpinButton1.Value = i
End If
'récup les infos
If i > 1 Then
RefProd = Feuil5.Cells(i, 1)
TextBox_Num_série = Feuil5.Cells(i, 2)
TextBox_Nom_prod = Feuil5.Cells(i, 3)
TextBox1 = Feuil5.Cells(i, 3)
TextBox_Desc = Feuil5.Cells(i, 4)
TextBox_Cat = Feuil5.Cells(i, 5)
TextBox_Taille = Feuil5.Cells(i, 6)
TextBox2 = Feuil5.Cells(i, 6)
TextBox_Qté_sto = Feuil5.Cells(i, 7)
TextBox_Seuil = Feuil5.Cells(i, 9)
TextBox_PUV = Feuil5.Cells(i, 11)
TextBox5 = Feuil5.Cells(i, 11)
RefFrn = Feuil5.Cells(i, 12)
TextBox_PUA = Feuil5.Cells(i, 13)
TextBox_Délai = Feuil5.Cells(i, 14)
End If
'Vide si pas de produit
If RefProd = 0 Then
TextBox_Num_série = ""
TextBox_Nom_prod = ""
TextBox_Desc = ""
TextBox_Cat = ""
TextBox_Taille = ""
TextBox_Qté_sto = ""
TextBox_Seuil = ""
TextBox_PUV = ""
TextBox_Nom_Frn = ""
TextBox_Num_Frn = ""
RefFrn = 0
TextBox_PUA = ""
TextBox_Délai = ""
TextBox_Qté_sto.Font.Bold = False
TextBox_Qté_sto.BackColor = &H8000000F
Exit Sub
End If
'Affiche si stock égale zéro
If TextBox_Qté_sto = 0 Then
TextBox_Qté_sto.Font.Bold = True
TextBox_Qté_sto.BackColor = vbRed
Else
TextBox_Qté_sto.Font.Bold = False
TextBox_Qté_sto.BackColor = &H8000000F
End If
'Affiche le nom du fournisseur
j = 2
While Feuil11.Cells(j, 1) <> ""
If Feuil11.Cells(j, 1) = RefFrn Then
TextBox_Nom_Frn = Feuil11.Cells(j, 2)
End If
j = j + 1
Wend
Button_Valider.Visible = False
Button_Créer.Visible = True
End Sub
Private Sub TextBox_Nom_frn_Change()
'Affiche le nom du fournisseur
j = 2
While Feuil11.Cells(j, 1) <> ""
If Feuil11.Cells(j, 2) = TextBox_Nom_Frn Then
RefFrn = Feuil11.Cells(j, 1)
TextBox_Num_Frn = RefFrn
Exit Sub
End If
j = j + 1
Wend
End Sub
Private Sub CheckBox_Frn_Click()
If CheckBox_Frn = True Then
Frame3.Visible = True
Else
Frame3.Visible = False
End If
End Sub
Private Sub CheckBox_Réappro_Click()
If CheckBox_Réappro = True Then
Frame2.Visible = True
Else
Frame2.Visible = False
End If
End Sub
Private Sub Button_Créer_Click()
i = 2
While Feuil5.Cells(i, 1) <> ""
i = i + 1
Wend
SpinButton1.Value = i
Button_Créer.Visible = False
Button_Valider.Visible = True
End Sub
Private Sub Button_Valider_Click()
'Enregistre les info
If TextBox_Num_série <> "" Then
RefProd = Feuil5.Cells(i - 1, 1) + 1
Feuil5.Cells(i, 1) = RefProd
Feuil5.Cells(i, 2) = TextBox_Num_série
Feuil5.Cells(i, 3) = TextBox_Nom_prod
Feuil5.Cells(i, 4) = TextBox_Desc
Feuil5.Cells(i, 5) = TextBox_Cat
Dim Taille As Integer
If TextBox_Taille <> "" Then
Taille = TextBox_Taille
End If
Feuil5.Cells(i, 6) = Taille
Feuil5.Cells(i, 7) = 0
Seuil = TextBox_Seuil
Feuil5.Cells(i, 9) = Seuil
If TextBox_PUV <> "" Then
PUV = TextBox_PUV
End If
Feuil5.Cells(i, 11) = PUV
Feuil5.Cells(i, 12) = RefFrn
Dim PUA As Double
If TextBox_PUA <> "" Then
PUA = TextBox_PUA
End If
Feuil5.Cells(i, 13) = PUA
Délai = TextBox_Délai
Feuil5.Cells(i, 14) = Délai
End If
Button_Valider.Visible = False
Button_Créer.Visible = True
End Sub
Private Sub Button_Suppr_Click()
If RefProd <> 0 Then
Dim Msg, Style, Ctxt, Response
Msg = "Voulez vous vraiment supprimer ce produit?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(Msg, Style)
If Response = vbYes Then
Feuil5.Rows(i).Delete
i = i - 1
SpinButton1.Value = i
Else
Exit Sub
End If
End If
End Sub
Private Sub Button_Rechercher_Click()
i = 2
While Feuil5.Cells(i, 1) <> ""
If TextBox_Num_série <> "" And TextBox_Taille <> "" Then
Dim Taille As Integer
If TextBox_Taille <> "" Then
Taille = TextBox_Taille
End If
If Feuil5.Cells(i, 2) = TextBox_Num_série And Feuil5.Cells(i, 6) = Taille Then
SpinButton1.Value = i
Exit Sub
End If
End If
i = i + 1
Wend
Button_Valider.Visible = False
Button_Créer.Visible = True
End Sub
Private Sub Button_Modifier_Click()
If RefProd <> 0 Then
Dim Msg, Style, Ctxt, Response
Msg = "Voulez vous vraiment modifier ce produit?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(Msg, Style)
If Response = vbYes Then
Feuil5.Cells(i, 2) = TextBox_Num_série
Feuil5.Cells(i, 3) = TextBox_Nom_prod
Feuil5.Cells(i, 4) = TextBox_Desc
Feuil5.Cells(i, 5) = TextBox_Cat
Dim Taille As Integer
If TextBox_Taille <> "" Then
Taille = TextBox_Taille
End If
Feuil5.Cells(i, 6) = Taille
Qté_sto = TextBox_Qté_sto
Feuil5.Cells(i, 7) = Qté_sto
Seuil = TextBox_Seuil
Feuil5.Cells(i, 9) = Seuil
If TextBox_PUV <> "" Then
PUV = TextBox_PUV
End If
Feuil5.Cells(i, 11) = PUV
Feuil5.Cells(i, 12) = RefFrn
Dim PUA As Double
If TextBox_PUA <> "" Then
PUA = TextBox_PUA
End If
Feuil5.Cells(i, 13) = PUA
Délai = TextBox_Délai
Feuil5.Cells(i, 14) = Délai
Else
Exit Sub
End If
End If
Button_Valider.Visible = False
Button_Créer.Visible = True
End Sub
Private Sub Button_Quitter_Click()
Button_Créer.Visible = True
Button_Valider.Visible = False
UserForm5_stock_plomb.Hide
End Sub |
Partager