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

📄 inv_otherout_pi.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
// 20001.05.04
unit Inv_OtherOut_Pi;

Interface

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

Type
  TFrm_Inv_OtherOut_Pi= 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;
    QRLabel16: TQRLabel;
    QRLabel18: TQRLabel;
    QRShApe16: TQRShApe;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRShApe17: TQRShApe;
    QRDBText9: TQRDBText;
    QRDBText10: TQRDBText;
    QRDBText12: TQRDBText;
    QRDBText13: TQRDBText;
    QRShApe1: TQRShApe;
    QRShApe20: TQRShApe;
    QRLabel9: TQRLabel;
    QRShApe10: TQRShApe;
    QRLabel19: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QLWHCode: TQRLabel;
    QLWhPositionCode: TQRLabel;
    QLVendorCode: TQRLabel;
    QRShApe2: TQRShApe;
    QRShApe4: TQRShApe;
    QRShApe5: TQRShApe;
    QRShApe6: TQRShApe;
    QRShApe7: TQRShApe;
    QRShApe8: TQRShApe;
    QRShApe3: TQRShApe;
    TitleBand1: TQRBand;
    QLSysParamValueC: TQRLabel;
    QLBillCtrlCode: TQRLabel;
    QLBillColorDESC: TQRLabel;
    QLWH_EmployeeCode: TQRLabel;
    QLEmployeeCode: TQRLabel;
    QRLabel23: TQRLabel;
    QLBillType2Code: TQRLabel;
    QLInvBillNo: TQRLabel;
    QLInvBillDate: TQRLabel;
    QLInvBillRemArk: TQRLabel;
    QRExpr1: TQRExpr;
    QRShApe9: TQRShApe;
    QRLabel6: TQRLabel;
    procedure QRDBText13Print(sender: TObject; var Value: String);
  private
    { Private declarations }
    FWHCode,FBillNo,Fcolor1,Fcolor2:string;
    FBillTypeCode:string;
    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_OtherOut_Pi: TFrm_Inv_OtherOut_Pi;

implementation

uses Sys_Global;

{$R *.DFM}
procedure TFrm_Inv_OtherOut_Pi.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_OtherOut_Pi.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.Text:='select opBill from InvOutBill where InvBillno='''+fBillno+''''+
              ' and whCode='''+fwhCode+''''+
              ' and BillTypeCode='''+'0299'+'''';
    open;
    if fieldbyname('opBill').asinteger=1 then
    begin
      Fcolor1:='BillCtrlCode2';
      Fcolor2:='BillColorDESC2';
    end
    else
    begin
      Fcolor1:='BillCtrlCode';
      Fcolor2:='BillColorDESC';
    end;
    Close;
    SQL.clear;
    SQL.Text:='Select '+Fcolor1+',BillTypeName,'+Fcolor2+
       ' From BillType Where BillTypeCode=:FBillTypeCode';
    Parameters.ParamByName('FBillTypeCode').Value:=FBillTypeCode;
    open;
  end;

  QLBillCtrlCode.Caption:=AdoQry_Tmp.fieldbyname(Fcolor1).asstring;
  QLSysParamValueC.Caption:=QLSysParamValueC.Caption+AdoQry_Tmp.fieldbyname('BillTypeName').asstring;
  QLBillColorDESC.Caption:=AdoQry_Tmp.fieldbyname(Fcolor2).asstring;

  AdoQry_Head.Close;
  AdoQry_Head.sql.text:=
    ' select B.WHCode,W.WHName,B.WhPositionCode,P.WhPositionName, '+
           ' B.InvBillNo,B.VendorCode,V.VendorName, '+
           ' B.CustomerCode,U.CustomerName,B.DeptCode,D.DeptName, '+
           ' B.InvBillDate,B.InvBillId,'+
           ' E.EmployeeName,F.EmployeeName as EmployeeName1,'+
           ' B.BillType2Code,T.BillType2Name,B.InvBillRemArk,B.InvBillValuation'+
      ' from InvOutBill B '+
      ' left join Employee E on B.WH_EmployeeCode=E.EmployeeCode '+
         ' left join Employee F on B.Stk_EmployeeCode=f.EmployeeCode '+
         ' left join Vendor   V on B.VendorCode=V.VendorCode '+
         ' left join Customer U ON B.CustomerCode=U.CustomerCode '+
         ' left join Dept D ON B.DeptCode=D.DeptCode '+
         ' left join BillType2 T on B.BillType2Code=T.BillType2Code ,'+
         ' Warehouse W,WhPosition P,Currency C '+
         ' where B.WHCode=:WHCode and '+
             ' B.InvBillNo=:BillNo and '+
             ' B.WHCode=W.WHCode and '+
             ' B.WhPositionCode=P.WhPositionCode and '+
             ' B.WHCode=P.WHCode ';

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

      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 )'+
            ' declAre @rc int'+
            ' insert into #tmp'+
            ' select L.InvBillLineno,L.ItemCode,I.ItemName,L.POLineNo,U.UomName,'+
            ' L.InvBillQty '+
            ' from InvOutBillLine 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%10 '+
            ' if @rc<>0'+
            ' while @rc<10'+
            ' begin  '+
            ' insert into #tmp'+
            ' Values(null,null,null,null,null,null)'+
            ' select @rc=@rc+1'+
            ' end';

     with  AdoQry_Line do
     begin
       Close;
       SQL.clear;
       SQL.Add(sqltext);
       ExecSQL;
       Close;
       SQL.clear;
       SQL.Add('select * from #tmp');
       open;
     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
   Else
    begin
     if AdoQry_Head.fieldbyname('DeptCode').asstring<>'' then
       QLVendorCode.Caption:='部门:'+AdoQry_Head.fieldbyname('DeptCode').asstring+' '+
        AdoQry_Head.fieldbyname('DeptName').asstring
     else
       if AdoQry_Head.fieldbyname('CustomerCode').asstring<>'' then
         QLVendorCode.Caption:='客户:'+AdoQry_Head.fieldbyname('CustomerCode').asstring+' '+
          AdoQry_Head.fieldbyname('CustomerName').asstring;
     end;

    if AdoQry_Head.fieldbyname('BillType2Code').asstring='' then
      QLBillType2Code.Caption:=''
    else if AdoQry_Head.fieldbyname('BillType2Code').asstring='115' then
      QLBillType2Code.Caption:='无订单委外发料'
    else if AdoQry_Head.fieldbyname('BillType2Code').asstring='100' then
      QLBillType2Code.Caption:='金额调整'
   else
   QLBillType2Code.Caption:=Trim(AdoQry_Head.fieldbyname('BillType2Code').asstring)+' '+
     Trim(AdoQry_Head.fieldbyname('BillType2Name').asstring);

   QLInvBillNo.Caption:=AdoQry_Head.fieldbyname('InvBillno').asstring;
   QLInvBillDate.Caption:=AdoQry_Head.fieldbyname('InvBillDate').asstring;

   QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
   QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName1').asstring;
   QLInvBillRemArk.Caption:=AdoQry_Head.fieldbyname('InvBillRemArk').asstring;

   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_OtherOut_Pi.QRDBText13Print(sender: TObject;
  var Value: String);
begin
  inherited;
{   if AdoQry_line.fieldbyname('InvBillQty').asfloat=0.00 then
      Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillQty').asfloat))
   else
      Value:=varToStr(formatfloat('#,##.##',AdoQry_line.fieldbyname('InvBillQty').asfloat));}
end;

end.

⌨️ 快捷键说明

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