📄 stk_enter_passcheckinvbill.pas
字号:
unit Stk_Enter_PassCheckInvBill;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check_Body, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, jpeg, linkedit, Mask;
Type
TFrm_Stk_Enter_PassCheckInvBill = Class(TFrm_Base_Check_Body)
Label1: TLabel;
CmBx_Warehouse: TComboBox;
Label5: TLabel;
CmBx_WhPosition: TComboBox;
Label7: TLabel;
Edt_BillNo: TEdit;
MEdt_InAccountDate: TMaskEdit;
Edt_CheckEmployeeName: TEdit;
LEdt_CheckEmployeeCode: TLinkEdit;
Lbl_VendorName: TEdit;
ExtEdt_VendorCode: TLinkEdit;
Label4: TLabel;
Label8: TLabel;
MEdt_BillDate: TMaskEdit;
Edt_RemArk: TEdit;
Label3: TLabel;
Label6: TLabel;
Label2: TLabel;
Label9: TLabel;
Edt_PassEmployeeName: TEdit;
LEdt_PassEmployeeCode: TLinkEdit;
AdoQry_BodyInvBillLineNo: TIntegerField;
AdoQry_BodyItemCode: TStringField;
AdoQry_BodyBatchNo: TStringField;
AdoQry_BodyItemName: TStringField;
AdoQry_BodyUomName: TStringField;
AdoQry_BodyAccountQty: TFloatField;
AdoQry_BodyCheckQty: TFloatField;
AdoQry_BodyProfitLossQty: TFloatField;
AdoQry_BodyPLCause: TStringField;
procedure Act_CheckExecute(Sender: TObject);
procedure LEdt_PassEmployeeCodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LEdt_PassEmployeeCodeButtonClick(Sender: TObject);
procedure LEdt_PassEmployeeCodeExit(Sender: TObject);
private
{ Private declarations }
FWhCode :String;
FPosition :String;
FInvBillno :String; //盘点单号;
FInAccountDatee :String;
FBilldate:string;
FRemArk:string;
FDeptCode :String;
FDeptName:string;
FCheckEmployeeCode:string;
FCheckEmployeeName:string;
FBillno:string; //其他入库单号;
procedure UpdateInv_CheckInvBill; //盘点单表头数据;
procedure CreateOtherInBill; //产生产生一张其他入库单;
function isProfitLoss:boolean; //是否有盈亏
public
{ Public declarations }
procedure InitControls;Override;
procedure SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6:String);Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,FrmParam6:String);Override;
procedure InitForm(AdOConnection:TAdOConnection;FormStatus:String;
AdoQuery:TAdoQuery);Override;
end;
var
Frm_Stk_Enter_PassCheckInvBill: TFrm_Stk_Enter_PassCheckInvBill;
implementation
uses Sys_Global;
{$R *.DFM}
{ TFrm_Stk_Enter_PassCheckInvBill }
procedure TFrm_Stk_Enter_PassCheckInvBill.InitControls;
var
I:integer;
begin
inherited;
{with DBGridEh do
begin
options:=options+[dgEditing]-[dgRowselect];
end;}
CmBx_Warehouse.text:=FWhCode ;
CmBx_WhPosition.text:=FPosition ;
Edt_BillNo.text:=FInvBillno ;
MEdt_InAccountDate.text:=FInAccountDatee;
MEdt_BillDate.text:=FBilldate;
Edt_RemArk.text:=FRemArk;
ExtEdt_VendorCode.text:=FDeptCode ;
Lbl_VendorName.text:=FDeptName;
LEdt_CheckEmployeeCode.text:=FCheckEmployeeCode;
Edt_CheckEmployeeName.text:=FCheckEmployeeName;
With AdoQry_Body do
begin
Close;
Sql.clear;
Sql.text:=' Select Inv_CheckInvBillLine.InvBillLineNo,' +
' Inv_CheckInvBillLine.ItemCode,'+
' Inv_CheckInvBillLine.BatchNo,'+
' Item.ItemName,'+
' Uom.UomName,'+
' Inv_CheckInvBillLine.AccountQty,'+
' Inv_CheckInvBillLine.CheckQty,'+
' Inv_CheckInvBillLine.ProfitLossQty,'+
' Inv_CheckInvBillLine.PLCause '+
' From Inv_CheckInvBillLine '+
' left Join Item On Inv_CheckInvBillLine.ItemCode=Item.ItemCode'+
' left Join Uom On Item.UomCode=Uom.UomCode'+
' Where Inv_CheckInvBillLine.InvBillno='''+FInvBillno+'''';
Open;
end;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.InitForm(
AdOConnection: TAdOConnection; FormStatus: String; AdoQuery: TAdoQuery);
begin
inherited;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.SetFormParam(FrmParam1,
FrmParam2, FrmParam3, FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
FDeptCode :=FrmParam1;
FDeptName:=FrmParam2;
FCheckEmployeeCode:=FrmParam3;
FCheckEmployeeName:=FrmParam4;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.SetUserParam(Param1, Param2,
Param3, Param4, Param5, Param6: String);
begin
inherited;
FWhCode :=Param1;
FPosition:=Param2;
FInvBillno:=Param3;
FInAccountDatee :=Param4;
FBilldate:=Param5;
FRemArk:=Param6;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.Act_CheckExecute(
Sender: TObject);
var
UserName:string;
begin
inherited;
if (ActiveControl.Name='ToolButton4') then
Abort;
{ if Trim(LEdt_PassEmployeeCode.text)='' then
begin
DispInfo('批准人不能为空请输入!',3);
LEdt_PassEmployeeCode.SetFocus ;
abort;
end;}
if Trim(LEdt_CheckEmployeeCode.text)=userCode then
begin
DispInfo('盘点人员与批准人员不能相同!',3);
//LEdt_PassEmployeeCode.SetFocus ;
abort;
end;
with AdoQry_tmp do
begin
Close;
sql.text:=' select DATEDiff(mm, InvBillDate, getdate()) AS Diffmoth '+
' from Inv_CheckInvBill '+
' where InvBillNo='''+FInvBillno+'''';
open;
if fieldbyname('Diffmoth').asinteger>0 then
begin
DispInfo('当前盘点单的盘点月份与存货控制的单据月份不一致,不能批准此盘点单?',3);
abort;
end;
end;
with AdoQry_tmp do
begin
Close;
sql.text:=' select DATEDiff(day, InvBillDate, getdate()) AS Diffday '+
' from Inv_CheckInvBill '+
' where InvBillNo='''+FInvBillno+'''';
open;
if fieldbyname('Diffday').asinteger>1 then
begin
if DispInfo('当前日期减盘点日期大于1天,物料帐面数据可能有变,是否继续批准此盘点单?',2)='n' then
abort;
end;
end;
with AdoQry_tmp do
begin
Close;
sql.text:='select EmployeeName from Employee where EmployeeCode='''+userCode+'''';
open;
UserName:=fieldbyname('EmployeeName').asstring;
Close;
end;
FBillno:='';
dbconnect.beginTrans ;
try
DBGridEh.Enabled :=False;
try
if not isProfitLoss then //是否有盈亏
begin
CreateOtherInBill; //产生产生一张其他入库单;
DispInfo('此盘点单有盈亏,产生产生一张其他入库单:'+FBillno,3);
end
else
DispInfo('此盘点单无盈亏!',3);
UpdateInv_CheckInvBill; //Update盘点单表头数据;
//更新库存标记
ChangeInvStatus(AdoQry_Tmp,GetCode(CmBx_Warehouse.Text),
FormatDateTime('yy.mm',StrToDate(MEdt_InAccountDate.Text)));
AdoQry_Head.edit;
AdoQry_Head.fieldbyname ('IsPassEmplyee').asinteger:=1;
AdoQry_Head.fieldbyname('PassEmployeeCode').asstring:=userCode;
AdoQry_Head.fieldbyname('psEmployeeName').asstring:=UserName;
AdoQry_Head.fieldbyname('InvBillNo_In').asstring:=FBillno;
AdoQry_Head.post;
dbconnect.CommitTrans ;
finally
DBGridEh.Enabled :=True;
end;
Act_Check.Enabled :=False;
except
AdoQry_tmp.Connection.RollBackTrans;
DispInfo('单据保存失败,请稍后再试!',1);
abort;
end;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.UpdateInv_CheckInvBill; //盘点单表头数据;
begin
with AdoQry_tmp do
begin
Close;
sql.text:=' update Inv_CheckInvBill '+
' set PassEmployeeCode='''+userCode+''''+','+
' IsPassEmplyee=1,'+
' InvBillNo_In='''+FBillno+''''+','+
' remArk='''+edt_remArk.text+''''+
' where InvBillNo='''+FInvBillNo+'''';
execsql;
end;
end;
procedure TFrm_Stk_Enter_PassCheckInvBill.CreateOtherInBill; //产生产生一张其他入库单;
var
update_field,fields,fieldValues,tmp_InvBillPrice,tmp_InvBillnotaxPrice,
tmp_InvBillAmount,tmp_InvBillnotaxAmount,tmp_InvBillPricec,tmp_WhCode,tmp_WhPositionCode,
tmp_InvBillnotaxPricec,tmp_InvBillAmountc,tmp_InvBillnotaxAmountc:string;
currencyCode,Billid:string;
NeedChangePrice,BeforeSaveError:boolean;
M:integer;
Amount:real;
OtherIncheck,Stkcheck:integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -