fdbdemoclient2.~pas
来自「Delphi开发webservice的一套例子」· ~PAS 代码 · 共 133 行
~PAS
133 行
unit fDBDemoClient2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, StdCtrls, dbcgrids, ComCtrls, DBCtrls, Mask, Buttons;
type
TForm3 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
DBCtrlGrid1: TDBCtrlGrid;
Label1: TLabel;
edtSQL: TEdit;
dsDemo2: TDataSource;
Label2: TLabel;
DBEdit1: TDBEdit;
Label3: TLabel;
DBEdit2: TDBEdit;
Label4: TLabel;
DBEdit3: TDBEdit;
Label5: TLabel;
DBEdit4: TDBEdit;
Label6: TLabel;
DBEdit5: TDBEdit;
Label7: TLabel;
DBEdit6: TDBEdit;
Label8: TLabel;
DBEdit7: TDBEdit;
Label9: TLabel;
DBEdit8: TDBEdit;
Label10: TLabel;
DBImage1: TDBImage;
sbtnRun: TSpeedButton;
cbCategory: TComboBox;
Label11: TLabel;
CLEVEL: TLabel;
cbLevel: TComboBox;
sbtnConditions: TSpeedButton;
procedure sbtnRunClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure sbtnConditionsClick(Sender: TObject);
private
{ Private declarations }
procedure FillComboBoxes;
procedure FillCategory;
procedure FillCLevel;
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses udmDBDemo2;
{$R *.dfm}
procedure TForm3.sbtnRunClick(Sender: TObject);
begin
dmDBDemo2.cdsDemo2.DisableControls;
try
dmDBDemo2.cdsDemo2.Active := False;
dmDBDemo2.cdsDemo2.CommandText := edtSQL.Text;
dmDBDemo2.cdsDemo2.Active := True;
finally
dmDBDemo2.cdsDemo2.EnableControls;
end;
end;
procedure TForm3.FormActivate(Sender: TObject);
begin
FillComboBoxes;
end;
procedure TForm3.FillComboBoxes;
begin
FillCategory;
FillCLevel;
end;
procedure TForm3.FillCategory;
begin
if (cbCATEGORY.Items.Count = 0) then
begin
dmDBDemo2.cdsGeneral.Active := False;
dmDBDemo2.cdsGeneral.CommandText := 'Select distinct CATEGORY from BOOKS';
dmDBDemo2.cdsGeneral.Active := True;
while not dmDBDemo2.cdsGeneral.Eof do
begin
cbCATEGORY.Items.Add(dmDBDemo2.cdsGeneral.Fields[0].Value);
dmDBDemo2.cdsGeneral.Next;
end;
cbCATEGORY.ItemIndex := 0;
end;
end;
procedure TForm3.FillCLevel;
begin
if (cbLevel.Items.Count = 0) then
begin
dmDBDemo2.cdsGeneral.Active := False;
dmDBDemo2.cdsGeneral.CommandText := 'Select distinct CLEVEL from BOOKS';
dmDBDemo2.cdsGeneral.Active := True;
while not dmDBDemo2.cdsGeneral.Eof do
begin
cbLevel.Items.Add(dmDBDemo2.cdsGeneral.Fields[0].Value);
dmDBDemo2.cdsGeneral.Next;
end;
cbLevel.ItemIndex := 0;
end;
end;
procedure TForm3.sbtnConditionsClick(Sender: TObject);
begin
dmDBDemo2.cdsConditions.Active := False;
if (dmDBDemo2.cdsConditions.Params.Count = 0) then
dmDBDemo2.cdsConditions.FetchParams;
dmDBDemo2.cdsConditions.Params.ParamByName('ID1').Value :=
cbCATEGORY.Text;
dmDBDemo2.cdsConditions.Params.ParamByName('ID2').Value := 1;
dmDBDemo2.cdsConditions.Active := True;
dsDemo2.DataSet := dmDBDemo2.cdsConditions;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?