var
i: integer;
begin
QRbjd := TQRbjd.Create(self);
try
i := 18;
BDE1.Close;
BDE1.CommandText := ' select count(*) from T_BJDMXB where BJDH=''' + Trim(bjdh.Text) + '''';
BDE1.Open;
if BDE1.RecordCount < 18 then
begin
for i := 1 to 18 - BDE1.RecordCountdo
begin
BDE2.Close;
BDE2.CommandText := ' insert into T_BJDMXB(BJDH,BJ) values(''' + Trim(bjdh.Text) + ''',1) ';
BDE2.Execute;
end;
end;
if BDE1.RecordCount > 18 then
begin
for i := 1 to 18 - (BDE1.RecordCount mod 18)do
begin
BDE2.Close;
BDE2.CommandText := ' insert into T_BJDMXB(BJDH,BJ) values(''' + Trim(bjdh.Text) + ''',1) ';
BDE2.Execute;
end;
end;
BDEBJMX.Close;
BDEBJMX.CommandText := ' select * from T_BJDMXB where BJDH=''' + Trim(bjdh.Text) + ''' ';
BDEBJMX.Open;
QRbjd.Preview;
finally
QRbjd.Free;
QRbjd := nil;
end;
BDE2.Close;
BDE2.CommandText := ' delete from T_BJDMXB where BJDH=''' + Trim(bjdh.Text) + ''' and BJ=''1'' ';
BDE2.Execute;
BDEBJMX.Close;
BDEBJMX.CommandText := ' select * from T_BJDMXB where BJDH=''' + Trim(bjdh.Text) + ''' ';
BDEBJMX.Open;
这段程序是打印18行,在要打印的表中添加BJ字段,不足18行的就向表中添加空记录。