1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
| On Error GoTo GestionErreur:
GestionErreur:
If Err.Number = 3421 Then
MsgBox "Vous avez saisi du texte dans un champ numérique. Veuillez vérifier vos informations.", vbOKOnly, "ATTENTION"
Exit Sub
End If
If Err.Number = 3163 Then
MsgBox "Vous ne pouvez pas ajouter de motif. Veuillez choisir un motif dans la zone de liste.", vbOKOnly, "ATTENTION"
Exit Sub
End If
Dim bd As Database
Dim tage As Recordset, tin As Recordset
Dim tct As Recordset, tmi As Recordset, treq As Recordset, tverif As Recordset, texist As Recordset
Dim req As String, verif As String, critere As String, exist As String, critere2 As String
Dim missionex As String, verifconduct As String, veriftache As String
Dim tverifconduct As Recordset, tconduct As Recordset, ttache As Recordset, tveriftache As Recordset
Dim tre As Recordset
Set bd = DBEngine.Workspaces(0).Databases(0)
If Me.noc.Value <> "" Then
'vérification existence du contrat pr savoir si Nveau ou MAJ
exist = "select count(nocontrat) as num from contrat where nocontrat='" + Me.noc + "'"
Set texist = bd.OpenRecordset(exist, DB_OPEN_DYNASET)
If texist![num] = 0 Then
'enregistrement des différentes données concernant le contrat établi
'gestion des oublis de remplissage de champs
If Me.nomagence.Value <> "" Then
If Me.lieum <> "" Then
If Me.basecs.Value <> "" Then
If Me.bcr.Value <> "" Then
If nosecu.Value <> "" Then
If datedebc <> "" And datefinc <> "" Then
If Me.taches <> "" Then
'enregistrement de l'agence intérim si nouvelle
If Me.agenceexist = 0 Then
Set tage = bd.OpenRecordset("agence", DB_OPEN_DYNASET)
tage.AddNew
tage![noagence] = Me.noagence
tage![noma] = nomagence.Value
tage![villea] = villa
tage.Update
End If
'enregistrement de la mission si nouvelle
If missionexist = 0 Then
Set tmi = bd.OpenRecordset("mission", DB_OPEN_DYNASET)
tmi.AddNew
tmi![nomission] = nomission
tmi![lieum] = lieum
tmi![cpm] = cpm
tmi![villem] = villem
tmi.Update
End If
'enregistrement du conducteur de travaux si nouveaux
'vérification existence conduct de travaux
If conductexist = 0 Then
Set tverifconduct = bd.OpenRecordset("condtravaux", DB_OPEN_DYNASET)
tverifconduct.AddNew
tverifconduct![noconduct] = Me.noconduct
tverifconduct![nomconduct] = nomconduct
tverifconduct.Update
End If
'enregistrement de la tache si nouvelle
If tacheexist = 0 Then
Set ttache = bd.OpenRecordset("tache", DB_OPEN_DYNASET)
ttache.AddNew
ttache![notache] = Me.notache
ttache![nomtache] = taches
ttache.Update
End If
'enregistrement de l'intérimaire
'vérification si l'interimaire existait ou non
verif = "SELECT Count(interimaire.nosecu) AS nb from interimaire where nosecu='" + Me.nosecu + "'"
Set tverif = bd.OpenRecordset(verif, DB_OPEN_DYNASET)
tverif.MoveFirst
'si l'interimaire n'existe pas alors on va le créer
If tverif![nb] = 0 Then
Set tin = bd.OpenRecordset("interimaire", DB_OPEN_DYNASET)
tin.AddNew
tin![nosecu] = Me.nosecu
tin![nomi] = nomi
tin![prenomi] = prenomi
tin![datenaiss] = datenaiss
tin![depnaiss] = depnaiss
tin![adressei] = adressei
tin![cpi] = cpi
tin![villei] = villei
tin![sexe] = sexe
If satisfait.Value = 1 Then
tin![satisfait] = True
Else
If satisfait.Value = 2 Then
tin![satisfait] = False
End If
End If
tin![observations] = observation
tin![noagence] = nomagence.Column(1)
tin.Update
Else
critere = "nosecu='" + nosecu + "'"
Set tin = bd.OpenRecordset("interimaire", DB_OPEN_DYNASET)
tin.FindFirst critere
'l'interimaire existe deja on met à jour l'adresse, le cp, la ville, la note et l'observation
tin.Edit
tin![adressei] = adressei
tin![cpi] = cpi
tin![villei] = villei
If satisfait.Value = 1 Then
tin![satisfait] = True
Else
If satisfait.Value = 2 Then
tin![satisfait] = False
End If
End If
tin![observations] = observation
tin.Update
End If
'enregistrement du contrat
Set tct = bd.OpenRecordset("contrat", DB_OPEN_DYNASET)
tct.AddNew
tct![nocontrat] = Me.noc
tct![datedeb] = datedebc
tct![datefin] = datefinc
tct![statut] = statut
tct![emploi] = emploi
tct![qualif] = qualif
tct![coef] = coef
If Me!basecs <> "" Then
tct![basecontrat] = basecs
End If
If Me!bcr <> "" Then
tct![basecontratref] = bcr
End If
If Me!coefbc <> "" Then
tct![coefbc] = coefbc
End If
If Me!primetrajet <> "" Then
tct![primetrajet] = primetrajet
End If
If Me!coeftrajet <> "" Then
tct![coeftrajet] = coeftrajet
End If
If Me!primepc <> "" Then
tct![primepanier] = primepc
End If
If Me!coefpcnc <> "" Then
tct![coefpaniernonchar] = coefpcnc
End If
If Me!indemnitetrspt <> "" Then
tct![indemnitetrspt] = indemnitetrspt
End If
If Me!coeftrspt <> "" Then
tct![coeftrspt] = coeftrspt
End If
If Me!kms <> "" Then
tct![kms] = kms
End If
If Me!indemnitepc <> "" Then
tct![indemnitepanier] = indemnitepc
End If
If Me!coefpcc <> "" Then
tct![coefpanierchar] = coefpcc
End If
tct![txhf] = Round(Me.txhfact, 2)
tct![nosecu] = nosecu
tct![noagence] = noagence
tct![nomission] = nomission
tct![nosociete] = nosociete
tct![motifcontrat] = motif
tct![noconduct] = noconduct
tct![notache] = Me.notache
tct![autreindem] = Me.autreindemn
tct![detailautreindemn] = Me.detailindemn
tct.Update
MsgBox "L'enregistrement s'est bien déroulé"
nomagence.Requery
lieum.Requery
noc = ""
nomagence.Visible = True
nomagence = ""
adressea = ""
villa = ""
lieum.Visible = True
lieum = ""
cpm = ""
villem = ""
nosecu = ""
nationalite.Enabled = True
nationalite = ""
datenaiss.Enabled = True
datenaiss = ""
sexe.Enabled = True
sexe = ""
nomi.Enabled = True
nomi = ""
depnaiss = ""
prenomi.Enabled = True
prenomi = ""
adressei = ""
cpi = ""
villei = ""
satisfait.Value = ""
observation = ""
datedebc = ""
datefinc = ""
statut = ""
emploi = ""
qualif = ""
coef = ""
basecs = ""
primetrajet = ""
primepc = ""
indemnitetrspt = ""
kms = ""
indemnitepc = ""
renouvellement.Value = ""
datedebr = ""
datefinr = ""
motif = ""
nomconduct = ""
coefbc = ""
coefpcnc = ""
coefpcc = ""
coeftrajet = ""
coeftrspt = ""
bcr = ""
depnaiss.Enabled = True
depnaiss.Locked = False
taches = ""
txhfact = ""
Me.daterenouv.Requery
Me.autreindemn = ""
Me.detailindemn = ""
'demande à l'utilisateur s'il veut changer de société pour le nouveau contrat
Dim b As String
b = MsgBox("Voulez vous changer de société ?", vbYesNo, "Félicitations")
If b = 6 Then
DoCmd.OpenForm "frmsociete"
End If
Else
MsgBox "Veuillez saisir une Tâche", vbOKOnly, "ATTENTION"
End If
Else
MsgBox "Veuillez saisir une date de début et une date de fin de contrat", vbOKOnly, "ATTENTION"
End If
Else
MsgBox "Vous avez oublié de rentrer un numéro de sécurité sociale", vbOKOnly, "ATTENTION"
End If
Else
MsgBox "Veuillez saisir une base de contrat de référence", vbOKOnly, "ATTENTION"
End If
Else
MsgBox "Veuillez saisir une base de contrat", vbOKOnly, "ATTENTION"
Exit Sub
End If
Else
MsgBox "Veuillez saisir un lieu de mission", vbOKOnly, "ATTENTION"
Exit Sub
End If
Else
MsgBox "Veuillez saisir une agence", vbOKOnly, "ATTENTION"
Exit Sub
End If |
Partager