|

楼主 |
发表于 2008-4-10 16:48:40
|
显示全部楼层
代码:
unit SJWGZYJHDDB;
interface
uses
Business.System, Business.Model, Business.Forms, Business.Data;
type
TSJWGZYJHDDB = class(TFormDoc)
InfoBroker: TInfoBroker;
DataSetBrokerZYJHDDB: TDataSetBroker;
DataGrid: TDataGrid;
procedure actFixAllExecute(Sender: TObject);
private
{private declarations}
public
{public declarations}
v_jhpc:string;
v_substring:string;
procedure autofillitem;
end;
implementation
procedure TSJWGZYJHDDB.autofillitem;
var
li:integer;
begin
li:=Forms.Application.MessageBox('Text5-0','Caption',0);
//调用DisableControls方法让数据感知控件不作变化,
//只有当执行EnableControls之后才体现数据集的变化
DataSetBrokerZYJHDDB.DataSet.DisableControls;
try
li:=Forms.Application.MessageBox('Text5-1','Caption',0);
//定位到数据集的第一条记录
DataSetBrokerZYJHDDB.DataSet.First;
DataSetBrokerZYJHDDB.DataSet.First;
//判断是否到达最后一行
li:=Forms.Application.MessageBox('Text5-2','Caption',0);
while not DataSetBrokerZYJHDDB.DataSet.Eof do
begin
//数据集编辑状态
DataSetBrokerZYJHDDB.DataSet.Edit;
//给当前行的 bz 列赋值
//DataSetBrokerZYJHDDB.DataSet.FieldByName('BZ').AsString :=v_jhpc;
DataSetBrokerZYJHDDB.DataSet.FieldByName('JHPC').AsInteger:=Sysutils.StrToInt(v_jhpc);
//提交修改或者新增的记录,修改数据集状态为dsBrowse
DataSetBrokerZYJHDDB.DataSet.Post;
//移动到下一条记录
DataSetBrokerZYJHDDB.DataSet.Next;
end;
li:=Forms.Application.MessageBox('Text5-3','Caption',0);
//把本地数据集的修改提交给应用服务端
//DataSetBrokerZYJHDDB.DataSet.ApplyUpdates;
finally
//建立数据感知控件与数据集的关联
li:=Forms.Application.MessageBox('Text5-4','Caption',0);
DataSetBrokerZYJHDDB.DataSet.EnableControls;
end;
end;
procedure TSJWGZYJHDDB.actFixAllExecute(Sender: TObject);
var
li:integer;
begin
DataGrid.ApplyBestFit(nil);
v_jhpc:=Sysutils.FormatDateTime('mmdd',Business.System.SysUtils.Now)+
Sysutils.FormatDateTime('hhnnss',Business.System.SysUtils.Time);
v_substring:=v_jhpc.Substring(0,2);
if Sysutils.StrToInt(v_substring)<10 then
v_jhpc:='1'+v_jhpc.Substring(1)
else
v_jhpc:='2'+v_jhpc.Substring(1);
li:=Forms.Application.MessageBox('Text5','Caption',0);
autofillitem;
li:=Forms.Application.MessageBox('Text6','Caption',0);
DataSetBrokerZYJHDDB.DataSet.First;
li:=Forms.Application.MessageBox('Text7','Caption',0);
DataSetBrokerZYJHDDB.DataSet.FieldByName('JHXH').FocusControl;
end;
end. |
|