Candidate-7-Pro/FrmInput1.vb
2021-09-10 01:15:10 +02:00

210 lines
9.2 KiB
VB.net

Public Class FrmInput1
Public nais As Integer REM en mois. ANS*12 + MOIS
Dim auj As Integer REM en mois. Today.Year*12 + Today.Month
Dim agem As Integer REM en mois, différence entre auj et nais
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
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 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 & " | " & FrmAccueil.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
Private Sub FrmIsc2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LblCaR.Tag = 60 REM initialisation du timer
auj = Today.Year * 12 + Today.Month
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 Le +12 intervient car la Scrollbar va de 0 à 99.
SBHAge.Minimum = agemin + 12
If FrmAccueil.Boule = True Then REM true == édition
Me.Tag = "Assistant édition de candidature (2/4)"
Me.Text = "Assistant édition de candidature (2/4)"
Lbl1.Text = "Editez l'identité du canditat ici :"
TxtNom.Text = FrmAccueil.cddts.Nom
TxtPrenom.Text = FrmAccueil.cddts.Prenom
TxtAdrss.Text = FrmAccueil.cddts.Adresse
TxtCP.Text = FrmAccueil.cddts.CP
TxtVille.Text = FrmAccueil.cddts.Ville
TxtMois.Text = FrmAccueil.cddts.Age Mod 12
TxtAns.Text = FrmAccueil.cddts.Age \ 12
LblAns.Text = conv(FrmAccueil.cddts.Age, 0)
SBHAge.Value = FrmAccueil.cddts.Age
CmdPre.Visible = True
LblCaR.Visible = False
LblID.Visible = True
LblID.Text = "Id : " & FrmEdit.SelectedID REM met d'ID en cas d'édition.
End If
If FrmAccueil.Boule = False Then REM false == inscription
Me.Tag = "Assistant création de candidature (2/4)"
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
Dim ChkNom, Chkprenom, ChkCP, ChkVille, ChkMois, chkAge As Boolean
ChkNom = False
Chkprenom = False
ChkCP = False
ChkVille = False
ChkMois = False
chkAge = False
CmdNext.Tag = ""
If TxtNom.Text = "" Then
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
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
ChkCP = True
OK = False
LblCP.Tag = "• La saisie du code postal est vide ou incomplète."
LblCP.ForeColor = Color.Red
End If
If TxtVille.Text = "" Then
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
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
'Call erreur(ChkNom, LblNom.Text)
'Call erreur(Chkprenom, LblPrenom.Tag)
'etc
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 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
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
'Function erreur(ByVal chk As Boolean, ByRef mess As String)
' If chk Then CmdNext.Tag = CmdNext.Tag & mess & vbNewLine
'End Function
Private Sub CmdPre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdPre.Click
REM retour au fichier précédant
Me.Hide()
FrmEdit.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
' TxtAns.Text = agea
' Call conv(Today.Month, TxtAns.Text)
' TxtMois.Text = Today.Month
' LblAge.ForeColor = Color.Black
' LblAnnee.ForeColor = Color.Black
'End Sub
Private Sub SBHAge_ValueChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles SBHAge.ValueChanged
agea = SBHAge.Value / 12
TxtAns.Text = agea
Call conv(Today.Month, TxtAns.Text)
TxtMois.Text = Today.Month
LblAge.ForeColor = Color.Black
LblAns.ForeColor = Color.Black
End Sub
Private Sub TxtMois_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtMois.LostFocus, TxtAns.LostFocus
If TxtMois.Text > 12 Then TxtMois.Text = 12
If TxtMois.Text < 1 Then TxtMois.Text = 1
Call conv(TxtMois.Text, TxtAns.Text)
If nais >= agemin And nais <= agemax Then
LblAge.ForeColor = Color.Black
LblAns.ForeColor = Color.Black
End If
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
Function conv(ByRef mois As Integer, ByRef annee As Integer) As Integer
nais = annee * 12 + mois
agem = auj - nais
agea = agem \ 12
LblAns.Text = agea & " ans"
End Function
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
End Class