⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pm_qry_printpo_p.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
                      +quotedstr(AdoQryMain.fieldbyname('podate').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('Vendorfax').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('date').asstring)+','
                      +quotedstr(tmpItemCode+'小计:')+','+quotedstr('小计:')+','+floattostr(getsum(tmpItemCode))+')');
              execsql;
              end;

      end;
     if not eof then
     next;
     while not eof do
      begin
       if fieldbyname('ItemCode').asstring=tmpItemCode then
         begin
         edit;
         fieldbyname('Itemflag').asstring:='';
         fieldbyname('UomName').asstring:='';
         post;
         end
       else
        begin
          tmpQryItemCode:=fieldbyname('ItemCode').asstring;
            with AdoQry_tmp do
             begin
              Close;
              sql.clear;
              sql.Add('insert into #tmp(VendorCode,VendorName,poType,podate,Vendorfax,date,'
                      +'ItemCode,Itemflag,poqty) Values('
                      +quotedstr(AdoQryMain.fieldbyname('VendorCode').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('VendorName').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('poType').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('podate').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('Vendorfax').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('date').asstring)+','
                      +quotedstr(tmpItemCode+'小计:')+','+quotedstr('小计:')+','+floattostr(getsum(tmpItemCode))+')');
              execsql;
              end;
          tmpItemCode:=tmpQryItemCode;

        end;
       next;
       if eof then
         begin
            with AdoQry_tmp do
             begin
              Close;
              sql.clear;
              sql.Add('insert into #tmp(VendorCode,VendorName,poType,podate,Vendorfax,date,'
                      +'ItemCode,Itemflag,poqty) Values('
                      +quotedstr(AdoQryMain.fieldbyname('VendorCode').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('VendorName').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('poType').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('podate').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('Vendorfax').asstring)+','
                      +quotedstr(AdoQryMain.fieldbyname('date').asstring)+','
                      +quotedstr(tmpItemCode+'小计:')+','+quotedstr('小计:')+','+floattostr(getsum(tmpItemCode))+')');
              execsql;
              end;

         end;
      end;
     { sqltext:=' declAre @rc int '+
      ' select @rc=@@rowCount % 21'+
    ' if @rc <>0'+
    ' while @rc<21'+
  ' begin  '+#13+
  ' insert into #tmp(Itemflag) '+#13+
  ' Values(''要'')'+#13+
  ' select @rc=@rc+1 '+
  ' end  ';
   with AdoQry_tmp do
     begin
      Close;
      sql.Text:=sqltext;
      execsql;
     end;  }

      AdoQryMain.Sort:='ItemCode';
      AdoQryMain.ReQuery;
      qrlabel13.Caption:='订单'+#13+'行号';
      qrlabel3.Caption:=getuser(userCode);
      qrlabel16.Caption:=qrlabel3.Caption;
      qrlabel24.Caption:='';
      qrlabel7.Caption:='';
      Executesql(AdoQry_tmp,'select * from PmParam where PmParamCode='+quotedstr('printassess'),0);
      if AdoQry_tmp.fieldbyname('PmParamValuen').asfloat>0.9 then
      begin
        qrlabel24.Caption:=AdoQryMain.fieldbyname('PassEmployeeCode').asstring;
        qrlabel7.Caption:=AdoQryMain.fieldbyname('PassEmployeeCode').asstring;
      end;
     Executesql(AdoQry_tmp,'select * from PmParam where PmParamCode='+quotedstr('PmOrderISPrintTerm'),0);
     printterm:=(AdoQry_tmp.fieldbyname('PmParamValuen').asinteger=1);
     termCode:=AdoQry_tmp.fieldbyname('PmParamValuec').asstring;
     if printterm then 
     begin 
       Executesql(AdoQry_tmp,'select top 8 * from PoTerm where PoTermSetCode='+quotedstr(termCode),0);
       AdoQry_tmp.First;
       while not AdoQry_tmp.Eof do
       begin
         Tqrlabel(self.FindComponent('qrlabel3'+inttostr(j))).Caption:=inttostr(j+1)+':'+AdoQry_tmp.fieldbyname('PoTermName').asstring;
    //     Tqrlabel(qrlabel30).Caption:=AdoQry_tmp.fieldbyname('PoTermName').asstring;
         inc(j);
         AdoQry_tmp.Next;
       end;
     end
     else summAryband1.HaSchild:=False;
     quickrep1.Prepare;
     Count:=quickrep1.Printer.PageCount;
     qrpageCount.Caption:=inttostr(Count);
     summAryband1.Size.Height:=7.7;
     pagefooterband1.Size.Height:=6.9;
     If Status='Preview' Then
      begin
       quickrep1.Previewmodal;
       end
     Else
      begin
       quickrep1.printer.PrintSetup;
       QuickRep1.Print;
      end;
     quickrep1.Destroy;

   end;
  Finally

    AdoQryMain.Close;
    AdoQryMain.sql.clear;
    AdoQryMain.sql.Add('drop table #tmp');
    try
    AdoQryMain.execsql;
    except
    end;
    Frm_Pm_Qry_PrintPo_P.Close;
  end;
end;

procedure TFrm_Pm_Qry_PrintPo_P.FormDestroy(Sender: TObject);
begin
  Frm_Pm_Qry_PrintPo_P:=Nil;
end;

function TFrm_Pm_Qry_PrintPo_P.lookupParam(ParamCode: string): string;
begin
  Result:='';
  with AdoQry_tmp do
    begin
     Close;
     sql.clear;
     sql.Add('select SysParamValuec from SysParam where SysParamCode=:SysName');
     Parameters.ParamByName('SysName').Value:=ParamCode;
     open;
    end;
  Result:=AdoQry_tmp.fieldbyname('SysParamValuec').asstring;
end;

function TFrm_Pm_Qry_PrintPo_P.getAmount: double;
begin
  Result:=0;
  with AdoQry_tmp do
   begin
     Close;
     sql.clear;
     sql.Add('select Amount=sum(isnull(potaxAmount,0)) from #tmp');
     try
       open;
     except
     end;
   end;
  Result:=AdoQry_tmp.fieldbyname('Amount').asfloat;

end;

function TFrm_Pm_Qry_PrintPo_P.getsum(ItemCode: string): real;
var AdoQry:TAdoQuery;
begin
  Result:=0;
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.EnableBCD:=False;
  with AdoQry do
    begin
      Connection:=AdoQryMain.Connection;
      Close;
      sql.clear;
      sql.Add('select SumQty=sum(isnull(poqty,0)) from #tmp where ItemCode='+quotedstr(ItemCode));
      try
        open;
        Result:=AdoQry.fieldbyname('SumQty').asfloat;
      finally
        AdoQry.Free;
      end;
    end;

end;

function TFrm_Pm_Qry_PrintPo_P.getuser(userCode: string): string;
var AdoQry:TAdoQuery;
begin
  Result:='';
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.EnableBCD:=False;
  with AdoQry do
   begin
     Connection:=AdoQryMain.Connection;
     Close;
     sql.clear;
     sql.Add('select userflag=EmployeeName from Employee where EmployeeCode='+quotedstr(userCode));
     try
       open;
       Result:=AdoQry.fieldbyname('userflag').asstring;
     finally
       AdoQry.Free;
     end;
   end;

end;

procedure TFrm_Pm_Qry_PrintPo_P.QuickRep1endPage(Sender: TCustomQuickRep);
begin
 qrlblpageno.Caption:=inttostr(quickrep1.Printer.PageNumber);
 if AdoQryMain.RecordCount=30 then
  begin
    summAryband1.Size.Height:=0;
    exit;
  end;
  if (AdoQryMain.recordCount div 31)=0 then
   begin
     pagefooterband1.Size.Height:=0;
     exit;
   end;
 if quickrep1.Printer.PageNumber=(AdoQryMain.recordCount div 31) then
  begin
    pagefooterband1.Size.Height:=0;
  end;
end;

procedure TFrm_Pm_Qry_PrintPo_P.QuickRep1StArtPage(Sender: TCustomQuickRep);
begin
  qrlblpageno.Caption:=inttostr(quickrep1.Printer.PageNumber);
  if AdoQryMain.RecordCount=30 then
    begin
      summAryband1.Size.Height:=0;
      exit;
    end;
  if (AdoQryMain.recordCount div 31)=0 then
    begin
      pagefooterband1.Size.Height:=0;
      exit;
    end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -