inv_mnoutaudit_b.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 1,334 行 · 第 1/4 页
PAS
1,334 行
//更改当前库存 更改Item表的库存数据
IF UpdateInv(AdoQry_tmp,
tmp_WhCode,
tmp_WhPositionCode,
fieldbyname('ItemCode').asstring,
'(-('+fieldbyname('InvBillqty').asstring+'))',
NeedChangePrice,True)<>'' then
abort;
//更改批次库存数量
if fieldbyname('Batchno').asstring<>'' then
begin
ChangeBatchInv(AdoQry_tmp,fieldbyname('Batchno').asstring,'C',medt_Date.text,tmp_WhCode,tmp_WhPositionCode,AdoQry_Body.fieldbyname('InvBillqty').asfloat);
end;
//更改MNItemList的记录
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
if tmp_Backflush=1 then
AdoQry_tmp.sql.text:=
'update mnItemList set '+
' bfrealqty=bfrealqty+'+fieldbyname('InvBillqty').asstring+
' where ItemListid='+fieldbyname('ItemListid').asstring
else
AdoQry_tmp.sql.text:=
'update mnItemList set '+
' MoRealqty=MoRealqty+'+fieldbyname('InvBillqty').asstring+
' where ItemListid='+fieldbyname('ItemListid').asstring;
AdoQry_tmp.execsql;
ScLL(AdoQry_tmp,
fieldbyname('ItemCode').asstring,
'MOScLL',
lbl_Mono.text,
strtoint(lbl_MoLineno.text));
end;
next;
end;
end;
//删除记录中领料数量为零的记录
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.text:=
' delete InvOutBillline '+
' where InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring+
' and InvBillqty=0 ';
AdoQry_tmp.execsql;
with AdoQuery1 do
begin
First;
while not eof do
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
if tmp_Backflush=1 then
AdoQry_tmp.sql.text:=
' update mnItemList set '+
' BFrealqty='+fieldbyname('MoRealqty').asstring+
' where ItemListid='+fieldbyname('ItemListid').asstring
else
AdoQry_tmp.sql.text:=
' update mnItemList set '+
' MoRealqty='+fieldbyname('MoRealqty').asstring+
' where ItemListid='+fieldbyname('ItemListid').asstring;
AdoQry_tmp.execsql;
next;
end;
end;
AdoQry_Head.Connection.CommitTrans;
DBGridEh.Enabled :=True;
AdoQry_Body.EnableControls ;
//保存后设置各控键状态
dbgrideh.SetFocus;
dbgrideh.Columns[8].ReadOnly:=True;
dbgrideh.Columns[9].ReadOnly:=True;
act_Check.Enabled:=False;
act_auto.Enabled :=False;
medt_Date.enabled:=False;
Extedt_memo.enabled:=False;
AdoQry_Head.edit;
AdoQry_Head.fieldbyname('InvBilltmpflag').asinteger:=1;
AdoQry_Head.post;
except
begin
AdoQry_Head.Connection.RollBackTrans;
DBGridEh.Enabled :=True;
AdoQry_Body.EnableControls ;
// if not BeforeSaveError then
DispInfo(' 存盘不成功,请稍后再试! ',1);
end;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.AdoQry_BodyAfterScroll(DataSet: TDataSet);
begin
inherited;
if AdoQry_Body.Eof then AdoQry_Body.Prior;
end;
procedure TFrm_Inv_MnOutAudit_B.AdoQry_BodyAfterPost(DataSet: TDataSet);
var
tmp_Bomqty,tmp_BomScrAp_Percent:real;
begin
inherited;
IOType:=AdoQry_Body.fieldbyname('InvBillqty').asfloat;
act_Check.enabled:=True;
if AdoQry_Body.fieldbyname('alterNative').asstring='1' then
with AdoQuery1 do
begin
tmp_Bomqty:=AdoQry_Body.fieldbyname('Bomqty').asfloat;
tmp_BomScrAp_Percent:=AdoQry_Body.fieldbyname('BomScrAp_Percent').asfloat;
First;
Locate('ItemListid',AdoQry_Body.fieldbyname('Parentid').asstring,[]);
edit;
fieldbyname('MoRealqty').asfloat:=fieldbyname('MoRealqty').asfloat-
(oldInvBillqty-
AdoQry_Body.fieldbyname('InvBillqty').asfloat)/
tmp_Bomqty/(1+tmp_BomScrAp_Percent/100);
post;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.AdoQry_BodyBeforePost(DataSet: TDataSet);
var
tmp_WhCode,tmp_WhPositionCode:string;
begin
inherited;
checkIOType;
checkcoCurrentqty;
//如果是批次控制,则修改后不能空,且要检验批次号,如果不是批次控制,不能进行修改,只能为空
//用OLDBatchNO来控制原批次号,OLDBatchNO为空,表示原批次号为空,不能修改,OLDBatchNO不为空
//则原批次号可以修改,但不能改为空。
tmp_WhCode:=getCode(lbl_WhCode.text);
tmp_WhPositionCode:=getCode(lbl_WhPosition.text);
if oldBatchno<>'' then
begin
if AdoQry_Body.fieldbyname('Batchno').asstring<>'' then
begin
if not BatchNoCheck(AdoQry_tmp,AdoQry_Body.fieldbyname('Batchno').asstring,AdoQry_Body.fieldbyname('ItemCode').asstring,'',medt_Date.text) then
begin
dbgrideh.SetFocus;
abort;
end
else
begin
if not BatchInvCheck(AdoQry_tmp,AdoQry_Body.fieldbyname('Batchno').asstring,'C',tmp_WhCode,tmp_WhPositionCode,AdoQry_Body.fieldbyname('InvBillqty').asfloat) then
begin
dbgrideh.setfocus;
abort;
end;
end;
end
else
begin
DispInfo('该批次号不能为空',1);
AdoQry_Body.fieldbyname('Batchno').asstring:=oldBatchno;
dbgrideh.SetFocus;
abort;
end;
end
else
begin
//如果实领数量为零,就不能录入批次号
if (AdoQry_Body.fieldbyname('InvBillqty').asstring='0') and
(AdoQry_Body.fieldbyname('Batchno').asstring<>'') then
begin
AdoQry_Body.fieldbyname('Batchno').asstring:='';
end;
//如果实领数量不为零
if (AdoQry_Body.fieldbyname('InvBillqty').asstring<>'0') then
begin
//且如果不受批次控制且批次号不为空,则令其空,且提示
if (not BatchCtrl(AdoQry_tmp,AdoQry_Body.fieldbyname('ItemCode').asstring)) then
begin
if (AdoQry_Body.fieldbyname('Batchno').asstring<>'') then
begin
DispInfo('该物料不受批次控制,不能录入批次号',1);
AdoQry_Body.fieldbyname('Batchno').asstring:='';
dbgrideh.setfocus;
abort;
end
end;
end;
//如果受批次控制,则做批次号是否存在检验,如果存在,则检验批次库存是否够
if (AdoQry_Body.fieldbyname('InvBillqty').asstring<>'0') then
begin
if (BatchCtrl(AdoQry_tmp,AdoQry_Body.fieldbyname('ItemCode').asstring)) then
begin
if (AdoQry_Body.fieldbyname('Batchno').asstring='') then
begin
DispInfo('请录入批次号',1);
dbgrideh.setfocus;
abort;
end
else
begin
if not BatchNoCheck(AdoQry_tmp,
AdoQry_Body.fieldbyname('Batchno').asstring,
AdoQry_Body.fieldbyname('ItemCode').asstring,
'',
medt_Date.text) then
begin
dbgrideh.setfocus;
abort;
end
else
begin
if not BatchInvCheck(AdoQry_tmp,
AdoQry_Body.fieldbyname('Batchno').asstring,
'C',
tmp_WhCode,
tmp_WhPositionCode,
AdoQry_Body.fieldbyname('InvBillqty').asfloat) then
begin
dbgrideh.setfocus;
abort;
end;
end;
end;
end;
end;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.setstrol;
begin
if AdoQry_Head.fieldbyname('InvBilltmpflag').asinteger=1 then
begin
medt_Date.enabled:=False;
Extedt_memo.enabled:=False;
act_Check.Enabled :=False;
act_auto.Enabled :=False;
dbgrideh.columns[8].ReadOnly:=True;
dbgrideh.columns[9].ReadOnly:=True;
end
else
begin
medt_Date.enabled:=True;
Extedt_memo.enabled:=True;
act_Check.Enabled :=True;
act_auto.Enabled :=True;
// act_Check.Enabled :=False;
dbgrideh.columns[8].ReadOnly:=False;
dbgrideh.columns[9].ReadOnly:=False;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if act_Check.Enabled =True then
begin
if DispInfo('数据发生改变,是否要审核?',2)='y' then
act_Check.Execute
else
inherited;
end
else
inherited;
end;
procedure TFrm_Inv_MnOutAudit_B.medt_DateChange(Sender: TObject);
begin
inherited;
act_Check.Enabled :=True;
end;
procedure TFrm_Inv_MnOutAudit_B.Extedt_memoChange(Sender: TObject);
begin
inherited;
act_Check.Enabled :=True;
end;
procedure TFrm_Inv_MnOutAudit_B.DateCheck(Sender: TObject);
begin
inherited;
if not WHClsPeriodCheck(AdoQry_tmp,getCode(lbl_WhCode.text),copy(medt_Date.text,1,7)) then
begin
medt_Date.setfocus;
abort;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.Act_PreviewExecute(Sender: TObject);
begin
//inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(lbl_WhCode.text),Extedt_Billno.Text,Param1,ModuleCode,True,False,True,'all');
end;
procedure TFrm_Inv_MnOutAudit_B.Act_PrintExecute(Sender: TObject);
begin
//inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(lbl_WhCode.text),Extedt_Billno.Text,Param1,ModuleCode,False,False,True,'all');
end;
procedure TFrm_Inv_MnOutAudit_B.AdoQry_BodyBeforeEdit(DataSet: TDataSet);
begin
inherited;
oldInvBillqty:=AdoQry_Body.fieldbyname('InvBillqty').asfloat;
oldBatchno:=AdoQry_Body.fieldbyname('Batchno').asstring;
if dbgrideh.SelectedField.fieldName='Batchno' then
begin
if AdoQry_Body.fieldbyname('Batchno').asstring='' then
begin
DispInfo('不允许修改该批次号',1);
DBGridEh.setfocus;
abort;
end;
end;
end;
procedure TFrm_Inv_MnOutAudit_B.DBGridEhKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if (AdoQry_Body.State in [dsedit]) and
(dbgrideh.SelectedField.fieldName='Batchno') and
(key=VK_F9) then
AdoQry_Body.fieldbyname('Batchno').asstring:=
BatchHint(AdoQry_tmp.Connection,AdoQry_Body.fieldbyname('ItemCode').asstring,'',getCode(lbl_WhCode.text),getCode(lbl_WhPosition.text));
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?