我没有采用TSocketConnection控件。
我的代码如下:
Server端定义:
TRate = class(TAutoObject, IRate)
protected
procedure AddRate(const StartDate, EndDate, Rate, DepositType: WideString);
safecall;
procedure DeleteRate(const StartDate, EndDate, Rate, DepositType: WideString); safecall;
procedure UpdateRate(const OldStartDate, OldEndDate, OldRate,
OldDepositType, NewStartDate, NewEndDate, NewRate,
NewDepositType: WideString); safecall;
procedure GetAllRate(out aAllRate: OleVariant); safecall;
procedure GetRate(const StartDate, Rate, DepositType: WideString;
out EndDate: OleVariant); safecall;
{ Protected declarations }
end;
客户端部分代码:
unit ufrmGetAllRate;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uframeGetAllRate, uframeNavigator, Menus;
type
TfrmRate = class(TForm)
frameGetAllRate1: TframeGetAllRate;
frameNavigator1: TframeNavigator;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure frameNavigator1Action5Execute(Sender: TObject);
procedure frameNavigator1Action1Execute(Sender: TObject);
procedure frameNavigator1Action2Execute(Sender: TObject);
procedure frameNavigator1Action3Execute(Sender: TObject);
procedure frameGetAllRate1sgRateDblClick(Sender: TObject);
procedure frameNavigator1Action2Update(Sender: TObject);
procedure frameNavigator1Action3Update(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmRate: TfrmRate;
implementation
uses ufrmModifyRate, BankServer_TLB;
{$R *.dfm}
procedure TfrmRate.FormCreate(Sender: TObject);
begin
frameGetAllRate1.ShowAllRate ;
end;
procedure TfrmRate.FormClose(Sender: TObject; var Action: TCloseAction);
begin
frmRate := nil;
Action := cafree;
end;
procedure TfrmRate.frameNavigator1Action5Execute(Sender: TObject);
begin
Close;
end;
procedure TfrmRate.frameNavigator1Action1Execute(Sender: TObject);
var
s:string;
begin
s:= '';
if not assigned(frmModifyRate) then
frmModifyRate := TfrmModifyRate.Create(Application);
frmModifyRate.Caption := '增加新利率';
frmModifyRate.frameModifyRate1.InitRate(s,s,s,s);
frmModifyRate.ShowModal;
frameGetAllRate1.ShowAllRate ;
end;
procedure TfrmRate.frameNavigator1Action2Execute(Sender: TObject);
var
StartDate,EndDate,Rate,DepositType:String;
begin
if not assigned(frmModifyRate) then
frmModifyRate := TfrmModifyRate.Create(Application);
frmModifyRate.Caption := '修改利率信息';
StartDate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][0];
EndDate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][1];
Rate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][2];
DepositType := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][3];
frmModifyRate.frameModifyRate1.InitRate(StartDate,EndDate,Rate,DepositType);
frmModifyRate.ShowModal;
frameGetAllRate1.ShowAllRate ;
end;
procedure TfrmRate.frameNavigator1Action3Execute(Sender: TObject);
var
StartDate,EndDate,Rate,DepositType:String;
cRate:IRate;
begin
if messagedlg('您确认要删除此利率信息?',mtwarning,[mbYes,mbNo],0)=mrYes then
begin
StartDate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][0];
EndDate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][1];
Rate := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][2];
DepositType := frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][3];
cRate := CoRate.Create;
cRate.DeleteRate(StartDate,EndDate,Rate,DepositType);
frameGetAllRate1.ShowAllRate ;
end;
end;
procedure TfrmRate.frameGetAllRate1sgRateDblClick(Sender: TObject);
begin
frameNavigator1Action2Execute(Sender);
end;
procedure TfrmRate.frameNavigator1Action2Update(Sender: TObject);
begin
frameNavigator1.Action2.Enabled := (trim(frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][0])<>'')
end;
procedure TfrmRate.frameNavigator1Action3Update(Sender: TObject);
begin
frameNavigator1.Action3.Enabled := (trim(frameGetAllRate1.sgRate.Rows[frameGetAllRate1.sgRate.Row][0])<>'')
end;
end.