Private Sub CommandButton1_Click()
'Mise à jour du stock et archivage du mouvement
i = CLng(TextBox1.Value)
j = CLng(TextBox3.Value)
r = LIBELLE(i)
S = ROWREF(i)
If Sortie Then
x = Worksheets("Bon de pret").Range("A65536").End(xlUp).Row + 1
Worksheets("Bon de pret").Cells(x, 1) = i
Worksheets("Bon de pret").Cells(x, 2) = r
Worksheets("Bon de pret").Cells(x, 4) = TextBox4.Value
Worksheets("Bon de pret").Cells(x, 5) = TextBox5.Value
Worksheets("Bon de pret").Cells(x, 3) = j
Worksheets("Bon de pret").Cells(x, 3) = j
Worksheets("BD produits").Cells(S, 3) = Worksheets("BD produits").Cells(S, 3) - j
End If
If Réappro = False Then
If Worksheets("BD produits").Cells(S, 3) <= 0 Then
UserForm1.SpinButton1.Enabled = False
MsgBox "Stock insuffisant, voulez vous forcer la saisie"
End If
End If
If Réappro Then
x = Worksheets("Réappro").Range("A65536").End(xlUp).Row + 1
Worksheets("Réappro").Cells(x, 1) = i
Worksheets("Réappro").Cells(x, 2) = r
Worksheets("Réappro").Cells(x, 4) = ComboBox1.Value
Worksheets("Réappro").Cells(x, 7) = TextBox4.Value
Worksheets("Réappro").Cells(x, 6) = TextBox5.Value
Worksheets("Réappro").Cells(x, 5) = Date
Worksheets("Réappro").Cells(x, 3) = j
Worksheets("Réappro").Cells(x, 3) = j
Worksheets("BD produits").Cells(S, 3) = Worksheets("BD produits").Cells(S, 3) + j
If Worksheets("BD produits").Cells(S, 3) <= 0 Then
MsgBox "Stock négatif, Attention le stock est toujours négatif", vbCritical, "Gestion du stock"
End If
End If
Unload Me
End Sub