📄 inv_enter_mounitmnrequestauditing1.pas
字号:
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.cmbbx_WhPositionCodeChange(
Sender: TObject);
begin
inherited;
//ShowDbgrid;
end;
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.cmbbx_WhCodeExit(
Sender: TObject);
var
tmp_WhCode,tmp_WhPositionCode:string;
begin
inherited;
//调用初始化货位过程
initcmbbx_WhPositionCode(getCode(cmbbx_WhCode.text));
//如果独立订单,则让货位显示在'冻结货位'上 ,WhPositionType=2表示冻结货位
tmp_WhCode:=getCode(cmbbx_WhCode.text);
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select WhPositionCode,WhPositionName '+
' from WhPosition '+
' where whCode='''+tmp_WhCode+''' and WhPositionType=2');
open;
tmp_WhPositionCode:=fieldbyname('WhPositionCode').asstring;
end;
//InitCmBxText(cmbbx_WhPositionCode,tmp_WhPositionCode);
//调用初化仓库过程
//InitCmbbx_WhEmployee(getCode(cmbbx_WhCode.text));
//由于仓库的改变,调用cmbbx_WhPositionCode的OnExit事件重新刷新数据
//if Trim(cmbbx_WhPositionCode.Text)<>'' then
// cmbbx_WhPositionCode.OnExit(sender);
end;
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.Act_autoExecute(
Sender: TObject);
var
M,tmp_OverPlan:integer;
tmp_BomScrAp_Percent,tmp_SwApMoRealqty,tmp_Bomqty,tmp_SwApmoCtrlqty,tmp_reMain,
InvBillqty,onhandInv,InvBillSfcqty,moCtrlqty,MoRealqty:real;
Batchno:string;
outqty:double;
//实领数量,当前库存,请领数量,限额数量,累计实领数量
begin
inherited;
//获取最佳数量代码,不包括
with AdoQry_Body do
begin
disablecontrols;
First;
for M:=0 to recordCount-1 do
begin
//InvBillqty:=fieldbyname('ThisRequestQty').asfloat;
InvBillSfcqty:=fieldbyname('MoRequestQty').asfloat;
//InvBillSfcqty:=fieldbyname('InvBillSfcqty').asfloat;
onhandInv:=fieldbyname('onhandInv').asfloat;
moCtrlqty:=fieldbyname('moCtrlqty').asfloat;
MoRealqty:=fieldbyname('MoRealqty').asfloat;
// tmp_Bomqty:=fieldbyname('Bomqty').asfloat;
// tmp_BomScrAp_Percent:=fieldbyname('BomScrAp_Percent').asfloat;
if (InvBillSfcqty=0) and ((onhandInv=0) or (onhandInv=null)) then
begin
end
else
begin
//如果是超计划,则实领数量=MIN(请领数量,库存数量)
if tmp_OverPlan=1 then
begin
if InvBillSfcqty>onhandInv then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
outqty:=fieldbyname('moCtrlqty').asfloat-
fieldbyname('MoRealqty').asfloat;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring
);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=fieldbyname('onhandInv').asfloat;
end;
end
else
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=fieldbyname('MoRequestQty').asfloat;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring
);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=fieldbyname('InvBillSfcqty').asfloat;
end;
end;
end
else
begin
//判断是否是替换实项,因替换实项的MoRealQTY,MOCtrlQTY 是从MNItemList表中的虚项中来
//{if fieldbyname('alterNative').asstring<>'1' then
begin
//不是超领,实领数量=MIN(请领数量,库存数量,限额数量-累计实领数量)
if InvBillSfcqty<onhandInv then
begin
if InvBillSfcqty<(moCtrlqty-MoRealqty) then
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=InvBillSfcqty;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=InvBillSfcqty;
end;
end
else
begin
if (moCtrlqty-MoRealqty)>0 then
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=(moCtrlqty-MoRealqty);
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=(moCtrlqty-MoRealqty);
end;
end;
end;
end
else
begin
if onhandInv<(moCtrlqty-MoRealqty) then
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=onhandInv;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('ItemCode').asstring);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=onhandInv;
end;
end
else
begin
if (moCtrlqty-MoRealqty)>0 then
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=(moCtrlqty-MoRealqty);
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('ThisRequestQty').asfloat:=(moCtrlqty-MoRealqty);
end;
end;
end;
end;
end;
{else
begin
//如果是替代件的最佳获取 不是超领,实领数量=MIN(请领数量,库存数量,限额数量-累计实领数量)
AdoQuery1.First;
//AdoQuery1.Locate ('ItemListid',AdoQry_Body.fieldbyname('Parentid').asstring,[]);
tmp_SwApmoCtrlqty:=AdoQuery1.fieldbyname('moCtrlqty').asfloat;
tmp_SwApMoRealqty:=AdoQuery1.fieldbyname('MoRealqty').asfloat;
//折合替换实项的:限额数量-累计实领数量
tmp_reMain:=(tmp_SwApmoCtrlqty-tmp_SwApMoRealqty)*tmp_Bomqty*(1+tmp_BomScrAp_Percent/100);
if InvBillSfcqty<onhandInv then
begin
if InvBillSfcqty<tmp_reMain then
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//如果是批处理控制,则根据处入来的数量OUTQTY与批处理库存中最佳数量比效,
//取最佳批次号
outqty:=InvBillSfcqty;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty,
AdoQry_Body.fieldbyname('Batchno').asstring);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('InvBillqty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('InvBillqty').asfloat:=InvBillSfcqty;
end;
end
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -