3. Kompletní skript bez komentářů |
Top Previous Next |
procedure OnBeforeReport(Sender : TReportProperty); var Query,QueryDetail : TQuery; r : integer; begin Sheet.BeginUpdate; Sheet.RowCount:=3; Sheet.ColCount:=6; Sheet.FixedRows:=2; Sheet.ClearMergeCells;
Query:=TQuery.Create(nil); with Query do try DatabaseName :=DefaultDatabaseName; SQL.Text:='select mena_id,(select nazev from dba.gstaty where id_stat=(select stat_id from dba.gmeny where mena_id=id_mena)) as nazev '+ 'from dba.gkurzy group by mena_id'; Open;
r:=3; while not Query.Eof do begin Sheet.AddRow;
Sheet.CellProperty[2,r].Tag:=1; Sheet.Cells[2,r]:=Query.FieldByName('mena_id').AsString; Sheet.MergeCells(3,r,4,r); Sheet.Cells[3,r]:=Query.FieldByName('nazev').AsString;
Sheet.CellProperty[2,r].Background:=$00bd814f;Sheet.CellProperty[2,r].Font.Color:=clWhite; Sheet.CellProperty[3,r].Background:=$00bd814f;Sheet.CellProperty[3,r].Font.Color:=clWhite;
Sheet.CellProperty[2,r].OnDblClick:=@MenaDblClick;
inc(r);
QueryDetail:=TQuery.Create(nil); with QueryDetail do try DatabaseName :=DefaultDatabaseName; SQL.Text:='select top 5 dne,koef from dba.gkurzy where mena_id=:mena order by dne desc'; Params.ParamByName('mena').AsString:=Query.FieldByName('mena_id').AsString; Open;
while not QueryDetail.Eof do begin Sheet.AddRow;
Sheet.Cells[3,r]:=QueryDetail.FieldByName('dne').AsString; Sheet.Cells[4,r]:=QueryDetail.FieldByName('koef').AsString;
Sheet.CellProperty[3,r].Background:=$00EAEAEA; Sheet.CellProperty[4,r].Background:=$00EAEAEA;
Sheet.Rows[r].Visible:=False;
inc(r); QueryDetail.Next; end; finally Free; end; Query.Next; end; finally Free; end;
Sheet.EndUpdate; end;
procedure DrillMe( mena : string; aRow : integer ); var r : integer; begin Sheet.BeginUpdate; r:=aRow+1; while (Sheet.CellProperty[2,r].Tag=0) and (r<Sheet.RowCount) do begin If Sheet.Rows[r].Visible then Sheet.Rows[r].Visible:=False else Sheet.Rows[r].Visible:=True; inc(r); end; Sheet.EndUpdate; end;
procedure MenaDblClick(Sender : TCellProperty); begin DrillMe(Value,Sheet.Row); end;
begin
end. |