16,748
社区成员
发帖
与我相关
我的任务
分享
begin
clk.Port:=cbComPort.ItemIndex+1;
clk.baudrate:=StrToInt(cbComRate.Text);
clk.clock_id:=StrToInt('$'+edClock_id.Text);
ClosePort(@clk, clk.CommStyle);
if OpenPort(@clk, clk.CommStyle) then
begin
Panel5.Visible := True;
//刪除離職
WhiteList.Close;
WhiteList.SQL.Clear;
WhiteList.SQL.Add('SELECT * FROM WhiteList WHERE CardNo NOT IN(SELECT PNL FROM P_PERSON_P20140922 WHERE [Status]<>''R'')');
WhiteList.Open;
if WhiteList.RecordCount >0 then
begin
WhiteList.First;
//while not WhiteList.Eof do
for L:=0 to WhiteList.RecordCount-1 do
begin
Showmessage(WhiteList.FieldByName('CardNo').AsString);
if DeleteAllowedCard(clk.hPort,pChar(WhiteList.FieldByName('CardNo').AsString)) then //这里经常出错,有时可以有时又不行
begin
//刪除數據庫
WhiteList.Delete;
Panel5.Caption := Format('正在刪除卡機第:%d笔记录, 剩余记录数:%d(总共记录数:%d)', [WhiteList.RecNO, WhiteList.RecordCount-WhiteList.RecNO, WhiteList.RecordCount]);
Panel5.Refresh;
inc(K);
end else
begin
Showmessage('刪除失敗,無法連接!');
//break;
end;
WhiteList.Next;
end;
end;
Showmessage(Format('本次共刪除:%d笔!!',[k]));
PageControl1.Enabled := True;
Panel5.Visible :=False;
//
if ReadClockTime(clk.hPort, CurTime) then
Label5.Caption:=formatDateTime(LongDateFormat+' '+LongTimeFormat, CurTime);
end else
begin
//連接失敗
PageControl1.Enabled := True;
Panel5.Visible :=False;
//ClosePort(@clk, clk.CommStyle);
//exit;
break;
end;
ClosePort(@clk, clk.CommStyle);
end;
if WhiteList.RecordCount >0 then
begin
WhiteList.First;
//while not WhiteList.Eof do
for L:=0 to WhiteList.RecordCount-1 do
begin
Showmessage(WhiteList.FieldByName('CardNo').AsString);
if DeleteAllowedCard(clk.hPort,pChar(WhiteList.FieldByName('CardNo').AsString)) then //这里经常出错,有时可以有时又不行
begin
//刪除數據庫
WhiteList.Delete;
Panel5.Caption := Format('正在刪除卡機第:%d笔记录, 剩余记录数:%d(总共记录数:%d)', [WhiteList.RecNO, WhiteList.RecordCount-WhiteList.RecNO, WhiteList.RecordCount]);
Panel5.Refresh;
inc(K);
end else
begin
Showmessage('刪除失敗,無法連接!');
//break;
end;
WhiteList.Next;
end;
end;
改为if WhiteList.RecordCount >0 then
begin
WhiteList.Last;
while not WhiteList.Bof do
begin
Showmessage(WhiteList.FieldByName('CardNo').AsString);
if DeleteAllowedCard(clk.hPort,pChar(WhiteList.FieldByName('CardNo').AsString)) then //这里经常出错,有时可以有时又不行
begin
//刪除數據庫
WhiteList.Delete;
Panel5.Caption := Format('正在刪除卡機第:%d笔记录, 剩余记录数:%d(总共记录数:%d)', [WhiteList.RecNO, WhiteList.RecordCount-WhiteList.RecNO, WhiteList.RecordCount]);
Panel5.Refresh;
inc(K);
end else
begin
Showmessage('刪除失敗,無法連接!');
//break;
end;
WhiteList.Prior;
end;
end;
试试