Um den Code noch zu erweitern:
Delphi-Quellcode:
procedure Tgrafiken.Button1Click(Sender: TObject);
begin
jahr:='2006';
jahrund1:='2007';
apg;
end;
procedure tgrafiken.apg;
var he,he2:integer;
monat: array of array of integer;
i,z:integer;
BEGIN
he:=1;
zqapg.SQL.Text:='select * from fehlerorte';
zqapg.Open;
setlength(monat,12,zqapg.RecordCount);
z:=zqapg.RecordCount;
repeat
chart3.AddSeries(tbarseries.Create(self));
chart3.Series[he].Title:=zqapg.FieldValues['bez'];
chart3.Series[he].SeriesColor:=farben[he];
zqapg.Next;
he:=he+1;
until zqapg.Eof;
he2:=1;
{ repeat
zqapg.SQL.Text:='select * from listeorte where `orte`='''+inttostr(he2)+'''';
zqapg.Open;
chart3.Series[he2].AddXY(1,zqapg.RecordCount,'Januar',farben[he2]);
he2:=he2+1;
until he2=he; }
FOR i:=1 TO 12 DO
begin
he2:=1;
if i<9 then
begin
repeat
zqapg.SQL.Text:='select * from liste INNER JOIN listeorte on reklamnr=liste where (`orte`='''+inttostr(he2)+''') AND (`reklamdatum`>='''+jahr+'-0'+inttostr(i)+'-01'') AND (`reklamdatum`<'''+jahr+'-0'+inttostr(i+1)+'-01'')';
zqapg.Open;
monat[i-1,he2]:=zqapg.RecordCount;
he2:=he2+1;
until he2=he;
end;
if i=9 then
begin
repeat
zqapg.SQL.Text:='select * from liste INNER JOIN listeorte on reklamnr=liste where `orte`='''+inttostr(he2)+''' AND (`reklamdatum`>='''+jahr+'-0'+inttostr(i)+'-01'') AND (`reklamdatum`<'''+jahr+'-'+inttostr(i+1)+'-01'')';
zqapg.Open;
monat[i-1,he2]:=zqapg.RecordCount;
he2:=he2+1;
until he2=he;
end;
if (i=10) or (i=11) then
begin
repeat
zqapg.SQL.Text:='select * from liste INNER JOIN listeorte on reklamnr=liste where `orte`='''+inttostr(he2)+''' AND (`reklamdatum`>='''+jahr+'-'+inttostr(i)+'-01'') AND (`reklamdatum`<'''+jahr+'-'+inttostr(i+1)+'-01'')';
zqapg.Open;
monat[i-1,he2]:=zqapg.RecordCount;
he2:=he2+1;
until he2=he;
end;
if i=12 then
begin
repeat
zqapg.SQL.Text:='select * from liste INNER JOIN listeorte on reklamnr=liste where `orte`='''+inttostr(he2)+''' AND (`reklamdatum`>='''+jahr+'-'+inttostr(i)+'-01'') AND (`reklamdatum`<'''+jahrund1+'-01-01'')';
zqapg.Open;
monat[i-1,he2]:=zqapg.RecordCount;
he2:=he2+1;
until he2=he;
end;
end;
end;
Nach dem Fehler Springt er ans ende des Buttonclick-ereignisses.