Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'AJOUT
- Private Sub btnAjouterModeleFormation_Click(sender As Object, e As EventArgs) Handles btnAjouterModeleFormation.Click
- 'Si la textbox n'est pas vide
- If txtNomModeleFormation.Text <> Nothing Then
- 'Si on veut ajouter l'élément
- If MsgBox("Cet élément sera ajouté. Continuer ?", vbYesNo, "Message") = vbYes Then
- 'Si la dgv est vide on ajoute quoi qu'il arrive
- If lbxModeleFormation.Items.Count() = 0 Then
- ajouterModeleFormation()
- afficherListeModeleFormations()
- 'Si la dgv n'est pas vide on vérifie si l'élément entré existe déjà
- Else
- Dim count = 0
- For i = 0 To lbxCacheModeleFormation.Items.Count() - 1
- If lbxCacheModeleFormation.Items(i).nomModele = txtNomModeleFormation.Text Then
- MsgBox("Cet élément existe déjà.", vbExclamation, "Erreur")
- Exit For
- Else
- count += 1
- End If
- If count = lbxCacheModeleFormation.Items.Count() Then
- ajouterModeleFormation()
- afficherListeModeleFormations()
- End If
- Next
- End If
- End If
- 'Si la textbox est vide on met un message d'erreur
- Else
- MsgBox("Veuillez insérer un nom de Formation.", vbExclamation, "Erreur")
- End If
- 'On rafraîchit la textbox
- End Sub
- 'MODIFICATION
- Private Sub btnModifierModeleFormation_Click(sender As Object, e As EventArgs) Handles btnModifierModeleFormation.Click
- Dim modeleFormation As New ModeleFormation()
- 'Si les textbox sont vides il y a un message d'erreur
- If txtNomModeleFormation.Text = "" Then
- MsgBox(" Veuillez entrer des valeurs dans les champs.", vbExclamation, "Erreur")
- 'Sinon on cherche si la valeur existe déjà dans la dgv
- ElseIf MsgBox("Voulez-vous modifier cet élément ?", vbYesNo, "Confirmation") = vbYes Then
- If lbxModeleFormation.SelectedItem.nomModele = txtNomModeleFormation.Text Then
- modifierModeleFormation(1)
- afficherListeModeleFormations()
- Else
- Dim count = 0
- For i = 0 To lbxCacheModeleFormation.Items.Count() - 1
- If txtNomModeleFormation.Text = lbxCacheModeleFormation.Items(i).nomModele Then
- MsgBox(" Le nom de modèle entré est déjà présent dans les modèles formation, veuillez choisir un autre nom.", vbExclamation, "Erreur")
- Exit For
- Else
- count += 1
- End If
- If count = lbxCacheModeleFormation.Items.Count() Then
- modifierModeleFormation(2)
- afficherListeModeleFormations()
- End If
- Next
- End If
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement