253 lines
12 KiB
VB.net
253 lines
12 KiB
VB.net
Public Class FrmInput1
|
|
Dim agea As Integer REM en années (entière), calculé a partir de agem
|
|
Dim agemin, agemax As Integer REM Intervalle de l'age, calculé a partir d'aujourd'hui - AGEMAX:25 AGEMIN:55
|
|
|
|
Private Sub FrmIsc2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
agemin = auj - (56 * 12) REM Permet aux personnes ayant 55 ans et quelques mois de se présenter. 56 ans pile est une valeur exclue : Df=[25, 56[
|
|
agemax = auj - (25 * 12)
|
|
SBHAge.Maximum = agemax + (SBHAge.LargeChange - SBHAge.SmallChange) + 6 REM Réajuste la scrollbar pour toujours donner un age dans l'interval.
|
|
SBHAge.Minimum = agemin + 12 REM Réajuste la scrollbar pour toujours donner un age dans l'interval.
|
|
End Sub
|
|
|
|
Private Sub FrmInput1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
|
|
|
|
End Sub
|
|
|
|
Private Sub FrmInput1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
|
|
If Me.Visible Then
|
|
If Boule = True Then REM true == édition
|
|
Me.Tag = "Assistant édition de candidature (2/4)"
|
|
Lbl1.Text = "Editez votre identité ici :"
|
|
TxtNom.Text = cddts.Nom
|
|
TxtPrenom.Text = cddts.Prenom
|
|
TxtAdrss.Text = cddts.Adresse
|
|
TxtCP.Text = cddts.CP
|
|
TxtVille.Text = cddts.Ville
|
|
TxtMois.Text = cddts.Age Mod 12
|
|
TxtAns.Text = cddts.Age \ 12
|
|
Call conv(cddts.Age, 0)
|
|
If cddts.Age > SBHAge.Minimum And cddts.Age <= SBHAge.Maximum Then SBHAge.Value = cddts.Age
|
|
LblID.Visible = True
|
|
LblID.Text = "Id : " & Format(Selectedclef, "00") REM met d'ID en cas d'édition.
|
|
End If
|
|
If Boule = False Then REM false == inscription
|
|
Me.Tag = "Assistant création de candidature (2/4)"
|
|
Lbl1.Text = "Renseignez votre identité ici :"
|
|
TxtNom.Text = ""
|
|
TxtPrenom.Text = ""
|
|
TxtAdrss.Text = ""
|
|
TxtCP.Text = ""
|
|
TxtVille.Text = ""
|
|
SBHAge.Value = SBHAge.Minimum
|
|
TxtMois.Text = Today.Month
|
|
TxtAns.Text = Today.Year
|
|
LblAns.Text = "Aujourd'hui"
|
|
LblID.Visible = False
|
|
End If
|
|
LblCaR.Tag = 60
|
|
Me.Text = Me.Tag & " | " & Horaire & " | Temps restant : 1:00"
|
|
TmrCaR.Start() REM lancement du timer
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub CmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNext.Click
|
|
Dim OK As Boolean = True REM Retourne un état d'erreur ou non, de manière général.
|
|
Dim ChkNom, Chkprenom, ChkCP, ChkVille, ChkMois, chkAge, chkCP00 As Boolean REM retourne un état d'erreur pour tout les tests.
|
|
Dim cp As Integer
|
|
|
|
REM Par defaut, il n'y a pas d'erreur, donc OK = TRUE, et tout les checks = FALSE.
|
|
REM Initialisation des test
|
|
ChkNom = False
|
|
Chkprenom = False
|
|
ChkCP = False
|
|
ChkVille = False
|
|
ChkMois = False
|
|
chkAge = False
|
|
chkCP00 = False
|
|
CmdNext.Tag = ""
|
|
|
|
REM Cas particulier : pour bien tester le Code Postal ("00" interdit), il faut une sécurité contre les chaines vides.
|
|
If TxtCP.Text.Length >= "2" Then cp = Microsoft.VisualBasic.Left(TxtCP.Text, 2)
|
|
|
|
If TxtNom.Text = "" Then REM Le nom est vide
|
|
ChkNom = True
|
|
OK = False
|
|
LblNom.Tag = "• La saisie du nom n'a pas été effectuée."
|
|
LblNom.ForeColor = Color.Red
|
|
End If
|
|
If TxtPrenom.Text = "" Then REM Le prénom est vide
|
|
Chkprenom = True
|
|
OK = False
|
|
LblPrenom.Tag = "• La saisie du prénom n'a pas été effectuée."
|
|
LblPrenom.ForeColor = Color.Red
|
|
End If
|
|
If TxtCP.TextLength < 5 Then REM Le Code Postal ne fait pas 5 caractères.
|
|
ChkCP = True
|
|
OK = False
|
|
LblCP.Tag = "• La saisie du code postal est vide ou incomplète."
|
|
LblCP.ForeColor = Color.Red
|
|
End If
|
|
If cp = 0 Then REM Le Code Postal commence par 00
|
|
chkCP00 = True
|
|
OK = False
|
|
TxtCP.Tag = "• Le code postal ne peut commencer par '00'."
|
|
LblCP.ForeColor = Color.Red
|
|
End If
|
|
If TxtVille.Text = "" Then REM La ville est vide.
|
|
ChkVille = True
|
|
OK = False
|
|
LblVille.Tag = "• La saisie de la ville n'a pas été effectuée."
|
|
LblVille.ForeColor = Color.Red
|
|
End If
|
|
If (nais > agemax Or nais <= agemin) And ChkMois = False Then REM L'age n'est pas dans [25; 56[
|
|
chkAge = True
|
|
OK = False
|
|
LblAns.Tag = "• L'age n'est pas compris entre 25 et 55 ans."
|
|
LblAns.ForeColor = Color.Red
|
|
LblAge.ForeColor = Color.Red
|
|
End If
|
|
If OK = False Then REM Cette partie prépare la MSGBOX a afficher.
|
|
|
|
If ChkNom Then CmdNext.Tag = LblNom.Tag & vbNewLine
|
|
If Chkprenom Then CmdNext.Tag = CmdNext.Tag & LblPrenom.Tag & vbNewLine
|
|
If ChkCP Then CmdNext.Tag = CmdNext.Tag & LblCP.Tag & vbNewLine
|
|
If chkCP00 Then CmdNext.Tag = CmdNext.Tag & TxtCP.Tag & vbNewLine
|
|
If ChkVille Then CmdNext.Tag = CmdNext.Tag & LblVille.Tag & vbNewLine
|
|
If ChkMois Then CmdNext.Tag = CmdNext.Tag & TxtMois.Tag & vbNewLine
|
|
If chkAge Then CmdNext.Tag = CmdNext.Tag & LblAns.Tag & vbNewLine
|
|
MsgBox("Les erreurs suivantes se sont produites : " & vbNewLine & vbNewLine & CmdNext.Tag, MsgBoxStyle.Exclamation, "Erreur")
|
|
End If
|
|
|
|
REM Après quoi, OK permet de continuer ou de rester.
|
|
If OK Then
|
|
TmrCaR.Stop() REM fin du timer
|
|
Me.Hide() REM cache feuille courante
|
|
FrmInput2.Show() REM montre feuille ajout
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CmdAnnul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdAnnul.Click
|
|
TmrCaR.Stop() REM arret du timer
|
|
FrmEdit.Close() REM ferme toutes les pages précédentes
|
|
FrmNouv.Close()
|
|
Me.Close() REM ferme la page courante
|
|
FrmAccueil.Show() REM retour a la page d'accueil (show)
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub TxtCP_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCP.KeyPress, TxtMois.KeyPress, TxtAns.KeyPress
|
|
If e.KeyChar = vbBack Then
|
|
Exit Sub
|
|
End If
|
|
If e.KeyChar < "0" Or e.KeyChar > "9" Then REM On peut utiliser aussi Not IsNumeric(<Objet>)
|
|
e.KeyChar = Chr(0)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SBHAge_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles SBHAge.Scroll
|
|
agea = SBHAge.Value \ 12 REM convertis les mois en années.
|
|
TxtAns.Text = agea REM l'affiche
|
|
Call conv(Today.Month, agea) REM convertit pour l'affichage de l'age.
|
|
TxtMois.Text = Today.Month REM remet le mois au mois pivot, pour ne pas créer d'erreur et parceque la scrollbar ne permet pas de choisir des mois, mais des années.
|
|
LblAge.ForeColor = Color.Black REM Comme une valeur choisit par la scrollbar est toujours juste, il ne peut y avoir d'erreur.
|
|
LblAns.ForeColor = Color.Black REM idem.
|
|
End Sub
|
|
|
|
Private Sub TxtMois_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtMois.LostFocus, TxtAns.LostFocus
|
|
Dim ans As Integer
|
|
Dim mois As Integer
|
|
ans = TxtAns.Text
|
|
mois = TxtMois.Text
|
|
|
|
If mois > 12 Then TxtMois.Text = 12 REM Empèche de mettre des mois supérieur a 12
|
|
If mois < 1 Then TxtMois.Text = 1 REM et inférieur a 1
|
|
|
|
Call conv(mois, ans) REM convertit les valeurs entrée pour l'affichage.
|
|
If nais > agemin And nais <= agemax Then REM Remet en noir si dans l'interval
|
|
LblAge.ForeColor = Color.Black
|
|
LblAns.ForeColor = Color.Black
|
|
End If
|
|
If nais > SBHAge.Minimum And nais <= SBHAge.Maximum Then SBHAge.Value = nais REM replace la scrollbar si dans l'inteval de celle-ci.
|
|
End Sub
|
|
|
|
'Private Sub Txtans_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtAns.LostFocus
|
|
' If nais >= SBHAge.Minimum And nais <= SBHAge.Maximum Then
|
|
' SBHAge.Value = nais
|
|
' End If
|
|
'End Sub
|
|
|
|
REM Cette fonction permet de convertir et d'afficher des mois ou des années,mois en années. Elle prend un delta de mois, un mois ou un année,mois.
|
|
Function conv(ByRef mois As Integer, ByRef annee As Integer) As Integer
|
|
nais = annee * 12 + mois
|
|
'agem = auj - nais REM Pour le développement.
|
|
agea = (auj - nais) \ 12
|
|
LblAns.Text = agea & " ans"
|
|
End Function
|
|
|
|
Private Sub TxtNom_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtNom.KeyPress, TxtPrenom.KeyPress, TxtVille.KeyPress
|
|
Dim car As String = "&é'(-è_çà)=~#{[|`\^@]},;:!ù*^$?./§%µ²¨£¤<>éèëêùûüìîïòôöâàä"
|
|
If InStr(car, e.KeyChar) Then
|
|
e.KeyChar = Chr(0)
|
|
Exit Sub
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TxtAdrss_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtAdrss.KeyPress
|
|
Dim car As String = "&é'(-_)=~#{[|`\^@]},;:!*^$?./§%µ¨£¤<>²"
|
|
If InStr(car, e.KeyChar) Then
|
|
e.KeyChar = Chr(0)
|
|
Exit Sub
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub txtNom_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtNom.LostFocus
|
|
If TxtNom.Text <> "" Then LblNom.ForeColor = Color.Black
|
|
End Sub
|
|
|
|
Private Sub txtPrenom_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtPrenom.LostFocus
|
|
If TxtPrenom.Text <> "" Then LblPrenom.ForeColor = Color.Black
|
|
End Sub
|
|
|
|
Private Sub txtCP_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtCP.LostFocus
|
|
If TxtCP.TextLength = 5 Then LblCP.ForeColor = Color.Black
|
|
End Sub
|
|
|
|
Private Sub txtVille_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtVille.LostFocus
|
|
If TxtVille.Text <> "" Then LblVille.ForeColor = Color.Black
|
|
End Sub
|
|
|
|
Private Sub TmrCaR_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TmrCaR.Tick
|
|
LblCaR.Tag -= 1 REM décremente le temps
|
|
Me.Text = Me.Tag & " | " & Horaire & " | Temps restant : " & LblCaR.Tag REM Indicateur compte a rebourt pour la barre de titre
|
|
|
|
REM condition d'affichage divers :
|
|
If LblCaR.Tag <= 1 Then
|
|
LblCaR.Text = "Vous disposez de " & LblCaR.Tag & " seconde."
|
|
End If
|
|
If LblCaR.Tag < 60 And LblCaR.Tag <> 1 Then
|
|
LblCaR.Text = "Vous disposez de " & LblCaR.Tag & " secondes."
|
|
End If
|
|
If LblCaR.Tag <= 10 Then
|
|
LblCaR.ForeColor = Color.Red
|
|
End If
|
|
If LblCaR.Tag <= 0 Then REM temps écoulé
|
|
TmrCaR.Stop() REM arret du timer
|
|
LblCaR.Text = "Le temps impartie est écoulé."
|
|
MsgBox("Le temps impartie est écoulé. L'inscription a échoué.", MsgBoxStyle.Exclamation, "Echec")
|
|
FrmEdit.Close() REM ferme les feuilles précédement fermés
|
|
FrmNouv.Close() REM : Est-il necessaire de tester la feuille a fermer en fonction de l'état de boule ?
|
|
Me.Close() REM ferme la feuille pour la réinitialiser
|
|
FrmAccueil.Show() REM retour a l'accueil
|
|
End If
|
|
End Sub
|
|
|
|
End Class |