unit Unit_QRCasesAssigned;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
qrctrls, qrprntr, ExtCtrls, QuickRpt, jpeg, Grids, StdCtrls;
type
TForm_QRCasesAssigned = class(TForm)
QuickRep1: TQuickRep;
TitleHeaderBand1: TQRBand;
ColumnHeaderBand1: TQRBand;
DetailBand1: TQRBand;
QRLabel1: TQRLabel;
QRLb_Title: TQRLabel;
QRImage1: TQRImage;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLb_FromDate: TQRLabel;
QRLb_ToDate: TQRLabel;
PageFooterBand1: TQRBand;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
procedure CreateLabels;
procedure FreeLabels;
procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
private
{ Private declarations }
public
{ Public declarations }
RowCounter,
MaxCols : integer;
ColumnLabels: array[0..29] of TQRLabel;
DataLabels: array[0..29] of TQRLabel;
QRStringGrid : TStringGrid;
end;
var
Form_QRCasesAssigned: TForm_QRCasesAssigned;
implementation
uses Unit_CasesAssigned, Unit_Main;
{$R *.DFM}
procedure TForm_QRCasesAssigned.CreateLabels;
var
nIndx: integer;
begin
QRLb_Title.caption:='Case Managment Statistics - Case Assignments';
QRLb_FromDate.caption:=DateToStr(Form_Main.DateTimePicker1.Date);
QRLb_ToDate.caption:=DateToStr(Form_Main.DateTimePicker2.Date);
with Form_CasesAssigned.StringGrid1 do
begin
nIndx:=0;
MaxCols := ColCount;
while nIndx <= MaxCols do
begin
ColumnLabels[nIndx]:=TQRLabel.Create(Self);
with ColumnLabels[nIndx] do
begin
Parent := QuickRep1.Bands.ColumnHeaderBand;
Height := Parent.Height;
AlignToBand := False;
Top := 0;
Autosize := false;
Width :=ColWidths[nIndx];
Font.Size := 8;
// Grab the captions from the StringGrid
Caption := Cells[nIndx, 0];
if nIndx = 0 then
Left := 0
else begin
Left := ColumnLabels[nIndx-1].Left + ColumnLabels[nIndx-1].Width + 2
end;
if nIndx = 0 then alignment := taCenter else
if nIndx = 1 then alignment := taLeftJustify else
alignment := taRightJustify;
DataLabels[nIndx] := TQRLabel.Create(Self);
with DataLabels[nIndx] do
begin
if nIndx = 0 then alignment := taCenter else
if nIndx = 1 then alignment := taLeftJustify else
alignment := taRightJustify;
Parent := QuickRep1.Bands.DetailBand;
Height := Parent.Height;
AlignToBand := False;
Top := 0;
Autosize := false;
// Size the detail labels to match the horizontal properties of the
// column header labels so that they line up evenly
Left := ColumnLabels[nIndx].Left;
Width := ColumnLabels[nIndx].Width;
end;
Inc(nIndx);
end;
end;
end;
end;
procedure TForm_QRCasesAssigned.FreeLabels;
var
nIdx: integer;
begin
for nIdx := 0 to 29 do
begin
if ColumnLabels[nIdx] <> nil then
begin
ColumnLabels[nIdx].Free;
ColumnLabels[nIdx] := nil;
end;
if DataLabels[nIdx] <> nil then
begin
DataLabels[nIdx].Free;
DataLabels[nIdx] := nil;
end;
end;
end;
procedure TForm_QRCasesAssigned.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
var
nIdx: integer;
begin
with Form_CasesAssigned.StringGrid1 do
begin
MoreData := RowCounter < RowCount;
// start with the first column in this row
nIdx := 0;
while nIdx <= MaxCols do
begin
with DataLabels[nIdx] do
begin
// Get the current data
Caption := Cells[nIdx, RowCounter];
end;
// Move to the next column in this row
Inc(nIdx);
end;
// Move to the next column
Inc(RowCounter);
end;
end;
procedure TForm_QRCasesAssigned.QuickRep1BeforePrint(
Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
RowCounter:=1;
end;
end.