📄 inv_enter_mounitmnrequestauditing.pas
字号:
unit Inv_Enter_MoUnitMnRequestAuditing;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check_Body, Mask, StdCtrls, ExtEdit, Db, ActnList, AdODB, Grids,dbgrids,
DBGridEh, ExtCtrls, ComCtrls, ToolWin, jpeg, ExtPrintReport,pr_PrintReportType, variants;
Type
TFrm_Inv_Enter_MoUnitMnRequestAuditing = Class(TFrm_Base_Check_Body)
Label1: TLabel;
Label2: TLabel;
Label7: TLabel;
Label4: TLabel;
Extedt_Billno: TExtEdit;
medt_Date: TMaskEdit;
Label6: TLabel;
Label5: TLabel;
Edt_Dept: TExtEdit;
Label3: TLabel;
Label12: TLabel;
Extedt_memo: TExtEdit;
AdoQuery1: TAdoQuery;
cmbbx_WhCode: TEdit;
cmbbx_WhPositionCode: TEdit;
cmbbx_Shift: TEdit;
cmbbx_WhEmployee: TEdit;
Label8: TLabel;
Edt_WhEmployeeCode: TEdit;
ExtPrintReport: TExtPrintReport;
Button2: TButton;
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DateCheck(Sender: TObject);
procedure DBGridEhKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGridEhColExit(Sender: TObject);
procedure cmbbx_WhPositionCodeChange(Sender: TObject);
procedure cmbbx_WhCodeExit(Sender: TObject);
procedure Act_autoExecute(Sender: TObject);
procedure Act_CheckExecute(Sender: TObject);
procedure Act_QuitExecute(Sender: TObject);
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
IsAfterPrint : Boolean;
InvBillid:string;
PriceType:integer;
procedure checkcoCurrentqty;
procedure InitCmbbx_WhPositionCode(whCode:string);
procedure InitCmbbx_WhEmployee(whCode:string);
procedure showdbgrid;
procedure initprint;
Function GetUserName(userCode:string):string;
procedure SetReport;
procedure GetTransValue(FieldName,OldValue:String;var NewValue:String);
procedure SetColumnsStyle(ItemIndex:Integer;FieldName:String);
Function repstr(str:string;times:integer):string;
procedure OutputMOList(I:integer) ; //0:preview;1:Print;
public
{ Public declarations }
tmp_Status:string;
procedure InitForm(AdOConnection:TAdOConnection;FormStatus:String;
AdoQuery:TAdoQuery); Override;
procedure InitControls; Override;//初始化Form上所有控件
end;
var
Frm_Inv_Enter_MoUnitMnRequestAuditing: TFrm_Inv_Enter_MoUnitMnRequestAuditing;
implementation
uses Sys_Global, Inv_Global, Sfc_MnOut_NotSave_P;
{$R *.DFM}
{ TFrm_Inv_Enter_MoUnitMnRequestAuditing }
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.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('ThisRequestQty').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('MoRequestQty').asfloat;
// tmp_Bomqty:=AdoQry_Body.fieldbyname('Bomqty').asfloat;
//tmp_BomScrAp_Percent:=AdoQry_Body.fieldbyname('BomScrAp_Percent').asfloat;
if AdoQry_Body.fieldbyname('ThisRequestQty').asstring='' then
begin
DispInfo('当前数量不能为空!',1);
abort;
AdoQry_Body.EnableControls;
end;
{ if tmp_InvBillqty=0 then
begin
DispInfo('实领数量不能为零!',3);
AdoQry_Body.EnableControls;
abort;
end;}
if tmp_InvBillqty<0 then
begin
DispInfo('实领数量不能小于零!',3);
AdoQry_Body.EnableControls;
abort;
end;
if tmp_InvBillqty> tmp_InvBillSfcqty then
begin
DispInfo('实领数量不能大于请领数量!',3);
AdoQry_Body.EnableControls;
abort;
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('ThisRequestQty').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
DispInfo('实际数量与请领数量的正负方向必须一致!',1);
AdoQry_Body.EnableControls;
abort;
end;
end;
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.InitCmbbx_WhEmployee(
whCode: string);
begin
//初始化仓管员,从物料主文件中选出当前仓库的缺省仓管员,可以为空
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select distinct i.wh_EmployeeCode,e.EmployeeName '+
' from Item i,Employee e '+
' where whCode='''+whCode+''''+
' and i.wh_EmployeeCode is not null '+
' and i.wh_EmployeeCode=e.EmployeeCode '+
' Order by i.wh_EmployeeCode');
open;
{cmbbx_WhEmployee.clear;
cmbbx_WhEmployee.Items.Add('');
if not Eof then
begin
First;
while not Eof do
begin
cmbbx_WhEmployee.Items.Add(fieldbyname('wh_EmployeeCode').asstring+' '+fieldbyname('EmployeeName').asstring);
Next;
end;
cmbbx_WhEmployee.Itemindex := 0;
end;}
end;
end;
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.InitCmbbx_WhPositionCode(
whCode: string);
begin
//初始化货位,根据当前传入的仓库号码,选出不是待检货位及不是拉式货位的货位
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select WhPositionCode,WhPositionName '+
' from WhPosition '+
' where whCode='''+whCode+''''+
' and WhPositionType<>1 '+
' and BackFlushWhP=0 '+
' Order by WhPositionCode ');
open;
{cmbbx_WhPositionCode.clear;
if not Eof then
begin
First;
while not Eof do
begin
cmbbx_WhPositionCode.Items.Add(fieldbyname('WhPositionCode').asstring+' '+fieldbyname('WhPositionName').asstring);
Next;
end;
end;}
end;
//cmbbx_WhPositionCode.Itemindex:=0;
end;
procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.InitControls;
var
sqltext:string;
I:integer;
begin
inherited;
//说明:用tmp_Status变量控制这个窗体, =notChange 为窗体刚进入
//是 =Change cmbbx_WhPositionCode 改变的状态,要根据货位的改变而刷新GRID
with dbgrideh do
begin
options:=options+[dgEditing]-[dgRowselect];
end;
pnl_Hint.Visible :=False;
//控制保存后届面不变SHOWFLAG是基类的参数
//if (showflag=True) and (status<>'Add') then
// exit;
//Edt_Dept.Text := Frm_Sfc_Enter_MoUnitMnRequestH.tmp_DeptCode;
cmbbx_WhCode.text:=AdoQry_Head.fieldbyname('whCodeName').asstring;
cmbbx_WhPositionCode.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;
cmbbx_Shift.text:=AdoQry_Head.fieldbyname('shiftType').asstring;
Edt_Dept.text:=AdoQry_Head.fieldbyname('DeptCodeName').asstring;
cmbbx_WhEmployee.text:=AdoQry_Head.fieldbyname('Sfc_EmployeeCodeName').asstring;
medt_Date.text:=DateToStr(Date);
ShowDbgrid;
//DBGRID只允许请领数量,批次号,备注可以更改
//if status='ReadOnly' then
//begin
{cmbbx_WhCode.Enabled:=True;
cmbbx_WhPositionCode.Enabled:=True ;
cmbbx_WhEmployee.Enabled :=True;
medt_Date.Enabled:=True;
dbgrideh.ReadOnly :=True;
dbgrideh.Columns[7].ReadOnly:=True;
dbgrideh.Columns[8].ReadOnly:=True;
dbgrideh.Columns[9].ReadOnly:=True;}
//Act_auto.Enabled :=False;
act_New.Enabled:=False;
{end
else
begin
Act_auto.Enabled :=True;
dbgrideh.ReadOnly :=False;
dbgrideh.Columns[0].ReadOnly:=True;
dbgrideh.columns[1].ReadOnly:=True;
dbgrideh.Columns[2].ReadOnly:=True;
dbgrideh.Columns[3].ReadOnly:=True;
dbgrideh.Columns[4].ReadOnly:=True;
dbgrideh.Columns[5].ReadOnly:=True;
dbgrideh.Columns[6].ReadOnly:=True;
dbgrideh.columns[7].ReadOnly:=False;
dbgrideh.Columns[8].ReadOnly:=False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -