P
pjxy
Unregistered / Unconfirmed
GUEST, unregistred user!
mem1中有2条记录。 (id:=1,xm_id:=1,sfje:=60)(id:=2,xm_id=3,sfje=50)
虽然cfhm返回的也是2条记录,可是数据都是第2条的数据(id:=2,xm_id:=3,sfje:=50)
我怀疑还是tlist没有用好。list总是指向最后一项成员数据。
//______________________________________________
//-----------------------------------------------
cf=record
id:integer;
xm_id:integer;
sfje:currency;
end;
var
list:tlist;
//数组
a_cf:cf;
pa:^cf;
function tf_hj.cflb:boolean;
var
//mem1 中的循环变量
i:integer;
begin
result:=false;
list:=tlist.Create ;
if mem1.RecordCount<=0 then
exit;
i:=1;
try
begin
mem1.DisableControls;
mem1.First;
while i<=mem1.RecordCount do
begin
a_cf.id :=mem1.fieldbyname('id').AsInteger;
a_cf.xm_id:=mem1.fieldbyname('xm_id').AsInteger;
a_cf.sfje :=mem1.fieldbyname('sfje').AsCurrency;
//依次将数组数据读入
pa:=@a_cf;
list.Add(pa);
inc(i);
mem1.Next;
end;
end;
finally
mem1.EnableControls;
end;
result:=true;
end;
procedure Tf_hj.BitBtn3Click(Sender: TObject);
var
i:integer;
j,k,id:integer;
s:currency;
begin
//如果处方列表没有处理就退出
if not cflb then
begin
exit;
end;
for j:=0 to list.Count-1 do
begin
with sp1 do
begin
ParamByName('@xm_id').AsInteger :=cf(list.Items[j]^).xm_id;
ParamByName('@sfje').AsCurrency :=cf(list.Items[j]^).sfje;
paramByname('@cfhm').AsString :='';
end;
sp1.ExecProc ;
cf(list.Items[j]^).cf_id:=sp1.parambyname('result').AsInteger;
cf(list.Items[j]^).cfhm :=sp1.parambyname('@cfhm').AsString;
end;
end;
虽然cfhm返回的也是2条记录,可是数据都是第2条的数据(id:=2,xm_id:=3,sfje:=50)
我怀疑还是tlist没有用好。list总是指向最后一项成员数据。
//______________________________________________
//-----------------------------------------------
cf=record
id:integer;
xm_id:integer;
sfje:currency;
end;
var
list:tlist;
//数组
a_cf:cf;
pa:^cf;
function tf_hj.cflb:boolean;
var
//mem1 中的循环变量
i:integer;
begin
result:=false;
list:=tlist.Create ;
if mem1.RecordCount<=0 then
exit;
i:=1;
try
begin
mem1.DisableControls;
mem1.First;
while i<=mem1.RecordCount do
begin
a_cf.id :=mem1.fieldbyname('id').AsInteger;
a_cf.xm_id:=mem1.fieldbyname('xm_id').AsInteger;
a_cf.sfje :=mem1.fieldbyname('sfje').AsCurrency;
//依次将数组数据读入
pa:=@a_cf;
list.Add(pa);
inc(i);
mem1.Next;
end;
end;
finally
mem1.EnableControls;
end;
result:=true;
end;
procedure Tf_hj.BitBtn3Click(Sender: TObject);
var
i:integer;
j,k,id:integer;
s:currency;
begin
//如果处方列表没有处理就退出
if not cflb then
begin
exit;
end;
for j:=0 to list.Count-1 do
begin
with sp1 do
begin
ParamByName('@xm_id').AsInteger :=cf(list.Items[j]^).xm_id;
ParamByName('@sfje').AsCurrency :=cf(list.Items[j]^).sfje;
paramByname('@cfhm').AsString :='';
end;
sp1.ExecProc ;
cf(list.Items[j]^).cf_id:=sp1.parambyname('result').AsInteger;
cf(list.Items[j]^).cfhm :=sp1.parambyname('@cfhm').AsString;
end;
end;