3. Kompletní skript bez komentářů |
Top Previous Next |
procedure Drill(const Order : integer); var Query : TQuery; r : integer; begin Sheet.BeginUpdate;
Query:=TQuery.Create(nil); with Query do try DatabaseName :=DefaultDatabaseName; SQL.Text:= 'SELECT mzosobnikarty.prijmeni+'' ''+mzosobnikarty.jmeno as clovek, '+ 'nemoc.rok_id,nemoc.rodne_cislo_id,nemoc.osobni_cislo_id,nemoc.neschopen_od,nemoc.neschopen_do '+ 'FROM DBA.mznemoc2009 as nemoc,DBA.mzosobnikarty '+ 'WHERE rok_id=nemoc.rok_id and rodne_cislo_id=id_rodne_cislo and '+ 'nemoc.data_id=mzosobnikarty.data_id and '+ '(nemoc.data_id = ggetdataid() or ggetdataid()>=999) '+ 'and (YMD(nemoc.rok_id,nemoc.proplatit_M,1)>=:qvar_date1 and '+ 'YMD(nemoc.rok_id,nemoc.proplatit_M,1)<=:qvar_date2) ';
If order=0 then SQL.Text:=SQL.Text+ 'ORDER BY rok_id, osobni_cislo_id, id_poradi '; If order=1 then SQL.Text:=SQL.Text+ 'ORDER BY rok_id, clovek ';
Params.ParamByName('qvar_date1').AsDate:=StrToDate(Sheet.CellByName('C2')); Params.ParamByName('qvar_date2').AsDate:=StrToDate(Sheet.CellByName('C3'));
Open;
r:=Sheet.FixedRows+1;
while not Query.Eof do begin while Sheet.RowCount-1<r do Sheet.AddRow;
Sheet.Cells[2,r]:=Query.FieldByName('osobni_cislo_id').AsString; Sheet.MergeCells(3,r,4,r); Sheet.Cells[3,r]:=Query.FieldByName('clovek').AsString; Sheet.Cells[5,r]:=Query.FieldByName('neschopen_od').AsString; Sheet.Cells[6,r]:=Query.FieldByName('neschopen_do').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[5,r].Background:=$00bd814f;Sheet.CellProperty[5,r].Font.Color:=clWhite; Sheet.CellProperty[6,r].Background:=$00bd814f;Sheet.CellProperty[6,r].Font.Color:=clWhite;
inc(r); Query.Next; end; finally Free; end;
Sheet.EndUpdate; end;
procedure OnBeforeReport(Sender : TReportProperty); begin Sheet.RowCount:=7; Sheet.ColCount:=8; Sheet.FixedRows:=5;
Drill(0); end;
procedure ChangeOrder(Sender : TObject); begin Drill(TComponent(Sender).Tag); end;
procedure OnPrepareScript(Sender : TReportProperty); begin If Sheet.GetCellProperty('E2').CellComponent<>nil then TCheckBox(Sheet.GetCellProperty('E2').CellComponent).OnClick:=@ChangeOrder;
If Sheet.GetCellProperty('E3').CellComponent<>nil then TCheckBox(Sheet.GetCellProperty('E3').CellComponent).OnClick:=@ChangeOrder; end;
begin end. |