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

📄 sfc_mnout_p1.pas

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

unit Sfc_MnOut_P1;

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_Sfc_MnOut_P1= Class(TFrm_Base_Common)
    AdoQry_Head: TAdoQuery;
    AdoQry_Line: TAdoQuery;
    QuickRep1: TQuickRep;
    DataSource1: TDataSource;
    DetailBand1: TQRBand;
    Label3: TLabel;
    DataSource2: TDataSource;
    ColumnHeaderBand1: TQRBand;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel18: TQRLabel;
    QRLabel17: TQRLabel;
    QRShApe16: TQRShApe;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel7: TQRLabel;
    QRDBText10: TQRDBText;
    QRDBText12: TQRDBText;
    QRDBText15: TQRDBText;
    QLWHCode: TQRLabel;
    QLWhPositionCode: TQRLabel;
    QLDeptCode: TQRLabel;
    QRShApe2: TQRShApe;
    QRShApe6: TQRShApe;
    QRShApe8: TQRShApe;
    QRShApe11: TQRShApe;
    QRShApe3: TQRShApe;
    QRLabel23: TQRLabel;

    QLInvBillNo: TQRLabel;
    QLInvBillDate: TQRLabel;
    QLMONo: TQRLabel;
    QRLabel10: TQRLabel;
    QRShApe12: TQRShApe;
    QRDBText2: TQRDBText;
    QLBillCtrlCode: TQRLabel;
    QLSysParamValueC: TQRLabel;
    PageFooterBand1: TQRBand;
    QRShApe1: TQRShApe;
    SummAryBand1: TQRBand;
    QRLabel19: TQRLabel;
    QLWH_EmployeeCode: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QLEmployeeCode: TQRLabel;
    QRSysData1: TQRSysData;
    QRLabel15: TQRLabel;
    QLWH_EmployeeCodea: TQRLabel;
    QRLabel24: TQRLabel;
    QRLabel25: TQRLabel;
    QLEmployeeCodeA: TQRLabel;
    QRSysData2: TQRSysData;
    QLPageTot: TQRLabel;
    QLPageTot1: TQRLabel;
    QRLabel1: TQRLabel;
    QLMoLineNo: TQRLabel;
    QRLabel5: TQRLabel;
    QLshifttime: TQRLabel;
    QRShApe4: TQRShApe;
    QRLabel6: TQRLabel;
    qlWhEmployee: TQRLabel;
    QRLabel9: TQRLabel;
    qlItemCodeName: TQRLabel;
    QRDBText1: TQRDBText;
    QRLabel8: TQRLabel;
    QRShApe5: TQRShApe;
    QRShApe7: TQRShApe;
    QRLabel11: TQRLabel;
    QRLabel12: TQRLabel;
    qlmoqty: TQRLabel;
    QRShApe9: TQRShApe;
    QRShApe10: TQRShApe;
    QRShApe13: TQRShApe;
    QRShApe15: TQRShApe;
    QRShApe17: TQRShApe;
    QRShApe19: TQRShApe;
    QRShApe20: TQRShApe;
    QRShApe21: TQRShApe;
    QRShApe22: TQRShApe;
    QRLabel22: TQRLabel;
    qlmemo: TQRLabel;
    QRExpr1: TQRExpr;
    QRExpr2: TQRExpr;
    QRLabel26: TQRLabel;
    QRShApe14: TQRShApe;
    QRShApe18: TQRShApe;
    QRExpr3: TQRExpr;
    procedure QRDBText2Print(sender: TObject; var Value: String);
    procedure QRExpr1Print(sender: TObject; var Value: String);
    procedure QRExpr2Print(sender: TObject; var Value: String);
    procedure QRExpr3Print(sender: TObject; var Value: String);
  private
    { Private declarations }
    FWHCode,FBillNo:string;
    FBillTypeCode:string;
    FHtot:Double;
    FHNoTaxtot:Double;
    FH:Double;
    FPreview:Boolean;
    FModuleCode:string;
    ISall:boolean;
  public
    { Public declarations }
    procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
    procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
     FrmParam6:String);Override;
    procedure check_all(tf:boolean);
  end;

var
  Frm_Sfc_MnOut_P1: TFrm_Sfc_MnOut_P1;

implementation

uses Sys_Global,Sfc_MnRequest_B;

{$R *.DFM}
procedure TFrm_Sfc_MnOut_P1.check_all(tf:boolean);
begin
  ISall:=tf;
end;

procedure TFrm_Sfc_MnOut_P1.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_Sfc_MnOut_P1.SetDBConnect(AdOConnection:TAdOConnection);
var
  tmpBillid:string;
  sqltext:string;
  WhPositionCode: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;

  AdoQry_Head.Close;
  AdoQry_Head.sql.text:=
    ' select B.WHCode,W.WHName,B.WhPositionCode,P.WhPositionName, '+
           ' B.InvBillNo,D.DeptCode,D.DeptName, '+
           ' B.InvBillDate,B.InvBillId,B.shiftType,'+
           ' E.EmployeeName,F.EmployeeName as EmployeeName1,'+
           ' B.Mono,B.MoLineNo,ml.ItemCode,ml.moqty,i.ItemName,'+
           ' B.InvBillRemArk,B.InvBillValuation,OverPlan,b.InvBillwhchck '+
       ' from InvOutBill B '+
         ' left join Employee E on B.WH_EmployeeCode2=E.EmployeeCode '+
         ' left join Employee F on B.Sfc_EmployeeCode=f.EmployeeCode, '+
         ' Warehouse W,WhPosition P,Dept D,MoLine ml,Item i '+
       ' where B.WHCode=:WHCode and '+
             ' B.InvBillNo=:BillNo and '+
             ' B.WHCode=W.WHCode and '+
             ' B.WHCode=P.WHCode and '+
             ' B.WhPositionCode=P.WhPositionCode and '+
             ' B.DeptCode=D.DeptCode and  '+
             ' B.mono=ml.mono and '+
             ' B.MoLineno=ml.MoLineno and '+
             ' ml.ItemCode=i.ItemCode ';
  AdoQry_Head.Parameters.ParamByName('WHCode').Value:=FWHCode;
  AdoQry_Head.Parameters.ParamByName('BillNo').Value:=FBillNo;
  AdoQry_Head.open;
  TmpBillId:=AdoQry_Head.fieldbyname('InvBillId').asstring;
  WhPositionCode:=AdoQry_Head.fieldbyname('WhPositionCode').asstring;
  sqltext:=' select O.WhCode,IsNull(C.OnHandInv,0) As OnHandInv,L.InvBillLineno,L.ItemCode,I.ItemName,i.ItemCode2,L.MoLineNo,U.UomName,'+
           '  M.MOQty,M.MoLineDate,L.InvBillSfcQty, L.InvBillQty,l.BomremArk,L.BillLineRemArk ,IsNull(MN.MoCtrlQty,0) As MoCtrlQty '+
           '  from InvOutBillLine L '
           +' Join InvOutBill O On O.InvBillID=L.InvBillID '
           +' Left Join CurrentInv C On O.WhCode=C.WhCode And L.ItemCode=C.ItemCode '
           +' And C.WhPositionCode='+QuotedStr(WhPositionCode)
           +' Left Join Item I  On L.ItemCode=I.ItemCode '
           +' Left Join Uom U  On  I.UomCode=U.UomCode  '
           +' Left Join MoLine M On L.MOnO=M.Mono  and '
           +' L.MoLineno=M.MoLineno  '
           +' Left Join MNItemList Mn On Mn.MoNo=L.MoNo And Mn.MoLineNo=L.MoLineNo '
           +' And Mn.ItemCode=L.ItemCode '
           +' where L.InvBillId='+TmpBillId
           +' Order by L.ItemCode ';
     with  AdoQry_Line do
     begin
       Close;
       SQL.clear;
       sql.Add(sqltext);
       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;

   QLDeptCode.Caption:=AdoQry_Head.fieldbyname('DeptCode').asstring+' '+
        AdoQry_Head.fieldbyname('DeptName').asstring;
   QLMONo.Caption:=AdoQry_Head.fieldbyname('Mono').asstring;

   QLInvBillNo.Caption:=AdoQry_Head.fieldbyname('InvBillno').asstring;
   QLInvBillDate.Caption:=AdoQry_Head.fieldbyname('InvBillDate').asstring;
   QLMoLineNo.Caption:=AdoQry_Head.fieldbyname('MoLineNo').asstring;
   qlshifttime.Caption:=AdoQry_Head.fieldbyname('shiftType').asstring;
   qlWhEmployee.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
   qlItemCodeName.Caption:=AdoQry_Head.fieldbyname('ItemCode').asstring+' '+AdoQry_Head.fieldbyname('ItemName').asstring;
   qlmoqty.Caption:=AdoQry_Head.fieldbyname('moqty').asstring;
   if AdoQry_Head.fieldbyname('OverPlan').asinteger=1 then
      qlmemo.Caption:='超订单 '+AdoQry_Head.fieldbyname('InvBillremArk').asstring
   else
      qlmemo.Caption:=AdoQry_Head.fieldbyname('InvBillremArk').asstring;
   if AdoQry_Head.fieldbyname('EmployeeName').asstring='' then
      QLWH_EmployeeCode.Caption:=''
   else
     begin
       QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
      end;
    QLWH_EmployeeCodeA.Caption:= QLWH_EmployeeCode.Caption;

   IF AdoQry_Head.fieldbyname('EmployeeName1').asstring='' then
      QLEmployeeCode.Caption:=''
   else
     begin
      QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName1').asstring;
     end;
    QLEmployeeCodeA.Caption:=QLEmployeeCode.Caption;


   if FPreview then
   begin
     QuickRep1.Prepare;
     QLPageTot1.Caption:='页 共'+Trim(inttoStr(QuickRep1.QRPrinter.PageCount))+'页' ;
     QLPageTot.Caption:=QLPageTot1.Caption;
     QuickRep1.Preview;
   end
   else
     begin
     QuickRep1.Prepare;
     QLPageTot1.Caption:='页 共'+Trim(inttoStr(QuickRep1.QRPrinter.PageCount))+'页' ;
     QLPageTot.Caption:=QLPageTot1.Caption;
     QuickRep1.print;
     end;
end;

procedure TFrm_Sfc_MnOut_P1.QRDBText2Print(sender: TObject;
  var Value: String);
begin
  inherited;
  if ((AdoQry_Head.fieldbyname('InvBillwhchck').asinteger=0) and  (Value='0')) then
     Value:='0';
end;

procedure TFrm_Sfc_MnOut_P1.QRExpr1Print(sender: TObject;
  var Value: String);
begin
  inherited;
  Value:=Trim(QRDBText2.DataSet.fieldbyname('ItemName').AsString);
end;

procedure TFrm_Sfc_MnOut_P1.QRExpr2Print(sender: TObject;
  var Value: String);
var
  bExit : boolean;
  iLen : integer;
  strSource, strTemp : string;
begin
  Inherited;
  //32是栏宽。
  Value:=Trim(QRDBText2.DataSet.fieldbyname('BomRemArk').AsString)+'/'
        +Trim(QRDBText2.DataSet.fieldbyname('BillLineRemArk').AsString);
  If Value='/' Then
    Value:='';
  if Length(Value) <= 30 then
    exit;

  strSource := Value;
  Value := '';
  //防止截断汉字。
  while True do
  begin
    iLen := 1;
    while iLen < 30 do
    begin
      if ord(strSource[iLen]) > 128 then
        inc(iLen, 2)
      else
        inc(iLen);
    end;
    dec(iLen);
    strTemp := Copy(strSource, 1, iLen);
    //加回车。
    if Value = '' then
      Value := strTemp
    else
      Value := Value +#13+strTemp;
    strSource := Copy(strSource, iLen + 1, Length(strSource) - iLen);
    if Length(strSource) <= 30 then
    begin
      Value := Value +#13+strSource;
      exit;
    end;
  end;
end;

procedure TFrm_Sfc_MnOut_P1.QRExpr3Print(sender: TObject;
  var Value: String);
begin
  inherited;
  Value:=QRDBText2.DataSet.fieldbyname('onhandInv').AsString;
end;

end.

⌨️ 快捷键说明

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