📄 inv_mnoutaudit_b.pas
字号:
unit Inv_MnOutAudit_B;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check_Body, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, ExtEdit, Mask, DBCtrls,dbgrids, jpeg,variants;
Type
TFrm_Inv_MnOutAudit_B = Class(TFrm_Base_Check_Body)
Label1: TLabel;
DBText1: TDBText;
Label7: TLabel;
lbl_WhCode1: TLabel;
Extedt_Billno: TExtEdit;
medt_Date: TMaskEdit;
Extedt_memo: TExtEdit;
AdoQuery1: TAdoQuery;
DataSource1: TDataSource;
Label8: TLabel;
lbl_WhCode: TEdit;
lbl_Dept: TEdit;
lbl_Mono: TEdit;
lbl_MoLineno: TEdit;
lbl_Item: TEdit;
lbl_MoRequestshift: TEdit;
lbl_WhPosition: TEdit;
lbl_WipWaster: TEdit;
Label13: TLabel;
EdtUserCode: TEdit;
procedure FormActivate(Sender: TObject);
procedure DBGridEhColExit(Sender: TObject);
procedure Act_autoExecute(Sender: TObject);
procedure Act_CheckExecute(Sender: TObject);
procedure Act_PreviewExecute(Sender:Tobject);
procedure Act_PrintExecute(Sender:Tobject);
procedure AdoQry_BodyAfterScroll(DataSet: TDataSet);
procedure AdoQry_BodyAfterPost(DataSet: TDataSet);
procedure AdoQry_BodyBeforePost(DataSet: TDataSet);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure medt_DateChange(Sender: TObject);
procedure Extedt_memoChange(Sender: TObject);
procedure DateCheck(Sender: TObject);
procedure AdoQry_BodyBeforeEdit(DataSet: TDataSet);
procedure DBGridEhKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
oldInvBillqty,IOType:real;
oldBatchno,BillTypeCode,InvBillid:string;
PriceType:integer;
procedure checkcoCurrentqty;
procedure checkIOType;
procedure setstrol;
{ Private declarations }
public
tmp_Status:string;
procedure InitControls; Override;//初始化Form上所有控件
{ Public declarations }
end;
var
Frm_Inv_MnOutAudit_B: TFrm_Inv_MnOutAudit_B;
implementation
uses Inv_MnOutAudit_H,Sys_Global,Inv_Global;
{$R *.DFM}
procedure TFrm_Inv_MnOutAudit_B.InitControls;
var
I:integer;
begin//初始化Form上的控件
inherited;
with DBGridEh do
begin
options:=options+[dgEditing]-[dgRowselect];
end;
BillTypeCode:=Param2;
lbl_WhCode.text:=AdoQry_Head.fieldbyname('whCodeName').asstring;
lbl_WhPosition.text:=AdoQry_Head.fieldbyname('WhPositionCodeName').asstring;
Extedt_Billno.text:=AdoQry_Head.fieldbyname('InvBillno').asstring;
lbl_Mono.text:=AdoQry_Head.fieldbyname('mono').asstring;
lbl_MoLineno.text:=AdoQry_Head.fieldbyname('MoLineno').asstring;
InvBillid:=AdoQry_Head.fieldbyname('InvBillid').asstring;
lbl_MoRequestshift.text:=AdoQry_Head.fieldbyname('shiftType').asstring;
lbl_Dept.text:=AdoQry_Head.fieldbyname('DeptCodeName').asstring;
if AdoQry_Head.fieldbyname('WipWaster').asinteger=0 then
lbl_WipWaster.text:='正常';
if AdoQry_Head.fieldbyname('WipWaster').asinteger=1 then
lbl_WipWaster.text:='料废';
// if AdoQry_Head.fieldbyname('WipWaster').asinteger=2 then
// lbl_WipWaster.text:='废料';
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:='select EmployeeName from Employee where EmployeeCode='''+UserCode+'''';
open;
if not eof then
edtUserCode.Text :=fieldbyname('EmployeeName').asstring;
end;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select PriceType from Warehouse where whCode='''+getCode(lbl_WhCode.text)+'''');
open;
PriceType:=fieldbyname('PriceType').asinteger;
end;
//取生产产品物料代码显示
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select ml.ItemCode,i.ItemName from MoLine ml,Item i '+
' where ml.mono='''+lbl_Mono.text+''''+
' and ml.MoLineno='+lbl_MoLineno.text+
' and ml.ItemCode=i.ItemCode');
open;
if not eof then
lbl_Item.text:=fieldbyname('ItemCode').asstring+' '+fieldbyname('ItemName').asstring
else
lbl_Item.text:='';
end;
medt_Date.text:=LoginDate;
//把产品的所需的物料的显示出来
with AdoQry_Body do
begin
Close;
sql.clear;
sql.Add('select '+
'ol.InvBillid,'+
'ol.InvBilllineno,'+
'ol.mono,'+
'ol.MoLineno,'+
'ol.ItemCode,'+
'ol.ite_ItemCode,'+
'ol.BilllineremArk,'+
'i.ItemName,'+
'i.ItemCode2,'+
'u.UomName,'+
'round(m.moCtrlqty,0) as moCtrlqty,'+
'm.MoRealqty,'+
'm.alterNative,'+
'm.ItemListid,'+
'm.Parentid,'+
'm.Bomqty,'+
'm.BomScrAp_Percent,'+
'ol.InvBillSfcqty, '+
'ol.InvBillqty,'+
'ol.Batchno,'+
'c.'+getInvfield(AdoQry_tmp,getCode(lbl_WhCode.text),getCode(lbl_WhPosition.text),'CurrentInv')+' as onhandInv '+
' from InvOutBillline ol'+
' left join CurrentInv c '+
' on ol.ItemCode=c.ItemCode '+
' and c.whCode='''+getCode(lbl_WhCode.text)+''''+
' and c.WhPositionCode='''+getCode(lbl_WhPosition.text)+''''+
' left join mnItemList m '+
' on ol.ItemListid=m.ItemListid '+
' left join Item i '+
' on ol.ItemCode=i.ItemCode '+
' left join Uom u '+
' on i.UomCode=u.UomCode '+
' where ol.InvBillid='+InvBillid+
' Order by ol.ItemCode ');
Open;
end;
tlbtn_Cancelcheck.action:=act_auto;
IOType:=0;
//设置各种状态
setstrol;
//选出替代件的限额数量 ,用于检验
AdoQuery1.Connection :=AdoQry_Body.Connection ;
AdoQuery1.EnableBCD :=False;
AdoQuery1.LockType :=ltBatchOptimistic;
with AdoQuery1 do
begin
Close;
sql.clear;
sql.Add('select ItemListid,Parentid,moCtrlqty,MoRealqty '+
' from mnItemList '+
' where mono='''+lbl_Mono.text+''''+
' and MoLineno='+lbl_MoLineno.text+
' and alterNative=1 '+
' and moCtrlqty>0 ');
open;
end;
//如果出现冲销的情况,即请领量为负数,就不进行自动获取功能。
with AdoQry_Body do
begin
First;
for I:=0 to recordCount-1 do
begin
if fieldbyname('InvBillSfcqty').asfloat<0 then
begin
act_auto.Enabled :=False;
break;
end;
next;
end;
end;
lbl_WhCode.Enabled :=False;
lbl_Dept.Enabled :=False;
lbl_Mono.Enabled :=False;
lbl_MoLineno.Enabled :=False;
lbl_Item.Enabled :=False;
lbl_MoRequestshift.Enabled :=False;
lbl_WhPosition.Enabled :=False;
lbl_WipWaster.Enabled :=False;
EdtUserCode.Enabled :=False;
end;
procedure TFrm_Inv_MnOutAudit_B.FormActivate(Sender: TObject);
begin
inherited;
Caption:='车间生产领料仓库核定';
pnl_title.Caption:='车间生产领料仓库核定';
ToolButton4.left:=ToolButton13.left+ToolButton4.Width;
// toolbutton4.Action:=act_quit;
if AdoQry_Head.fieldbyname('InvBilltmpflag').asinteger=1 then
dbgrideh.SetFocus
else
medt_Date.setfocus;
end;
procedure TFrm_Inv_MnOutAudit_B.checkcoCurrentqty;
var
tmp_SwApMoRealqty,tmp_SwApmoCtrlqty,tmp_InvBillqty,tmp_MoRealqty,tmp_MoCtrlqty,
tmp_InvBillSfcqty,tmp_onhandInv,tmp_Bomqty,tmp_BomScrAp_Percent:real;
begin
tmp_InvBillqty:=AdoQry_Body.fieldbyname('InvBillqty').asfloat;
tmp_MoRealqty:=AdoQry_Body.fieldbyname('MoRealqty').asfloat;
tmp_MoCtrlqty:=AdoQry_Body.fieldbyname('moCtrlqty').asinteger;
tmp_onhandInv:=AdoQry_Body.fieldbyname('onhandInv').asfloat;
tmp_InvBillSfcqty:=AdoQry_Body.fieldbyname('InvBillSfcqty').asfloat;
tmp_Bomqty:=AdoQry_Body.fieldbyname('Bomqty').asfloat;
tmp_BomScrAp_Percent:=AdoQry_Body.fieldbyname('BomScrAp_Percent').asfloat;
if AdoQry_Body.fieldbyname('InvBillqty').asstring='' then
begin
DispInfo('当前数量不能为空!',1);
abort;
AdoQry_Body.EnableControls;
end;
//如果不是超订单领料,则领料数量+实领数量不能大于限额数量
if AdoQry_Head.fieldbyname('OverPlan').asinteger<>1 then
begin
//如果物料是限额领料控制
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select limitout from Item where ItemCode='''+AdoQry_Body.fieldbyname('ItemCode').asstring+'''');
open;
if fieldbyname('limitout').asinteger=1 then
begin
if (AdoQry_Body.fieldbyname('alterNative').asstring='1') then
begin
//领料数+实领<限额数
//公式:(替换虚项限额数-替换虚项实领)*实项定额*(1+损耗)>=当前实项请领数-旧请领数
AdoQuery1.First;
AdoQuery1.Locate ('ItemListid',AdoQry_Body.fieldbyname('Parentid').asstring,[]);
tmp_SwApmoCtrlqty:=AdoQuery1.fieldbyname('moCtrlqty').asfloat;
tmp_SwApMoRealqty:=AdoQuery1.fieldbyname('MoRealqty').asfloat;
if ((tmp_SwApmoCtrlqty-tmp_SwApMoRealqty)*tmp_Bomqty*(1+tmp_BomScrAp_Percent/100)<tmp_InvBillqty-oldInvBillqty) then
begin
if AdoQry_Body.fieldbyname('InvBillqty').asstring<>'0' then
begin
DispInfo('领料总数量超过了限额数量,请使用“超订单领料”!',1);
AdoQry_Body.EnableControls;
abort;
end;
end;
end
else
begin
if (tmp_InvBillqty+tmp_MoRealqty)>tmp_MoCtrlqty then
begin
if AdoQry_Body.fieldbyname('InvBillqty').asstring<>'0' then
begin
DispInfo('领料总数量超过了限额数量,请使用“超订单领料”!',1);
AdoQry_Body.EnableControls;
abort;
end;
end;
end;
end;
end;
end;
//假如是负数回冲,则控制回冲的数量不能大于累计领用数量
if tmp_InvBillqty<0 then
begin
//替代件的换算
if (AdoQry_Body.fieldbyname('alterNative').asstring='1') then
begin
//领料数+实领<限额数
//公式:(替换虚项限额数-替换虚项实领)*实项定额*(1+损耗)>=当前实项请领数-旧请领数
AdoQuery1.First;
AdoQuery1.Locate ('ItemListid',AdoQry_Body.fieldbyname('Parentid').asstring,[]);
tmp_SwApmoCtrlqty:=AdoQuery1.fieldbyname('moCtrlqty').asfloat;
tmp_SwApMoRealqty:=AdoQuery1.fieldbyname('MoRealqty').asfloat;
if (abs(tmp_SwApMoRealqty)-abs(tmp_InvBillqty)<0) then
begin
DispInfo('冲销的数量不能大于累计领料数量!',1);
AdoQry_Body.EnableControls;
abort;
end;
end
else
begin
//非替代件
tmp_MoRealqty:=AdoQry_Body.fieldbyname('MoRealqty').asfloat;
if (abs(tmp_MoRealqty)-abs(tmp_InvBillqty)<0) then
begin
DispInfo('冲销的数量不能大于累计领料数量!',1);
AdoQry_Body.EnableControls;
abort;
end;
end;
end;
if tmp_InvBillqty>tmp_onhandInv then
begin
DispInfo('当前可用库存是:'+AdoQry_Body.fieldbyname('onhandInv').asstring,1);
AdoQry_Body.EnableControls;
abort;
end;
//实际领用数量与请领数量的方向要一致
if (tmp_InvBillqty*tmp_InvBillSfcqty)<0 then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -