📄 inv_enter_homemadeckinvin.pas
字号:
unit Inv_Enter_HomemadeCkInvIn;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Body, Db, ActnList, AdODB, Grids, DBGridEh, ExtCtrls,
ComCtrls, ToolWin, StdCtrls, Mask, ExtEdit, DBCtrls, ExtPrintReport, jpeg;
Type
TFrm_Inv_Enter_HomemadeCkInvIn = Class(TFrm_Base_Entry_Body)
Label1: TLabel;
CmBx_Warehouse: TComboBox;
Label2: TLabel;
Edt_PoNO: TEdit;
Label4: TLabel;
Label7: TLabel;
Edt_BillNo: TEdit;
Label8: TLabel;
MEdt_BillDate: TMaskEdit;
Lbl_VendorName: TLabel;
Label3: TLabel;
Label5: TLabel;
CmBx_WhPosition: TComboBox;
Edt_RemArk: TEdit;
ExtEdt_VendorCode: TExtEdit;
Label6: TLabel;
Edt_VendorBillNo: TEdit;
procedure FormCreate(Sender: TObject);
procedure CmBx_WarehouseChange(Sender: TObject);
procedure PoCodeCheck(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure DateCheck(Sender: TObject);
procedure Edt_PoNOKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure Act_InsertLineExecute(Sender: TObject);
procedure Act_ModifyExecute(Sender: TObject);
procedure DBGridEhColExit(Sender: TObject);
procedure DBGridEhColEnter(Sender: TObject);
procedure AdoQry_BodyBeforeEdit(DataSet: TDataSet);
procedure DBGridEhKeyPress(Sender: TObject; var Key: ChAr);
procedure DBGridEhExit(Sender: TObject);
private
{ Private declarations }
Ffdays:String;//比订单要求的“约定交货期”提前多少天到货可以接受
Fbdays:String;//比订单要求的“约定交货期”滞后多少天到货可以接受
Foqty:String;//比订单要求的“约定交货量”超过百分之多少可以接受
FFromCheckIn:Boolean;
IsSpecial:Boolean;
OLDPoNo :String;
Invmodify:Boolean;
oldInvBillQTY:double;
public
{ Public declarations }
procedure SetStatus(CurrentStatus:String;var AnswerStatus,
EnableControls:String); Override;
procedure InitControls; Override;
procedure SaveHeadData; Override;
procedure SaveData; Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
FrmParam6:String);Override;
end;
var
Frm_Inv_Enter_HomemadeCkInvIn: TFrm_Inv_Enter_HomemadeCkInvIn;
implementation
uses Sys_Global,Inv_Global, Inv_Enter_HomemadeCkInvInH;
{$R *.DFM}
procedure TFrm_Inv_Enter_HomemadeCkInvIn.InitControls;
var
Bill_ID,OnCheckBillId,Tempstr:String;
i:integer;
mypost:TDataSetNotifyEvent;
begin
SetFocus_Control:=CmBx_Warehouse;
inherited;
if (ShowFlag=True)and(Status<>'Add') then
Exit;
If FFromCheckIn then//从待检入库
begin
Caption:=FormCaption;
Pnl_Title.Caption:=FormCaption;
Act_InsertLine.Enabled:=False;
Act_Modify.Enabled:=False;
Act_DeleteLine.Enabled:=False;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select PmParamValueN From PmParam'
+' Where PmParamCode=''forwArddaysdeny''';
AdoQry_Tmp.Open;//提前天数
Ffdays:=AdoQry_Tmp.fieldbyname('PmParamValueN').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select PmParamValueN From PmParam'
+' Where PmParamCode=''BackwArddaysdeny''';
AdoQry_Tmp.Open;//推迟天数
Fbdays:=AdoQry_Tmp.fieldbyname('PmParamValueN').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select PmParamValueN From PmParam'
+' Where PmParamCode=''Overqtydeny_Percent''';
AdoQry_Tmp.Open;//可超比率
Foqty:=AdoQry_Tmp.fieldbyname('PmParamValueN').AsString;
// if CmBx_Warehouse.Items.Count=0 then
// begin//设置可用仓库
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select WHAccessCtrl.WHCode+'' ''+Warehouse.WHName As WHCodeName'
+' From WHAccessCtrl'
+' Join Warehouse On WHAccessCtrl.WHCode=Warehouse.WHCode'
+' Where WHAccessCtrl.EmployeeCode='''+UserCode+''''
//+' And Warehouse.PriceType<>1'
+' Order By WHAccessCtrl.WHCode ';
{ SQl.Text := ' select WHAccessCtrl.WHCode+'' ''+Warehouse.WHName As WHCodeName' '
+' from WHAccessCtrl '
+' join Warehouse on WhAccessCtrl.WhCode=Warehouse.WhCode '
+' where WhAccessCtrl.EmployeeCode='+QuotedSTr(userCode)
+' and ( WhAccessCtrl.WhCode In (select WhCode from CurrentInv ) '
+' 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 ';}
AdoQry_Tmp.Open;
AdoQry_Tmp.First;
while not AdoQry_Tmp.Eof do
begin
CmBx_Warehouse.Items.Add(AdoQry_Tmp.fieldbyname('WHCodeName').AsString);
AdoQry_Tmp.Next;
end;
CmBx_Warehouse.ItemIndex:=0;
//end;
//取ID值
if (Status='ReadOnly')and(not FFromCheckIn) then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select InvBillId,InvBillNo'
+' From InvInBill'
+' Where InvBillNo='''+AdoQry_Head.fieldbyname('InvBillNo').AsString+''''
+' And WHCode='''+AdoQry_Head.fieldbyname('WHCode').AsString+'''';
AdoQry_Tmp.Open;
Bill_ID:=AdoQry_Tmp.fieldbyname('InvBillId').AsString;
Edt_BillNo.Text:=AdoQry_Tmp.fieldbyname('InvBillNo').AsString;
end
else
begin
Bill_ID:='-1';
Edt_BillNo.Text:='';
end;
AdoQry_Body.Close;
AdoQry_Body.SQL.Text:='Select InvInBillLine.PoLineNo'
+',InvInBillLine.ItemCode'
+',InvInBillLine.BatchNo'
+',Item.ItemName'
+',Uom.UomName'
+',InvInBillLine.InvBillQty'
+',InvInBillLine.InvBillSfcQty'
+',InvInBillline.BillLineRemArk '
+' From InvInBillLine'
+' Join Item On InvInBillLine.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode'
+' Where InvInBillLine.InvBillId='+Bill_ID+'';
AdoQry_Body.Open;
AdoQry_Body.Sort:='POLineNo';
if FFromCheckIn then
begin//从待检入库,表体自动产生.
Edt_VendorBillNo.Text:='';
if AdoQry_Head.RecordCount<=0 then
begin
DispInfo('无相应资料不能入库!',3);
abort;
end;
AdoQry_Head.First;
for i:=0 to AdoQry_Head.RecordCount-1 do
begin
if AdoQry_Head.fieldbyname('ReceiveStatus').AsInteger=1 then
begin
if Tempstr<>AdoQry_Head.fieldbyname('VendorBillNo').AsString then
begin
Tempstr:=AdoQry_Head.fieldbyname('VendorBillNo').AsString;
Edt_VendorBillNo.Text:=Edt_VendorBillNo.Text
+' '+AdoQry_Head.fieldbyname('VendorBillNo').AsString;
end;
Edt_PoNo.Text:=AdoQry_Head.fieldbyname('PoNo').AsString;
OnCheckBillId:=AdoQry_Head.fieldbyname('OnCheckBillId').AsString;
//AdoQry_Body.First;
mypost:=AdoQry_Body.afterinsert;
AdoQry_Body.afterinsert:=nil;
while not AdoQry_Body.Eof do
begin
if (AdoQry_Body.fieldbyname('PoLineNo').AsString=
AdoQry_Head.fieldbyname('PoLineNo').AsString)
and(AdoQry_Body.fieldbyname('BatchNo').AsString=
AdoQry_Head.fieldbyname('BatchNo').AsString) then
begin
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('InvBillQty').AsFloat:=
AdoQry_Head.fieldbyname('ReceivedQty').Asfloat+
AdoQry_Body.fieldbyname('InvBillQty').AsFloat;
AdoQry_Body.fieldbyname('InvBillSfcQty').AsFloat:=
AdoQry_Head.fieldbyname('OnCheckQty').Asfloat+
AdoQry_Body.fieldbyname('InvBillSfcQty').AsFloat;
AdoQry_Body.Post;
Break;
end;
AdoQry_Body.Next;
end;
if (AdoQry_Body.RecordCount=0)or
(AdoQry_Body.fieldbyname('PoLineNo').AsString<>
AdoQry_Head.fieldbyname('PoLineNo').AsString)
or(AdoQry_Body.fieldbyname('BatchNo').AsString<>
AdoQry_Head.fieldbyname('BatchNo').AsString) then
begin
mypost:=AdoQry_Body.beforeinsert;
AdoQry_Body.beforeinsert:=nil;
AdoQry_Body.Append;
AdoQry_Body.fieldbyname('PoLineNo').AsString:=AdoQry_Head.fieldbyname('PoLineNo').AsString;
AdoQry_Body.fieldbyname('BatchNo').AsString:=AdoQry_Head.fieldbyname('BatchNo').AsString;
AdoQry_Body.fieldbyname('ItemCode').AsString:=AdoQry_Head.fieldbyname('ItemCode').AsString;
AdoQry_Body.fieldbyname('ItemName').AsString:=AdoQry_Head.fieldbyname('ItemName').AsString;
AdoQry_Body.fieldbyname('UomName').AsString:=AdoQry_Head.fieldbyname('UomName').AsString;
AdoQry_Body.fieldbyname('InvBillQty').AsFloat:=AdoQry_Head.fieldbyname('ReceivedQty').Asfloat;
AdoQry_Body.fieldbyname('InvBillSfcQty').AsFloat:=AdoQry_Head.fieldbyname('OnCheckQty').Asfloat;
AdoQry_Body.Post;
end;
end;
AdoQry_Head.Next;
end;
AdoQry_Body.beforeinsert:=mypost;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select OnCheckBill.WHCode'
+',OnCheckBill.WhPositionCode'
+',OnCheckBill.VendorCode'
+',Vendor.VendorName'
+',Po.PoSpecial'
+' From OnCheckBill'
+' Left Join Vendor On OnCheckBill.VendorCode=Vendor.VendorCode'
+' Left Join Po On OnCheckBill.PoNo=Po.PoNo '
+' Where OnCheckBill.OnCheckBillId='+OnCheckBillId+'';
AdoQry_Tmp.Open;
InitCmBxText(Cmbx_Warehouse,AdoQry_Tmp.fieldbyname('WHCode').AsString);
ExtEdt_VendorCode.Text:=AdoQry_Tmp.fieldbyname('VendorCode').AsString;
Lbl_VendorName.Caption:=AdoQry_Tmp.fieldbyname('VendorName').AsString;
MEdt_BillDate.Text:=FormatDateTime('yyyy.mm.dd',Now);
if AdoQry_Tmp.fieldbyname('PoSpecial').AsString='1' then
begin
Cmbx_Warehouse.OnChange(Cmbx_Warehouse);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select WhPosition.WhPositionCode'
+',WhPosition.WhPositionName'
+' From WhPosition'
+' Where WhPosition.WHCode='''+GetCode(CmBx_Warehouse.Text)+''''
+' And WhPositionType=2 ';
AdoQry_Tmp.Open;
InitCmBxText(CmBx_WhPosition,AdoQry_Tmp.fieldbyname('WhPositionCode').AsString);
end
else
Cmbx_Warehouse.OnChange(Cmbx_Warehouse);;
with AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('select InvValuen from InvParam where InvParamCode=''oncheckfullin''');
open;
Invmodify:=True;
if fieldbyname('InvValuen').asinteger=1 then
Invmodify:=False;
Close;
if not Invmodify then
begin
dbgrideh.ReadOnly:=Invmodify;
dbgrideh.columns[0].ReadOnly:=not Invmodify ;
dbgrideh.columns[1].ReadOnly:=not Invmodify ;
dbgrideh.columns[2].ReadOnly:=not Invmodify ;
dbgrideh.columns[3].ReadOnly:=not Invmodify ;
dbgrideh.columns[4].ReadOnly:=not Invmodify ;
dbgrideh.columns[6].ReadOnly:=not Invmodify ;
dbgrideh.Columns[5].ReadOnly:= Invmodify;
end;
end;
end;
if not FFromCheckIn then
with AdoQry_Head do
begin//把根据表头当前数据初始化,表头控件
InitCmBxText(CmBx_Warehouse,fieldbyname('WHCode').AsString);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Select PoSpecial From Po Where PoNo='''+fieldbyname('pono').AsString+'''');
AdoQry_Tmp.Open;
If AdoQry_Tmp.fieldbyname('PoSpecial').AsFloat=1 then
IsSpecial:=True
else
IsSpecial:=False;
CmBx_Warehouse.OnChange(CmBx_Warehouse);
Edt_PoNO.Text:=fieldbyname('PONO').AsString;
Lbl_VendorName.Caption:=fieldbyname('VendorName').AsString;
ExtEdt_VendorCode.Text:=fieldbyname('VendorCode').AsString;
Edt_VendorBillNo.Text:=fieldbyname('VendorBillNo').AsString;
if Status<>'Add' then
MEdt_BillDate.Text:=fieldbyname('InvBillDate').AsString
else
MEdt_BillDate.Text:=FormatDateTime('yyyy.mm.dd',Now);
if Status<>'Add' then
Edt_RemArk.Text:=fieldbyname('InvBillRemArk').AsString
else
Edt_RemArk.Text:='';
end
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.SaveData;
var
InvBillWHChck,Bill_No,OldSort,FromCheckIn,OverPlan:String;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -