📄 ap_qry_apdetail_condition.pas
字号:
unit Ap_Qry_ApDetail_Condition;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Dialog, Db, AdODB, StdCtrls, Mask, ExtEdit, ActnList;
Type
TFrm_Ap_Qry_ApDetail_Condition = Class(TFrm_Base_Dialog)
Label1: TLabel;
Label5: TLabel;
Label6: TLabel;
Medt_beginMonth: TMaskEdit;
Medt_EndMonth: TMaskEdit;
Label2: TLabel;
Edt_VendorCode: TEdit;
Label3: TLabel;
Lbl_VendorName: TLabel;
ActionList1: TActionList;
Action1: TAction;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure Action1Execute(Sender: TObject);
procedure Edt_VendorCodeExit(Sender: TObject);
procedure Medt_EndMonthExit(Sender: TObject);
procedure Medt_beginMonthExit(Sender: TObject);
private
{ Private declarations }
openMonth :string;//开帐月份;
SourceMonth:string; //系统开始使用月份!
procedure SetDialog;
procedure SetVendor(R_VendorCode: String);
function VendorCodeUsable(R_VendorCode:String):Boolean;
function PickVendorCode(InitCode:String):String;
public
{ Public declarations }
VendorCode:String;
beginMonth:String;
endMonth:string;
end;
var
Frm_Ap_Qry_ApDetail_Condition: TFrm_Ap_Qry_ApDetail_Condition;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Ap_Qry_ApDetail_Condition.FormCreate(Sender: TObject);
begin
inherited;
Edt_VendorCode.Text:='';
Lbl_VendorName.Caption:='';
VendorCode:='';
beginMonth:=formatdatetime('yyyy.mm',date);
endMonth:=formatdatetime('yyyy.mm',date);
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.SetDialog;
begin
Medt_beginMonth.Text:=beginMonth;
Medt_EndMonth.Text:=endMonth;
Edt_VendorCode.Text:=VendorCode;
SetVendor(VendorCode);
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.FormActivate(Sender: TObject);
begin
inherited;
SetDialog;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select ApParamValuec '+
' from ApParam '+
' where ApParamCode=''clsperiod''');
open;
openMonth:=fieldbyname('ApParamValuec').asstring;
Close;
sql.text:=' select min(ApBalanceMonth) as ApBalanceMonth from ApBalance ';
open;
SourceMonth:=fieldbyname('ApBalanceMonth').AsString;
Close;
end;
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.btn_okClick(Sender: TObject);
begin
inherited;
beginMonth:=Medt_beginMonth.Text;
endMonth:=Medt_EndMonth.Text;
VendorCode:=Edt_VendorCode.Text;
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.SetVendor(R_VendorCode: String);
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select VendorName '+
'from Vendor '+
'where VendorCode='''+R_VendorCode+''' ');
open;
if not eof then
Lbl_VendorName.Caption:=fieldbyname('VendorName').asString;
Close;
end;
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.Action1Execute(Sender: TObject);
begin
inherited;
if ActiveControl.Name='Edt_VendorCode' then
begin
Edt_VendorCode.Text:=PickVendorCode(Edt_VendorCode.Text);
Edt_VendorCode.SetFocus;
end;
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.Edt_VendorCodeExit(
Sender: TObject);
begin
inherited;
if VendorCodeUsable(Edt_VendorCode.Text) then
begin
SetVendor(Edt_VendorCode.Text);
end
else
begin
DispInfo('输入的代码没找到!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
function TFrm_Ap_Qry_ApDetail_Condition.VendorCodeUsable(R_VendorCode:String):Boolean;
var
T_Count:integer;
T_Sql:string;
begin
T_Sql:=
'Select Count(*) as RecordCount '+
'from Vendor '+
'where VendorCode='''+R_VendorCode+''' ';
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add(T_Sql);
open;
T_Count:=fieldbyname('RecordCount').AsInteger;
Close;
end;
if T_Count>0 then Result:=True
else Result:=False;
end;
function TFrm_Ap_Qry_ApDetail_Condition.PickVendorCode(InitCode:String):String;
begin
Result:=GetCodeHint(
AdoQry_Tmp,
'VendorName','供应商名称',
'VendorCode','供应商代码',
'Vendor',InitCode,'');
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.Medt_EndMonthExit(
Sender: TObject);
begin
inherited;
if activecontrol.Name='btn_Cancel' then
abort;
if Trim(Medt_EndMonth.text)='' then
begin
DispInfo('月份不能为空',3);
Medt_EndMonth.setfocus;
abort;
end
else
begin
try
strtodatetime(Trim(Medt_EndMonth.text)+'.01');
except
DispInfo('日期非法!',1);
Medt_EndMonth.setfocus;
abort;
end;
end;
end;
procedure TFrm_Ap_Qry_ApDetail_Condition.Medt_beginMonthExit(
Sender: TObject);
var
str:string;
beginMonth,endMonth:Tdatetime;
begin
inherited;
if activecontrol.Name='btn_Cancel' then
abort;
if Trim(Medt_beginMonth.text)='' then
begin
DispInfo('月份不能为空',3);
Medt_beginMonth.setfocus;
abort;
end
else
begin
try
strtodatetime(Trim(Medt_beginMonth.text)+'.01');
except
DispInfo('日期非法!',1);
Medt_beginMonth.setfocus;
abort;
end;
end;
if openMonth='' then
begin
DispInfo('系统未结帐!',3);
abort;
end
else
begin
if SourceMonth>(Medt_beginMonth.text) then
Medt_beginMonth.text:=SourceMonth;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -