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 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
| Public Function maFonctionAffichage()
Semaine = CInt(Forms![Formulaire102FicheMachine]![Controle0310TexteCache2].Value)
DoCmd.OpenForm "Formulaire105Planning", acDesign, , , , acHidden
Dim r2 As DAO.Recordset
Set r2 = CurrentDb.OpenRecordset("SELECT N°, StatutUtilisateur, DateReservee, HeureDebut, HeureFin, NomUtilisateur, PrenomUtilisateur FROM Table03Reservations WHERE Table03Reservations.N°Machine=" & Forms![Formulaire102FicheMachine]![Controle0309TexteCache1] & ";")
If Not r2.EOF Then
r2.MoveFirst
Dim T As Integer
Dim l As Integer
Dim H As Integer
Dim W As Integer
T = 0
l = 1800
H = 300
W = 1800
Dim CreneauR As Control
Dim i As Integer
i = 1
While Not r2.EOF
Dim r3 As DAO.Recordset
Set r3 = CurrentDb.OpenRecordset("SELECT N° FROM Table23HeureQuart WHERE heure = '" & r2.Fields(3).Value & "';")
Dim r4 As DAO.Recordset
Set r4 = CurrentDb.OpenRecordset("SELECT N° FROM Table23HeureQuart WHERE heure = '" & r2.Fields(4).Value & "';")
r3.MoveFirst
r4.MoveFirst
'Il faudra changer le bloc suivant, en incluant les conditions sur la semaine directement dans la requète
'de l'"OpenRecordset" de r2, pour diminuer le temps de calcul lorsque le nombre total de réservation
'(notamment celles dans le passée) sera devenu très élevé.
'bloc à changer ulterieurement : début
If r2.Fields(2).Value > Date - Weekday(Date, vbMonday) Then
Set CreneauR = CreateControl(Forms![Formulaire105Planning].Name, acCommandButton, , "", "", _
l + W * (Weekday(r2.Fields(2).Value, vbMonday) - 1), T + H * (r3.Fields(0).Value - 1), W, H * (r4.Fields(0).Value - r3.Fields(0).Value))
'CreneauR.BackColor = QBColor(11)
CreneauR.Caption = r2.Fields(3).Value + " - " + r2.Fields(4).Value
CreneauR.Name = "CreneauR" + CStr(i)
CreneauR.ForeColor = QBColor(0)
CreneauR.OnClick = "=TestClick2(" + CStr(r2.Fields(0).Value) + ")"
CreneauR.ControlTipText = r2.Fields(6).Value & " " & r2.Fields(5).Value
CreneauR.Visible = False
If r2.Fields(1).Value = 1 Then
CreneauR.BackColor = QBColor(8)
Else
If r2.Fields(1).Value = 2 Then
CreneauR.BackColor = QBColor(6)
Else
If r2.Fields(1).Value = 3 Then
CreneauR.BackColor = QBColor(4)
Else
If r2.Fields(1).Value = 4 Then
CreneauR.BackColor = QBColor(2)
Else
CreneauR.BackColor = QBColor(11)
End If
End If
End If
End If
If r2.Fields(2).Value > Date - Weekday(Date, vbMonday) + Semaine * 7 Then
If r2.Fields(2).Value < Date - Weekday(Date, vbMonday) + 8 + Semaine * 7 Then
CreneauR.Visible = True
End If
End If
i = i + 1
End If
'bloc à changer ulterieurement : fin
Forms![Formulaire102FicheMachine]![Controle0311TexteCache3] = i - 1
r2.MoveNext
Wend
End If
Dim r6 As DAO.Recordset
Set r6 = CurrentDb.OpenRecordset("SELECT jour FROM Table22Jour WHERE N° = " & Weekday(Date, vbMonday) & ";")
Forms![Formulaire105Planning]![EtiquetteDateEtHeure].Caption = r6.Fields(0).Value & vbCrLf & Date & vbCrLf & Time
Dim r7 As DAO.Recordset
Set r7 = CurrentDb.OpenRecordset("SELECT jour FROM Table22Jour;")
r7.MoveFirst
Forms![Formulaire105Planning]![Creneau01].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 1 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau02].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 2 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau03].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 3 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau04].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 4 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau05].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 5 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau06].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 6 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau07].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 7 + Semaine * 7
Forms![Formulaire105Planning]![SemaineCourante].Caption = "Semaine du " & Date - Weekday(Date, vbMonday) + 1 + Semaine * 7 & " au " & Date - Weekday(Date, vbMonday) + 7 + Semaine * 7
DoCmd.SetWarnings False
DoCmd.Close acForm, "Formulaire105Planning"
DoCmd.SetWarnings True
End Function
Public Function TestClick2(k)
Forms![Formulaire105Planning]![Texte627] = k
DoCmd.OpenForm "Formulaire108InfoReservation"
Forms![Formulaire108InfoReservation]![Controle0803TexteCache1] = k
End Function
Public Function maFonctionAffichage2()
Semaine = CInt(Forms![Formulaire102FicheMachine]![Controle0310TexteCache2].Value)
Dim r2 As DAO.Recordset
Set r2 = CurrentDb.OpenRecordset("SELECT N°, StatutUtilisateur, DateReservee, HeureDebut, HeureFin, NomUtilisateur, PrenomUtilisateur FROM Table03Reservations WHERE Table03Reservations.N°Machine=" & Forms![Formulaire102FicheMachine]![Controle0309TexteCache1] & ";")
If Not r2.EOF Then
r2.MoveFirst
Dim j As Integer
j = 0
While Not r2.EOF
If r2.Fields(2).Value > Date - Weekday(Date, vbMonday) Then
j = j + 1
End If
r2.MoveNext
Wend
If Not j = Forms![Formulaire102FicheMachine]![Controle0311TexteCache3].Value Then
maFonctionEffacement
maFonctionAffichage
DoCmd.OpenForm "Formulaire105Planning", acNormal, , , , acWindowNormal
Forms![Formulaire105Planning]![Texte610] = Forms![Formulaire102FicheMachine]![Controle0309TexteCache1].[Value]
Else
r2.MoveFirst
Dim T As Integer
Dim l As Integer
Dim H As Integer
Dim W As Integer
T = 0
l = 1800
H = 300
W = 1800
Dim CreneauR As Control
Dim i As Integer
i = 1
While Not r2.EOF
If r2.Fields(2).Value > Date - Weekday(Date, vbMonday) Then
Dim r3 As DAO.Recordset
Set r3 = CurrentDb.OpenRecordset("SELECT N° FROM Table23HeureQuart WHERE heure = '" & r2.Fields(3).Value & "';")
Dim r4 As DAO.Recordset
Set r4 = CurrentDb.OpenRecordset("SELECT N° FROM Table23HeureQuart WHERE heure = '" & r2.Fields(4).Value & "';")
Dim r5 As DAO.Recordset
r3.MoveFirst
r4.MoveFirst
Set CreneauR = Forms![Formulaire105Planning].Controls("CreneauR" + CStr(i))
CreneauR.Visible = False
If r2.Fields(2).Value > Date - Weekday(Date, vbMonday) + Semaine * 7 Then
If r2.Fields(2).Value < Date - Weekday(Date, vbMonday) + 8 + Semaine * 7 Then
CreneauR.Visible = True
End If
End If
i = i + 1
End If
r2.MoveNext
Wend
End If
End If
Dim r6 As DAO.Recordset
Set r6 = CurrentDb.OpenRecordset("SELECT jour FROM Table22Jour WHERE N° = " & Weekday(Date, vbMonday) & ";")
Forms![Formulaire105Planning]![EtiquetteDateEtHeure].Caption = r6.Fields(0).Value & vbCrLf & Date & vbCrLf & Time
Dim r7 As DAO.Recordset
Set r7 = CurrentDb.OpenRecordset("SELECT jour FROM Table22Jour;")
r7.MoveFirst
Forms![Formulaire105Planning]![Creneau01].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 1 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau02].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 2 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau03].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 3 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau04].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 4 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau05].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 5 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau06].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 6 + Semaine * 7
r7.MoveNext
Forms![Formulaire105Planning]![Creneau07].Caption = r7.Fields(0).Value & vbCrLf & Date - Weekday(Date, vbMonday) + 7 + Semaine * 7
Forms![Formulaire105Planning]![SemaineCourante].Caption = "Semaine du " & Date - Weekday(Date, vbMonday) + 1 + Semaine * 7 & " au " & Date - Weekday(Date, vbMonday) + 7 + Semaine * 7
End Function
Public Function maFonctionCréation()
Dim r7 As DAO.Recordset
Set r7 = CurrentDb.OpenRecordset("SELECT * FROM Table23HeureQuart;")
Dim r8 As DAO.Recordset
Set r8 = CurrentDb.OpenRecordset("SELECT * FROM Table22Jour;")
Dim T As Integer
Dim l As Integer
Dim H As Integer
Dim W As Integer
T = 0
l = 1800
H = 300
W = 1800
Dim r70 As DAO.Recordset
Set r70 = CurrentDb.OpenRecordset("SELECT max(N°) FROM Table23HeureQuart;")
Dim r80 As DAO.Recordset
Set r80 = CurrentDb.OpenRecordset("SELECT max(N°) FROM Table22Jour;")
r70.MoveFirst
r80.MoveFirst
Dim im As Integer
Dim jm As Integer
im = r70.Fields(0).Value
jm = r80.Fields(0).Value
r7.MoveFirst
r8.MoveFirst
Dim Creneau As Control
DoCmd.OpenForm "Formulaire112Semaine", acDesign, , , , acHidden
Set Creneau = CreateControl(Forms![Formulaire112Semaine].Name, acCommandButton, , "", "", _
0, 0, W / 2, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = "Mois" & vbCrLf & "Précédent"
Creneau.Name = "MoisPrécédent"
Creneau.FontSize = 10
Creneau.ForeColor = QBColor(0)
Set Creneau = CreateControl(Forms![Formulaire112Semaine].Name, acCommandButton, , "", "", _
W / 2, 0, W / 2, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = "Mois" & vbCrLf & "Suivant"
Creneau.Name = "MoisSuivant"
Creneau.FontSize = 10
Creneau.ForeColor = QBColor(0)
Set Creneau = CreateControl(Forms![Formulaire112Semaine].Name, acCommandButton, , "", "", _
W, 0, W / 2, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = "Semaine" & vbCrLf & "Précédente"
Creneau.Name = "SemainePrécédente"
Creneau.FontSize = 8
Creneau.ForeColor = QBColor(0)
Set Creneau = CreateControl(Forms![Formulaire112Semaine].Name, acCommandButton, , "", "", _
3 * W / 2, 0, W / 2, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = "Semaine" & vbCrLf & "Suivante"
Creneau.Name = "SemaineSuivante"
Creneau.FontSize = 8
Creneau.ForeColor = QBColor(0)
DoCmd.SetWarnings False
DoCmd.Close acForm, "Formulaire112Semaine"
DoCmd.SetWarnings True
DoCmd.OpenForm "Formulaire105Planning", acDesign, , , , acHidden
Dim i As Integer
Dim j As Integer
Dim p As Integer
p = 0
For i = 1 To im - 1
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acCommandButton, , "", "", _
0, T + (i - 1) * H, l, H)
Creneau.BackColor = QBColor(7)
Creneau.Caption = r7.Fields(1).Value
Creneau.Name = "Creneau" + CStr(i) + "0"
Creneau.ForeColor = QBColor(0)
For j = 1 To jm
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acCommandButton, , "", "", _
l + (j - 1) * W, T + (i - 1) * H, W, H)
If p = 0 Then
Creneau.BackColor = QBColor(14)
Else
Creneau.BackColor = QBColor(15)
End If
Creneau.Name = "Creneau" + CStr(i) + CStr(j)
Next j
r7.MoveNext
If p = 0 Then
p = 1
Else: p = 0
End If
Next i
DoCmd.SelectObject acForm, Forms![Formulaire105Planning].Name, False
Application.RunCommand acCmdFormHdrFtr
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acCommandButton, acHeader, "", "", _
0, 3 * H, l, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = "Heure"
Creneau.Name = "Creneau" + "00"
Creneau.ForeColor = QBColor(0)
For j = 1 To jm
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acCommandButton, acHeader, "", "", _
l + (j - 1) * W, 3 * H, W, 2 * H)
Creneau.BackColor = QBColor(8)
Creneau.Caption = r8.Fields(1).Value
Creneau.Name = "Creneau0" + CStr(j)
Creneau.ForeColor = QBColor(0)
r8.MoveNext
Next j
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
l, 0, l, H)
Creneau.Visible = False
Creneau.Name = "Texte610"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
l, H, l, H)
Creneau.Visible = False
Creneau.Name = "Texte621"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
l, 2 * H, l, H)
Creneau.Visible = False
Creneau.Name = "Texte623"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
2 * l, 0, l, H)
Creneau.Visible = False
Creneau.Name = "Texte625"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
2 * l, H, l, H)
Creneau.Visible = False
Creneau.Name = "Texte627"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acTextBox, acHeader, "", "", _
2 * l, 2 * H, l, H)
Creneau.Visible = False
Creneau.Name = "Texte629"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acLabel, acHeader, "", "", _
l, 0, 4 * W, 3 * H)
Creneau.Caption = "Etiquette"
Creneau.Name = "Étiquette620"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acLabel, acHeader, "", "", _
l + 6 * W + 300, 0, W - 300, 3 * H)
Creneau.Name = "EtiquetteDateEtHeure"
Forms![Formulaire105Planning]![EtiquetteDateEtHeure].ForeColor = QBColor(0)
Forms![Formulaire105Planning]![EtiquetteDateEtHeure].FontSize = 12
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acSubform, acHeader, "", "", _
l + 4 * W, 0, 2 * W, 2 * H)
Creneau.Name = "ControleSousform"
Creneau.SourceObject = "Formulaire112Semaine"
Set Creneau = CreateControl(Forms![Formulaire105Planning].Name, acLabel, acHeader, "", "", _
l + 4 * W, 2 * H, 2 * W, H)
Creneau.Name = "SemaineCourante"
Creneau.ForeColor = QBColor(0)
DoCmd.SetWarnings False
DoCmd.Close acForm, "Formulaire105Planning"
DoCmd.SetWarnings True
End Function
Public Function maFonctionEffacement()
DoCmd.SetWarnings False
DoCmd.Close acForm, "Formulaire105Planning"
DoCmd.SetWarnings True
DoCmd.OpenForm "Formulaire105Planning", acDesign, , , , acHidden
Dim j As Integer
j = 0
For Each ctrl In Forms![Formulaire105Planning].Controls
If ctrl.Name Like "CreneauR*" Then
j = j + 1
End If
Next
If Not j = 0 Then
Dim i As Integer
For i = 1 To j
DeleteControl Forms![Formulaire105Planning].Name, "CreneauR" + CStr(i)
Next
End If
DoCmd.SetWarnings False
DoCmd.Close acForm, "Formulaire105Planning"
DoCmd.SetWarnings True
End Function |
Partager