1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
{*****************************************}
{ }
{ FastReport v2.3 }
{ Fields list }
{ }
{ Copyright (c) 1998-99 by Tzyganenko A. }
{ }
{*****************************************}
unit LR_Flds;
interface
{$I LR_Vers.inc}
uses
Classes, SysUtils, LResources,
Forms, Controls, Graphics, Dialogs,
StdCtrls,LCLType;
type
{ TfrFieldsForm }
TfrFieldsForm = class(TForm)
ValCombo: TComboBox;
ValList: TListBox;
Label1: TLabel;
procedure ValComboClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
procedure ValListDblClick(Sender: TObject);
procedure ValListKeyDown(Sender: TObject; var Key: Word;
{%H-}Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word;
{%H-}Shift: TShiftState);
procedure ValListSelectionChange(Sender: TObject; {%H-}User: boolean);
private
{ Private declarations }
procedure FillValCombo;
procedure UpdateDBField;
public
{ Public declarations }
DBField: String;
end;
var
frFieldsForm: TfrFieldsForm;
implementation
{$R *.lfm}
uses LR_Class, LR_Const, LR_Utils, LR_DBRel, DB;
var
LastDB: String;
procedure TfrFieldsForm.ValListKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_Return then
begin
UpdateDBField;
ModalResult := mrOk;
end;
end;
procedure TfrFieldsForm.FillValCombo;
var
Lst : TStringList;
begin
Lst := TStringList.Create;
try
if Curreport.DataType = dtDataSet then
frGetComponents(CurReport.Owner, TDataSet, Lst, nil)
else
frGetComponents(CurReport.Owner, TDataSource, Lst, nil);
Lst.Sort;
ValCombo.Items.Assign(Lst);
ValCombo.Enabled:=(Lst.Count>0);
finally
Lst.Free;
end;
end;
procedure TfrFieldsForm.UpdateDBField;
begin
if ValCombo.Items.Count>0 then
begin
LastDB := ValCombo.Items[ValCombo.ItemIndex];
if ValList.ItemIndex <> -1 then
DBField:=LastDB + '."' + ValList.Items[ValList.ItemIndex] + '"';
end
else DBField:='';
end;
procedure TfrFieldsForm.ValComboClick(Sender: TObject);
var
DataSet: TfrTDataSet;
begin
ValList.Items.Clear;
if ValCombo.Items.Count>0 then
begin
DataSet := nil;
DataSet := frGetDataSet(ValCombo.Items[ValCombo.ItemIndex]);
if Assigned(DataSet) then
begin
try
frGetFieldNames(DataSet, ValList.Items);
except
end;
end;
end;
end;
procedure TfrFieldsForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_Escape then
ModalResult := mrCancel;
end;
procedure TfrFieldsForm.ValListSelectionChange(Sender: TObject; User: boolean);
begin
{ if User then
begin
UpdateDbField;
if DBField<>'' then
ModalResult := mrOk;
end;}
end;
procedure TfrFieldsForm.FormCreate(Sender: TObject);
begin
Caption := sFieldsFormInsert;
Label1.Caption := sFieldsFormAviableDB;
end;
procedure TfrFieldsForm.FormActivate(Sender: TObject);
begin
FillValCombo;
if ValCombo.Items.Count>0 then
begin
if ValCombo.Items.IndexOf(LastDB) <> -1 then
ValCombo.ItemIndex := ValCombo.Items.IndexOf(LastDB)
else
ValCombo.ItemIndex := 0;
ValComboClick(nil);
end;
end;
procedure TfrFieldsForm.FormDeactivate(Sender: TObject);
begin
//UpdateDBField;
end;
procedure TfrFieldsForm.ValListDblClick(Sender: TObject);
begin
UpdateDbField;
if DBField<>'' then
ModalResult := mrOk;
end;
end.
|