lazarus/components/lazreport/source/lr_dbrel.pas
jesus 118cc819c4 LazReport: New big patch from Alexey Lagunov (with small changes)
-------------------------------------------------------
Addfunction / frFuncStr
  - Fixed string functions - accounted for UTF8 strings

DialogControls
  - Fixed reports generation with built-in query mode, MDI (multiple reports open for viewing at the same time)
  - Fixed UNDO in editor
  - Added property HINT for dialog controls
  - A new component - TlrRadioGroup

lrOfficeImport
  - New tool reports designer to import data from a spreadsheet as a report template

source
  - The object TfrMemoView added new handlers
    - OnClick - Event when you click on TfrMemoView in playback mode built reports
    - OnMouseEnter - Event at the Enter of the mouse over TfrMemoView in playback mode built reports
    - OnMouseLeave - Event at the Leave of the mouse TfrMemoView in playback mode built reports

  - The object TfrMemoView added new properties
    - Cursor - the mouse cursor when moving over TfrMemoView in playback mode built reports
    - DetailReport - a reference to the detail-report - called when the user clicks the mouse on TfrMemoView in playback mode built reports

  - A mechanism to detail-report - call a detailed report of the current report
  - In ineterpretatore added new features (for compatibility with FastReport 2.5):
      - FINALPASS
      - CURY
      - PAGEHEIGH
      - PAGEWIDTH
  - In the reports, the editor started saving paramerov editor (the location of the Object Inspector, fonts)
  - In the reports, the editor corrected the addition of new tools (implemented a new tool - Import report template from excel/OpenOffice)
  - Editor of reports finalized Inspector data - now you can also insert variables
  - For export to txt implemented request form export options

images
  - Made in the resources icon tool insert fields in a report from the editor

Demo included (detail_reports)

And new extensions:
- import report template from calc/excel
- send email from report preview (for sending used local mail app, installed on user PC - in windows its TheBat! and Mozilla Thunderbird).
  In future I'm plan make direct send.

git-svn-id: trunk@46079 -
2014-08-28 04:10:20 +00:00

140 lines
3.3 KiB
ObjectPascal

{*****************************************}
{ }
{ FastReport v2.3 }
{ DB related stuff }
{ }
{ Copyright (c) 1998-99 by Tzyganenko A. }
{ }
{*****************************************}
unit LR_DBRel;
interface
{$I LR_Vers.inc}
uses
SysUtils, Classes, DB;
const
frEmptyBookmark = nil;
type
{ TODO -oalexs : Remove this }
TfrBookmark = TBookmark;
TfrTDataSet =class(TDataSet);
TfrTField = class(TField);
TfrTBlobField = class(TBlobField);
function frIsBlob(Field: TfrTField): Boolean;
function frIsBookmarksEqual(DataSet: TfrTDataSet; b1, b2: TfrBookmark): Boolean;
procedure frGetFieldNames(DataSet: TfrTDataSet; List: TStrings);
function frGetBookmark(DataSet: TfrTDataSet): TfrBookmark;
procedure frFreeBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
procedure frGotoBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
function frGetDataSource(Owner: TComponent; d: TDataSet): TDataSource;
function lrGetFieldValue(F:TField):Variant;
const
TypeStringField = [ftString, ftMemo, ftFmtMemo, ftFixedChar, ftWideString,
ftFixedWideChar, ftWideMemo];
TypeNumericField = [ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,
ftTimeStamp];
TypeIntegerField = [ftSmallint, ftInteger, ftWord, ftAutoInc, ftLargeint];
TypeBooleanField = [ftBoolean];
implementation
uses LR_Utils;
function frIsBlob(Field: TfrTField): Boolean;
begin
Result := (Field <> nil) and (Field.DataType in [ftBlob..ftTypedBinary]);
end;
procedure frGetFieldNames(DataSet: TfrTDataSet; List: TStrings);
begin
if not Assigned(DataSet) then exit;
if DataSet.FieldCount > 0 then
DataSet.GetFieldNames(List)
else
begin
{ DataSet.Open;
DataSet.GetFieldNames(List);
DataSet.Close;}
DataSet.FieldDefs.Update;
DataSet.FieldDefs.GetItemNames(List);
end;
end;
function frGetBookmark(DataSet: TfrTDataSet): TfrBookmark;
begin
Result := DataSet.GetBookmark;
end;
procedure frGotoBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
begin
DataSet.GotoBookmark(BookMark);
end;
function frGetDataSource(Owner: TComponent; d: TDataSet): TDataSource;
var
i: Integer;
sl: TStringList;
ds: TDataSource;
begin
sl := TStringList.Create;
Result := nil;
frGetComponents(Owner, TDataSource, sl, nil);
for i := 0 to sl.Count - 1 do
begin
ds := frFindComponent(Owner, sl[i]) as TDataSource;
if (ds <> nil) and (ds.DataSet = d) then
begin
Result := ds;
break;
end;
end;
sl.Free;
end;
function lrGetFieldValue(F: TField): Variant;
begin
if Assigned(F) then
begin
if F.IsNull then
begin
if F.DataType in TypeStringField then
Result:=''
else
if F.DataType in (TypeIntegerField + TypeNumericField) then
Result:=0
else
if F.DataType in TypeBooleanField then
Result:=false
else
Result:=null
end
else
Result:=F.Value;
end
else
Result:=null;
end;
procedure frFreeBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
begin
DataSet.FreeBookmark(BookMark);
end;
function frIsBookmarksEqual(DataSet: TfrTDataSet; b1, b2: TfrBookmark): Boolean;
begin
Result := DataSet.CompareBookmarks(b1, b2) = 0;
end;
end.