Problème avec objet

[Résolu]
Signaler
Messages postés
15
Date d'inscription
lundi 5 janvier 2009
Statut
Membre
Dernière intervention
6 janvier 2013
-
Messages postés
15
Date d'inscription
lundi 5 janvier 2009
Statut
Membre
Dernière intervention
6 janvier 2013
-
Salut j'ai un objet qui est un étudiant je veux avoir les information de mon étudiant au formload mais je suis incapable mon code est :

Voila ma form(gestion)

Public Class Gestion
'instanciation d'une éleve....
Dim x As New Eleve
Dim action As String

Private Sub cmdajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdajouter.Click
grpetu.Enabled = True
grpnavigation.Enabled = False
grpsupetrech.Enabled = False
cmdajouter.Enabled = False
cmdsupp.Enabled = False
cmdlister.Enabled = False
cmdmoyenne.Enabled = False
cmdrechercher.Enabled = False
cmdmodifier.Enabled = False
cmdannuler.Enabled = True
cmdok.Enabled = True
txtda.Enabled = True
action = "ajouter"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(x.NbEtu)
End Sub

Private Sub cmdok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdok.Click
If action = "ajouter" Then
If x.AjouterEleve(txtda.Text, txtnom.Text, txtprenom.Text, cbosexe.Items.ToString(), txtville.Text, nudcourreussi.Value, nudmoyenne.Value, cbostatut.Items.ToString()) = True Then
MsgBox("Élève ajouter avec succèes.")
txtda.Clear()
txtnom.Clear()
txtprenom.Clear()
txtville.Clear()
txtda.Enabled = False
End If
End If
If action = "supp" Then
x.supprimereleve(txt2nom.Text, txt2prenom.Text)
End If
cmdannuler.PerformClick()
End Sub

Private Sub cmdannuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdannuler.Click
grpnavigation.Enabled = True
grpsupetrech.Enabled = True
grpetu.Enabled = False
cmdajouter.Enabled = True
cmdsupp.Enabled = True
cmdlister.Enabled = True
cmdmoyenne.Enabled = True
cmdrechercher.Enabled = True
cmdmodifier.Enabled = True
cmdannuler.Enabled = False
cmdok.Enabled = False
End Sub

Private Sub cmdpremier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdpremier.Click
x.premier()
End Sub

Private Sub cmdsupp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsupp.Click
grpsupetrech.Enabled = True
txt2da.Enabled = False
grpnavigation.Enabled = False
cmdajouter.Enabled = False
cmdsupp.Enabled = False
cmdlister.Enabled = False
cmdmoyenne.Enabled = False
cmdrechercher.Enabled = False
cmdmodifier.Enabled = False
cmdannuler.Enabled = True
cmdok.Enabled = True
action = "supp"
End Sub

Private Sub Gestion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
grpetu.Enabled = False
grpsupetrech.Enabled = False
End Sub
End Class


et mon objet :

Imports System.IO

Structure etu

Public da As String
Public nom As String
Public prenom As String
Public sexe As String
Public ville As String
Public NbCourReussi As Integer
Public moyenne As Single
Public status As String

End Structure


Public Class Eleve
'Variable
Private e1 As etu
Private e2 As etu
Private tabeleve As New ArrayList

'Propriété

Public ReadOnly Property NbEtu() As Integer
Get
Return tabeleve.Count
End Get
End Property

'Méthode
Public Function AjouterEleve(ByVal da As String, ByVal nom As String, ByVal prenom As String, ByVal sexe As String, ByVal ville As String, ByVal nbcourreeusi As Integer, ByVal moyenne As Single, ByVal status As String)
e1.da = da
e1.nom = nom
e1.prenom = prenom
e1.sexe = sexe
e1.ville = ville
e1.NbCourReussi = nbcourreeusi
e1.moyenne = moyenne
e1.status = status
Try
If (trouverno(da)) = True Then
MsgBox("DA deja existant")
Return False
End If
tabeleve.Add(e1)
Return True
Catch ex As Exception
Return False
End Try
End Function

Public Sub modifiereleve()

End Sub

Public Sub supprimereleve(ByVal nom As String, ByVal prenom As String)
Dim rep As DialogResult
rep = MessageBox.Show("Voulez-vous vraiment supprimer cette étudiant ?", "supression", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
If rep = DialogResult.Yes Then
For i = 0 To tabeleve.Count - 1
If e1.nom nom And e1.prenom prenom Then
tabeleve.RemoveAt(i)
MsgBox("Éleve supprimer avec succèes")
Exit Sub
End If
Next
MsgBox("Éleve inexistant")
End If
End Sub

Public Sub listereleve()

End Sub

Public Sub recherchereleve()

End Sub

Public Sub calculermoyenne()

End Sub

Public Function premier()
Return tabeleve(0)
End Function

Private Function trouverno(ByVal n As Integer)
Dim i As Integer
For i = 0 To tabeleve.Count - 1
e2 = CType(tabeleve(i), etu)
If e2.da = n Then
Return True
End If
Next
Return False
End Function

'Private Function trouvernomprenom(ByVal nom As String, ByVal prenom As String)
' Dim i As Integer
' For i = 0 To tabeleve.Count - 1
' e2 = CType(tabeleve(i), etu)
' If e2.nom nom And e2.prenom prenom Then
' Return True
' End If
' Next
' Return False
'End Function

'CONSTRUCTEUR
Public Sub New()
'on doit remplir la liste des étudiants...
Try
Dim fs As New FileStream("etu.bin", FileMode.OpenOrCreate, FileAccess.Read)
Dim br As New BinaryReader(fs)
Do While (br.PeekChar() <> -1)
e1.da = br.ReadString()
e1.nom = br.ReadString()
e1.prenom = br.ReadString()
e1.sexe = br.ReadString()
e1.ville = br.ReadString()
e1.NbCourReussi = br.ReadUInt32()
e1.moyenne = br.ReadSingle()
e1.status = br.ReadString()
tabeleve.Add(e1)
Loop
br.Close()
fs.Close()
Catch ex As Exception
MsgBox("try sub new")
MsgBox(ex.Message)
End Try

End Sub


'DESTRUCTEUR
Protected Overrides Sub finalize()
'on doit remplir la liste des étudiant
Dim fs As New FileStream("etu.bin", FileMode.Create, FileAccess.Write)
Dim bw As New BinaryWriter(fs)
'boucle sur la liste
Dim i As Integer
For i = 0 To tabeleve.Count - 1
e2 = CType(tabeleve(i), etu)
bw.Write(e2.da)
bw.Write(e2.nom)
bw.Write(e2.prenom)
bw.Write(e2.sexe)
bw.Write(e2.ville)
bw.Write(e2.NbCourReussi)
bw.Write(e2.moyenne)
bw.Write(e2.status)
Next
bw.Close()
fs.Close()
End Sub

'Événement

Public Event BesoinProf(ByVal prof As String)

Public Event DiplomeObtenue(ByVal diplome As String)

Public Event EchecEleve(ByVal echec As String)

End Class

donc la question c'est comment faire pour remplis mais textbox avec un arraylist private et des étudiant private ? Merci beaucoup pour votre aide...

1 réponse

Messages postés
15
Date d'inscription
lundi 5 janvier 2009
Statut
Membre
Dernière intervention
6 janvier 2013

j'ai réglé mon problème a+