Candidate-7-Pro/Module1.vb

249 lines
8.8 KiB
VB.net

Module Module1
Structure PERS
<VBFixedString(8)> Dim Nom As String
<VBFixedString(6)> Dim Prenom As String
<VBFixedString(10)> Dim Adresse As String
<VBFixedString(5)> Dim CP As Integer
<VBFixedString(15)> Dim Ville As String
<VBFixedString(5)> Dim Age As Integer REM Stocke la date de naissance en mois (plus facile pour convertir après)
<VBFixedString(1)> Dim Region As Integer REM Stocke l'index
<VBFixedArray(3)> Dim Ecrit() As Integer REM index
<VBFixedArray(2)> Dim Oral() As Integer REM index
<VBFixedString(2)> Dim Fac As Integer REM Stocke l'index
End Structure
Structure Index
'Dim no As Integer
Dim nom As String
Dim prenom As String
Dim Suppr As Boolean
End Structure
Public tme() As String = {"Lancer", "Natation", "Saut", "Allemand", "Anglais", "Astronomie", "Espagnol", "Histoire", "Russe", "Biologie", "Français", "Géographie", "Géologie", "Mathématique", "Philosophie"}
Public treg() As String = {"Auvergne", "Bordelais", "Bretagne", "Morvan", "Nord", "Normandie", "Paris", "Poitou"}
Public nais As Integer REM en mois. ANS*12 + MOIS
Public cddts As PERS REM sert de "Tampon" entre les données entrées dans les feuilles et le fichier.
Public Tindex() As Index REM Sert pour le bilan des supprimés, et pour générer la liste des candidats valides (sans consulter le fichier).
Public Boule As Boolean REM Boule sert a deux choses : 0 Inscription d'un candidat, 1 Edition d'un candidats car ont passe par les même fenetres des Input.
' REM 0 Pour consultation des Bilans, 1 pour consultation avant de Quitter, car ont passe aussi par les mêmes fenetres des Bilans.
Public Horaire As String REM Sert a stoquer l'heure pour les autres fenetres dont le timer empèche un affichage normal.
Public nf As Integer REM Numéro de flux.
Public lgcddts As Integer REM Sert a obtenir la bonne longueur.
Public ClefMAX As Integer = 1 REM Dernier/Nombre de candidats dans le Fichier.
Public PosMAX As Integer = 0 REM Dernier/Nombre de candidats dans le tableau de structure.
REM Pour s'y retrouver entre ClefMAX et PosMAX :
REM ClefMAX indique le nombre de clefs dans le fichier.
REM PosMAX indique le nombre de poste dans le tableau d'index.
REM La relation entre ces deux variables sont PosMAX = ClefMAX - 2. Le premier candidat stocké dans le fichier (clef = 2), il a la position 0 dans le fichier.
Public IndexFac As Integer REM Retient l'index de l'examen (du tableau) pour l'examen facultatif. L'ancien index retenait la position dans la CboBox, et ne correspondait pas toujours a celui du tableau.
Public Selectedclef As Integer REM Pour la feuille FrmEdit : elle contient le n° d'inscription choisit donné par l'utilisateur
Public auj As Integer REM en mois. Today.Year*12 + Today.Month
Public UbdE As Integer REM Comme il y a beaucoup de test Ubound(cddts.ecrit) autant mettre ca dans une variable et l'utilser directement.
Public UbdO As Integer REM idem pour le tableau d'oral.
Public Sub InscBdD()
If PosMAX - 1 >= UBound(Tindex) Then
ReDim Preserve Tindex(PosMAX + 2)
End If
REM Entrée depuis la feuille 1
cddts.Nom = FrmInput1.TxtNom.Text
cddts.Prenom = FrmInput1.TxtPrenom.Text
cddts.Adresse = FrmInput1.TxtAdrss.Text
cddts.CP = FrmInput1.TxtCP.Text
cddts.Ville = FrmInput1.TxtVille.Text
cddts.Age = nais
'Tindex(ClefMAX - 2).no = ClefMAX
Tindex(PosMAX).nom = cddts.Nom
Tindex(PosMAX).prenom = cddts.Prenom
REM Entrée depuis la feuille 2
cddts.Region = FrmInput2.CboRegion.SelectedIndex
Dim b As CheckBox
Dim j As Integer = 0
Dim i As Integer = 0
For Each b In FrmInput2.GBEcrit.Controls
If b.Checked Then
cddts.Ecrit(j) = i + 3
j += 1
End If
If j >= 4 Then Exit For
i += 1
Next
j = 0
i = 0
For Each b In FrmInput2.GBOral.Controls
If b.Checked Then
cddts.Oral(j) = i
If j >= 3 Then Exit For
j += 1
End If
i += 1
Next
If FrmInput2.RBYes.Checked Then cddts.Fac = IndexFac Else cddts.Fac = -1
REM Entrée depuis la feuille 3
Tindex(PosMAX).Suppr = False
REM Sauvegarde
FilePut(nf, cddts, ClefMAX)
Dim nb As PERS
Call efface(nb, ClefMAX)
FilePut(nf, nb, 1)
ClefMAX += 1
PosMAX += 1
End Sub
Public Sub MaJBdD()
REM EST-IL NECESSAIRE DE FAIRE DES TESTS POUR VOIR DES MODIFICATIONS UTILISATEURS, OU MODIFIER TOUT DE MÊME ?
REM OUI.
REM Entrée depuis la feuille 1
cddts.Nom = FrmInput1.TxtNom.Text
cddts.Prenom = FrmInput1.TxtPrenom.Text
cddts.Adresse = FrmInput1.TxtAdrss.Text
cddts.CP = FrmInput1.TxtCP.Text
cddts.Ville = FrmInput1.TxtVille.Text
cddts.Age = nais
REM Entrée depuis la feuille 2
cddts.Region = FrmInput2.CboRegion.SelectedIndex
Dim b As CheckBox
Dim j As Integer = 0
Dim i As Integer = 0
For Each b In FrmInput2.GBEcrit.Controls
If b.Checked Then
cddts.Ecrit(j) = i + 3
j += 1
End If
If j >= 4 Then Exit For
i += 1
Next
j = 0
i = 0
For Each b In FrmInput2.GBOral.Controls
If b.Checked Then
cddts.Oral(j) = i
If j >= 3 Then Exit For
j += 1
End If
i += 1
Next
If FrmInput2.RBYes.Checked Then
cddts.Fac = IndexFac
End If
REM Sauvegarde
FilePut(nf, cddts, Selectedclef)
End Sub
Public Sub SupprBdD(ByVal ID As Integer)
Dim i As Integer = 0
Call efface(cddts, 0)
REM efface() le fait très bien.
'REM Entrée depuis la feuille 1
'cddts.Nom = ""
'cddts.Prenom = ""
'cddts.Adresse = ""
'cddts.CP = 0
'cddts.Ville = ""
'cddts.Age = 0
'REM Entrée depuis la feuille 2
'For i = 0 To UBound(cddts.Ecrit) - 1
' cddts.Ecrit(i) = 0
'Next
'For i = 0 To UBound(cddts.Oral) - 1
' cddts.Oral(i) = 0
'Next
'cddts.Fac = 0
'cddts.Region = 0
Tindex(ID - 2).Suppr = True
FilePut(nf, cddts, ID)
End Sub
Public Sub generator(ByRef CBNP As ComboBox)
Dim i As Integer
For i = 0 To PosMAX - 1 REM UBound(Tindex) -1, car le tableau est déjà alloué, mais ajoute des items vides dans CBNP.
If Tindex(i).Suppr = False Then
CBNP.Items.Add(Tindex(i).nom & " " & Tindex(i).prenom & " - " & Format(i + 2, "00"))
End If
Next i
End Sub
Function efface(ByRef Info As PERS, ByVal clef As Integer) As Boolean
ReDim Preserve Info.Ecrit(3)
ReDim Preserve Info.Oral(2)
Dim i As Integer
REM Entrée depuis la feuille 1
Info.Nom = ""
Info.Prenom = ""
Info.Adresse = ""
Info.CP = clef
Info.Ville = ""
Info.Age = 0
REM Entrée depuis la feuille 2
For i = 0 To UbdE - 1
Info.Ecrit(i) = 0
Next
For i = 0 To UbdO - 1
Info.Oral(i) = 0
Next
Info.Fac = 0
Info.Region = 0
End Function
Function DetectModif() As Boolean
Dim identique As Boolean = True
Dim i As Integer
REM Depuis frminput1
If cddts.Nom <> FrmInput1.TxtNom.Text Then identique = False
If cddts.Prenom <> FrmInput1.TxtPrenom.Text Then identique = False
If cddts.Adresse <> FrmInput1.TxtAdrss.Text Then identique = False
If cddts.CP <> FrmInput1.TxtCP.Text Then identique = False
If cddts.Ville <> FrmInput1.TxtVille.Text Then identique = False
If cddts.Age <> nais Then identique = False
Dim CB As CheckBox
i = 0
For Each CB In FrmInput2.GBEcrit.Controls
If CB.Checked Then
If CB.Text <> tme(cddts.Ecrit(i)) Then identique = False
i += 1
End If
Next
i = 0
For Each CB In FrmInput2.GBOral.Controls
If CB.Checked Then
If CB.Text <> tme(cddts.Oral(i)) Then identique = False
i += 1
End If
Next
If cddts.Fac <> IndexFac Then identique = False
If cddts.Region <> FrmInput2.CboRegion.SelectedIndex Then identique = False
Return Not identique
End Function
End Module