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

📄 glbudgetform.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 Budget (Filtered)'
  else                             caption := 'GL Budget';
end;

procedure TfrmGLBudget.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 TfrmGLBudget.mnuExitClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmGLBudget.mnuSortAccountnoClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortAccountno.checked := true;
  qryGLAccnt.close;
  qryGLAccnt.sql.clear;
  qryGLAccnt.sql.add('SELECT G.GLAccount, G.AccountName, G.AccountType, B.* FROM GLAccnt G LEFT OUTER JOIN GLBudget B ON G.GLAccount = B.GLAccount');
  qryGLAccnt.sql.add('ORDER BY G.GLAccount, B.GLYear');
  qryGLAccnt.open;
  screen.cursor := crDefault;
end;

procedure TfrmGLBudget.mnuSortNameClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  mnuSortName.checked := true;
  qryGLAccnt.close;
  qryGLAccnt.sql.clear;
  qryGLAccnt.sql.add('SELECT G.GLAccount, G.AccountName, G.AccountType, B.* FROM GLAccnt G LEFT OUTER JOIN GLBudget B ON G.GLAccount = B.GLAccount');
  qryGLAccnt.sql.add('ORDER BY G.AccountName, B.GLYear');
  qryGLAccnt.open;
  screen.cursor := crDefault;
end;

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

procedure TfrmGLBudget.mnuPrintClick(Sender: TObject);
var
  strWHERE: string;
begin
  screen.cursor := crHourglass;
  application.createform (TrptGLBudget,rptGLBudget);
  rptGLBudget.qryGLAccnt.SQL := frmGLBudget.qryGLAccnt.SQL;
  if mnuFilter.checked = true then begin
    strWHERE := ' WHERE (1 = 1)';
    try  //Try in case filter form not loaded.
      if (frmGLBudgetFilter.chkYearAll.checked <> true) then strWHERE := strWHERE + ' AND (GLYear = ' + frmGLBudgetFilter.editYear.text + ')';
      if (frmGLBudgetFilter.cboAccountType.text <> '<All>') then strWHERE := strWHERE + ' AND (AccountType = ' + IntToStr(frmGLBudgetFilter.cboAccountType.ItemIndex) + ')';
    except; end;
    rptGLBudget.qryGLAccnt.SQL[0] := rptGLBudget.qryGLAccnt.SQL[0] + strWHERE;
  end;
  rptGLBudget.qryGLAccnt.Active := true;
  screen.cursor := crDefault;
  rptGLBudget.QuickReport.Preview;
end;

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

procedure TfrmGLBudget.qryGLAccntFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;   //Default.
  try  //Try in case filter form not loaded.
    if (frmGLBudgetFilter.chkYearAll.checked <> true) and (qryGLAccntGLYear.AsString <> frmGLBudgetFilter.editYear.text) then Accept := false;
    if (frmGLBudgetFilter.cboAccountType.text <> '<All>') and (qryGLAccntAccountType.value <> frmGLBudgetFilter.cboAccountType.ItemIndex) then Accept := false;
  except; end;
end;

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

procedure TfrmGLBudget.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 TfrmGLBudget.mnuGLBudgetHelpClick(Sender: TObject);
begin
  Application.HelpContext(330);
end;

procedure TfrmGLBudget.mnuNewClick(Sender: TObject);
begin
  //if qryGLAccntGLAccount.AsVariant = null then exit;   //Allow no account no. ...will happen if year selected and no budget yet.
  screen.cursor := crHourglass;
  application.createform (TfrmGLBudgetAccount,frmGLBudgetAccount);
  frmGLBudgetAccount.tblGLBudget.Insert;
  frmGLBudgetAccount.Show;
  screen.cursor := crDefault;
end;

procedure TfrmGLBudget.mnuEditClick(Sender: TObject);
begin
  if qryGLAccntGLAccount.AsVariant = null then exit;
  if qryGLAccntGLYear.AsVariant = null then mnuNewClick(sender)
  else begin
    screen.cursor := crHourglass;
    application.createform (TfrmGLBudgetAccount,frmGLBudgetAccount);
    frmGLBudgetAccount.tblGLBudget.Locate('GLAccount;GLYear', VarArrayOf([qryGLAccntGLAccount.value, qryGLAccntGLYear.value]), []);
    frmGLBudgetAccount.Show;
    screen.cursor := crDefault;
  end;
end;

procedure TfrmGLBudget.mnuDeleteClick(Sender: TObject);
var
  Bookmark: TBookmark;
begin
  if qryGLAccntGLYear.AsVariant = null then exit;   //Bypass if not on a GLBudget record.
  tblGLBudget.Active := true;
  if tblGLBudget.Locate('GLAccount;GLYear', VarArrayOf([qryGLAccntGLAccount.value, qryGLAccntGLYear.value]), []) = true then begin
    tblGLBudget.delete;   //Delete from table as query is read-only.
    DbiSaveChanges(tblGLBudget.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 TfrmGLBudget.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 TfrmGLBudget.tblGLBudgetBeforeDelete(DataSet: TDataSet);
begin
  if MessageDlg('Delete ' + tblGLBudgetGLYear.AsString + ' budget for ' + '''' + tblGLBudgetGLAccount.AsString + ': ' + qryGLAccntAccountName.AsString + '''' + '?',mtConfirmation,mbOKCancel,0) <> mrOK then raise(EAbort.create(''));   //Silent Exception: "abort;" replaced by "raise etc" since abort conflicts with BDE (required by DbiSaveChanges).
  repaint;
end;

end.

⌨️ 快捷键说明

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