Probleme supprimer et modifier
3alamokom
-
heyquem Messages postés 808 Statut Membre -
heyquem Messages postés 808 Statut Membre -
Bonjour,
mon application est composé de 4 formes
une principale
une pour l'ajout
une pour modifier
une pour supprimer
une classe
le code de la forme ajouter est :
Public Class Ajouter
Public Sub Vider()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
DateTimePicker1.Value = Now
ListBox1.ClearSelected()
TextBox1.Select()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Se As String
Dim Drapo As Boolean = False
For i = 0 To t.Count - 1
If TextBox1.Text = t(i).Get_N Then
Drapo = True
End If
Next
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champ", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le groupe", 0 + 16, "Attention")
ElseIf Drapo = True Then
MsgBox("Le num d'inscription est déja existé")
Else
If RadioButton1.Checked = True Then
Se = "M"
Else
Se = "F"
End If
O = New Etudiant(TextBox1.Text, TextBox2.Text, TextBox3.Text, Se, ComboBox1.Text, ListBox1.Text, DateTimePicker1.Text)
t.Add(O)
MsgBox("L'ajout effectué avec succès")
n = n + 1
End If
Vider()
End Sub
Private Sub Ajouter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 7 To 100
ComboBox1.Items.Add(i)
Next
For i = 1 To 100
ListBox1.Items.Add(i)
Next
DateTimePicker1.MinDate = Now
TextBox1.Select()
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Vider()
End Sub
End Class
le code du button modifier dans une autre forme est:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Se As String
Dim Drapo As Boolean = False
For i = 0 To t.Count - 1
If TextBox1.Text = t(i).Get NThen
Drapo = True
End If
Next
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champ", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le groupe", 0 + 16, "Attention")
ElseIf Drapo = True Then
MsgBox("Le num d'inscription est déja existé")
Else
If RadioButton1.Checked = True Then
Se = "M"
Else
Se = "F"
End If
o = New etudiant (TextBox1.Text, TextBox2.Text, TextBox3.Text, Se, ComboBox1.Text, Se,ListBox1.Text, DateTimePicker1.Text)
t.Add(o)
MsgBox("L'ajout effectué avec succès")
vider()
n = n + 1
End If
End Sub
le code du forme modifier est:
Public Class Modifier
'declaration
Dim p As Integer = -1
Public Sub Vider()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
DateTimePicker1.Value = Now
TextBox1.Select()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'recherche
For i = 0 To t.Count - 1
If Val(TextBox1.Text) = t(i).Get_N Then
p = i
End If
Next
'teste et affichage de resultats
If TextBox1.Text = "" Then
MsgBox("Remplire le champ", 0 + 48, "Attention")
ElseIf p = -1 Then
MsgBox("L'etudiant n'existe pas", 0 + 16, "Attention")
Else
TextBox2.Text = t(p)._Nom
TextBox3.Text = t(p)._Prénom
ComboBox1.Text = t(p)._age
If t(p)._sexe = "M" Then
RadioButton1.Checked = True
Else
RadioButton2.Checked = True
End If
ListBox1.Text = (t(p)._groupe)
DateTimePicker1.Text = t(p)._dateInscription
Me.Height = 351
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Vider()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim se As String
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champs", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'Age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le Sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le Groupe", 0 + 16, "Attention")
Else
If RadioButton1.Checked = True Then
se = "M"
Else
se = "F"
End If
O = New Etudiant(TextBox1.Text, TextBox2.Text, TextBox3.Text, ComboBox1.Text, ListBox1.Text, DateTimePicker1.Text)
t(p) = O
MsgBox("Modifications effectués avec succès")
Vider()
n = n + 1
Me.Height = 67
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Modifier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 7 To 100
ComboBox1.Items.Add(i)
Next
For i = 1 To 100
ListBox1.Items.Add(i)
Next
DateTimePicker1.MinDate = Now
Me.Height = 67
End Sub
code de la classe est :
<Serializable()> Public Class Etudiant
'les atributs
Public _N As Integer
Public _Nom As String
Public _Prénom As String
Public _dateInscription As Date
Public _sexe As String
Public _groupe As Integer
Public _age As Double
'les constructeurs
Private Sub New()
End Sub
Private Sub New(ByVal _N As Integer, ByVal _Nom As String, ByVal _Prénom As String, ByVal _dateInscription As Date, ByVal _sexe As String, ByVal _groupe As Integer, ByVal _age As Double)
Me._N = _N
Me._Nom = _Nom
Me._Prénom = _Prénom
Me._dateInscription = _dateInscription
Me._sexe = _sexe
Me._groupe = _groupe
Me._age = _age
End Sub
'getters
Public Function Get_N() As Integer
Return _N
End Function
'les methodes
End Class
End Class
code de module est:
Module Module1
Public t As New ArrayList
Public n As Integer 'responsable de nbr des etud
Public O As Etudiant
End Module
mon application est composé de 4 formes
une principale
une pour l'ajout
une pour modifier
une pour supprimer
une classe
le code de la forme ajouter est :
Public Class Ajouter
Public Sub Vider()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
DateTimePicker1.Value = Now
ListBox1.ClearSelected()
TextBox1.Select()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Se As String
Dim Drapo As Boolean = False
For i = 0 To t.Count - 1
If TextBox1.Text = t(i).Get_N Then
Drapo = True
End If
Next
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champ", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le groupe", 0 + 16, "Attention")
ElseIf Drapo = True Then
MsgBox("Le num d'inscription est déja existé")
Else
If RadioButton1.Checked = True Then
Se = "M"
Else
Se = "F"
End If
O = New Etudiant(TextBox1.Text, TextBox2.Text, TextBox3.Text, Se, ComboBox1.Text, ListBox1.Text, DateTimePicker1.Text)
t.Add(O)
MsgBox("L'ajout effectué avec succès")
n = n + 1
End If
Vider()
End Sub
Private Sub Ajouter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 7 To 100
ComboBox1.Items.Add(i)
Next
For i = 1 To 100
ListBox1.Items.Add(i)
Next
DateTimePicker1.MinDate = Now
TextBox1.Select()
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Vider()
End Sub
End Class
le code du button modifier dans une autre forme est:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Se As String
Dim Drapo As Boolean = False
For i = 0 To t.Count - 1
If TextBox1.Text = t(i).Get NThen
Drapo = True
End If
Next
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champ", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le groupe", 0 + 16, "Attention")
ElseIf Drapo = True Then
MsgBox("Le num d'inscription est déja existé")
Else
If RadioButton1.Checked = True Then
Se = "M"
Else
Se = "F"
End If
o = New etudiant (TextBox1.Text, TextBox2.Text, TextBox3.Text, Se, ComboBox1.Text, Se,ListBox1.Text, DateTimePicker1.Text)
t.Add(o)
MsgBox("L'ajout effectué avec succès")
vider()
n = n + 1
End If
End Sub
le code du forme modifier est:
Public Class Modifier
'declaration
Dim p As Integer = -1
Public Sub Vider()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
DateTimePicker1.Value = Now
TextBox1.Select()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'recherche
For i = 0 To t.Count - 1
If Val(TextBox1.Text) = t(i).Get_N Then
p = i
End If
Next
'teste et affichage de resultats
If TextBox1.Text = "" Then
MsgBox("Remplire le champ", 0 + 48, "Attention")
ElseIf p = -1 Then
MsgBox("L'etudiant n'existe pas", 0 + 16, "Attention")
Else
TextBox2.Text = t(p)._Nom
TextBox3.Text = t(p)._Prénom
ComboBox1.Text = t(p)._age
If t(p)._sexe = "M" Then
RadioButton1.Checked = True
Else
RadioButton2.Checked = True
End If
ListBox1.Text = (t(p)._groupe)
DateTimePicker1.Text = t(p)._dateInscription
Me.Height = 351
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Vider()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim se As String
'test
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Remplir tous les champs", 0 + 16, "Attention")
ElseIf ComboBox1.Text = "" Then
MsgBox("Selectioner l'Age", 0 + 16, "Attention")
ElseIf RadioButton1.Checked = False And RadioButton2.Checked = False Then
MsgBox("Selectioner le Sexe", 0 + 16, "Attention")
ElseIf ListBox1.Text = "" Then
MsgBox("Selectioner le Groupe", 0 + 16, "Attention")
Else
If RadioButton1.Checked = True Then
se = "M"
Else
se = "F"
End If
O = New Etudiant(TextBox1.Text, TextBox2.Text, TextBox3.Text, ComboBox1.Text, ListBox1.Text, DateTimePicker1.Text)
t(p) = O
MsgBox("Modifications effectués avec succès")
Vider()
n = n + 1
Me.Height = 67
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Modifier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 7 To 100
ComboBox1.Items.Add(i)
Next
For i = 1 To 100
ListBox1.Items.Add(i)
Next
DateTimePicker1.MinDate = Now
Me.Height = 67
End Sub
code de la classe est :
<Serializable()> Public Class Etudiant
'les atributs
Public _N As Integer
Public _Nom As String
Public _Prénom As String
Public _dateInscription As Date
Public _sexe As String
Public _groupe As Integer
Public _age As Double
'les constructeurs
Private Sub New()
End Sub
Private Sub New(ByVal _N As Integer, ByVal _Nom As String, ByVal _Prénom As String, ByVal _dateInscription As Date, ByVal _sexe As String, ByVal _groupe As Integer, ByVal _age As Double)
Me._N = _N
Me._Nom = _Nom
Me._Prénom = _Prénom
Me._dateInscription = _dateInscription
Me._sexe = _sexe
Me._groupe = _groupe
Me._age = _age
End Sub
'getters
Public Function Get_N() As Integer
Return _N
End Function
'les methodes
End Class
End Class
code de module est:
Module Module1
Public t As New ArrayList
Public n As Integer 'responsable de nbr des etud
Public O As Etudiant
End Module
A voir également:
- Probleme supprimer et modifier
- Supprimer rond bleu whatsapp - Guide
- Modifier dns - Guide
- Modifier liste déroulante excel - Guide
- Supprimer page word - Guide
- Modifier extension fichier - Guide