📄 inv_fromcheckin.pas
字号:
unit Inv_FromCheckIn;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, jpeg, ExtPrintReport;
Type
TFrm_Inv_FromCheckIn = Class(TFrm_Base_Entry_Head)
Lbl_FSelectCount: TLabel;
AdoQry_HeadWHCode: TStringField;
AdoQry_HeadWHCodeName: TStringField;
AdoQry_HeadWhPositionCode: TStringField;
AdoQry_HeadOnCheckBillLIneNo: TIntegerField;
AdoQry_HeadReceiveStatus: TIntegerField;
AdoQry_HeadOnCheckBillId: TAutoIncField;
AdoQry_HeadPoNo: TStringField;
AdoQry_HeadPoLineNo: TIntegerField;
AdoQry_HeadItemCode: TStringField;
AdoQry_HeadItemName: TStringField;
AdoQry_HeadUomName: TStringField;
AdoQry_HeadOnCheckDate: TDateTimeField;
AdoQry_HeadOnCheckQty: TFloatField;
AdoQry_HeadBatchNo: TStringField;
AdoQry_HeadQcStatus: TIntegerField;
AdoQry_HeadReceivedQty: TFloatField;
AdoQry_HeadVendorBillNo: TStringField;
procedure Act_autoExecute(Sender: TObject);
procedure AdoQry_HeadAfterInsert(DataSet: TDataSet);
procedure AdoQry_HeadReceiveStatuSChange(Sender: TField);
procedure AdoQry_HeadAfterPost(DataSet: TDataSet);
procedure AdoQueryAfterOpen(DataSet: TDataSet);
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure Act_ExcelExecute(Sender: TObject);
private
{ Private declarations }
FSelectedLine:TStrinGlist;
FSelectedPoNo:String;
FBillLines:Integer;
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
end;
var
Frm_Inv_FromCheckIn: TFrm_Inv_FromCheckIn;
implementation
uses Inv_FromCheckIn_C, Inv_PurchaseIn_B, Sys_Global;
{$R *.DFM}
{ TFrm_Inv_CheckIn }
procedure TFrm_Inv_FromCheckIn.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
inherited;
if Param1='0101' then
Caption:='采购合格入库'
else if Param1='0102' then
Caption:='进口采购合格入库'
else if Param1='0103' then
Caption:='委外加工合格入库';
if UpperCase(Param2)='Over' then
Caption:='超订单'+Caption;
SelectFromSql:='Select OnCheckBill.WHCode'
+',OnCheckBill.WHCode+'' ''+Warehouse.WHName As WHCodeName'
+',OnCheckBill.WhPositionCode'
+',OnCheckBillLine.OnCheckBillLIneNo'
+',OnCheckBillLine.ReceiveStatus'
+',OnCheckBill.OnCheckBillId'
+',OnCheckBill.PoNo'
+',OnCheckBill.VendorBillNo'
+',OnCheckBillLine.PoLineNo'
+',OnCheckBillLine.ItemCode'
+',Item.ItemName'
+',Uom.UomName'
+',OnCheckBill.OnCheckDate'
+',OnCheckBillLine.OnCheckQty'
+',OnCheckBillLine.BatchNo'
+',OnCheckBillLine.QcStatus'
+',OnCheckBillLine.ReceivedQty'
+' From OnCheckBillLine'
+' left Join OnCheckBill On OnCheckBillLine.OnCheckBillId=OnCheckBill.OnCheckBillId'
+' left Join Warehouse On OnCheckBill.WHCode=Warehouse.WHCode'
+' Join Item On OnCheckBillLine.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode'
+' join WHAccessCtrl on WHAccessCtrl.WHCode=OnCheckBill.WHCode '
+' and WHAccessCtrl.EmployeeCode='+QuotedStr(UserCode);
ConditionUserDefine:=' OnCheckBillLine.OnCheckStatus=0'
+' And OnCheckBillLine.ReceivedQty<>0'
+' And OnCheckBillLine.QcStatus<>0'
+' And OnCheckBillLine.QcStatus<>2'
+' And OnCheckBill.OnCheckType<>2 '
+' And OnCheckBill.BillTypeCode='''+Param1+'''';
if UpperCase(Param2)='Over' then
ConditionUserDefine:=ConditionUserDefine+' And OnCheckBill.OverPlan=1'
else
ConditionUserDefine:=ConditionUserDefine+' And OnCheckBill.OverPlan<>1';
OrderByFields:='PoNo,PoLineNo';
Tlbtn_Modify.Action:=Act_Auto;
//取单据行数
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select BillLines From BillType'
+' Where BillTypeCode='''+Param1+'''';
AdoQry_Tmp.Open;
FBillLines:=AdoQry_Tmp.fieldbyname('BillLines').AsInteger;
Frm_Sys_Condition:=TFrm_Inv_FromCheckIn_C.Create(Application);
Act_Filter.Execute;
Frm_Entry_Body:=TFrm_Inv_PurchaseIn_B.Create(Application);
Frm_Entry_Body.Caption:=Caption;
Pnl_Title.Caption:=Caption;
FSelectedLine:=TStrinGlist.Create;
FSelectedPoNo:='';
end;
procedure TFrm_Inv_FromCheckIn.Act_autoExecute(Sender: TObject);
begin
inherited;
if DBGridEh.DataSource.DataSet.Active=True then
begin
if AdoQry_Head.State<>dsBrowse then
AdoQry_Head.Post;
if FSelectedLine.Count=0 then
begin
DispInfo('没有任何记录被选中,不能生成单据!',1);
Abort;
end
else
begin
Frm_Entry_Body.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Entry_Body.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Entry_Body.SetFormParam('CheckIn','','','','','');
Frm_Entry_Body.InitForm(DBConnect,'Edit',AdoQry_Head);
Frm_Entry_Body.ShowModal;
end;
end;
end;
procedure TFrm_Inv_FromCheckIn.AdoQry_HeadAfterInsert(DataSet: TDataSet);
begin
inherited;
AdoQry_Head.Cancel;
end;
procedure TFrm_Inv_FromCheckIn.AdoQry_HeadReceiveStatuSChange(
Sender: TField);
begin
inherited;
if Sender.AsInteger=1 then
begin
if FSelectedLine.IndexOf(AdoQry_Head.fieldbyname('PoLineNo').AsString+'.'
+AdoQry_Head.fieldbyname('BatchNo').AsString)=-1 then
begin
if FSelectedLine.Count=FBillLines then
begin
DispInfo('一张该单据类型的单据最多只能容纳'+IntToStr(FBillLines)+'行记录',1);
Sender.AsInteger:=0;
end;
end;
if (FSelectedPoNo<>'')
and(AdoQry_Head.fieldbyname('PoNo').AsString+
AdoQry_Head.fieldbyname('WHCode').AsString<>FSelectedPoNo)then
begin
DispInfo('一张入库单,只能对应相同仓库的同一采购订单!',1);
Sender.AsInteger:=0;
end;
end;
end;
procedure TFrm_Inv_FromCheckIn.AdoQry_HeadAfterPost(DataSet: TDataSet);
var
BookmArk:TBookmArk;
begin
inherited;
DataSet.DisableControls;
BookmArk:=DataSet.GetBookmArk;
FSelectedLine.clear;
FSelectedPoNo:='';
DataSet.First;
while not DataSet.Eof do
begin
if AdoQry_Head.fieldbyname('ReceiveStatus').AsInteger=1 then
begin
if FSelectedLine.IndexOf(AdoQry_Head.fieldbyname('PoLineNo').AsString+'.'
+AdoQry_Head.fieldbyname('BatchNo').AsString)=-1 then
begin
FSelectedLine.Append(AdoQry_Head.fieldbyname('PoLineNo').AsString+'.'
+AdoQry_Head.fieldbyname('BatchNo').AsString);
FSelectedPoNo:=AdoQry_Head.fieldbyname('PoNo').AsString+
AdoQry_Head.fieldbyname('WHCode').AsString;
end;
end;
DataSet.Next;
end;
DataSet.GotoBookmArk(BookmArk);
DataSet.FreeBookmArk(BookmArk);
DataSet.EnableControls;
Lbl_FSelectCount.Caption:='产生的单据行数:'+IntToStr(FSelectedLine.Count);
end;
procedure TFrm_Inv_FromCheckIn.AdoQueryAfterOpen(DataSet: TDataSet);
begin
inherited;
Lbl_FSelectCount.Caption:='';
end;
procedure TFrm_Inv_FromCheckIn.Act_PreviewExecute(Sender: TObject);
begin
try
DBGridEh.Columns [0].Visible :=False;
inherited;
finally
DBGridEh.Columns [0].Visible :=True;
end;
end;
procedure TFrm_Inv_FromCheckIn.Act_PrintExecute(Sender: TObject);
begin
try
DBGridEh.Columns [0].Visible :=False;
inherited;
finally
DBGridEh.Columns [0].Visible :=True;
end;
end;
procedure TFrm_Inv_FromCheckIn.Act_ExcelExecute(Sender: TObject);
begin
try
DBGridEh.Columns [0].Visible :=False;
inherited;
finally
DBGridEh.Columns [0].Visible :=True;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -