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

📄 companyform.pas

📁 功能全面的商业财会系统源码,清晰,很有参考价值.扩展性强.
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TfrmCompany.btnCancelClick(Sender: TObject);
begin
  tblCompany.cancel;
  Close;
end;

procedure TfrmCompany.popWordWrapClick(Sender: TObject);
begin
  if popWordWrap.checked = true then begin
    popWordWrap.checked := false;
    memoNotes.WordWrap := false;
    memoNotes.ScrollBars := ssBoth;
  end else begin
    popWordWrap.checked := true;
    memoNotes.WordWrap := true;
    memoNotes.ScrollBars := ssVertical;
  end;
end;

procedure TfrmCompany.tblCompanyFiscalYearGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyFiscalYear.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyFiscalYear.AsString;
end;

procedure TfrmCompany.tblCompanyFiscalYearSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyFiscalYear.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Current Fiscal Year invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyFiscalYear.value := StrToInt(Text) + 2000
    else tblCompanyFiscalYear.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.tblCompanyDefaultPeriodYYYYGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyDefaultPeriodYYYY.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyDefaultPeriodYYYY.AsString;
end;

procedure TfrmCompany.tblCompanyDefaultPeriodYYYYSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyDefaultPeriodYYYY.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Default Period invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyDefaultPeriodYYYY.value := StrToInt(Text) + 2000
    else tblCompanyDefaultPeriodYYYY.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.tblCompanyWPeriodToYYYYGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyWPeriodToYYYY.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyWPeriodToYYYY.AsString;
end;

procedure TfrmCompany.tblCompanyEPeriodFromYYYYGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyEPeriodFromYYYY.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyEPeriodFromYYYY.AsString;
end;

procedure TfrmCompany.tblCompanyEPeriodToYYYYGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyEPeriodToYYYY.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyEPeriodToYYYY.AsString;
end;

procedure TfrmCompany.tblCompanyWPeriodToYYYYSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyWPeriodToYYYY.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Warn After Period invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyWPeriodToYYYY.value := StrToInt(Text) + 2000
    else tblCompanyWPeriodToYYYY.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.tblCompanyEPeriodFromYYYYSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyEPeriodFromYYYY.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Error Before Period invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyEPeriodFromYYYY.value := StrToInt(Text) + 2000
    else tblCompanyEPeriodFromYYYY.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.tblCompanyEPeriodToYYYYSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyEPeriodToYYYY.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Error After Period invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyEPeriodToYYYY.value := StrToInt(Text) + 2000
    else tblCompanyEPeriodToYYYY.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.tblCompanyWPeriodFromYYYYGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if DisplayText = false then Text := Copy(tblCompanyWPeriodFromYYYY.AsString,3,2)   //If editing, show last 2 digits of year.
  else Text := tblCompanyWPeriodFromYYYY.AsString;
end;

procedure TfrmCompany.tblCompanyWPeriodFromYYYYSetText(Sender: TField;
  const Text: string);
begin
  if Text = '' then tblCompanyWPeriodFromYYYY.AsVariant := null else begin   //Convert 2 digit year to 4.
    if (StrToInt(Text) < 0) or (StrToInt(Text) > 99) then raise(exception.create('Warn Before Period invalid...' + #13 + 'Enter year as 2 digits'));
    if StrToInt(Text) < 50 then tblCompanyWPeriodFromYYYY.value := StrToInt(Text) + 2000
    else tblCompanyWPeriodFromYYYY.value := StrToInt(Text) + 1900;
  end;
end;

procedure TfrmCompany.btnCurrencyClick(Sender: TObject);
var
  aComponent: TComponent;
begin
  screen.cursor := crHourglass;
  aComponent := Application.FindComponent('frmCurrencies');
  if not Assigned (aComponent) then frmCurrencies := TfrmCurrencies.Create(Application);
  if frmCurrencies.WindowState = wsMinimized then frmCurrencies.WindowState := wsNormal;
  if frmCurrencies.visible = true then frmCurrencies.FormShow(sender)
  else frmCurrencies.Show;
  if not frmCurrencies.tblCurrency.Locate('CurrencyID', tblCompanyDefaultCurrencyID.value, []) then frmCurrencies.tblCurrency.First;
  screen.cursor := crDefault;
end;

procedure TfrmCompany.cboCurrencyKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = VK_Delete then begin
    tblCompany.Edit;
    tblCompanyDefaultCurrencyID.AsVariant := null;
  end;
end;

procedure TfrmCompany.tblCompanyFiscalYearValidate(Sender: TField);
begin
  if YearEnd = false then begin
    if tblCompany.RecordCount > 0 then begin
      tblJV.open;
      if tblJV.RecordCount > 0 then raise(Exception.Create('Fiscal Year cannot be changed...' +#13 + 'Journal Voucher(s) exist'));
      tblAPInv.open;
      if tblAPInv.RecordCount > 0 then raise(Exception.Create('Fiscal Year cannot be changed...' +#13 + 'AP Invoice(s) exist'));
      tblARInv.open;
      if tblARInv.RecordCount > 0 then raise(Exception.Create('Fiscal Year cannot be changed...' +#13 + 'AR Invoice(s) exist'));
      tblGLHist.open;
      if tblGLHist.RecordCount > 0 then raise(Exception.Create('Fiscal Year cannot be changed...' +#13 + 'GL History exists'));
    end;
  end;
end;

procedure TfrmCompany.dsCompanyDataChange(Sender: TObject; Field: TField);
begin
  if tblCompanyFiscalYear.value > 0 then btnYearEnd.Enabled := true
  else btnYearEnd.Enabled := false;
end;

procedure TfrmCompany.btnYearEndClick(Sender: TObject);
begin
  screen.cursor := crHourglass;
  application.createform (TfrmYearEnd,frmYearEnd);
  screen.cursor := crDefault;
  if frmYearEnd.ShowModal = mrOk then begin
    editCompanyName.setfocus;
    if MessageDlg('Year End: Permanently close ' + tblCompanyFiscalYear.AsString + '?' + #13 + #13 +
                  'GL balances have been carried forward, etc. so you can now print financial statements for ' + IntToStr(tblCompanyFiscalYear.value + 1) + '.  ' +
                  'You can leave ' + tblCompanyFiscalYear.AsString + ' open if there will be more transactions.',mtConfirmation, [mbYes, mbNo],0) = mrYes then begin
      YearEnd := true;   //Suppress field validation on FiscalYear.
      tblCompany.Edit;
      tblCompanyFiscalYear.value := tblCompanyFiscalYear.value + 1;
      if tblCompanyDefaultPeriodYYYY.value >0 then tblCompanyDefaultPeriodYYYY.value := tblCompanyFiscalYear.value;   //Only set default period if being used.
      if tblCompanyDefaultPeriodPP.value >0 then tblCompanyDefaultPeriodPP.value := 1;
      tblCompanyWPeriodFromYYYY.value := tblCompanyFiscalYear.value;
      tblCompanyWPeriodFromPP.value := 1;
      tblCompanyWPeriodToYYYY.value := tblCompanyFiscalYear.value;
      tblCompanyWPeriodToPP.value := 1;
      tblCompanyEPeriodFromYYYY.value := tblCompanyFiscalYear.value;
      tblCompanyEPeriodFromPP.value := 1;
      tblCompanyEPeriodToYYYY.value := tblCompanyFiscalYear.value;
      tblCompanyEPeriodToPP.value := 1;
      //tblCompany.Post;   //Allow cancel button to prevent advancing the year (yet GL closing entries made).
      YearEnd := false;
    end;
  end;
end;

procedure TfrmCompany.cboDfltSalesGLAccountKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key = VK_Delete then begin
    tblCompany.Edit;
    tblCompanyDfltSalesGLAccount.AsVariant := null;
  end;
end;

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

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

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

procedure TfrmCompany.tblCompanyDfltSalesGLAccountValidate(Sender: TField);
begin
  if (editDfltSalesGLAccount.text <> '') and (dmLookUps.tblGLAccnt.Locate('GLAccount', editDfltSalesGLAccount.Text, []) <> true) then raise(Exception.Create('GL Account ' + '''' + editDfltSalesGLAccount.Text + '''' + ' not found'));
end;

procedure TfrmCompany.btnHelpClick(Sender: TObject);
begin
  Application.HelpContext(410);
end;

end.

⌨️ 快捷键说明

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