📄 inv_opout_b.pas
字号:
unit Inv_OpOut_B;
//委外加工领料表体单元
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Body, Db, ActnList, AdODB, Grids, DBGridEh, ExtCtrls,math,dbgrids,
ComCtrls, ToolWin, Mask, StdCtrls, DBCtrls, ExtPrintReport, Buttons, jpeg;
Type
TFrm_Inv_OpOut_B = Class(TFrm_Base_Entry_Body)
Label2: TLabel;
Cmbx_WhCodeName: TComboBox;
Label5: TLabel;
Cmbx_Position: TComboBox;
Label9: TLabel;
Medt_Date: TMaskEdit;
Label10: TLabel;
Edt_Memo: TEdit;
Label4: TLabel;
Label1: TLabel;
Lbl_VendorCodeName: TLabel;
Label3: TLabel;
Lbl_PoNo: TLabel;
Label6: TLabel;
AdoQry_BodyPoLIneNo: TIntegerField;
AdoQry_BodyItemCode: TStringField;
AdoQry_BodyItemName: TStringField;
AdoQry_BodyUomName: TStringField;
AdoQry_BodyPoCtrlQty: TFloatField;
AdoQry_BodyPoRealQty: TFloatField;
AdoQry_BodyPOOutQty: TFloatField;
Lbl_PoItemName: TLabel;
AdoQry_Tmp2: TAdoQuery;
Label7: TLabel;
Edt_BillNo: TEdit;
DBText1: TDBText;
AdoQry_Bodypono: TStringField;
AdoQry_BodyUseableStore: TFloatField;
AdoQry_BodyBillLineRemArk: TStringField;
AdoQry_BodyBomQty: TFloatField;
AdoQry_BodyBomScrAp_Percent: TFloatField;
AdoQry_Bodyite_ItemCode: TStringField;
AdoQry_BodyItemListid: TAutoIncField;
AdoQry_BodyBatchNo: TStringField;
Btn_QryOpCurrentInv: TBitBtn;
AdoQry_Bodyusestyle: TIntegerField;
CheckBox1: TCheckBox;
procedure AdoQry_BodyAfterScroll(DataSet: TDataSet);
procedure Act_DeleteLineExecute(Sender: TObject);
procedure Act_InsertLineExecute(Sender: TObject);
procedure Act_ModifyExecute(Sender: TObject);
procedure Cmbx_WhCodeNameChange(Sender: TObject);
procedure Cmbx_WhCodeNameExit(Sender: TObject);
procedure Cmbx_PositionExit(Sender: TObject);
procedure Medt_DateExit(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Act_SaveExecute(Sender: TObject);
procedure Cmbx_PositionChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure AdoQry_BodyBeforePost(DataSet: TDataSet);
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure Act_autoExecute(Sender: TObject);
procedure DBGridEhKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Btn_QryOpCurrentInvClick(Sender: TObject);
procedure DBGridEhEnter(Sender: TObject);
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
private
IsSpecial:boolean;
Addormodify:boolean;
Scrollflag:boolean;
IsOverPlan :Boolean;
FPoNo :String;
MaxRecLineCount: integer;
BillTypeCode :String;
AllowNegative :String;
function CheckNotZero:boolean;
function CheckAllSame:boolean;
procedure refreshall;
procedure DisableAll(flag:boolean);
procedure InitCmbx_WhPosition(whCode:string);
function InitwhposIfSpec:integer;
procedure SaveData; OverRide;
procedure set_OverPlan(flag:boolean);
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;FormStatus:String;
AdoQuery:TAdoQuery);OverRide;
procedure InitControls;Override;
procedure SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6:String);OverRide;
procedure SetStatus(CurrentStatus:String;var AnswerStatus,
EnableControls:String);OverRide;
{ Public declarations }
end;
var
Frm_Inv_OpOut_B: TFrm_Inv_OpOut_B;
implementation
uses Sys_Global,Inv_Global,Inv_OpOut_D,Sys_Hint;
{$R *.DFM}
{ TFrm_Inv_OpOut_B }
procedure TFrm_Inv_OpOut_B.InitCmbx_WhPosition(whCode: string);
begin
//对货位COMBOBOX的填充
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select P.WhPositionCode,P.WhPositionName '+
' from WhPosition P '+
' where P.WhCode='''+WhCode+''''+
' and P.BackFlushWhP=0 '+
' and p.WhPositionType<>1');
open;
cmbx_Position.clear;
if not Eof then
begin
First;
while not Eof do
begin
cmbx_Position.Items.Add(fieldbyname('WhPositionCode').asstring+' '+fieldbyname('WhPositionName').asstring);
Next;
end;
end;
end;
end;
procedure TFrm_Inv_OpOut_B.InitControls;
begin
inherited;
TlBtn_Modify.action:=act_auto;
Scrollflag:=False;
//act_Save.Enabled:=False;
if AdoQry_Head.fieldbyname('PoSpecial').asinteger=1 then
IsSpecial:=True
else IsSpecial:=False;
if showflag=True then
exit;
If UpperCase(Param1)='InPlan' then
begin
Cmbx_WhCodeName.clear;
with AdoQry_tmp do
begin
Close;
SQL.clear;
SQl.Text := ' select WhAccessCtrl.WHCode,WHName '
+' from WHAccessCtrl '
+' join Warehouse on WhAccessCtrl.WhCode=Warehouse.WhCode '
+' where WhAccessCtrl.EmployeeCode='+QuotedSTr(userCode)
+' and ( WhAccessCtrl.WhCode In (select WhCode from CurrentInv '
+' where ItemCode in(select distinct ItemCode from opItemList '
+' where poNo ='''+AdoQry_Head.fieldbyname('Pono').asstring+ ''''
+' and Polineno='+AdoQry_Head.fieldbyname('Polineno').asstring+' ) ) '
+' or WhAccessCtrl.WhCode in (select WhCode from Item where ItemCode in( select distinct ItemCode from opItemList '
+' where poNo ='''+AdoQry_Head.fieldbyname('Pono').asstring+ ''''
+' and Polineno='+AdoQry_Head.fieldbyname('Polineno').asstring+' ) ) ) '
+ ' Order by WhAccessCtrl.WHCode ';
Open;
if not Eof then
begin
First;
while not Eof do
begin
Cmbx_WhCodeName.Items.Add(fieldbyname('whCode').AsString+' '+fieldbyname('whName').asstring);
Next;
end;
Cmbx_WhCodeName.ItemIndex:=0;
end;
end;
end
else
InitUsableWHCmbx(AdoQry_Tmp,UserCode,Cmbx_WhCodeName,False);
InitCmbx_WhPosition(getCode(Cmbx_WhCodeName.text));
Cmbx_Position.ItemIndex:=InitwhposIfSpec;
Edt_BillNo.Text:='';
//刷新数据
refreshall;
//超订单标志
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('select '+
' Count(*) As RecCount '+
'from OpItemList OP '+
' Where Op.PoNo='''+FPoNo+''''+
//' and Op.PoCtrlQty<=Op.PoRealQty '+
' and POOutQty<0 ');
Open;
If fieldbyname('RecCount').AsInteger>0 then
AllowNegative:='YES'
Else
begin
Close;
Sql.clear;
Sql.Add('select '+
' Count(*) As RecCount '+
'from OpItemList OP '+
' Where Op.PoNo='''+FPoNo+''''+
//' and Op.PoCtrlQty<=Op.PoRealQty '+
' and POOutQty>0 ');
Open;
If fieldbyname('RecCount').AsInteger>0 then
AllowNegative:='NO'
Else AllowNegative:='NONE';
end;
end;
Lbl_PoNo.Caption:=FPoNo;
Medt_Date.Text:=FormatDateTime('YYYY.MM.DD',Now());
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('select '+
' PO.VendorCode+'' ''+Vendor.VendorName as VendorCodeName '+
'from PO,Vendor '+
'where PO.VendorCode*=Vendor.VendorCode and Po.PoNo='''+FPoNo+'''');
Open;
Lbl_VendorCodeName.Caption:=AdoQry_Tmp.fieldbyname('VendorCodeName').AsString;
//添加备注 by johnson
{ Close;
sql.Text:='select PORemArk from po where pono='''+FPoNo+'''';
open;
Edt_Memo.Text:=fieldbyname('poremArk').asstring;}
end;
end;
procedure TFrm_Inv_OpOut_B.InitForm(AdOConnection: TAdOConnection;
FormStatus: String; AdoQuery: TAdoQuery);
begin
inherited;
//设定DBGRID为编辑属性
with DBGridEh do
begin
options:=options+[dgEditing]-[dgRowselect];
end;
AdoQry_Tmp2.Connection:=AdoConnection;
AdoQry_Tmp.EnableBCD:=False;
AdoQry_Body.EnableBCD:=False;
AdoQry_Tmp2.EnableBCD:=False;
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select BillLINES From BillType Where BillTypeCode='''+BillTypeCode+'''');
Open;
MaxRecLineCount:=fieldbyname('BillLINES').AsInteger;
Param4:=IntToStr(MaxRecLineCount);
end;
SetFocus_Control:=Cmbx_WhCodeName;
end;
procedure TFrm_Inv_OpOut_B.AdoQry_BodyAfterScroll(DataSet: TDataSet);
begin
inherited;
//如果当前记录移动(订单行号改变),则更新下面的‘当前订单行物料描述’
With AdoQry_tmp do
begin
Close;
Sql.clear;
Sql.Add('Select '+
' Item.ItemName '+
'From PoLine,Item '+
'Where PoLine.PoLineNo='''+AdoQry_Body.fieldbyname('PoLineNo').AsString+''''+
' and PoLine.PoNo='''+FPoNo+''''+
' and Item.ItemCode=PoLine.ItemCode');
Open;
Lbl_PoItemName.Caption:=fieldbyname('ItemName').AsString;
end;
if (AdoQry_Body.Eof) and (not Scrollflag) then AdoQry_Body.Cancel;
end;
procedure TFrm_Inv_OpOut_B.SetUserParam(Param1, Param2, Param3, Param4,
Param5, Param6: String);
begin
inherited;
FPoNo:=Param2;
BillTypeCode:=Param3;
//判断传入参数的正确性
If UpperCase(Param1)='OverPlan' then
IsOverPlan:=True
Else If UpperCase(Param1)='InPlan' then
IsOverPlan:=False
Else
begin
DispInfo('系统参数传入不正确,请与系统管理员联系!',1);
Abort;
end;
end;
procedure TFrm_Inv_OpOut_B.SetStatus(CurrentStatus: String;
var AnswerStatus, EnableControls: String);
begin
inherited;
{ if (CurrentStatus='Edit') then
begin
AnswerStatus:='AllEdit';
EnableControls:='Cmbx_WhCodeName,Cmbx_Position,Medt_Date,Edt_Memo,';
end
else}
if (CurrentStatus='Add') then
begin
AnswerStatus:='Add';
EnableControls:='Cmbx_WhCodeName,Cmbx_Position,Medt_Date,Edt_Memo,';
Addormodify:=True;
end
else
begin
Addormodify:=False;
EnableControls:='Cmbx_WhCodeName,Cmbx_Position,';
AnswerStatus:='Alledit';
end;
end;
procedure TFrm_Inv_OpOut_B.Act_DeleteLineExecute(Sender: TObject);
begin
//在删除一行前进行检查,必须限额领料数量和累计领料数量均为0才可以删除
If (AdoQry_Body.fieldbyname('PoCtrlQty').AsFloat<>0)
or (AdoQry_Body.fieldbyname('PoRealQty').AsFloat<>0) then
begin
DispInfo('不是新增的行,不允许删除! ',1);
Abort;
end;
inherited;
end;
procedure TFrm_Inv_OpOut_B.Act_InsertLineExecute(Sender: TObject);
begin
if not WHClsPeriodCheck(AdoQry_Tmp,GetCode(Cmbx_WhCodeName.Text),Copy((Medt_Date.Text),1,7)) then
begin
Medt_Date.SetFocus;
abort;
end;
Param5:=GetCode(Cmbx_WhCodeName.Text);
Param6:=GetCode(Cmbx_Position.Text);
If Param5='' then
begin
DispInfo('请选择一个仓库!',1);
Abort;
end;
If Param6='' then
begin
DispInfo('请选择一个货位!',1);
Abort;
end;
Frm_Entry_Detail.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Entry_Detail.SetFormParam(AllowNegative,Medt_Date.text,'','','','');
Scrollflag:=True;
inherited;
Scrollflag:=False;
end;
procedure TFrm_Inv_OpOut_B.Act_ModifyExecute(Sender: TObject);
begin
{ AdoQry_Body.First;
with AdoQry_Body do
for i:=0 to recordCount-1 do
begin
edit;
fieldbyname('PooutQty').asfloat:=
min(round(fieldbyname('PoCtrlQty').asfloat)-round(fieldbyname('PoRealQty').asfloat),
fieldbyname('UseableStore').asfloat);
if fieldbyname('PooutQty').asfloat<0 then fieldbyname('PooutQty').asfloat:=0;
post;
next;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -