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
|
//------------------------------------------------------------------------------
procedure TModuleCalculAlterationForm.ShowAlterationPoste();
procedure InitCombo();
var
PosteDico: TEntityPoste;
PosteObj: TPosteComboObject;
begin
// Récupération de la liste des Postes
PosteDico := TEntityPoste.CreateAsSet();
try
PosteDico.Connection := TModule.Instance.DBConnection;
if PosteDico.Load() then
begin
PosteDico.First();
while not PosteDico.EOF do
begin
with TProfilBaseTypeParPoste.Create() do
try
Connection := TModulePrimes.Instance.DBConnection;
if Load(TBusinessProfilBaseTypeParPoste.MakeCriteriaByProfilAndPoste(FCalculView.Calculator.ProfilID, PosteDico.PosteID.AsInteger)) then
begin
PosteObj := TPosteComboObject.Create(PosteID.AsInteger, PosteDico.PosteCode);
cbxAlterationPoste.Items.AddObject(PosteObj.PosteLibelle, PosteObj);
end;
finally
Free();
end;
PosteDico.Next();
end;
end;
finally
PosteDico.Free();
end;
PosteObj := TPosteComboObject.Create(0, 'Poste ignoré');
cbxAlterationPoste.Items.AddObject(PosteObj.PosteLibelle, PosteObj);
PosteObj := TPosteComboObject.Create(-1, 'Rétablir poste');
cbxAlterationPoste.Items.AddObject(PosteObj.PosteLibelle, PosteObj);
end;
var
PosteCalculated, Poste: Integer;
begin
// Remplissage de la combo !
InitCombo();
PosteCalculated := FCalculView.Calcul.PosteIDTheorique.TryAsVariant();
Poste := FCalculView.Calcul.PosteIDFinal.TryAsVariant();
if PosteCalculated > 0 then
lblPosteCalculated.Caption := 'Poste : ' + FCalculView.Calcul.CodePoste
else
lblPosteCalculated.Caption := 'Poste indéterminé';
if not FAlterationLoaded then
FAlterationLoaded := FCalculAlteration.Load(TBusinessCalculAlteration.MakeCriteriaByCalcul(FCalculView.Calcul));
if Poste <> PosteCalculated then
begin
// Si le Poste utilisé en finalité est différent du Poste calculé,
// c'est qu'il y a nécessairement une altération !
if FAlterationLoaded then
begin
if Poste > 0 then
begin
cbxAlterationPoste.ItemIndex := TPosteComboObject.IndexOf(cbxAlterationPoste, Poste);
lblPosteAlteration.Caption := 'Poste forcé : ' + TPosteComboObject.GetSelected(cbxAlterationPoste).PosteLibelle;
end
else
begin
lblPosteAlteration.Caption := 'Poste ignoré';
cbxAlterationPoste.ItemIndex := TPosteComboObject.IndexOf(cbxAlterationPoste, 0);
end;
if FCalculAlteration.PosteAltered then
lblPosteAlteration.Font.Style := [fsBold]
else
lblPosteAlteration.Font.Style := [fsStrikeOut];
end
else
raise EModuleCalculatorError.Create(ERR_INCOHERENT_CALCUL_ALTERATION);
end
else
begin
lblPosteAlteration.Caption := '';
cbxAlterationPoste.ItemIndex := -1;
end;
end;
//------------------------------------------------------------------------------
procedure TModulePrimesCalculAlterationForm.cbxAlterationPosteChange(Sender: TObject);
var
PosteObj: TPosteComboObject;
PosteCalculated, PosteOld, PosteNew: Integer;
begin
// OnChange d'un ComboBox ne se produit que lors de la modification utilisateur
PosteObj := TPosteComboObject.GetSelected(cbxAlterationPoste);
if Assigned(PosteObj) then
begin
// une option pour rétablir l'ancienne valeur
if PosteObj.PosteID = -1 then
begin
FCalculAlteration.Edit();
FCalculAlteration.PosteAltered := False;
PreviewAlterationPoste();
end
// une option pour forcer une valeur vide
else if PosteObj.PosteID = 0 then
begin
FCalculAlteration.Edit();
FCalculAlteration.PosteAltered := not FCalculView.Calcul.PosteIDTheorique.IsNull;
FCalculAlteration.Poste.IsNull := True;
PreviewAlterationPoste();
end
else
begin
PosteCalculated := FCalculView.Calcul.PosteIDTheorique.TryAsVariant();
if FAlterationLoaded then
PosteOld := FCalculAlteration.Poste.TryAsVariant()
else
PosteOld := FCalculView.Calcul.PosteIDPourPrime.TryAsVariant();
PosteNew := PosteObj.PosteID;
if PosteNew <> PosteOld then
begin
FCalculAlteration.Edit();
if PosteNew <> PosteCalculated then
begin
FAlterationLoaded := True;
FCalculAlteration.Poste.AsInteger := PosteNew;
FCalculAlteration.PosteAltered := True;
end
else
FCalculAlteration.PosteAltered := False;
PreviewAlterationPoste();
end;
end;
end;
end; |
Partager