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

📄 inv_checkin_p.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:

unit Inv_CheckIn_P;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Common, ExtCtrls, QuickRpt, Db, AdODB, Grids, DBGrids, StdCtrls,
  Mask, DBCtrls, QrCtrls,printers,variants;

Type
  TFrm_Inv_CheckIn_P= Class(TFrm_Base_Common)
    AdoQry_Head: TAdoQuery;
    AdoQry_Line: TAdoQuery;
    QuickRep1: TQuickRep;
    DataSource1: TDataSource;
    DetailBand1: TQRBand;
    Label3: TLabel;
    DataSource2: TDataSource;
    ColumnHeaderBand1: TQRBand;
    SummAryBand1: TQRBand;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel18: TQRLabel;
    QRShApe16: TQRShApe;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRShApe17: TQRShApe;
    QRDBText9: TQRDBText;
    QRDBText10: TQRDBText;
    QRDBText12: TQRDBText;
    QRDBText13: TQRDBText;
    QRDBText14: TQRDBText;
    QRDBText15: TQRDBText;
    QRShApe1: TQRShApe;
    QRLabel8: TQRLabel;
    QRShApe20: TQRShApe;
    QRLabelTot: TQRLabel;
    QRShApe10: TQRShApe;
    QRShApe18: TQRShApe;
    QRLabel19: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QLWHCode: TQRLabel;
    QLWhPositionCode: TQRLabel;
    QLVendorCode: TQRLabel;
    QRShApe2: TQRShApe;
    QRShApe4: TQRShApe;
    QRShApe5: TQRShApe;
    QRShApe6: TQRShApe;
    QRExpr2: TQRExpr;
    QRExpr3: TQRExpr;
    QRShApe7: TQRShApe;
    QRShApe8: TQRShApe;
    QRShApe9: TQRShApe;
    QRShApe11: TQRShApe;
    QRShApe3: TQRShApe;
    QRShApe12: TQRShApe;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QLtot: TQRLabel;
    QRLabel12: TQRLabel;
    TitleBand1: TQRBand;
    QLSysParamValueC: TQRLabel;
    QLBillCtrlCode: TQRLabel;
    QLInvBillTaxRate: TQRLabel;
    QLBillColorDESC: TQRLabel;
    QLInvBillnotaxAmount: TQRLabel;
    QLInvBillAmount: TQRLabel;
    QLWH_EmployeeCode: TQRLabel;
    QLEmployeeCode: TQRLabel;
    QRLabel23: TQRLabel;
    QLBillType2Code: TQRLabel;
    QLInvBillNo: TQRLabel;
    QLInvBillDate: TQRLabel;
    QLInvBillRemArk: TQRLabel;
    QRDBText1: TQRDBText;
    procedure QRDBText15Print(sender: TObject; var Value: String);
    procedure QRDBText1Print(sender: TObject; var Value: String);
    procedure QRDBText14Print(sender: TObject; var Value: String);
  private
    { Private declarations }
    FWHCode,FBillNo:string;
    FBillTypeCode:string;
    FHtot:Double;
    FHNoTaxtot:Double;
    FH:Double;
    FPreview:Boolean;
    FModuleCode:string;
  public
    { Public declarations }
    procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
    procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
     FrmParam6:String);Override;
  end;

var
  Frm_Inv_CheckIn_P: TFrm_Inv_CheckIn_P;

implementation

uses Sys_Global;

{$R *.DFM}
procedure TFrm_Inv_CheckIn_P.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
  FrmParam4, FrmParam5, FrmParam6: String);
begin
  inherited;
  FBillNo:=lowercase(FrmParam1);
  FWHCode:=lowercase(FrmParam2);
  FBillTypeCode:=lowercase(FrmParam3);
  FPreview:=(lowercase(FrmParam4)='preview');
  FModuleCode:=lowercase(FrmParam5);
end;

procedure TFrm_Inv_CheckIn_P.SetDBConnect(AdOConnection:TAdOConnection);
var
  tmpBillid:string;
  sqltext:string;
begin
  inherited;
  AdoQry_Head.Connection:=AdoConnection;
  AdoQry_Line.Connection:=AdoConnection;
  //从参数表中取打印表头第一行文字
  with AdoQry_Tmp do
  begin
    Close;
    SQL.clear;
    SQL.Text:='Select SysParamValueC from SysParam Where SysParamCode=''Name0''';
    open;
  end;
  QLSysParamValueC.Caption:=AdoQry_Tmp.fieldbyname('SysParamValueC').asstring;
//取单据类型中文名字
  with AdoQry_Tmp do
  begin
    Close;
    SQL.clear;
    SQL.Text:='Select BillCtrlCode,BillTypeName,BillColorDESC  '+
       'From BillType Where BillTypeCode=:FBillTypeCode';
    Parameters.ParamByName('FBillTypeCode').Value:=FBillTypeCode;
    open;
  end;

  QLBillCtrlCode.Caption:=AdoQry_Tmp.fieldbyname('BillCtrlCode').asstring;
  //组合显示第一行表头文字
  QLSysParamValueC.Caption:=QLSysParamValueC.Caption+'待检入库'; // AdoQry_Tmp.fieldbyname('BillTypeName').asstring;
  //颜色组合
  QLBillColorDESC.Caption:=AdoQry_Tmp.fieldbyname('BillColorDESC').asstring;

  AdoQry_Head.Close;
  AdoQry_Head.sql.text:='Select B.WHCode,W.WHName,B.WhPositionCode,P.WhPositionName'
    +',B.OncheckBillNo,B.VendorCode,V.VendorName,B.OncheckDate,B.oncheckBillId'
    +',B.EmployeeCode,E.EmployeeName,B.BillTypeCode,T.BillTypeName,B.VendorBillNo'
    +' From OncheckBill B '
    +' left join Employee E on B.WH_EmployeeCode=E.EmployeeCode '
    +' left join Vendor   V on B.VendorCode=V.VendorCode, '+
         ' Warehouse W,WhPosition P,BillType T '+
         ' where B.WHCode=:WHCode and '+
             ' B.OnCheckBillNo=:BillNo and '+
             ' B.WHCode=W.WHCode and '+
             ' B.WHCode=P.WHCode and '+
             ' B.WhPositionCode=P.WhPositionCode and '+
             ' B.BillTypeCode=T.BillTypeCode  ';

  AdoQry_Head.Parameters.ParamByName('WHCode').Value:=FWHCode;
  AdoQry_Head.Parameters.ParamByName('BillNo').Value:=FBillNo;
  AdoQry_Head.open;
  TmpBillId:=AdoQry_Head.fieldbyname('oncheckBillId').asstring;

 if FModuleCode='Stk' then
    begin
  sqltext:='Create table #tmp'+
           '(InvBillLineno int null,'+
            'ItemCode varchAr(16) null,'+
            'ItemName varchAr (80) null,'+
            'POLineNo int    null,'+
            'UomName  varchAr (10) null,'+
            'InvBillQty  float null,'+
            'InvBillnoTaxPrice float null,'+
            'InvBillnoTaxAmount float null,'+
            'InvBillTot float null,'+
            'InvBillAmount float null)'+
            ' declAre @rc int'+
            ' insert into #tmp'+
            ' select L.InvBillLineno,L.ItemCode,I.ItemName,L.POLineNo,U.UomName,'+
            ' L.InvBillQty,L.InvBillNoTaxPrice,L.InvBillNoTaxAmount,'+
            ' L.InvBillAmount,L.InvBillAmount-L.InvBillNoTaxAmount as InvBillTot '+
            ' from InvInBillLine L,Item I,Uom U '+
            ' where L.InvBillId='+TmpBillId+' and '+
            ' L.ItemCode=I.ItemCode and '+
            ' I.UomCode=U.UomCode '+
            ' Order by InvBillLineno '+
            ' select @rc=@@rowCount%5'+
            ' if @rc<>0'+
            ' while @rc<5'+
            ' begin  '+
            ' insert into #tmp'+
            ' Values(null,null,null,null,null,null,null,null,null,null)'+
            ' select @rc=@rc+1'+
            ' end';
    end;

    if FModuleCode='Inv' then
     begin
      sqltext:='Create table #tmp'+
           '(InvBillLineno int null,'+
            'ItemCode varchAr(16) null,'+
            'ItemName varchAr (80) null,'+
            'POLineNo int  null,'+
            'UomName  varchAr (10) null,'+
            'InvBillQty  float null,'+
            'InvBillnoTaxPrice float null,'+
            'InvBillnoTaxAmount float null,'+
            'InvBillTot float null,'+
            'InvBillAmount float null)'+
            ' declAre @rc int'+
            ' insert into #tmp '+
            ' select L.oncheckBillLineno,L.ItemCode,I.ItemName,L.POLineNo,U.UomName,'+
            ' L.OnCheckQty,Null as  InvBillNoTaxPrice,Null as InvBillNoTaxAmount,'+
            ' Null as  InvBillAmount,Null as InvBillTot'+
            ' from OnCheckBillline L,Item I,Uom U'+
            ' where L.OnCheckBillId='+TmpBillId+' and '+
            ' L.ItemCode=I.ItemCode and '+
            ' I.UomCode=U.UomCode '+
            ' Order by OnCheckBillLineno '+
            ' select @rc=@@rowCount%5'+
            ' if @rc<>0'+
            ' while @rc<5'+
            ' begin  '+
            ' insert into #tmp '+
            ' Values(null,null,null,null,null,null,null,null,null,null)'+
            ' select @rc=@rc+1'+
            ' end';

      QLInvBillnotaxAmount.Caption:='';
      QLInvBillAmount.Caption:='';
      QLtot.Caption:='';
      QRLabelTot.Caption:='';
     end;

     with  AdoQry_Line do
     begin
       Close;
       SQL.clear;
       SQL.Add(sqltext);
       ExecSQL;
       Close;
       SQL.clear;
       SQL.Add('select * from #tmp');
       open;
     end;

    FHNoTAXtot:=0;
    FHtot:=0;
    FH:=0;

   if FModuleCode='Stk' then
   begin
    with AdoQry_Line do
    begin
       First;
       while Not(Eof) do
       begin
         FHNoTAXtot:=FHNoTAXtot+fieldbyname('InvBillnotaxAmount').asfloat;
         FHtot:=FHtot+fieldbyname('InvBillTot').asfloat;
         FH:=FHNoTaxtot+FHTOT;
         next;
       end;
    end;

     if FHNoTAXtot=0.00 then
        QLInvBillnotaxAmount.Caption:=''
     else
       QLInvBillnotaxAmount.Caption:='¥'+varToStr(FormatFloat('##0.00',FHNoTAXtot))+'元';

     if FHtot=0.00 then
        QLInvBillAmount.Caption:=''
     else
       QLInvBillAmount.Caption:='¥'+varToStr(FormatFloat('##0.00',FHtot))+'元';

     if FH=0.00 then
        begin
        QLtot.Caption:='';
        QRLabelTot.Caption:='';
        end
     else
       begin
        QLtot.Caption:='¥'+varToStr(FormatFloat('##0.00',FH))+'元';
        QRLabelTot.Caption:=SmallTOBig(FH);
       end;
   end;

   QLWHCode.Caption:=AdoQry_Head.fieldbyname('WHCode').asstring+' '+
        AdoQry_Head.fieldbyname('WHName').asstring;
   QLWhPositionCode.Caption:=AdoQry_Head.fieldbyname('WhPositionCode').asstring+' '+
        AdoQry_Head.fieldbyname('WhPositionName').asstring;

   if  AdoQry_Head.fieldbyname('VendorCode').asstring<>'' then
     QLVendorCode.Caption:='供应商:'+ AdoQry_Head.fieldbyname('VendorCode').asstring+' '+
        AdoQry_Head.fieldbyname('VendorName').asstring;

   if AdoQry_Head.fieldbyname('BillTypeCode').asstring='' then
      QLBillType2Code.Caption:=''
   else
   QLBillType2Code.Caption:=Trim(AdoQry_Head.fieldbyname('BillTypeCode').asstring)+' '+
     Trim(AdoQry_Head.fieldbyname('BillTypeName').asstring);

   QLInvBillNo.Caption:=AdoQry_Head.fieldbyname('oncheckBillno').asstring;
   QLInvBillDate.Caption:=AdoQry_Head.fieldbyname('oncheckdate').asstring;
   if FModuleCode='Stk' then
     begin
     QLInvBillTaxRate.Caption:='0';
     end;
   if FModuleCode='Inv' then
     begin
     QLInvBillTaxRate.Caption:='';
     end;
   QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
   QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;

   if AdoQry_Head.fieldbyname('VendorBillNo').AsString<>'' then
     QLInvBillRemArk.Caption:='送货单号:'+AdoQry_Head.fieldbyname('VendorBillNo').AsString
   else
     QLInvBillRemArk.Caption:='';
   AdoQry_Head.Close;
   AdoQry_Head.sql.clear;
   AdoQry_Head.SQL.Add('drop table #tmp');
   AdoQry_Head.ExecSQL;
   if FPreview then
   begin
     QuickRep1.PreviewModal;
   end
   else
     QuickRep1.print;
end;
procedure TFrm_Inv_CheckIn_P.QRDBText15Print(sender: TObject;
  var Value: String);
begin
  inherited;
  if AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat=0.00 then
      Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat))
   else
     // Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat));
      Value:=varToStr(formatfloat('##0.00',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat));
end;

procedure TFrm_Inv_CheckIn_P.QRDBText1Print(sender: TObject;
  var Value: String);

begin
  inherited;
   if FModuleCode='Stk' then
    begin
     if AdoQry_line.fieldbyname('InvBillTot').asfloat=0.00 then
         Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillTot').asfloat))
      else
       //Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillTot').asfloat));
       Value:=varToStr(formatfloat('##0.00',AdoQry_line.fieldbyname('InvBillTot').asfloat));

    end;
  if FModuleCode='Inv' then
    begin
    Value:=varToStr(FormatFloat('##.#', AdoQry_line.fieldbyname('InvBillTot').asfloat));
    end;
end;

procedure TFrm_Inv_CheckIn_P.QRDBText14Print(sender: TObject;
  var Value: String);
begin
  inherited;
   if AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat=0.00 then
      Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat))
  else
    // Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat));
end;

end.

⌨️ 快捷键说明

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