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.BitBtn1Click(Sender: TObject);
var
Debut, Fin: TDateTime;
s: TDateTime;
Delta: Integer;
begin
executiontache.Open;
tache_poste_detail.Open;
Debut := DateTimePicker1.Date;
Fin := IncYear(Debut, 1);
Delta := 0;
tache_poste_detail.first;
while not tache_poste_detail.Eof do
begin
if tache_poste_detail.FieldByName('Fréquance').AsString = 'Hebdomadaire' then
begin
s := IncDay(Debut, Delta);
while s < Fin do
begin
executiontache.insert;
executiontache.FieldByName('Nposte_tache').AsInteger := tache_poste_detail.FieldByName('Nposte_tache').AsInteger;
executiontache.FieldByName('dateplan').AsDateTime := s;
executiontache.post;
s := IncWeek(s, 1);
end;
Delta := (Delta + 1) mod 7;
end;
if tache_poste_detail.FieldByName('Fréquance').AsString = 'Mensuel' then
begin
s := IncDay(Debut, Delta);
while s < Fin do
begin
executiontache.insert;
executiontache.FieldByName('Nposte_tache').AsInteger := tache_poste_detail.FieldByName('Nposte_tache').AsInteger;
executiontache.FieldByName('dateplan').AsDateTime := s;
executiontache.post;
s := IncMonth(s, 1);
end;
Delta := (Delta + 1) mod 7;
end;
if tache_poste_detail.FieldByName('Fréquance').AsString = 'Trimestriel' then
begin
s := IncDay(Debut, Delta);
while s < Fin do
begin
executiontache.insert;
executiontache.FieldByName('Nposte_tache').AsInteger := tache_poste_detail.FieldByName('Nposte_tache').AsInteger;
executiontache.FieldByName('dateplan').AsDateTime := s;
executiontache.post;
s := IncMonth(s, 3);
end;
Delta := (Delta + 1) mod 7;
end;
if tache_poste_detail.FieldByName('Fréquance').AsString = 'Semestriel' then
begin
s := IncDay(Debut, Delta);
while s < Fin do
begin
executiontache.insert;
executiontache.FieldByName('Nposte_tache').AsInteger := tache_poste_detail.FieldByName('Nposte_tache').AsInteger;
executiontache.FieldByName('dateplan').AsDateTime := s;
executiontache.post;
s := IncMonth(s, 6);
end;
Delta := (Delta + 1) mod 7;
end;
if tache_poste_detail.FieldByName('Fréquance').AsString = 'Annuel' then
begin
s := IncDay(Debut, Delta);
while s < Fin do
begin
executiontache.insert;
executiontache.FieldByName('Nposte_tache').AsInteger := tache_poste_detail.FieldByName('Nposte_tache').AsInteger;
executiontache.FieldByName('dateplan').AsDateTime := s;
executiontache.post;
s := IncYear(s, 1);
end;
Delta := (Delta + 1) mod 7;
end;
tache_poste_detail.Next;
end;
end; |
Partager