⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arpaymentsform.pas

📁 功能全面的商业财会系统源码,清晰,很有参考价值.扩展性强.
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  screen.cursor := crHourglass;
  mnuSortDate.checked := true;
  mnuSortDateAscending.checked := true;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY P.PaymentDate, C.CustomerName, P.ChequeNo');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuSortDateDescendingClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortDate.checked := true;
  mnuSortDateDescending.checked := true;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY P.PaymentDate DESC, C.CustomerName, P.ChequeNo');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuSortNameClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortName.checked := true;
  mnuSortDateAscending.checked := false;
  mnuSortDateDescending.checked := false;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY C.CustomerName, C.CustomerNo, P.PaymentDate, P.ChequeNo');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuSortAmountClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortAmount.checked := true;
  mnuSortDateAscending.checked := false;
  mnuSortDateDescending.checked := false;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY P.ChequeAmount DESC, P.PaymentDate');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuSortBillToNoClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortBillToNo.checked := true;
  mnuSortDateAscending.checked := false;
  mnuSortDateDescending.checked := false;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY C.CustomerNo, P.PaymentDate, P.ChequeNo');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuSortChequenoClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortChequeno.checked := true;
  mnuSortDateAscending.checked := false;
  mnuSortDateDescending.checked := false;
  qryARPmt.close;
  qryARPmt.sql.clear;
  qryARPmt.sql.add('SELECT P.*, C.CustomerNo, C.CustomerName, C.CurrencyID, C.Phone, C.EMail FROM ARPmt P INNER JOIN Customer C ON P.BillToID = C.CustomerID');
  qryARPmt.sql.add('ORDER BY P.ChequeNo, C.CustomerName');
  qryARPmt.open;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.mnuBillToClick(Sender: TObject);
begin
  if qryARPmtBillToID.AsVariant = null then exit;   //Bypass if no record selected (eg. if no records).
  screen.cursor := crHourglass;
  application.createform (TfrmCustomer,frmCustomer);
  if (frmCustomer.tblCustomer.Locate('CustomerID', qryARPmtBillToID.value, [])) = true then frmCustomer.Show;
  screen.cursor := crDefault;
end;

procedure TfrmARPayments.editFindChequeKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    Key := #0;   //Cancel Enter key.
    if (editFindCheque.Text = '') or (editFindCheque.Text = '<Cheque no.>') then begin
      Perform(WM_NEXTDLGCTL, 0, 0);   //Advance to next control.
      exit;
    end;
    if (editFindCustomer.Text <> '') and (editFindCustomer.Text <> '<Bill-to no.>') then begin
      if qryARPmt.Locate('CustomerNo;ChequeNo', VarArrayOf([editFindCustomer.Text,editFindCheque.Text]), []) <> true then begin
        editFindCheque.SelectAll;
        raise(Exception.Create('Cheque ' + '''' + editFindCheque.Text + '''' + ' not found for bill-to ' + '''' + editFindCustomer.Text + ''''));
      end else DBGrid1.setfocus;
    end else if (cboFindCustomer.Text <> '') and (cboFindCustomer.Text <> '<Bill-to name>') then begin
      if qryARPmt.Locate('BillToID;ChequeNo', VarArrayOf([cboFindCustomer_CustomerIDs[cboFindCustomer.ItemIndex],editFindCheque.Text]), []) <> true then begin
        editFindCheque.SelectAll;
        raise(Exception.Create('Cheque ' + '''' + editFindCheque.Text + '''' + ' not found for bill-to ' + '''' + cboFindCustomer.Text + ''''));
      end else DBGrid1.setfocus;
    end else editFindCustomer.setfocus;
  end;
end;

procedure TfrmARPayments.FormResize(Sender: TObject);
begin
  if (WindowState <> OldWindowState)   //Prevent grid resize bugs.
  and (WindowState <> wsMinimized)
  and (OldWindowState <> wsMinimized)
  then mnuRefreshClick(sender);
  OldWindowState := WindowState;
end;

procedure TfrmARPayments.mnuPostClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  application.createform (TfrmARPaymentsPost,frmARPaymentsPost);
  screen.cursor := crDefault;
  if frmARPaymentsPost.ShowModal = mrOk then begin   //Show payments 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 TfrmARPayments.mnuFilterClick(Sender: TObject);
var
  aComponent: TComponent;
begin
  aComponent := Application.FindComponent('frmARPaymentsFilter');
  if not Assigned (aComponent) then frmARPaymentsFilter := TfrmARPaymentsFilter.Create(Application);
  frmARPaymentsFilter.ShowModal;
end;

procedure TfrmARPayments.qryARPmtFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;   //Default.
  try  //Try in case filter form not loaded.
    if (frmARPaymentsFilter.optPostedYes.checked = true) and (qryARPmtPosted.value <> true) then Accept := false
    else if (frmARPaymentsFilter.optPostedNo.checked = true) and (qryARPmtPosted.value <> false) then Accept := false;
    if (frmARPaymentsFilter.CurrencyID > 0) and (qryARPmtCurrencyID.value <> frmARPaymentsFilter.CurrencyID) then Accept := false;
    if (frmARPaymentsFilter.CustomerID > 0) and (qryARPmtBillToID.value <> frmARPaymentsFilter.CustomerID) then Accept := false;
  except; end;
end;

procedure TfrmARPayments.mnuPrintClick(Sender: TObject);
var
  strWHERE: string;
begin
  //if license = '' then begin frmBS1.FreewareMessage; exit; end;
  screen.cursor := crHourglass;
  application.createform (TrptARPayments,rptARPayments);
  rptARPayments.qryARPmt.SQL := frmARPayments.qryARPmt.SQL;
  if mnuFilter.checked = true then begin
    strWHERE := ' WHERE (1 = 1)';
    try  //Try in case filter form not loaded.
      if (frmARPaymentsFilter.optPostedYes.checked = true) then strWHERE := strWHERE + ' AND (Posted = true)'
      else if (frmARPaymentsFilter.optPostedNo.checked = true) then strWHERE := strWHERE + ' AND (Posted = false)';
      if (frmARPaymentsFilter.CurrencyID > 0) then strWHERE := strWHERE + ' AND (BillToID = ' + IntToStr(frmARPaymentsFilter.CurrencyID) + ')';
      if (frmARPaymentsFilter.CustomerID > 0) then strWHERE := strWHERE + ' AND (BillToID = ' + IntToStr(frmARPaymentsFilter.CustomerID) + ')';
    except; end;
    rptARPayments.qryARPmt.SQL[0] := rptARPayments.qryARPmt.SQL[0] + strWHERE;
  end;
  rptARPayments.qryARPmt.Active := true;
  screen.cursor := crDefault;
  rptARPayments.QuickReport.Preview;
end;

procedure TfrmARPayments.popPhoneClick(Sender: TObject);
begin
  with frmDialer do begin
    NameToDial := qryARPmtCustomerName.value;
    NumberToDial := qryARPmtPhone.value;
    ShowModal;
  end;
end;

procedure TfrmARPayments.cboFindCustomerClick(Sender: TObject);
begin
  if cboFindCustomer.Text = '' then exit;
  editFindCustomer.text := '';
  if cboFindCustomer.Items.IndexOf(cboFindCustomer.Text) < 0 then raise(Exception.Create('Choose an item from the list'));
end;

procedure TfrmARPayments.editFindCustomerKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    Key := #0;   //Cancel Enter key.
    if (editFindCustomer.Text = '') or (editFindCustomer.Text = '<Bill-to no.>') then begin
      Perform(WM_NEXTDLGCTL, 0, 0);   //Advance to next control.
      exit;
    end;
    cboFindCustomer.text := '';
    editFindCheque.SetFocus;
  end;
end;

procedure TfrmARPayments.cboFindCustomerDropDown(Sender: TObject);
begin
  if frmARPayments_cboFindCustomer_RequeryRequired = true then cboFindCustomer_Load(dmLookUps.tblCustomer, cboFindCustomer);   //Populate "find" combobox.
end;

procedure TfrmARPayments.cboFindCustomerKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if frmARPayments_cboFindCustomer_RequeryRequired = true then cboFindCustomer_Load(dmLookUps.tblCustomer, cboFindCustomer);   //Populate "find" combobox.
end;

procedure TfrmARPayments.cboFindCustomerKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    Key := #0;   //Cancel Enter key.
    if (cboFindCustomer.Text = '') or (cboFindCustomer.Text = '<Bill-to name>') then begin
      Perform(WM_NEXTDLGCTL, 0, 0);   //Advance to next control.
      exit;
    end;
    cboFindCustomerClick(Sender);   //Trigger click event (in case partial text was entered then combobox opened: item would show as selected, but Enter wouldn't process it).
    Perform(WM_NEXTDLGCTL, 0, 0);   //Advance to next control.
  end;
end;

procedure TfrmARPayments.mnuAPInvoicesHelpClick(Sender: TObject);
begin
  Application.HelpContext(230);
end;

procedure TfrmARPayments.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  screen.cursor := crHourglass;
  application.createform (TfrmARPaymentsPost,frmARPaymentsPost);
  screen.cursor := crDefault;
  if frmARPaymentsPost.qryARPmt.RecordCount = 0 then begin
    frmARPaymentsPost.close;
    exit;
  end;
  //if frmARPaymentsPost.ShowModal = mrOk then mnuRefreshClick(sender);
  if frmARPaymentsPost.ShowModal = mrOk then begin   //Show payments 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 TfrmARPayments.popEMailClick(Sender: TObject);
var
  zFileName, zParams, zDir: array[0..79] of Char;
begin
  ShellExecute(Application.MainForm.Handle, nil,
  StrPCopy(zFileName, 'mailto:' + qryARPmtEMail.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 TfrmARPayments.dsARPmtDataChange(Sender: TObject; Field: TField);
begin
  if qryARPmtPhone.AsString = '' then popPhone.Enabled := False
  else popPhone.Enabled := True;
  if qryARPmtEMail.AsString = '' then popEMail.Enabled := False
  else popEMail.Enabled := True;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -