保存 问题?(15分)

  • 主题发起人 主题发起人 dreamya
  • 开始时间 开始时间
D

dreamya

Unregistered / Unconfirmed
GUEST, unregistred user!
请问我有这样一个问题:我用了catchupdate来对table进行操作,我想在退出系统之前判断是否将catch中的数据写入了table,如写了就退出,没有就返回,怎么完成?谢谢
 
table.UpdatesPending
If UpdatesPending is True, then there are edited, deleted, or inserted records
to apply to the database. If UpdatesPending is False, there are no records in
the cache.
 
//函数,apply=true 保存,FALSE 不存
function TDmod1.DataSetApplyUpdates(DataSet: TDataSet; Apply: Boolean): Boolean;
begin
Result := True;
with TDBDataSet(DataSet) do
begin
if (State in dsEditModes) or UpdatesPending then
begin
if Apply then
begin
Database.ApplyUpdates([DataSet as TDBDataSet]);
{ Always call CancelUpdates to remove any discard changes }
CancelUpdates;
end
else
begin
if (APPLICATION.MessageBOX('数据还没有保存,您是否要放弃?', '提示',
MB_OKCANCEL or MB_ICONINFORMATION)=IDOK) then
CancelUpdates
else
Result := False;
end;
end;
end;
end;

//调用
procedure Tfrmuseclass.BtneditClick(Sender: TObject);
begin
if Dmod1.DataSetApplyUpdates(dmod1.USECLASSTab,True) then
Application.messagebox('存盘成功了!','提示',MB_OK or MB_ICONINFORMATION)
else
Application.messagebox('存盘失败了!','提示',MB_ICONERROR);
end;
 
接受答案了.
 
后退
顶部