Unit Script;
var MyForm : TForm;
OKButton : TButton;
SaveButton : TButton;
DBEdit1:TDBEdit;
DataSource : TDataSource;
ClientDataset : TClientDataset;
PttypeEdit : TEdit;
PttypeLabel : TLabel;
PttypeNameLabel : TLabel;
DBGrid : TDBGrid;
Implementation
Procedure OKButtonClick;
begin
MyForm.close;
end;
Procedure SaveButtonClick;
begin
if ClientDataset.state = dsedit then ClientDataset.post;
if ClientDataset.changecount>0 then HOSxP_UpdateDelta(clientdataset.delta,'select * from pttype where pttype="'+PttypeEdit.text+'"');
MyForm.close;
end;
Procedure PttypeEditChange;
begin
ClientDataset.Data:=HOSxP_GetDataset('select * from pttype where pttype="'+PttypeEdit.text+'"');
SaveButton.enabled:=ClientDataset.recordcount>0;
end;
Procedure InitilizeForm;
begin
MyFORM:=TForm.create(nil);
MyForm.top:=200;
MyForm.left:=200;
MyForm.Width := 400;
MyForm.Height := 550;
MyForm.caption:='Pttype name changer version 1.0';
OKButton:=TButton.Create(MyForm);
OKButton.parent:=MyForm;
OKButton.Caption:='Close';
OKButton.left:=150;
OKButton.top:=450;
OKButton.OnClick:=OkButtonClick;
SaveButton:=TButton.Create(MyForm);
SaveButton.parent:=MyForm;
SaveButton.Caption:='Save';
SaveButton.left:=50;
SaveButton.top:=450;
SaveButton.enabled:=false;
SaveButton.OnClick:=SaveButtonClick;
DataSource:=TDataSource.create(MyForm);
ClientDataset:=TClientDataset.create(MyForm);
ClientDataset.data:=HOSxP_GetDataset('select * from pttype limit 0');
DataSource.Dataset := ClientDataset;
PttypeEdit:=TEdit.create(MyForm);
PttypeEdit.parent:=MyForm;
PttypeEdit.left:=100;
PttypeEdit.top:=20;
PttypeEdit.width:=40;
PttypeEdit.onchange:=PttypeEditChange;
PttypeLabel:=TLabel.create(MyForm);
PttypeLabel.parent:=MyForm;
PttypeLabel.caption:='ÃËÑÊÊÔ·¸Ô';
PttypeLabel.left:=20;
PttypeLabel.top:=23;
PttypeNameLabel:=TLabel.create(MyForm);
PttypeNameLabel.parent:=MyForm;
PttypeNameLabel.caption:='ª×èÍÊÔ·¸Ô';
PttypeNameLabel.left:=20;
PttypeNameLabel.top:=53;
DBEdit1:=TDBEdit.create(MyForm);
DBEdit1.parent:=MyForm;
DBEdit1.left:=100;
DBEdit1.top:=50;
DBEdit1.DataSource:=Datasource;
DBEdit1.DataField:='name';
DBGrid := TDBGrid.create(MyForm);
DBGrid.parent := MyForm;
DBGrid.top:=100;
DBGrid.left:=20;
DBGrid.datasource := Datasource;
MyForm.activecontrol := PttypeEdit;
end;
Procedure Main;
var
i:integer;
begin
InitilizeForm;
MyForm.showmodal;
MyForm.free;
end;
end.