📄 sfc_mnrequest_b1.pas
字号:
else
begin
if not BatchNoCheck(AdoQry_tmp,dbgrideh.SelectedField.Value,AdoQry_Body.fieldbyname('ItemCode').asstring,'',medt_Date.text) then
begin
dbgrideh.setfocus;
abort
end
else
begin
tmp_WhCode:=getCode(cmbbx_WhCode.text);
tmp_WhPositionCode:=getCode(cmbbx_WhPositionCode.text);
if not BatchInvCheck(AdoQry_tmp,dbgrideh.SelectedField.Value,'C',tmp_WhCode,tmp_WhPositionCode,AdoQry_Body.fieldbyname('moRequestqty').asfloat) then
begin
dbgrideh.setfocus;
abort;
end;
end;
end;
end
end;
end;
procedure TFrm_Sfc_MnRequest_B1.Act_autoExecute(Sender: TObject);
var
M:integer;
Batchno:string;
outqty:double;
begin
inherited;
if swApflag>0 then
begin
DispInfo('本功能只适合非替代件,替代件的请领数量请手工维护!',1);
end;
if (activecontrol.Name='cmbbx_WhPositionCode') or
(activecontrol.Name='cmbbx_WhCode') or
(activecontrol.Name='cmbbx_WhEmployee') then
medt_Date.setfocus;
with AdoQry_Body do
begin
AdoQry_Body.First;
for M:=0 to recordCount-1 do
begin
if AdoQry_Body.fieldbyname('alterNative').asinteger<>2 Then
begin
if AdoQry_Body.fieldbyname('alterNative').asinteger<>1 then
begin
if fieldbyname('onhandInv').asfloat>
(fieldbyname('moCtrlqty').asfloat-
fieldbyname('MoRealqty').asfloat)
then
begin
if fieldbyname('moCtrlqty').asfloat<fieldbyname('MoRealqty').asfloat then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
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);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('moRequestqty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('moRequestqty').asfloat:=fieldbyname('moCtrlqty').asfloat-
fieldbyname('MoRealqty').asfloat;
end;
end;
end
else
begin
if BatchCtrl(AdoQry_tmp,fieldbyname('ItemCode').asstring) then
begin
//批次处理的自动获取 ,如果批次库存小于当前库存,则取批次库存
outqty:=fieldbyname('onhandInv').asfloat;
Batchno:=GiveBatchNo(AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
medt_Date.text,
outqty);
if Batchno='' then
begin
// edit;
// fieldbyname('moRequestqty').asfloat:=0;
end
else
begin
edit;
fieldbyname('moRequestqty').asfloat:=outqty;
fieldbyname('Batchno').asstring:=Batchno;
end;
end
else
begin
edit;
fieldbyname('moRequestqty').asfloat:=fieldbyname('onhandInv').asfloat;
end;
end;
end;
end;
AdoQry_Body.next;
end;
end;
end;
procedure TFrm_Sfc_MnRequest_B1.FormCreate(Sender: TObject);
begin
inherited;
IsAfterprint:=False;
TlBtn_InsertLine.Action:=Act_Auto;
SetFocus_Control:=cmbbx_WhCode;
end;
procedure TFrm_Sfc_MnRequest_B1.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
//如果未保存打印,则调用Frm_Sfc_MnOut_NotSave_P,否则调用Frm_Sfc_MnOut_P
if Trim(Extedt_Billno.text)<>'' then
begin
BillPrint(AdoQry_Tmp.Connection,GetCode(cmbbx_WhCode.Text),Extedt_Billno.Text,Param2,ModuleCode,True,False,True,'');
end
else
begin
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P,Frm_Sfc_MnOut_NotSave_P);
Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),Param2,'Preview',ModuleCode,'');
initprint;
Frm_Sfc_MnOut_NotSave_P.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P.release;
end;
end;
procedure TFrm_Sfc_MnRequest_B1.Act_PrintExecute(Sender: TObject);
begin
//如果未保存打印,则调用Frm_Sfc_MnOut_NotSave_P,否则调用Frm_Sfc_MnOut_P
IsAfterprint:=True;
if Trim(Extedt_Billno.text)<>'' then
BillPrint(AdoQry_Tmp.Connection,GetCode(cmbbx_WhCode.Text),Extedt_Billno.Text,Param2,ModuleCode,False,False,True,'')
else
begin
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P,Frm_Sfc_MnOut_NotSave_P);
Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),Param2,'Print',ModuleCode,'');
initprint;
Frm_Sfc_MnOut_NotSave_P.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P.release;
end;
IsAfterprint:=False;
end;
procedure TFrm_Sfc_MnRequest_B1.AdoQry_BodyAfterPost(DataSet: TDataSet);
var sqltext:string;
BookmArk:string;
begin
inherited;
BookmArk:=AdoQry_Body.BookmArk;
IOType:=AdoQry_Body.fieldbyname('moRequestqty').asfloat;
sqltext:=' update #Sfcmo'
+' set moRequestqty='+AdoQry_Body.fieldbyname('moRequestqty').asstring
+' where ItemListid='+AdoQry_Body.fieldbyname('ItemListid').asstring;
Executesql(AdoQry_tmp,sqltext,1);
sqltext:=' declAre @tmplevel int '
+' select @tmplevel=max(Bomlevel) from #Sfcmo '
+' while @tmplevel<>0 '
+' begin '
+' update #Sfcmo '
+' set moRequestqty=(select min( t2.moRequestqty*1/(t2.Bomqty*(1+t2.BomScrAp_Percent/100.0))) from #Sfcmo t2 '
+' where #Sfcmo.ItemCode=t2.ite_ItemCode and t2.Bomlevel=@tmplevel) '
+' where #Sfcmo.Bomlevel=@tmplevel-1 '
+' and alterNative<>0 '
+' select @tmplevel=@tmplevel-1 '
+' end ';
Executesql(AdoQry_tmp,sqltext,1);
AdoQry_Body.ReQuery;
AdoQry_Body.BookmArk:=BookmArk;
end;
procedure TFrm_Sfc_MnRequest_B1.cmbbx_WhPositionCodeExit(Sender: TObject);
begin
inherited;
if (cmbbx_WhPositionCode.text<>'') and (cmbbx_WhPositionCode.text<>oldWhPosition) then
begin
showdbgrid;
end ;
oldWhPosition:=cmbbx_WhPositionCode.text;
end;
procedure TFrm_Sfc_MnRequest_B1.CheckBox1Click(Sender: TObject);
begin
inherited;
showdbgrid;
end;
procedure TFrm_Sfc_MnRequest_B1.FormActivate(Sender: TObject);
begin
if IsAfterprint=False then
inherited;
//初始化仓库
end;
procedure TFrm_Sfc_MnRequest_B1.cmbbx_WhCodeExit(Sender: TObject);
var
tmp_WhCode,tmp_WhPositionCode:string;
begin
inherited;
//调用初始化货位过程
initcmbbx_WhPositionCode(getCode(cmbbx_WhCode.text));
//如果独立订单,则让货位显示在'冻结货位'上 ,WhPositionType=2表示冻结货位
if AdoQry_Head.fieldbyname('moSpecial').asinteger=1 then
begin
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);
end;
//调用初化仓库过程
InitCmbbx_WhEmployee(getCode(cmbbx_WhCode.text));
//由于仓库的改变,调用cmbbx_WhPositionCode的OnExit事件重新刷新数据
if Trim(cmbbx_WhPositionCode.Text)<>'' then
cmbbx_WhPositionCode.OnExit(sender);
end;
procedure TFrm_Sfc_MnRequest_B1.SaveData;
var
M,N:integer;
tmp_qty:real;
Billno,Billid:string;
saveplace:tBookmArk;
begin
// inherited;
if AdoQry_Body.State in [dsEdit,dsInsert] then
AdoQry_Body.Post;
if AdoQry_SwAp.state in [dsEdit,dsInsert] then
AdoQry_SwAp.post;
medt_Date.onexit(medt_Date);
AdoQry_Body.Connection.beginTrans;
try
saveplace:=AdoQry_Body.GetBookmArk;
AdoQry_Body.DisableControls;
//检验库存
AdoQry_Body.First;
for M:=0 to AdoQry_Body.recordCount-1 do
begin
if (AdoQry_Body.fieldbyname('moRequestqty').asstring<>'0') and
(AdoQry_Body.fieldbyname('alterNative').asstring='0') then
begin
if not InvQtyCheck
(False,
AdoQry_Body,
AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
'moRequestqty',
AdoQry_Body.fieldbyname('moRequestqty').asfloat,
False) then
begin
AdoQry_Body.gotoBookmArk(saveplace);
AdoQry_Body.freeBookmArk(saveplace);
AdoQry_Body.enablecontrols;
abort;
end;
if AdoQry_Body.fieldbyname('Batchno').asstring<>'' then
begin
//批次库存检验
if not BatchInvCheck(AdoQry_tmp,
AdoQry_Body.fieldbyname('Batchno').asstring,
'C',
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('moRequestqty').asfloat) then
begin
AdoQry_Body.gotoBookmArk(saveplace);
AdoQry_Body.freeBookmArk(saveplace);
AdoQry_Body.enablecontrols;
abort;
end;
end;
end;
AdoQry_Body.next;
end;
//如果有替代件的,则检验替代件当前库存
{if swApflag>0 then
begin
AdoQry_SwAp.Filtered:=False;
AdoQry_SwAp.DisableControls;
AdoQry_SwAp.First;
for M:=0 to AdoQry_SwAp.recordCount-1 do
begin
if AdoQry_SwAp.fieldbyname('moRequestqty').asstring<>'0' then
begin
if not InvQtyCheck
(False,
AdoQry_Body,
AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_SwAp.fieldbyname('ItemCode').asstring,
'moRequestqty',
AdoQry_SwAp.fieldbyname('moRequestqty').asfloat,
False) then
begin
AdoQry_SwAp.gotoBookmArk(saveplace);
AdoQry_SwAp.freeBookmArk(saveplace);
AdoQry_SwAp.enablecontrols;
abort;
end;
if AdoQry_SwAp.fieldbyname('Batchno').asstring<>'' then
begin
//批次库存检验
if not BatchInvCheck(AdoQry_tmp,
AdoQry_SwAp.fieldbyname('Batchno').asstring,
'C',
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_SwAp.fieldbyname('moRequestqty').asfloat) then
begin
AdoQry_SwAp.gotoBookmArk(saveplace);
AdoQry_SwAp.freeBookmArk(saveplace);
AdoQry_SwAp.enablecontrols;
abort;
end;
end;
end;
AdoQry_SwAp.next;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -