📄 inv_global.pas
字号:
unit Inv_Global;
Interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Dialog, StdCtrls, Db, AdODB;
procedure BillPrint(DBConnection:TAdoConnection;WHCode,BillNo,BillTypeCode,ModuleCode:string;
Preview,MultiBill,PrintPrinted:Boolean;PrintCondition:string);//模块代码 ModuleCode唯一的
Function GetPONo(VendorCode:string;
PoType:String;
AdoConnection:TAdoConnection):String;
Function GetOtherPrice(ItemCode:string;
PriceType:String;
AdoConnection:TAdoConnection):String;
procedure InvDataChangeCheck(AdoQuery:TAdoQuery;CheckMonth:String);
function DefaultWHCheck(AdoQuery:TAdoQuery;WHCode,ItemCode:String):Boolean;
function MoInBackFlush(AdOConnection:TAdOConnection;
MoNo,UserCode,CurrentDate,ShiftType:String;
MoLineNo:Integer;MoInQty:Double):Boolean;
function BatchCtrl(AdoQry:TAdoQuery;ItemCode:String):Boolean;
function BatchNoCheck(AdoQry:TAdoQuery;BatchNo,ItemCode,VendorCode,CurrentDate:String):Boolean;
function BatchInvCheck(AdoQry:TAdoQuery;BatchNo,IO,WhCode,WhPositionCode:String;Qty:Double):Boolean;
function BatchHint(AdOConnection:TAdOConnection;ItemCode,VendorCode,WhCode,WhPositionCode:String):String;
procedure ChangeBatchInv(AdoQry:TAdoQuery;BatchNo,IO,CurrentDate,WhCode,WhPositionCode:String;Qty:Double);
function GiveBatchNo(AdoQry:TAdoQuery;WHCode,WhPositionCode,ItemCode,CurrentDate:String;
var Qty:Double;BatchNo:String=''):String;
Function GetPrice(AdoQry:TAdoQuery;ItemCode:string;PriceType:integer):double;//得到全月平均价和标准成本价
implementation
uses Sys_Global,Inv_BillPrint,Base_Common,Inv_SaleMaterial_P,Inv_PurchaseIn_P,
Inv_PurchaseIn_Pc,Inv_PurchaseIn_Po,Inv_OpOut_P,Inv_OpOut_Pi,
Inv_OtherIn_P,Inv_OtherOut_P,Inv_OtherOut_Pi,Inv_PoHeadHint,Sfc_MnIn_P,
Sfc_MnOut_P,Inv_CheckIn_P,Inv_OtherPrice_Hint,Inv_WhPMove_P,Inv_AmountAdjust_P,
Inv_BatchHint,Sfc_MnOut_P1;
procedure BillPrint(DBConnection:TAdoConnection; WHCode,
BillNo, BillTypeCode, ModuleCode: string; Preview,MultiBill,
PrintPrinted: Boolean;PrintCondition:string);
var
BillNoChAr:String;//BillNoChAr='R'或'C',
InvBill:String;//InvBill='InvInBill'或'InvOutBill'
Common_Report:TFrm_Base_Common;
AdoQry_Tmp,AdoQry_BillTmp:TAdoQuery;
tmp_BillTypeCode:string; //标识是否为待检入库
iSall_Condition:boolean; //0201
begin
AdoQry_BillTmp:=TAdoQuery.Create(nil);
AdoQry_BillTmp.EnableBCD:=False;
AdoQry_BillTmp.Connection:=DBConnection ;
AdoQry_Tmp:=TAdoQuery.Create(nil);
AdoQry_Tmp.EnableBCD:=False;
AdoQry_Tmp.Connection:=DBConnection ;
try
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Drop Table #tmp';
AdoQry_BillTmp.ExecSQL;
except
end;
Common_Report:=nil;
tmp_BillTypeCode:='';
if ((BillTypeCode='0203') or (BillTypeCode='0204')) and ((ModuleCode='Sal') or (ModuleCode='Inv') or (ModuleCode='Stk') ) then
begin
Application.CreateForm(TFrm_Inv_SaleMaterial_P,Frm_Inv_SaleMaterial_P);
Common_Report:=Frm_Inv_SaleMaterial_P;
end
else if ((BillTypeCode='0101') or (BillTypeCode='0102') or (BillTypeCode='0103') or (BillTypeCode='1201') or (BillTypeCode='1202')) and ((ModuleCode='Stk') or (ModuleCode='Inv')) then
begin
if PrintCondition='' then
begin
Application.CreateForm(TFrm_Inv_PurchaseIn_P,Frm_Inv_PurchaseIn_P);
Common_Report:=Frm_Inv_PurchaseIn_P;
end
else if PrintCondition='C' then
begin
Application.CreateForm(TFrm_Inv_PurchaseIn_Pc,Frm_Inv_PurchaseIn_Pc);
Common_Report:=Frm_Inv_PurchaseIn_Pc;
end
else if PrintCondition='B' then
begin
Application.CreateForm(TFrm_Inv_PurchaseIn_Po,Frm_Inv_PurchaseIn_Po);
Common_Report:=Frm_Inv_PurchaseIn_Po;
end;
end;
if BillTypeCode='0202' then
begin
IF uppercase(ModuleCode)='Stk' then
begin
Application.CreateForm(TFrm_Inv_OpOut_P,Frm_Inv_OpOut_P);
Common_Report:=Frm_Inv_OpOut_P;
end
else
begin
IF uppercase(ModuleCode)='Inv' then
begin
Application.CreateForm(TFrm_Inv_OpOut_Pi,Frm_Inv_OpOut_Pi);
Common_Report:=Frm_Inv_OpOut_Pi;
end;
end;
end;
if BillTypeCode='0199' then //其它入库
begin
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Select AmountAdjust'
+' From InvInBill'
+' Where WHCode='''+WHCode+''''
+' And InvBillNo='''+BillNo+'''';
AdoQry_BillTmp.Open;
if AdoQry_BillTmp.fieldbyname('AmountAdjust').AsString='1' then
begin
Application.CreateForm(TFrm_Inv_AmountAdjust_P,Frm_Inv_AmountAdjust_P);
Common_Report:=Frm_Inv_AmountAdjust_P;
end
else
begin
Application.CreateForm(TFrm_Inv_OtherIn_P,Frm_Inv_OtherIn_P);
Common_Report:=Frm_Inv_OtherIn_P;
end;
end;
if BillTypeCode='0299' then //其它出库
begin
with AdoQry_BillTmp do
begin
Close;
sql.Text:='select opBill from InvOutBill where InvBillno='''+Billno+''''+
' and whCode='''+whCode+''''+
' and BillTypeCode='''+'0299'+'''';
open;
end;
IF (uppercase(ModuleCode)='Stk') and (AdoQry_Billtmp.fieldbyname('opBill').asinteger=0)then
begin
Application.CreateForm(TFrm_Inv_OtherOut_P,Frm_Inv_OtherOut_P);
Common_Report:=Frm_Inv_OtherOut_P;
end
else
begin
Application.CreateForm(TFrm_Inv_OtherOut_Pi,Frm_Inv_OtherOut_Pi);
Common_Report:=Frm_Inv_OtherOut_Pi;
end;
end;
if (BillTypeCode='0104') or (BillTypeCode='0105') then //半成品生产入库单,成品生产入库单
begin
Application.CreateForm(TFrm_Sfc_MnIn_P,Frm_Sfc_MnIn_P);
Common_Report:=Frm_Sfc_MnIn_P;
end;
if BillTypeCode='1101' then
begin
tmp_BillTypeCode:='1101';
Application.CreateForm(TFrm_Inv_WhPMove_P,Frm_Inv_WhPMove_P);
Common_Report:=Frm_Inv_WhPMove_P;
end;
if (BillTypeCode='0201') then //生产领料单
begin
{ if printcondition='all' then
iSall_Condition:=True;
if printcondition='notall' then
iSall_Condition:=False; }
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select SfcParamValueN '
+' From SfcParam '
+' Where SfcParamCode=''ISMnRequestReport1''';
AdoQry_Tmp.Open;
If (AdoQry_Tmp.RecordCount>0) And (AdoQry_Tmp.fieldbyname('SfcParamValueN').AsInteger=1) Then
begin
Application.CreateForm(TFrm_Sfc_MnOut_P1,Frm_Sfc_MnOut_P1);
Common_Report:=Frm_Sfc_MnOut_P1;
end
Else
begin
Application.CreateForm(TFrm_Sfc_MnOut_P,Frm_Sfc_MnOut_P);
Common_Report:=Frm_Sfc_MnOut_P;
end;
end;
if BillTypeCode='1102' then //待检入库
begin
begin
tmp_BillTypeCode:='1102';
Application.CreateForm(TFrm_Inv_CheckIn_P,Frm_Inv_CheckIn_P);
Common_Report:=Frm_Inv_CheckIn_P;
AdoQry_BillTmp.Close;
AdoQry_BillTmp.sql.clear;
AdoQry_BillTmp.sql.text:=
' select BillTypeCode from oncheckBill where whCode='''+WHCode+''' and oncheckBillno='''+Billno+'''';
AdoQry_BillTmp.Open;
BillTypeCode:=AdoQry_BillTmp.fieldbyname('BillTypeCode').asstring;
end
end;
if Common_Report=nil then
begin
AdoQry_BillTmp.free;
Common_Report.Release;
Exit;
end;
if(not MultiBill)and(Billno='')then
begin
DispInfo('没有保存的单据不能打印',1);
AdoQry_BillTmp.free;
Common_Report.Release;
Exit;
end;
common_Report.Caption:='注意:使用预览中的打印按钮,不影响单据的打印次数.';
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Select IO From BillType'
+' Where BillTypeCode='''+BillTypeCode+'''';
AdoQry_BillTmp.Open;
if AdoQry_BillTmp.fieldbyname('IO').AsInteger=0 then
begin
BillNoChAr:='R';
InvBill:='InvInBill';
end
else if AdoQry_BillTmp.fieldbyname('IO').AsInteger=1 then
begin
BillNoChAr:='C';
InvBill:='InvOutBill';
end;
if not MultiBill then//单份单据
begin
if not Preview then
begin
if tmp_BillTypeCode='' then
begin
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Select PrintTimes From '+InvBill
+' Where WHCode='''+WHCode+''''
+' And InvBillNo='''+BillNo+'''';
AdoQry_BillTmp.Open;
//if AdoQry_BillTmp.fieldbyname('PrintTimes').AsInteger>=1 then
//if DispInfo('该单据已经打印过'+AdoQry_BillTmp.fieldbyname('PrintTimes').
//AsString+'次,还需要打印吗?',2)='n' then
//Exit;
Common_Report.SetFormParam(BillNo,WHCode,BillTypeCode,'Print',ModuleCode,'');
Common_Report.SetDBConnect(AdoQry_BillTmp.Connection);
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Update '+InvBill+' Set PrintTimes=PrintTimes+1'
+' Where WHCode='''+WHCode+''''
+' And InvBillNo='''+BillNo+'''';
AdoQry_BillTmp.ExecSQL;
end
else
begin
Common_Report.SetFormParam(BillNo,WHCode,BillTypeCode,'Print',ModuleCode,'');
Common_Report.SetDBConnect(AdoQry_BillTmp.Connection);
end;
end
else
begin
Common_Report.SetFormParam(BillNo,WHCode,BillTypeCode,'Preview',ModuleCode,'');
Common_Report.SetDBConnect(AdoQry_BillTmp.Connection);
end;
end
else
begin
Frm_Inv_BillPrint:=TFrm_Inv_BillPrint.Create(nil);
if Frm_Inv_BillPrint.ShowModal=mrOk then
begin
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Select InvBillNo From '+InvBill
+' Where WHCode='''+WHCode+''''
+' And InvBillNo>='''+Frm_Inv_BillPrint.begInBillNo+''''
+' And InvBillNo<='''+Frm_Inv_BillPrint.endBillNo+''''
+' And BillTypeCode='''+BillTypeCode+'''';
if not PrintPrinted then
AdoQry_BillTmp.SQL.Text:=AdoQry_BillTmp.SQL.Text
+' And PrintTimes=0';
AdoQry_BillTmp.Open;
while not AdoQry_BillTmp.Eof do
begin
BillNo:=AdoQry_BillTmp.fieldbyname('InvBillNo').AsString;
if not preview then
begin
Common_Report.SetFormParam(BillNo,WHCode,BillTypeCode,'Print',ModuleCode,'');
Common_Report.SetDBConnect(AdoQry_BillTmp.Connection);
end
else
begin
Common_Report.SetFormParam(BillNo,WHCode,BillTypeCode,'Preview',ModuleCode,'');
Common_Report.SetDBConnect(AdoQry_BillTmp.Connection);
end;
AdoQry_BillTmp.Next;
end;
AdoQry_BillTmp.Close;
AdoQry_BillTmp.SQL.Text:='Update '+InvBill+' Set PrintTimes=PrintTimes+1'
+' Where WHCode='''+WHCode+''''
+' And InvBillNo>='''+Frm_Inv_BillPrint.begInBillNo+''''
+' And InvBillNo<='''+Frm_Inv_BillPrint.endBillNo+''''
+' And BillTypeCode='''+BillTypeCode+'''';
if not PrintPrinted then
AdoQry_BillTmp.SQL.Text:=AdoQry_BillTmp.SQL.Text
+' And PrintTimes=0';
AdoQry_BillTmp.ExecSQL;
end;
Frm_Inv_BillPrint.Release;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -