📄 qrycust.pas
字号:
unit QryCust;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TQueryCustDlg = class(TForm)
Label1: TLabel;
Label2: TLabel;
FromEdit: TEdit;
ToEdit: TEdit;
CancelBtn: TButton;
OkBtn: TButton;
Msglab: TLabel;
PopupCalBtnFrom: TSpeedButton;
PopupCalToBtn: TSpeedButton;
Bevel1: TBevel;
procedure OkBtnClick(Sender: TObject);
procedure PopupCalBtnFromClick(Sender: TObject);
procedure PopupCalToBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
function GetFromDate: TDateTime;
function GetToDate: TDateTime;
procedure SetFromDate(NewDate: TDateTime);
procedure SetToDate(NewDate: TDateTime);
public
property FromDate: TDateTime read GetFromDate write SetFromDate;
property ToDate: TDateTime read GetToDate write SetToDate;
class function getInstance: TQueryCustDlg;
end;
var
QueryCustDlg: TQueryCustDlg;
implementation
{$R *.DFM}
uses Pickdate;
class function TQueryCustDlg.getInstance: TQueryCustDlg;
begin
if not assigned(QueryCustDlg) then
QueryCustDlg := TQueryCustDlg.Create(Application);
result := QueryCustDlg;
end;
procedure TQueryCustDlg.SetFromDate(NewDate: TDateTime);
begin
FromEdit.Text := DateToStr(NewDate);
end;
procedure TQueryCustDlg.SetToDate(NewDate: TDateTime);
begin
ToEdit.Text := DateToStr(NewDate);
end;
function TQueryCustDlg.GetFromDate: TDateTime;
begin
if FromEdit.Text = '' then Result := 0
else Result := StrToDate(FromEdit.Text);
end;
function TQueryCustDlg.GetToDate: TDateTime;
begin
if ToEdit.Text = '' then Result := 0
else Result := StrToDate(ToEdit.Text);
end;
procedure TQueryCustDlg.OkBtnClick(Sender: TObject);
begin
try
if (ToDate <> 0) and (ToDate < FromDate) then
begin
ShowMessage('"TO" date cannot be less than "FROM" date');
ModalResult := mrNone;
end
else ModalResult := mrOk;
except
ShowMessage(' Invalid date specified');
ModalResult := mrNone;
end;
end;
procedure TQueryCustDlg.PopupCalBtnFromClick(Sender: TObject);
begin
TBrDateForm.getInstance.Date := StrToDate(FromEdit.Text); { start with current date }
if TBrDateForm.getInstance.ShowModal = mrOk then
FromEdit.Text := DateToStr(TBrDateForm.getInstance.Date);
end;
procedure TQueryCustDlg.PopupCalToBtnClick(Sender: TObject);
begin
TBrDateForm.getInstance.Date := StrToDate(ToEdit.Text); { start with current date }
if TBrDateForm.getInstance.ShowModal = mrOk then
ToEdit.Text := DateToStr(TBrDateForm.getInstance.Date);
end;
procedure TQueryCustDlg.FormCreate(Sender: TObject);
begin
MsgLab.Caption := 'Customers with LastInvoiceDate ranging:';
FromDate := EncodeDate(1995, 01, 01);
ToDate := Now;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -