M
mark_du
Unregistered / Unconfirmed
GUEST, unregistred user!
使用下列代碼發生錯誤﹕Row cannot be located for updating,Some values may have benn changed since it was last read!
源代碼絕確業沒有問題﹗
with SelectKq do
begin
first;
repeat
edit;
fDate:=FieldByName('wkdate').AsDateTime;
i:=strToint(formatDateTime('dd',fDate));
wkno := Fieldbyname('fwkno').asstring;
yyyymm :=MaskEdit1.text;
if i = 1 then //清除已有記錄
begin
DelRecDaily.SQL.Text := 'delete from EntryDaily where code ='+wkno+' and yyyymm = '+yyyymm;
DelRecDaily.Prepared;
DelRecDaily.ExecSQL;
end;
{EntryTable.close;
EntryTable.Parameters.ParamByName('yyyymm').value := trim(MaskEdit1.text);
EntryTable.Prepared;
EntryTable.open;}
EntryTable.Refresh;
if EntryTable.locate('code;yyyymm',VarArrayOf([wkno,yyyymm]),[loCaseInsensitive]) then
begin
EntryTable.edit;
EntryTable.FieldByName('f'+inttostr(i)+'1').AsString:=FieldByName('book_on').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'2').AsString:=FieldByName('lunch_out').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'3').AsString:=FieldByName('lunch_in').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'4').AsString:=FieldByName('book_off').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'5').AsString:=FieldByName('atime11').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'6').AsString:=FieldByName('atime21').AsString;
EntryTable.fieldByName('addtime').Asinteger:=EntryTable.fieldByName('addtime').Asinteger+fieldByName('addtime').Asinteger;
EntryTable.fieldByName('worktime').AsFloat:=EntryTable.fieldByName('worktime').Asinteger+fieldByName('worktime').Asinteger;
EntryTable.post;
end
else
begin
EntryTable.Insert;
EntryTable.FieldByName('code').AsString:=FieldByName('fwkno').AsString;
EntryTable.FieldByName('name').AsString:=FieldByName('fname').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'1').AsString:=FieldByName('book_on').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'2').AsString:=FieldByName('lunch_out').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'3').AsString:=FieldByName('lunch_in').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'4').AsString:=FieldByName('book_off').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'5').AsString:=FieldByName('atime11').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'6').AsString:=FieldByName('atime21').AsString;
EntryTable.fieldByName('addtime').Asinteger:=EntryTable.fieldByName('addtime').Asinteger+fieldByName('addtime').AsInteger;
EntryTable.fieldByName('worktime').Asinteger:=EntryTable.fieldByName('worktime').AsInteger+fieldByName('worktime').AsInteger;
EntryTable.FieldByName('yyyymm').asstring := yyyymm;
EntryTable.post;
end;
next;
Gauge1.position :=Gauge1.position+1;
until eof;
源代碼絕確業沒有問題﹗
with SelectKq do
begin
first;
repeat
edit;
fDate:=FieldByName('wkdate').AsDateTime;
i:=strToint(formatDateTime('dd',fDate));
wkno := Fieldbyname('fwkno').asstring;
yyyymm :=MaskEdit1.text;
if i = 1 then //清除已有記錄
begin
DelRecDaily.SQL.Text := 'delete from EntryDaily where code ='+wkno+' and yyyymm = '+yyyymm;
DelRecDaily.Prepared;
DelRecDaily.ExecSQL;
end;
{EntryTable.close;
EntryTable.Parameters.ParamByName('yyyymm').value := trim(MaskEdit1.text);
EntryTable.Prepared;
EntryTable.open;}
EntryTable.Refresh;
if EntryTable.locate('code;yyyymm',VarArrayOf([wkno,yyyymm]),[loCaseInsensitive]) then
begin
EntryTable.edit;
EntryTable.FieldByName('f'+inttostr(i)+'1').AsString:=FieldByName('book_on').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'2').AsString:=FieldByName('lunch_out').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'3').AsString:=FieldByName('lunch_in').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'4').AsString:=FieldByName('book_off').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'5').AsString:=FieldByName('atime11').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'6').AsString:=FieldByName('atime21').AsString;
EntryTable.fieldByName('addtime').Asinteger:=EntryTable.fieldByName('addtime').Asinteger+fieldByName('addtime').Asinteger;
EntryTable.fieldByName('worktime').AsFloat:=EntryTable.fieldByName('worktime').Asinteger+fieldByName('worktime').Asinteger;
EntryTable.post;
end
else
begin
EntryTable.Insert;
EntryTable.FieldByName('code').AsString:=FieldByName('fwkno').AsString;
EntryTable.FieldByName('name').AsString:=FieldByName('fname').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'1').AsString:=FieldByName('book_on').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'2').AsString:=FieldByName('lunch_out').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'3').AsString:=FieldByName('lunch_in').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'4').AsString:=FieldByName('book_off').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'5').AsString:=FieldByName('atime11').AsString;
EntryTable.FieldByName('f'+inttostr(i)+'6').AsString:=FieldByName('atime21').AsString;
EntryTable.fieldByName('addtime').Asinteger:=EntryTable.fieldByName('addtime').Asinteger+fieldByName('addtime').AsInteger;
EntryTable.fieldByName('worktime').Asinteger:=EntryTable.fieldByName('worktime').AsInteger+fieldByName('worktime').AsInteger;
EntryTable.FieldByName('yyyymm').asstring := yyyymm;
EntryTable.post;
end;
next;
Gauge1.position :=Gauge1.position+1;
until eof;