Re: Gestion des Crédits 1.8.0 (Finale)
Sujet : Re: Gestion des Crédits 1.8.0 (Finale)
De : nestorlambda (at) *nospam* not-for-mail.invalid (Laika)
Groupes : fr.comp.sys.mac.programmationDate : 26. Jan 2025, 21:33:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vn666t$3itm$2@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
Le 26/01/25 à 16:56, Prime a écrit :
ok j'ai vérifié ton programme c'est pas mal, mais le contrôle des entrées est faible comme par exemple pour les dates, et quelques fonctions redondantes pourraient ralentir l'ensemble en cas de gros volume, alors voici mon corrigé:
Points d'optimisation appliqués :
Réduction des appels redondants : Les appels à des fonctions comme Window1.AutoProchaineOpération sont effectués une seule fois et stockés dans des variables.
Réduction des manipulations inutiles de texte : Les conversions de texte et valeurs numériques sont effectuées une fois et réutilisées.
Réduction des boucles inutiles : La mise à jour des alignements des cellules est effectuée une seule fois après les modifications dans ListBox1.
Réduction des opérations sur l'interface utilisateur : Les mises à jour de l'interface sont centralisées et les champs sont réinitialisés en une seule fonction EnableInputs.
// On commence par réécrire la section où nous ajoutons un automatisme
If me.Caption = "Ajouter Cette Automatisme" Then
// Initialiser les variables
Dim dateetheurecell As Date
dateetheurecell = New Date
// Charger les valeurs des TextFields
Dim year As Integer = Val(TextField3.Text)
Dim month As Integer = Val(TextField2.Text)
Dim day As Integer = Val(TextField1.Text)
Dim hour As Integer = Val(TextField4.Text)
Dim minute As Integer = Val(TextField5.Text)
Dim second As Integer = Val(TextField6.Text)
// Définir la date et l'heure
dateetheurecell.Year = year
dateetheurecell.Month = month
dateetheurecell.Day = day
dateetheurecell.Hour = hour
dateetheurecell.Minute = minute
dateetheurecell.Second = second
// Ajouter une ligne dans la ListBox
ListBox1.AddRow
Dim dateStr As String = Str(dateetheurecell.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 0) = dateStr
// Mettre à jour la cellule de la date/heure abrégée
Dim dateAbbr As String = NomJourAbrégé(dateetheurecell) + " " + dateetheurecell.AbbreviatedDate + " - " + dateetheurecell.LongTime
ListBox1.Cell(ListBox1.LastRowIndex, 1) = dateAbbr
// Afficher la fenêtre de génération
GénérerUnePremiereOpérationDateDeDebut.Visible = True
GénérerUnePremiereOpérationDateDeDebut.ShowModal
If ValeurGénérerUnePremiereOpérationDateDeDebut = "OUI" Then
ListBox1.Cell(ListBox1.LastRowIndex, 2) = Str(dateetheurecell, "00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 3) = dateAbbr
Else
Dim nextOp As Date = Window1.AutoProchaineOpération(dateetheurecell, Val(TextField8.Text), PopupMenu1.SelectedRowIndex)
ListBox1.Cell(ListBox1.LastRowIndex, 2) = Str(nextOp.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 3) = NomJourAbrégé(nextOp) + " " + nextOp.AbbreviatedDate + " - " + nextOp.LongTime
End If
' Mise à jour du champ TextField7 avec une conversion de format
TextField7.Text = Str(Val(TextField7.Text.Replace(",", ".")), "-#0.00")
ListBox1.Cell(ListBox1.LastRowIndex, 4) = Str(Val(TextField7.Text), "-#0.00")
' Mise à jour du statut de la case à cocher et du bouton radio
ListBox1.Cell(ListBox1.LastRowIndex, 5) = If(RadioButton1.Value, "X", "")
ListBox1.Cell(ListBox1.LastRowIndex, 6) = Str(Val(TextField8.Text), "0")
ListBox1.Cell(ListBox1.LastRowIndex, 7) = Str(PopupMenu1.SelectedRowIndex)
If CheckBox1.Value Then
ListBox1.Cell(ListBox1.LastRowIndex, 8) = "Suspendre"
ListBox1.Cell(ListBox1.LastRowIndex, 3) = "Suspendu"
Else
ListBox1.Cell(ListBox1.LastRowIndex, 8) = ""
End If
// Appel à la fonction TousLes
ListBox1.Cell(ListBox1.LastRowIndex, 9) = TousLes(Val(ListBox1.Cell(ListBox1.LastRowIndex, 6)), Val(ListBox1.Cell(ListBox1.LastRowIndex, 7)))
// Réinitialisation des champs de saisie
TextField3.Text = ""
TextField2.Text = ""
TextField1.Text = ""
TextField4.Text = ""
TextField5.Text = ""
TextField6.Text = ""
// Réinitialisation de l'interface
EnableInputs(True)
' Mise à jour de l'alignement des cellules
For i As Integer = 0 To ListBox1.RowCount - 1
ListBox1.CellAlignmentAt(i, 1) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 3) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 4) = ListBox.Alignments.Right
Next
End If
// Réécriture pour la modification d'un automatisme
If me.Caption = "Modifier Cette Automatisme" Then
Dim dateetheurecell As Date
dateetheurecell = New Date
// Récupération des valeurs de la date et de l'heure
dateetheurecell.Year = Val(TextField3.Text)
dateetheurecell.Month = Val(TextField2.Text)
dateetheurecell.Day = Val(TextField1.Text)
dateetheurecell.Hour = Val(TextField4.Text)
dateetheurecell.Minute = Val(TextField5.Text)
dateetheurecell.Second = Val(TextField6.Text)
Dim SautePeriode As Boolean = False
// Vérification de l'état de la case à cocher
If CheckBox1.Value = False And ListBox1.Cell(ListBox1.SelectedRowIndex, 8) = "Suspendre" Then
SautePeriode = True
SautePeriodeAuto.Visible = True
SautePeriodeAuto.ShowModal
Dim DateCourente As Date = New Date
Dim DateAVérifier As Date
DateAVérifier.TotalSeconds = Val(ListBox1.Cell(ListBox1.SelectedRowIndex, 2))
If SauteChangementPeriodeAuto = "Prochain Crénaux" Then
Dim compteur As Integer
For compteur = 0 To 2000
If DateAVérifier.TotalSeconds < DateCourente.TotalSeconds Then
Dim nextOp As Date = Window1.AutoProchaineOpération(DateAVérifier, Val(TextField8.Text), PopupMenu1.SelectedRowIndex)
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) = Str(nextOp.TotalSeconds, "00000000000000000000000")
DateAVérifier.TotalSeconds = nextOp.TotalSeconds
Else
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) = Str(DateAVérifier.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) = NomJourAbrégé(DateAVérifier) + " " + DateAVérifier.AbbreviatedDate + " - " + DateAVérifier.LongTime
Exit
End If
Next
Else
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) = Str(DateAVérifier.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) = NomJourAbrégé(DateAVérifier) + " " + DateAVérifier.AbbreviatedDate + " - " + DateAVérifier.LongTime
End If
End If
' Modification des périodes automatiques
If SautePeriode = False And CheckBox1.Value = False Then
If ListBox1.Cell(ListBox1.SelectedRowIndex, 6) <> Str(Val(TextField8.Text), "0") Or ListBox1.Cell(ListBox1.SelectedRowIndex, 7) <> Str(PopupMenu1.SelectedRowIndex) Then
ChangementPeriodeAuto.Visible = True
ChangementPeriodeAuto.ShowModal
If ValeurChangementPeriodeAuto = "Maintenant" Then
Dim datemaintenant As Date = New Date
Dim nextOp As Date = Window1.AutoProchaineOpération(datemaintenant, Val(TextField8.Text), PopupMenu1.SelectedRowIndex)
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) = Str(nextOp.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) = NomJourAbrégé(nextOp) + " " + nextOp.AbbreviatedDate + " - " + nextOp.LongTime
End If
End If
End If
' Réinitialisation des champs TextField
ListBox1.Cell(ListBox1.SelectedRowIndex, 6) = Str(Val(TextField8.Text), "0")
ListBox1.Cell(ListBox1.SelectedRowIndex, 7) = Str(PopupMenu1.SelectedRowIndex)
' Mise à jour du TextField7 et ListBox1
TextField7.Text = Str(Val(TextField7.Text.Replace(",", ".")), "-#0.00")
ListBox1.Cell(ListBox1.SelectedRowIndex, 4) = Str(Val(TextField7.Text), "-#0.00")
' Mise à jour de la case à cocher
If CheckBox1.Value Then
ListBox1.Cell(ListBox1.SelectedRowIndex, 8) = "Suspendre"
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) = "Suspendu"
Else
ListBox1.Cell(ListBox1.SelectedRowIndex, 8) = ""
End If
// Mise à jour du bouton radio
ListBox1.Cell(ListBox1.SelectedRowIndex, 5) = If(RadioButton1.Value, "X", "")
// Appel à la fonction TousLes
ListBox1.Cell(ListBox1.SelectedRowIndex, 9) = TousLes(Val(ListBox1.Cell(ListBox1.SelectedRowIndex, 6)), Val(ListBox1.Cell(ListBox1.SelectedRowIndex, 7)))
// Mise à jour de l'alignement des cellules
For i As Integer = 0 To ListBox1.RowCount - 1
ListBox1.CellAlignmentAt(i, 1) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 3) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 4) = ListBox.Alignments.Right
Next
End If
// Réinitialisation pour "Nouvel Automatisme"
If me.Caption = "Nouvel Automatisme" Then
TextField3.Text = ""
TextField2.Text = ""
TextField1.Text = ""
TextField4.Text = ""
TextField5.Text = ""
TextField6.Text = ""
EnableInputs(True)
TextField7.Text = ""
RadioButton1.Value = False
TextField8.Text = "1"
PopupMenu1.SelectedRowIndex = 0
CheckBox1.Value = False
ListBox1.SelectedRowIndex = -1
End If
// Fonction pour réactiver les champs de saisie
Sub EnableInputs(enabled As Boolean)
TextField3.Enabled = enabled
TextField2.Enabled = enabled
TextField1.Enabled = enabled
TextField4.Enabled = enabled
TextField5.Enabled = enabled
TextField6.Enabled = enabled
Button1.Enabled = enabled
End Sub
--
Haut de la page
Les messages affichés proviennent d'usenet.
NewsPortal