请看如下代码
function Tdm.TranNoProtection(TranNozz:string):boolean;
var
TranNoProtectionquery1:TZMysqlquery;
TranNoName:string;
begin
if TranNozz='' then ReSult:=true;
TranNoName:=TranNozz;
TranNoProtectionQuery1:=TZMysqlQuery.Create(nil);
with TranNoProtectionQuery1 do begin
TranNoProtectionQuery1.Database:=dm.ZMySqlDatabase1;
TranNoProtectionQuery1.Transaction :=dm.ZMySqlTransact1;
SQl.Clear;
SQL.Add('select * from trannoprotection where TranNo=:var1');
ParamByName('Var1').value:=TranNoName;
Active:=True;
end;
if TranNoProtectionQuery1.eof and TranNoProtectionQuery1.bof then
begin
ReSult:=true;
//save date
end
else
begin
if (abs(strtofloat(formatdatetime('hh',now))-strtofloat(formatdatetime('hh',TranNoProtectionQuery1.fieldbyname('date1').asdatetime)))>1 ) then
begin
ReSult:=true
end
else
begin
ReSult:=false
end;
end
end;
procedure Tdm.SaveTranNoProtection( TranNozz:string );
var
TranNoName:string;
begin
if TranNozz='' then Exit;
TranNoName:= TranNozz;
dm.tbTranNoProtection.open;
DM.tbTranNoProtection.append;
dm.tbTranNoProtection.fieldbyname('TranNo').asstring:= TranNoName ;
dm.tbTranNoProtection.fieldbyname('date1').asdatetime:=now;
CommitData(DM.tbTranNoProtection);
end ;
procedure TDM.DeleteTranNoProtection(TranlNozz:string );
var
TranNoProtectionquery100:TZMysqlquery;
TranlNoName:string;
begin
if TranlNozz='' then exit;
TranNoProtectionquery100:=TZMysqlquery.CREATE(NIL) ;
TranlNoName:=TranlNozz;
TranNoProtectionquery100.Database:=dm.ZMySqlDatabase1;
TranNoProtectionquery100.Transaction:=dm.ZMySqlTransact1;
TranNoProtectionquery100.SQL.Add('DELETE FROM trannoprotection WHERE TranNo=:VAR1') ;
TranNoProtectionQUERY100.ParamByName('VAR1').value:=TranlNozz;
TranNoProtectionquery100.ExecSQL ;
TranNoProtectionquery100.Close ;
TranNoProtectionquery100.Free;
end;
在修改时调用的,每张单或都每个记录都有他的关键字,把关键字写进
function Tfrmoutfinished.RecordProtection:boolean;
begin
if DM.TranNoProtection(dbedit2.text) then
begin
DM.SaveTranNoProtection(dbedit2.text);
Result := False;
end
else
begin
MessageDlg(Msg5, mtInformation, [mbYes, mbNo], 0);
Result := True;
end;
end;
在close时
if (KK=False) and (EditorAppend=2) then
dm.deleteTranNoProtection(DBEdit2.text);
kk:boolean;用于记录它是什么状态。
加分!我要加分