Не вижу Источников данных
Проблема заключается в том что я не вижу в дизайнере Источников данных, хотя объектам датасет присвоил свойство name. Этот пример работал когда я использовал визуальный компонент Form и все объекты FastReport лежали на этой форме , а датасеты я объявлял и создавал вручную. Может что посоветуете, буду очень приззнателен.
В качесnве датасет использовал библу VKDBFNTX
Ниже привожу код
В качесnве датасет использовал библу VKDBFNTX
Ниже привожу код
unit uReport;
interface
uses
Classes, Dialogs, DB, VKDBFDataSet, VKDBFIndex, VKDBFNTX, Variants, uDM,
SysUtils, FR_DSet, FR_DBSet, FR_Desgn, FR_Class, Dbtables;
type
TStatReport = class(TComponent)
FormReport: TfrReport;
FormDesigner: TfrDesigner;
s07frDBDataSet: TfrDBDataSet;
mtsfrDBDataSet: TfrDBDataSet;
totalfrDBDataSet: TfrDBDataSet;
ktcfrDBDataSet: TfrDBDataSet;
procedure Execute;
private
{ Private declarations }
protected
end;
implementation
procedure TStatReport.Execute;
var
s07total, mtstotal, ktc, ttr, total: TVKDBFNTX;
dsKtc: TDataSource;
begin
s07total := TVKDBFNTX.Create(Self);
mtstotal := TVKDBFNTX.Create(Self);
ktc := TVKDBFNTX.Create(Self);
ttr := TVKDBFNTX.Create(Self);
total := TVKDBFNTX.Create(Self);
FormReport := TfrReport.Create(Self);
s07frDBDataSet := TfrDBDataSet.Create(Self);
mtsfrDBDataSet := TfrDBDataSet.Create(Self);
totalfrDBDataSet := TfrDBDataSet.Create(Self);
ktcfrDBDataSet := TfrDBDataSet.Create(Self);
dsKtc := TDataSource.Create(Self);
with ttr do begin
DBFFileName := 'ref_ttr.dbf';
OEM := True;
Name := 'ttr';
AccessMode.AccessMode := 66;
Open;
with Indexes.Add as TVKNTXIndex do begin
NTXFileName := 'ttr.ntx';
KeyExpresion := 'chrold';
CreateIndex(True);
end;
end;
with total do begin
DBFFileName := 'total.dbf';
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'NAME';
field_type := 'C'; //Standard Dbase III type
len := 25;
end;
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'KTG';
field_type := 'C'; //Standard Dbase III type
len := 1;
end;
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'TYP';
field_type := 'C'; //Standard Dbase III type
len := 1;
end;
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'KOLV';
field_type := 'N'; //Standard Dbase III type
len := 10;
end;
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'MINUTE';
field_type := 'N'; //Standard Dbase III type
len := 10;
end;
with DBFFieldDefs.Add as TVKDBFFieldDef do begin
Name := 'SUMM';
field_type := 'N'; //Standard Dbase III type
len := 10;
dec := 2;
end;
CreateTable;
AccessMode.AccessMode := 66;
OEM := True;
Name := 'total';
/// AfterScroll := TotalAfterScroll;
Open;
with Indexes.Add as TVKNTXIndex do begin
NTXFileName := 'total.ntx';
KeyExpresion := 'KTG+TYP';
CreateIndex(True);
end;
end;
with mtstotal do begin
DBFFileName := 'mtstotal.dbf';
Name := 'mtstotal';
OEM := True;
AccessMode.AccessMode := 66;
// AfterScroll := MtsTotalAfterScroll;
with DBFIndexDefs.Add as TVKNTXBag do IndexFileName := 'mtstotal.ntx';
Open;
end;
with s07total do begin
DBFFileName := 's07total.dbf';
Name := 's07total';
OEM := True;
// AfterScroll := S07TotalAfterScroll;
AccessMode.AccessMode := 66;
with DBFIndexDefs.Add as TVKNTXBag do IndexFileName := 's07total.ntx';
Open;
end;
with ktc do begin
DBFFileName := 'ref_ktc.dbf';
Name := 'ktc';
OEM := True;
AccessMode.AccessMode := 66;
Open;
end;
while not mtstotal.Eof do begin
total.AppendRecord([Null,
mtstotal.FieldByName('KTG').AsString,
mtstotal.FieldByName('TYP').AsString,
mtstotal.FieldByName('KOLV').AsInteger,
mtstotal.FieldByName('MINUTE').AsInteger,
mtstotal.FieldByName('SUMM').AsVariant]);
mtstotal.Next;
end;
while not s07total.Eof do begin
if total.FindKey([s07total.FieldByName('KTG').AsString+s07total.FieldByName('TYP').AsString]) then begin
total.Edit;
total.FieldByName('KOLV').AsInteger := total.FieldByName('KOLV').AsVariant +
s07total.FieldByName('KOLV').AsVariant;
total.FieldByName('MINUTE').AsInteger := total.FieldByName('MINUTE').AsVariant +
s07total.FieldByName('MINUTE').AsVariant;
total.FieldByName('SUMM').AsVariant := total.FieldByName('SUMM').AsVariant +
s07total.FieldByName('SUMM').AsVariant;
total.Post;
end
else begin
total.AppendRecord([Null,
s07total.FieldByName('KTG').AsString,
s07total.FieldByName('TYP').AsString,
s07total.FieldByName('KOLV').AsInteger,
s07total.FieldByName('MINUTE').AsInteger,
s07total.FieldByName('SUMM').AsVariant]);
end;
s07total.Next;
end;
dsKtc.DataSet := ktc;
mtstotal.DataSource := dsKtc;
mtstotal.MasterFields := 'KTG';
s07total.DataSource := dsKtc;
s07total.MasterFields := 'KTG';
total.DataSource := dsKtc;
total.MasterFields := 'KTG';
mtsfrDBDataSet.DataSet := mtstotal;
mtsfrDBDataSet.Name := 'mtsfrDBDataSet';
s07frDBDataSet.DataSet := s07total;
ktcfrDBDataSet.DataSet := ktc;
totalfrDBDataSet.DataSet := total;
if FormReport.LoadFromFile('c:\myprog\stat\fr.frf') then
FormReport.DesignReport;
FreeAndNIl(s07total);
FreeAndNIl(mtstotal);
FreeAndNIl(ktc);
FreeAndNIl(ttr);
end;
end.
Комментарии