📄 ar_enter_arap_d.pas
字号:
unit Ar_Enter_ArAp_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, Mask, ExtEdit, linkedit;
Type
TFrm_Ar_Enter_ArAp_D = Class(TFrm_Base_Entry_Detail)
Edt_TotalAmount: TEdit;
Label4: TLabel;
Label3: TLabel;
medt_ApInvoicedate: TMaskEdit;
Label2: TLabel;
Label1: TLabel;
edt_reMainAmount: TEdit;
Label5: TLabel;
edt_thiSCancelAmount: TEdit;
cmb_ApInvoiceno: TLinkEdit;
procedure btn_okClick(Sender: TObject);
procedure cmb_ApInvoicenoExit(Sender: TObject);
procedure cmb_ApInvoicenoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cmb_ApInvoicenoButtonClick(Sender: TObject);
private
UomName:String; //记录当前单位
MnldTime:Integer;//记录制造提前期
runlt:integer;
LineNo:Integer;//行号
MoStArtWorkDate:String;//当前开工日期
{ Private declarations }
public
permitBackflush:integer;
procedure InitControls; Override;
procedure SaveBodyData; Override;
procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
function existSalterson(ItemCode:string):boolean;
end;
var
Frm_Ar_Enter_ArAp_D: TFrm_Ar_Enter_ArAp_D;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Ar_Enter_ArAp_D.InitControls;
var
SqlText:String;
begin
If (status='Add') Then
SetFocus_Control:=cmb_ApInvoiceno
Else
begin
SetFocus_Control:=edt_thiSCancelAmount;
end;
Inherited;
with AdoQry_Body do
begin
cmb_ApInvoiceno.Text:=fieldbyname('ApInvoiceno').AsString;
If (Status='Add') then
begin
Medt_ApInvoiceDate.Text:='';
edt_TotalAmount.Text:='';
edt_reMainAmount.Text:='';
edt_thiSCancelAmount.Text:='0';
end
else
begin
Medt_ApInvoiceDate.Text:=FormatDateTime('yyyy.mm.dd',fieldbyname('ApInvoiceDate').Asdatetime);
edt_TotalAmount.Text:=floattostr(fieldbyname('TotalAmount').asfloat);
edt_reMainAmount.Text:=floattostr(fieldbyname('reMainTotalAmount').asfloat);
edt_thiSCancelAmount.Text:=floattostr(fieldbyname('thiSCancelAmount').asfloat);
end;
end;
end;
procedure TFrm_Ar_Enter_ArAp_D.SaveBodyData;
var tMpsqltext:string;
begin
If Status='Add' Then
AdoQry_Body.Append
Else
AdoQry_Body.Edit;
with AdoQry_Body do
begin
fieldbyname('ApInvoiceno').AsString:=Trim(cmb_ApInvoiceno.Text);
fieldbyname('ApInvoicedate').Asdatetime:=strtodatetime(Medt_ApInvoiceDate.Text);
fieldbyname('TotalAmount').Asfloat:=strtofloat(edt_TotalAmount.text);
fieldbyname('reMainTotalAmount').AsFloat:=StrtoFloat(Edt_reMainAmount.Text);
fieldbyname('thiSCancelAmount').asfloat:=strtofloat(edt_thiSCancelAmount.text);
Post;
end;
end;
procedure TFrm_Ar_Enter_ArAp_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
if(CurrentStatus='Add')then
EnableControls:='cmb_ApInvoiceno,edt_thiSCancelAmount,'
Else
EnableControls:='edt_thiSCancelAmount,'
end;
procedure TFrm_Ar_Enter_ArAp_D.btn_okClick(Sender: TObject);
var
I:String;
begin
If (Status='Add') Then
begin
begin
If AdoQry_Body.RecordCount>0 Then
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
If (Trim(cmb_ApInvoiceno.Text)=Trim(AdoQry_Body.fieldbyname('ApInvoiceno').AsString)) then
begin
DispInfo('你不能输入两笔相同采购发票号的记录!',3);
Btn_Ok.Enabled:=False;
cmb_ApInvoiceno.SetFocus;
Abort;
end;
AdoQry_Body.Next;
end; //end while
end; //end if
end; //end (Add)
inherited;
end;
function TFrm_Ar_Enter_ArAp_D.existSalterson(ItemCode: string): boolean;
var AdoQry:TAdoQuery;
sqltext:string;
begin
Result:=False;
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
sqltext:='select ItemCode from Bom where BomItemType=6 and ite_ItemCode='+quotedstr(ItemCode);
try
Executesql(AdoQry,sqltext,0);
if AdoQry.RecordCount>0 then Result:=True;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Ar_Enter_ArAp_D.cmb_ApInvoicenoExit(Sender: TObject);
begin
inherited;
if activecontrol=btn_Cancel then exit;
if Trim(cmb_ApInvoiceno.text)='' then
begin
DispInfo('请选择采购发票号!',3);
cmb_ApInvoiceno.SetFocus;
abort;
end;
Executesql(AdoQry_tmp,'select * from ApInvoice where ApInvoiceno='+quotedstr(Tcombobox(sender).text),0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('采购发票号错误!',3);
cmb_ApInvoiceno.SetFocus;
abort;
end;
medt_ApInvoicedate.Text:=formatdatetime('yyyy.mm.dd',AdoQry_tmp.fieldbyname('ApInvoicedate').asdatetime);
edt_TotalAmount.Text:=AdoQry_tmp.fieldbyname('ApInvoiceAmount').asstring;
edt_reMainAmount.Text:=floattostr(AdoQry_tmp.fieldbyname('ApInvoiceAmount').asfloat-AdoQry_tmp.fieldbyname('ApPayedAmount').asfloat);
end;
procedure TFrm_Ar_Enter_ArAp_D.cmb_ApInvoicenoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'ApInvoicedate',
'发票日期','ApInvoiceno','采购发票号','ApInvoice','ApInvoiceAmount>ApPayedAmount');
end;
procedure TFrm_Ar_Enter_ArAp_D.cmb_ApInvoicenoButtonClick(Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'ApInvoicedate',
'发票日期','ApInvoiceno','采购发票号','ApInvoice','ApInvoiceAmount>ApPayedAmount');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -