📄 sfc_mnrequest_b.pas
字号:
abort;
end;
end;
end;
end
end;
end;
procedure TFrm_Sfc_MnRequest_B.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 (Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)<>'+') Then
begin
if (Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,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_B.FormCreate(Sender: TObject);
begin
inherited;
IsAfterprint:=False;
TlBtn_InsertLine.Action:=Act_Auto;
SetFocus_Control:=cmbbx_WhCode;
end;
procedure TFrm_Sfc_MnRequest_B.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
//如果未保存打印,则调用Frm_Sfc_MnOut_NotSave_P,否则调用Frm_Sfc_MnOut_P
IsAfterprint:=True;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select SfcParamValueN '
+' From SfcParam '
+' Where SfcParamCode=''ISMnRequestReport1''';
AdoQry_Tmp.Open;
if Trim(Extedt_Billno.text)<>'' then
begin
BillPrint(DbConnect,GetCode(cmbbx_WhCode.Text),Extedt_Billno.Text,Param2,ModuleCode,True,False,True,'');
end
else
begin
If (AdoQry_Tmp.RecordCount>0) And (AdoQry_Tmp.fieldbyname('SfcParamValueN').AsInteger=1) Then
begin
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P1,Frm_Sfc_MnOut_NotSave_P1);
Frm_Sfc_MnOut_NotSave_P1.SetFormParam('',getCode(cmbbx_WhCode.text),Param2,'Preview',ModuleCode,'');
initprint;
Frm_Sfc_MnOut_NotSave_P1.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P1.release;
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;
end;
procedure TFrm_Sfc_MnRequest_B.Act_PrintExecute(Sender: TObject);
begin
//如果未保存打印,则调用Frm_Sfc_MnOut_NotSave_P,否则调用Frm_Sfc_MnOut_P
IsAfterprint:=True;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select SfcParamValueN '
+' From SfcParam '
+' Where SfcParamCode=''ISMnRequestReport1''';
AdoQry_Tmp.Open;
if Trim(Extedt_Billno.text)<>'' then
BillPrint(AdoQry_Tmp.Connection,GetCode(cmbbx_WhCode.Text),Extedt_Billno.Text,Param2,ModuleCode,False,False,True,'')
else
begin
If (AdoQry_Tmp.RecordCount>0) And (AdoQry_Tmp.fieldbyname('SfcParamValueN').AsInteger=1) Then
begin
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P1,Frm_Sfc_MnOut_NotSave_P1);
Frm_Sfc_MnOut_NotSave_P1.SetFormParam('',getCode(cmbbx_WhCode.text),Param2,'Preview',ModuleCode,'');
initprint;
Frm_Sfc_MnOut_NotSave_P1.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P1.release;
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;
//IsAfterprint:=False;
end;
procedure TFrm_Sfc_MnRequest_B.Act_ExcelExecute(Sender: TObject);
begin
inherited;
//
end;
procedure TFrm_Sfc_MnRequest_B.AdoQry_BodyAfterPost(DataSet: TDataSet);
begin
inherited;
IOType:=AdoQry_Body.fieldbyname('moRequestqty').asfloat;
end;
procedure TFrm_Sfc_MnRequest_B.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_B.CheckBox1Click(Sender: TObject);
begin
inherited;
showdbgrid;
end;
procedure TFrm_Sfc_MnRequest_B.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_B.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);
DbConnect.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<>'1') 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;
end;
AdoQry_SwAp.EnableControls;
end;
//生产单据号
Billno:=getno(DbConnect,getCode(cmbbx_WhCode.text)+'C'+copy(medt_Date.text,3,2)+copy(medt_Date.text,6,2),'InvBill');
//增加InvOutBill
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add('insert InvOutBill'+
'(InvBillno,'+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -