📄 apinvoicesform.pas
字号:
qryAPInv.FreeBookmark(BookMark);
if qryAPInvAPInvoiceID.AsVariant = null then qryAPInv.first; //If deleting last record, prevent blank record with focus after last record (move to 1st record as per other grids).
end;
end;
procedure TfrmAPInvoices.mnuExitClick(Sender: TObject);
begin
Close;
end;
procedure TfrmAPInvoices.qryAPInvCalcFields(DataSet: TDataSet);
begin
qryAPInvPeriodppyyyy.value := qryAPInvGLPeriod.AsString + '/' + qryAPInvGLYear.AsString;
end;
procedure TfrmAPInvoices.mnuSortDateAscendingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortDate.checked := true;
mnuSortDateAscending.checked := true;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.InvoiceDate, V.VendorName, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortDateDescendingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortDate.checked := true;
mnuSortDateDescending.checked := true;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.InvoiceDate DESC, V.VendorName, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortDueDateAscendingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortDueDate.checked := true;
mnuSortDueDateAscending.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.DueDate, V.VendorName, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortDueDateDescendingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortDueDate.checked := true;
mnuSortDueDateDescending.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.DueDate DESC, V.VendorName, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortNameClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortName.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY V.VendorName, V.VendorNo, I.InvoiceDate, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortAmountClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortAmount.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.InvoiceAmount DESC, I.InvoiceDate';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortOwingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortOwing.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.Owing DESC, I.InvoiceDate';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortVendorNoClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortVendorNo.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY V.VendorNo, I.InvoiceDate, I.InvoiceNo';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuSortInvoicenoClick(Sender: TObject);
begin
screen.cursor := crHourglass;
mnuSortInvoiceno.checked := true;
mnuSortDateAscending.checked := false;
mnuSortDateDescending.checked := false;
mnuSortDueDateAscending.checked := false;
mnuSortDueDateDescending.checked := false;
qryAPInv.close;
qryAPInv.sql[0] := 'SELECT I.*, V.VendorNo, V.VendorName, V.CurrencyID, V.Phone, V.Email FROM APInv I INNER JOIN Vendor V ON I.VendorID = V.VendorID';
qryAPInv.sql[2] := 'ORDER BY I.InvoiceNo, V.VendorName';
qryAPInv.open;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuVendorClick(Sender: TObject);
begin
if qryAPInvVendorID.AsVariant = null then exit; //Bypass if no record selected (eg. if no records).
screen.cursor := crHourglass;
application.createform (TfrmVendor,frmVendor);
if (frmVendor.tblVendor.Locate('VendorID', qryAPInvVendorID.value, [])) = true then frmVendor.Show;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.editFindInvoiceKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then begin
Key := #0; //Cancel Enter key.
if (editFindInvoice.Text = '') or (editFindInvoice.Text = '<Invoice no.>') then begin
Perform(WM_NEXTDLGCTL, 0, 0); //Advance to next control.
exit;
end;
if (editFindVendor.Text <> '') and (editFindVendor.Text <> '<Vendor no.>') then begin
if qryAPInv.Locate('VendorNo;InvoiceNo', VarArrayOf([editFindVendor.Text,editFindInvoice.Text]), []) <> true then begin
editFindInvoice.SelectAll;
raise(Exception.Create('Invoice ' + '''' + editFindInvoice.Text + '''' + ' not found for vendor ' + '''' + editFindVendor.Text + ''''));
end else DBGrid1.setfocus;
end else if (cboFindVendor.Text <> '') and (cboFindVendor.Text <> '<Vendor name>') then begin
if qryAPInv.Locate('VendorID;InvoiceNo', VarArrayOf([cboFindVendor_VendorIDs[cboFindVendor.ItemIndex],editFindInvoice.Text]), []) <> true then begin
editFindInvoice.SelectAll;
raise(Exception.Create('Invoice ' + '''' + editFindInvoice.Text + '''' + ' not found for vendor ' + '''' + cboFindVendor.Text + ''''));
end else DBGrid1.setfocus;
end else editFindVendor.setfocus;
end;
end;
procedure TfrmAPInvoices.FormResize(Sender: TObject);
begin
if (WindowState <> OldWindowState) //Prevent grid resize bugs.
and (WindowState <> wsMinimized)
and (OldWindowState <> wsMinimized)
then mnuRefreshClick(sender);
OldWindowState := WindowState;
end;
procedure TfrmAPInvoices.mnuPostClick(Sender: TObject);
begin
screen.cursor := crHourglass;
application.createform (TfrmAPInvoicesPost,frmAPInvoicesPost);
screen.cursor := crDefault;
if frmAPInvoicesPost.ShowModal = mrOk then begin //Show invoices post form & if posting done, show JVs post form.
screen.cursor := crHourglass;
application.createform (TfrmJVsPost,frmJVsPost);
screen.cursor := crDefault;
if frmJVsPost.qryJV.RecordCount = 0 then frmJVsPost.close
else frmJVsPost.ShowModal;
mnuRefreshClick(sender);
end;
end;
procedure TfrmAPInvoices.mnuFilterClick(Sender: TObject);
var
aComponent: TComponent;
begin
aComponent := Application.FindComponent('frmAPInvoicesFilter');
if not Assigned (aComponent) then frmAPInvoicesFilter := TfrmAPInvoicesFilter.Create(Application);
frmAPInvoicesFilter.ShowModal;
end;
procedure TfrmAPInvoices.qryAPInvFilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
Accept := true; //Default.
try //Try in case filter form not loaded.
if (frmAPInvoicesFilter.optPostedYes.checked = true) and (qryAPInvPosted.value <> true) then Accept := false
else if (frmAPInvoicesFilter.optPostedNo.checked = true) and (qryAPInvPosted.value <> false) then Accept := false;
if (frmAPInvoicesFilter.CurrencyID > 0) and (qryAPInvCurrencyID.value <> frmAPInvoicesFilter.CurrencyID) then Accept := false;
if (frmAPInvoicesFilter.VendorID > 0) and (qryAPInvVendorID.value <> frmAPInvoicesFilter.VendorID) then Accept := false;
except; end;
end;
procedure TfrmAPInvoices.mnuPrintClick(Sender: TObject);
var
strWHERE: string;
begin
//if license = '' then begin frmBS1.FreewareMessage; exit; end;
screen.cursor := crHourglass;
application.createform (TrptAPInvoices,rptAPInvoices);
rptAPInvoices.qryAPInv.SQL := frmAPInvoices.qryAPInv.SQL;
{if mnuFilter.checked = true then begin
strWHERE := ' WHERE (1 = 1)';
try //Try in case filter form not loaded.
if (frmAPInvoicesFilter.optPostedYes.checked = true) then strWHERE := strWHERE + ' AND (Posted = true)'
else if (frmAPInvoicesFilter.optPostedNo.checked = true) then strWHERE := strWHERE + ' AND (Posted = false)';
if (frmAPInvoicesFilter.CurrencyID > 0) then strWHERE := strWHERE + ' AND (CurrencyID = ' + IntToStr(frmAPInvoicesFilter.CurrencyID) + ')';
if (frmAPInvoicesFilter.VendorID > 0) then strWHERE := strWHERE + ' AND (VendorID = ' + IntToStr(frmAPInvoicesFilter.VendorID) + ')';
except; end;
rptAPInvoices.qryAPInv.SQL[0] := rptAPInvoices.qryAPInv.SQL[0] + strWHERE;
end;}
if mnuFilter.checked = true then begin
if rptAPInvoices.qryAPInv.SQL[1] = '' then rptAPInvoices.qryAPInv.SQL[1] := ' WHERE (1 = 1)';
try //Try in case filter form not loaded.
if (frmAPInvoicesFilter.optPostedYes.checked = true) then rptAPInvoices.qryAPInv.SQL[1] := rptAPInvoices.qryAPInv.SQL[1] + ' AND (Posted = true)'
else if (frmAPInvoicesFilter.optPostedNo.checked = true) then rptAPInvoices.qryAPInv.SQL[1] := rptAPInvoices.qryAPInv.SQL[1] + ' AND (Posted = false)';
if (frmAPInvoicesFilter.CurrencyID > 0) then rptAPInvoices.qryAPInv.SQL[1] := rptAPInvoices.qryAPInv.SQL[1] + ' AND (CurrencyID = ' + IntToStr(frmAPInvoicesFilter.CurrencyID) + ')';
if (frmAPInvoicesFilter.VendorID > 0) then rptAPInvoices.qryAPInv.SQL[1] := rptAPInvoices.qryAPInv.SQL[1] + ' AND (VendorID = ' + IntToStr(frmAPInvoicesFilter.VendorID) + ')';
except; end;
end;
if mnuOutstanding.checked = true then rptAPInvoices.QuickReport.ReportTitle := 'AP Invoices (Outstanding)';
rptAPInvoices.qryAPInv.Active := true;
screen.cursor := crDefault;
rptAPInvoices.QuickReport.Preview;
end;
procedure TfrmAPInvoices.mnuChequesClick(Sender: TObject);
begin
if qryAPInvAPInvoiceID.AsVariant = null then exit; //Bypass if no record selected (eg. if no records).
screen.cursor := crHourglass;
application.createform (TfrmAPInvoiceCheques,frmAPInvoiceCheques);
frmAPInvoiceCheques.Show;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.popPhoneClick(Sender: TObject);
begin
with frmDialer do begin
NameToDial := qryAPInvVendorName.value;
NumberToDial := qryAPInvPhone.value;
ShowModal;
end;
end;
procedure TfrmAPInvoices.mnuOutstandingClick(Sender: TObject);
begin
screen.cursor := crHourglass;
if mnuOutstanding.checked = true then begin
mnuOutstanding.checked := false;
if mnuFilter.checked = true then caption := 'AP Invoices (Filtered)'
else caption := 'AP Invoices';
qryAPInv.close; qryAPInv.SQL[1] := ''; qryAPInv.open;
end else begin
mnuOutstanding.checked := true;
if mnuFilter.checked = true then caption := 'AP Invoices (Outstanding, Filtered)'
else caption := 'AP Invoices (Outstanding)';
qryAPInv.close; qryAPInv.SQL[1] := 'WHERE I.Owing <> 0'; qryAPInv.open;
end;
screen.cursor := crDefault;
end;
procedure TfrmAPInvoices.mnuAPInvoicesHelpClick(Sender: TObject);
begin
Application.HelpContext(120);
end;
procedure TfrmAPInvoices.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
screen.cursor := crHourglass;
application.createform (TfrmAPInvoicesPost,frmAPInvoicesPost);
screen.cursor := crDefault;
if frmAPInvoicesPost.qryAPInv.RecordCount = 0 then begin
frmAPInvoicesPost.close;
exit;
end;
//if frmAPInvoicesPost.ShowModal = mrOk then mnuRefreshClick(sender);
if frmAPInvoicesPost.ShowModal = mrOk then begin //Show invoices post form & if posting done, show JVs post form.
screen.cursor := crHourglass;
application.createform (TfrmJVsPost,frmJVsPost);
screen.cursor := crDefault;
if frmJVsPost.qryJV.RecordCount = 0 then frmJVsPost.close
else frmJVsPost.ShowModal;
end;
end;
procedure TfrmAPInvoices.popEMailClick(Sender: TObject);
var
zFileName, zParams, zDir: array[0..79] of Char;
begin
ShellExecute(Application.MainForm.Handle, nil,
StrPCopy(zFileName, 'mailto:' + qryAPInvEMail.value), {filename}
StrPCopy(zParams, ' '), {command line perameters}
StrPCopy(zDir, ''), {default directory}
SW_SHOW); {SW_SHOW Normal window. or SW_SHOWMINIMIZED, SW_HIDE, etc}
end;
procedure TfrmAPInvoices.dsAPInvDataChange(Sender: TObject; Field: TField);
begin
if qryAPInvPhone.AsString = '' then popPhone.Enabled := False
else popPhone.Enabled := True;
if qryAPInvEMail.AsString = '' then popEMail.Enabled := False
else popEMail.Enabled := True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -