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

📄 glaccountsform.pas

📁 功能全面的商业财会系统源码,清晰,很有参考价值.扩展性强.
💻 PAS
📖 第 1 页 / 共 2 页
字号:
begin
  cboFind.ItemIndex := 0;   //Reset selected item to 1st (so down arrow scrolls from start).
  cboFind.text := '<Account name>';   //Clear selection.
  editFind.text := '<Account no.>';
  editFind.setfocus;
  editFind.SelectAll;
  qryGLAccnt.First;   //Reset grid to start at 1st record.
  if mnuFilter.checked = true then caption := 'GL Accounts (Filtered)'
  else                             caption := 'GL Accounts';
end;

procedure TfrmGLAccounts.editFindKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    Key := #0;   //Cancel Enter key.
    if (editFind.Text = '') or (editFind.Text = '<Account no.>') then begin
      Perform(WM_NEXTDLGCTL, 0, 0);   //Advance to next control.
      exit;
    end;
    cboFind.text := '';
    if qryGLAccnt.Locate('GLAccount', editFind.Text, []) <> true then begin
      editFind.SelectAll;
      raise(Exception.Create('Account ' + '''' + editFind.Text + '''' + ' not found'));
    end else DBGrid1.setfocus;
  end;
end;

procedure TfrmGLAccounts.mnuNewClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  application.createform (TfrmGLAccount,frmGLAccount);
  frmGLAccount.tblGLAccnt.Insert;
  frmGLAccount.Show;
  screen.cursor := crDefault;
end;

procedure TfrmGLAccounts.mnuEditClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  application.createform (TfrmGLAccount,frmGLAccount);
  frmGLAccount.tblGLAccnt.Locate('GLAccount', qryGLAccntGLAccount.AsString, []);
  frmGLAccount.Show;
  screen.cursor := crDefault;
end;

procedure TfrmGLAccounts.mnuDeleteClick(Sender: TObject);
var
  Bookmark: TBookmark;
begin
  if tblGLAccnt.Locate('GLAccount', qryGLAccntGLAccount.value, []) = true then begin
    tblGLAccnt.delete;   //Delete from table as query is read-only.
    DbiSaveChanges(tblGLAccnt.handle);
  end;
  Bookmark := qryGLAccnt.GetBookmark;
  with qryGLAccnt do begin close; open; end;   //Refresh.
  try qryGLAccnt.GotoBookmark(Bookmark); except; end;
  qryGLAccnt.FreeBookmark(BookMark);
  if qryGLAccntGLAccount.AsVariant = null then qryGLAccnt.first;   //If deleting last record, prevent blank record with focus after last record (move to 1st record as per other grids).
end;

procedure TfrmGLAccounts.mnuExitClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmGLAccounts.qryGLAccntCalcFields(DataSet: TDataSet);
begin
  case qryGLAccntAccountType.Value of
    1: qryGLAccntAccountTypeName.Value := 'Asset';
    2: qryGLAccntAccountTypeName.Value := 'Liability';
    3: qryGLAccntAccountTypeName.Value := 'Revenue';
    4: qryGLAccntAccountTypeName.Value := 'Expense';
    5: qryGLAccntAccountTypeName.Value := 'Ret. Earnings';
    else qryGLAccntAccountTypeName.Value := '';
  end;
end;

procedure TfrmGLAccounts.mnuSortAccountnoClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortAccountno.checked := true;
  qryGLAccnt.close;
  qryGLAccnt.sql.clear;
  qryGLAccnt.sql.add('SELECT Suspended, GLAccount, AccountName, AccountType FROM GLAccnt');
  qryGLAccnt.sql.add('ORDER BY GLAccount');
  qryGLAccnt.open;
  screen.cursor := crDefault;
end;

procedure TfrmGLAccounts.mnuSortNameClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortName.checked := true;
  qryGLAccnt.close;
  qryGLAccnt.sql.clear;
  qryGLAccnt.sql.add('SELECT Suspended, GLAccount, AccountName, AccountType FROM GLAccnt');
  qryGLAccnt.sql.add('ORDER BY AccountName');
  qryGLAccnt.open;
  screen.cursor := crDefault;
end;

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

procedure TfrmGLAccounts.mnuPrintClick(Sender: TObject);
var
  strWHERE: string;
begin
  screen.cursor := crHourglass;
  application.createform (TrptGLAccounts,rptGLAccounts);
  rptGLAccounts.qryGLAccnt.SQL := frmGLAccounts.qryGLAccnt.SQL;
  rptGLAccounts.qryGLAccnt.SQL[0] := 'SELECT GLAccnt.* FROM GLAccnt';   //Replace 1st line to include "notes", etc.
  if mnuFilter.checked = true then begin
    strWHERE := ' WHERE (1 = 1)';
    try  //Try in case filter form not loaded.
      if (frmGLAccountsFilter.optSuspendedYes.checked = true) then strWHERE := strWHERE + ' AND (Suspended = true)'
      else if (frmGLAccountsFilter.optSuspendedNo.checked = true) then strWHERE := strWHERE + ' AND (Suspended = false)';
      if (frmGLAccountsFilter.cboAccountType.text <> '<All>') then strWHERE := strWHERE + ' AND (AccountType = ' + IntToStr(frmGLAccountsFilter.cboAccountType.ItemIndex) + ')';
    except; end;
    rptGLAccounts.qryGLAccnt.SQL[0] := rptGLAccounts.qryGLAccnt.SQL[0] + strWHERE;
  end;
  rptGLAccounts.qryGLAccnt.Active := true;
  screen.cursor := crDefault;
  rptGLAccounts.QuickReport.Preview;
end;

procedure TfrmGLAccounts.mnuFilterClick(Sender: TObject);
var
  aComponent: TComponent;
begin
  aComponent := Application.FindComponent('frmGLAccountsFilter');
  if not Assigned (aComponent) then frmGLAccountsFilter := TfrmGLAccountsFilter.Create(Application);
  frmGLAccountsFilter.ShowModal;
end;

procedure TfrmGLAccounts.qryGLAccntFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;   //Default.
  try  //Try in case filter form not loaded.
    if (frmGLAccountsFilter.optSuspendedYes.checked = true) and (qryGLAccntSuspended.value <> true) then Accept := false
    else if (frmGLAccountsFilter.optSuspendedNo.checked = true) and (qryGLAccntSuspended.value <> false) then Accept := false;
    if (frmGLAccountsFilter.cboAccountType.text <> '<All>') and (qryGLAccntAccountType.value <> frmGLAccountsFilter.cboAccountType.ItemIndex) then Accept := false;
  except; end;
end;

procedure TfrmGLAccounts.tblGLAccntFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;   //Default.
  try  //Try in case filter form not loaded.
    if (frmGLAccountsFilter.optSuspendedYes.checked = true) and (tblGLAccntSuspended.value <> true) then Accept := false
    else if (frmGLAccountsFilter.optSuspendedNo.checked = true) and (tblGLAccntSuspended.value <> false) then Accept := false;
    if (frmGLAccountsFilter.cboAccountType.text <> '<All>') and (tblGLAccntAccountType.value <> frmGLAccountsFilter.cboAccountType.ItemIndex) then Accept := false;
  except; end;
end;

procedure TfrmGLAccounts.mnuHistoryClick(Sender: TObject);
var
  aComponent: TComponent;
begin
  screen.cursor := crHourglass;
  aComponent := Application.FindComponent('frmGLHistory');
  if not Assigned (aComponent) then frmGLHistory := TfrmGLHistory.Create(Application);

  aComponent := Application.FindComponent('frmGLHistoryFilter');
  if Assigned (aComponent) then try frmGLHistoryFilter.btnResetClick(sender); except; end
  else begin
    frmGLHistoryFilter := TfrmGLHistoryFilter.Create(Application);
    frmGLHistoryFilter.FormShow(sender);   //Set up cboGLAccounts so SetGLAccount will work.
  end;
  frmGLHistoryFilter.GLAccount := qryGLAccntGLAccount.value;
  frmGLHistoryFilter.editGLAccount.text := qryGLAccntGLAccount.value;
  frmGLHistory.mnuFilter.Checked := true;
  frmGLHistory.qryGLHist.Filtered := true;
  frmGLHistory.tblGLAccnt.Filtered := false;
  frmGLHistory.qryGLHist.close; frmGLHistory.qryGLHist.open;

  if frmGLHistory.WindowState = wsMinimized then frmGLHistory.WindowState := wsNormal;
  if frmGLHistory.visible = true then frmGLHistory.FormShow(sender)
  else frmGLHistory.Show;
  if not frmGLHistory.qryGLHist.Locate('GLAccount', qryGLAccntGLAccount.value, []) then frmGLHistory.qryGLHist.First;
  screen.cursor := crDefault;
end;

procedure TfrmGLAccounts.mnuBalancesClick(Sender: TObject);
var
  aComponent: TComponent;
begin
  //if license = '' then begin frmBS1.FreewareMessage; exit; end;
  screen.cursor := crHourglass;
  aComponent := Application.FindComponent('frmGLBalances');
  if Assigned (aComponent) then try frmGLBalances.qryGLAccnt.close; frmGLBalances.qryGLAccnt.open; except; end
  else frmGLBalances := TfrmGLBalances.Create(Application);

  aComponent := Application.FindComponent('frmGLBalancesFilter');
  if Assigned (aComponent) then try frmGLBalancesFilter.btnResetClick(sender); except; end;
  frmGLBalances.mnuFilter.Checked := false;
  frmGLBalances.qryGLAccnt.Filtered := false;
  frmGLBalances.tblGLAccnt.Filtered := false;

  if frmGLBalances.WindowState = wsMinimized then frmGLBalances.WindowState := wsNormal;
  if frmGLBalances.visible = true then frmGLBalances.FormShow(sender)
  else frmGLBalances.Show;
  if not frmGLBalances.qryGLAccnt.Locate('GLAccount', qryGLAccntGLAccount.value, []) then frmGLBalances.qryGLAccnt.First;
  screen.cursor := crDefault;
end;

procedure TfrmGLAccounts.mnuGLAccountsHelpClick(Sender: TObject);
begin
  Application.HelpContext(310);
end;

end.

⌨️ 快捷键说明

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