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
| procedure TForm1.BitBtn2Click(Sender: TObject);
var
tNM_Client: String;
tCde_Cne, tCode, tAnnee: Integer;
tPyt: Boolean;
tMt: Real;
begin
if MessageDlg('Voulez vous transférer vos tâches',
mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Exit;
// Transfert accepté
with DM do
begin
// Désactiver les contrôles orientés données
{TClient.DisableControls;}
TProduit.DisableControls;
TRecap.DisableControls;
try
// Fermeture, vidage, et réouverture de la table
TRecap.Close;
TRecap.EmptyTable;
TRecap.Open;
// Ouverture de la table 'Clients'
{TClient.Open;}
// Ouverture de la table 'Produit'
TProduit.Open;
// Parcours de la table 'Clients'
{while not TClient.Eof do}
{begin}
// On se place sur le 1° produit
TProduit.First;
// Parcours de la table 'Produit'
while not TProduit.Eof do
begin
{Keep Previous values}
tMt := TProduitTaxe_Total.AsFloat;
tCde_Cne := TProduitCde_Cne.AsInteger;
tCode := TProduitCode.AsInteger;
tAnnee := TProduitAnnee.AsInteger;
tNM_Client := TProduitNM_Client.AsString;
tPyt := TProduitPayement.AsBoolean;
// L'enregistrement existe ?
if TRecap.Locate('Code;Annee;Cde_Cne;Payement',
VarArrayOf([tCode, tAnnee, tCde_Cne, tPyt]),
[loCaseInsensitive, loPartialKey]) then
begin
// Oui, on le modifie
TRecap.Edit;
end
else
begin
// Non, on en crée un
TRecap.Insert;
end;
// On renseigne les valeurs
TRecapCde_Cne.AsInteger := tCde_Cne;
TRecapCode.AsInteger := tCode;
TRecapAnnee.AsInteger := tAnnee;
TRecapMontant.Asfloat := tMt;
TRecapNM_Client.AsString := tNM_Client;
TRecapPayement.value := tPyt;
// On enregistre dans la table 'Recap'
TRecap.Post;
// Produit suivant
TProduit.Next;
end;
// Client suivant
{TClient.Next;}
{end;}
MessageDlg('Votre transfert est terminé.', mtInformation, [mbOk], 0);
finally
// Réactiver les contrôles orientés données
TRecap.EnableControls;
TProduit.EnableControls;
{TClient.EnableControls;}
end;
end;
Close;
end; |
Partager