📄 clientunit.pas
字号:
// Direct Oracle Access - Client
// Allround Automations
// support@allroundautomations.nl
// http://www.allroundautomations.nl
//
// This application demonstrates:
// - The Client part of a 3 Tier application
// - Interfacing to the TOracleProvider component
// - Using variables to create a master/detail relation
unit ClientUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, DBCtrls, Grids, DBGrids, Db, DBClient, Buttons, ReconcileUnit,
ComCtrls;
type
TMainForm = class(TForm)
RemoteServer: TRemoteServer;
DeptClientDataSet: TClientDataSet;
EmpClientDataSet: TClientDataSet;
DeptDataSource: TDataSource;
EmpDataSource: TDataSource;
StatusBar: TStatusBar;
EmpPanel: TPanel;
EmpTopPanel: TPanel;
EmpApplyBtn: TSpeedButton;
EmpDBNavigator: TDBNavigator;
EmpDBGrid: TDBGrid;
DeptPanel: TPanel;
DeptTopPanel: TPanel;
DeptDBNavigator: TDBNavigator;
DeptApplyBtn: TSpeedButton;
DeptDBGrid: TDBGrid;
EmpCancelBtn: TSpeedButton;
DeptCancelBtn: TSpeedButton;
procedure DeptApplyBtnClick(Sender: TObject);
procedure EmpApplyBtnClick(Sender: TObject);
procedure DeptClientDataSetReconcileError(DataSet: TClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
procedure EmpClientDataSetReconcileError(DataSet: TClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
procedure DeptClientDataSetAfterScroll(DataSet: TDataSet);
procedure EmpCancelBtnClick(Sender: TObject);
procedure DeptCancelBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
procedure TMainForm.FormCreate(Sender: TObject);
begin
DeptClientDataSet.Active := True;
EmpClientdataSet.Active := True;
end;
// Apply the updates in the dept table
procedure TMainForm.DeptApplyBtnClick(Sender: TObject);
begin
DeptClientDataSet.ApplyUpdates(1);
end;
// Apply the updates in the demp table
procedure TMainForm.EmpApplyBtnClick(Sender: TObject);
begin
EmpClientDataSet.ApplyUpdates(1);
end;
// Use the 'standard' Recondile Error Dialog for handling errors
procedure TMainForm.DeptClientDataSetReconcileError(DataSet: TClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
begin
Action := HandleReconcileError(DataSet, UpdateKind, E);
end;
procedure TMainForm.EmpClientDataSetReconcileError(DataSet: TClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
begin
Action := HandleReconcileError(DataSet, UpdateKind, E);
end;
// Use the AfterScroll event to make the master/detail link
procedure TMainForm.DeptClientDataSetAfterScroll(DataSet: TDataSet);
begin
EmpClientDataSet.Provider.SetParams(DeptClientDataSet.FieldByName('DEPTNO').Value);
if EmpClientDataSet.Active then EmpClientDataSet.Refresh;
end;
// Cancel the updates
procedure TMainForm.EmpCancelBtnClick(Sender: TObject);
begin
EmpClientDataSet.CancelUpdates;
end;
procedure TMainForm.DeptCancelBtnClick(Sender: TObject);
begin
DeptClientDataSet.CancelUpdates;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -