var
r_id :string;
begin
if Qry.FieldByName('code1').AsString<>'' then
begin
if (Application.MessageBox('確認刪除?', '提示', MB_YESNO+mb_iconinformation)=IDYES) then
begin
r_id:=Qry.fieldByName('id').AsString;
del_ado.Connection.BeginTrans;
try
with del_ado do
begin
del_ado.Close;
del_ado.SQL.Clear();
del_ado.SQL.Add('delete from u_qianyue where r_id='''+r_id+'''');
del_ado.ExecSQL;
del_ado.SQL.Clear();
//刪除完u_qianyue表中的記錄後,更新u_report表中的簽約日期和過戶日期為空
del_ado.SQL.Add('update u_report set bargain_date = null,register_date = null where id='''+r_id+'''');
del_ado.ExecSQL;
showmessage('刪除成功!');
del_ado.Connection.CommitTrans;
btnQueryClick(self);
end;
except
on E: Exception do
begin
del_ado.Connection.RollbackTrans; //如有異常,事務回滾
ShowMessage(E.Message);
end
end;
{ try
del_ado.Connection.BeginTrans;//.begainTrans; //BeginTransComplete
//on Error Goto ErrNum
del_ado.Close;
del_ado.SQL.Clear();
del_ado.SQL.Add('delete from u_qianyue where r_id='''+r_id+'''');
del_ado.ExecSQL;
del_ado.SQL.Clear();
//刪除完u_qianyue表中的記錄後,更新u_report表中的簽約日期和過戶日期為空
del_ado.SQL.Add('update u_report set bargain_date = null,register_date = null where id='''+r_id+'''');
del_ado.ExecSQL;
showmessage('刪除成功!');
del_ado.Connection.CommitTrans;
btnQueryClick(self);
except
del_ado.Connection.RollBackTrans;
end; }
end;
end;
end;