为什么,我做的职工基本情况报表只能输出两条一样的记录(本公司只有两个员工);为什么不会出现两个不一样的记录,我用的是查询语句

解决方案 »

  1.   

    //按单位编号查询
      if state1=0 then
     with dmform.Query_zgqkbb do
      begin
       begin
         close;
         sql.Clear;
         sql.Add('select b.dwq_mc,a.grq_xm,a.grq_card,a.grq_csrq,a.grq_gzrq,a.grq_gzrq,a.grq_jfrq,a.grq_ygz,a.grq_ngz,a.grq_tzgz from grqkb a inner join dwqkb b on b.dwq_bh=a.grq_dwbh where a.grq_dwbh=:dwbh');
         params[0].AsString:=edit1.Text;
         open;
         if recordcount=0 then
          begin
            application.MessageBox('没有你要得记录!','提示',0);
            edit1.SetFocus;
            exit;
          end
         else
          begin
            zgjbform.QRLabel3.Caption:=fields[0].AsString+'的职工基本情况';
            zgjbform.QRLabel4.Caption:=fields[1].AsString;
            zgjbform.QRLabel14.Caption:=fields[2].AsString;
            zgjbform.QRLabel15.Caption:=datetostr(fields[3].AsDateTime);
            zgjbform.QRLabel16.Caption:=datetostr(fields[4].AsDateTime);
            zgjbform.QRLabel17.Caption:=datetostr(fields[5].AsDateTime);
            zgjbform.QRLabel18.Caption:=datetostr(fields[6].AsDateTime);
            zgjbform.QRLabel19.Caption:=floattostr(fields[7].AsFloat);
            zgjbform.QRLabel20.Caption:=floattostr(fields[8].AsFloat);
            zgjbform.QRLabel21.Caption:=floattostr(fields[9].AsFloat);
          end;
            application.MessageBox('你的记录已查到!','系统信息',0);
            bitbtn2.Enabled:=true;
            bitbtn2.SetFocus;
    //zgjbform.QuickRep1.Preview;
       end;
      end;
      

  2.   

    //按单位编号查询
      if state1=0 then
     with dmform.Query_zgqkbb do
      begin
       begin
         close;
         sql.Clear;
         sql.Add('select b.dwq_mc,a.grq_xm,a.grq_card,a.grq_csrq,a.grq_gzrq,a.grq_gzrq,a.grq_jfrq,a.grq_ygz,a.grq_ngz,a.grq_tzgz from grqkb a inner join dwqkb b on b.dwq_bh=a.grq_dwbh where a.grq_dwbh=:dwbh');
         params[0].AsString:=edit1.Text;
         open;
         if recordcount=0 then
          begin
            application.MessageBox('没有你要得记录!','提示',0);
            edit1.SetFocus;
            exit;
          end
         else
          begin
            zgjbform.QRLabel3.Caption:=fields[0].AsString+'的职工基本情况';
            zgjbform.QRLabel4.Caption:=fields[1].AsString;
            zgjbform.QRLabel14.Caption:=fields[2].AsString;
            zgjbform.QRLabel15.Caption:=datetostr(fields[3].AsDateTime);
            zgjbform.QRLabel16.Caption:=datetostr(fields[4].AsDateTime);
            zgjbform.QRLabel17.Caption:=datetostr(fields[5].AsDateTime);
            zgjbform.QRLabel18.Caption:=datetostr(fields[6].AsDateTime);
            zgjbform.QRLabel19.Caption:=floattostr(fields[7].AsFloat);
            zgjbform.QRLabel20.Caption:=floattostr(fields[8].AsFloat);
            zgjbform.QRLabel21.Caption:=floattostr(fields[9].AsFloat);
          end;
            application.MessageBox('你的记录已查到!','系统信息',0);
            bitbtn2.Enabled:=true;
            bitbtn2.SetFocus;
    //zgjbform.QuickRep1.Preview;
       end;
      end;