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

📄 gettingstartedform.pas

📁 功能全面的商业财会系统源码,清晰,很有参考价值.扩展性强.
💻 PAS
字号:
unit GettingStartedForm;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, Mask, Dialogs, DBTables, DB, Menus, DBCtrls, BDE;

type
  TfrmGettingStarted = class(TForm)
    panelBottom: TPanel;
    btnBack: TButton;
    btnNext: TButton;
    btnCancel: TButton;
    PanelCompany: TPanel;
    PanelCurrency: TPanel;
    PanelFinish: TPanel;
    lblHeading: TLabel;
    Image1: TImage;
    Label2: TLabel;
    Image2: TImage;
    Image3: TImage;
    lblFinish: TLabel;
    tblCompany: TTable;
    dsCompany: TDataSource;
    tblCompanyCompanyName: TStringField;
    tblCompanyFiscalYear: TSmallintField;
    lblCompanyName: TLabel;
    editCompanyName: TDBEdit;
    lblFiscalYear: TLabel;
    editFiscalYear: TDBEdit;
    tblCompanyCompanyNo: TSmallintField;
    tblBank: TTable;
    tblBankBankID: TAutoIncField;
    tblBankBankName: TStringField;
    tblBankBankGLAccount: TStringField;
    tblBankCurrencyID: TIntegerField;
    tblCurrency: TTable;
    tblCurrencyCurrencyID: TAutoIncField;
    tblCurrencyCurrencyName: TStringField;
    tblCurrencyExchangeRate: TFloatField;
    tblCurrencyAPGLAccount: TStringField;
    tblCurrencyGainLossExchangeGLAccount: TStringField;
    tblCurrencyAPDiscGLAccount: TStringField;
    tblCurrencyARGLAccount: TStringField;
    tblCurrencyARDiscGLAccount: TStringField;
    tblCurrencyDfltWriteOffGLAccount: TStringField;
    dsCurrency: TDataSource;
    dsBank: TDataSource;
    lblCurrencyName: TLabel;
    editCurrencyName: TDBEdit;
    lblBankName: TLabel;
    editBankName: TDBEdit;
    tblGLAccnt: TTable;
    tblGLAccntGLAccount: TStringField;
    tblGLAccntAccountName: TStringField;
    tblGLAccntAccountType: TSmallintField;
    tblGLAccntSuspended: TBooleanField;
    tblCompanyDefaultCurrencyID: TIntegerField;
    tblCompanyDfltSalesGLAccount: TStringField;
    tblCompanyDefaultPeriodYYYY: TSmallintField;
    tblCompanyDefaultPeriodPP: TSmallintField;
    tblSalesman: TTable;
    tblCusType: TTable;
    tblSalesmanSalesmanID: TAutoIncField;
    tblSalesmanLastName: TStringField;
    tblCusTypeCustomerTypeID: TAutoIncField;
    tblCusTypeTypeName: TStringField;
    lblFinish2: TLabel;
    lblFinish3: TLabel;
    tblTax: TTable;
    tblTaxTaxID: TAutoIncField;
    tblTaxTaxName: TStringField;
    tblTaxRate: TFloatField;
    tblTaxTaxCode: TStringField;
    tblTaxTaxDescription: TStringField;
    tblTaxTaxGLAccount: TStringField;
    dsTax: TDataSource;
    panelTax: TPanel;
    Label1: TLabel;
    Image4: TImage;
    lblTaxName: TLabel;
    editTaxName: TDBEdit;
    lblRate: TLabel;
    editRate: TDBEdit;
    editAddressLine1: TDBEdit;
    tblCompanyAddressLine1: TStringField;
    tblCompanyAddressLine2: TStringField;
    tblCompanyAddressLine3: TStringField;
    lblAddress: TLabel;
    editAddressLine2: TDBEdit;
    editAddressLine3: TDBEdit;
    tblCompanyAPInvPONumbers: TBooleanField;
    tblCompanyAPInvDescriptions: TBooleanField;
    procedure btnNextClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnBackClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure CreateGLAccount(GLAccount, AccountName: string; AccountType: integer);
  public
    { Public declarations }
  end;

var
  frmGettingStarted: TfrmGettingStarted;

implementation

uses BS1Form;

{$R *.DFM}

procedure TfrmGettingStarted.CreateGLAccount(GLAccount, AccountName: string; AccountType: integer);
begin
  tblGLAccnt.insert;
  tblGLAccntGLAccount.value := GLAccount;
  tblGLAccntAccountName.value := AccountName;
  tblGLAccntAccountType.value := AccountType;
  tblGLAccntSuspended.value := false;
  tblGLAccnt.post;
end;

procedure TfrmGettingStarted.btnNextClick(Sender: TObject);
begin
  btnNext.setfocus;   //Trigger field update if Enter pressed (btnNext default = true).
  if panelCompany.visible = true then begin
    if tblCompanyCompanyName.AsString = '' then begin
      with editCompanyName do begin Show; SetFocus; end;
      raise(exception.create('Field ' + '''Company Name''' + ' must have a value'));
    end;
    if (tblCompanyFiscalYear.AsInteger < 1995) or (tblCompanyFiscalYear.AsInteger > 2050) then begin
      with editFiscalYear do begin Show; SetFocus; end;
      raise(exception.create('Fiscal Year must be between 1995 and 2050'));
    end;
    panelCompany.visible := false;
    btnBack.enabled := true;
    panelCurrency.visible := true;
    editBankName.setfocus;
  end else if panelCurrency.visible = true then begin
    if tblBankBankName.AsString = '' then begin
      with editBankName do begin Show; SetFocus; end;
      raise(exception.create('Field ' + '''Bank Name''' + ' must have a value'));
    end;
    if tblCurrencyCurrencyName.AsString = '' then begin
      with editCurrencyName do begin Show; SetFocus; end;
      raise(exception.create('Field ' + '''Currency Name''' + ' must have a value'));
    end;
    panelCurrency.visible := false;
    panelTax.visible := true;
    editTaxName.setfocus;
  end else if panelTax.visible = true then begin
    if (tblTaxRate.AsFloat <> 0) and (tblTaxTaxName.AsString = '') then begin
      with editTaxName do begin Show; SetFocus; end;
      raise(exception.create('Field ' + '''Tax Name''' + ' must have a value (if rate entered)'));
    end;
    if (tblTaxTaxName.AsString <> '') and (tblTaxRate.AsFloat = 0) then begin
      with editRate do begin Show; SetFocus; end;
      raise(exception.create('Field ' + '''Rate''' + ' must have a value (if tax name entered)'));
    end;
    panelTax.visible := false;
    panelFinish.visible := true;
    btnNext.caption := '&Finish';
  end else if panelFinish.visible = true then begin
    CreateGLAccount('1006', tblBankBankName.value, 1);   //Required GL accounts.
    CreateGLAccount('1112', 'Accounts Receivable', 1);
    CreateGLAccount('2032', 'Accounts Payable', 2);
    CreateGLAccount('4000', 'Sales', 3);
    CreateGLAccount('4999', 'Cash Discounts', 3);
    CreateGLAccount('9030', 'Purchase Discounts', 4);

    CreateGLAccount('1113', 'Exchange on Foreign Receivables', 1);   //Optional GL accounts.
    CreateGLAccount('1200', 'Inventory', 1);
    CreateGLAccount('1721', 'Equipment', 1);
    CreateGLAccount('1821', 'Accumulated Depreciation Equipment', 2);
    CreateGLAccount('2034', 'Exchange on Foreign Payables', 2);
    CreateGLAccount('2040', 'Sales Tax Payable', 2);
    CreateGLAccount('2050', 'Income Tax Payable', 2);
    CreateGLAccount('3110', 'Proprietor' + '''' + 's Capital or Retained Earnings', 5);
    CreateGLAccount('3111', 'Proprietor' + '''' + 's Withdrawals or Salary', 4);
    CreateGLAccount('5000', 'Cost of Goods Sold', 4);
    CreateGLAccount('5110', 'Auto Supplies', 4);
    CreateGLAccount('5111', 'Office Supplies', 4);
    CreateGLAccount('5112', 'Courier', 4);
    CreateGLAccount('5113', 'Telephone', 4);
    CreateGLAccount('5114', 'Postage', 4);
    CreateGLAccount('5115', 'Banking Charges', 4);
    CreateGLAccount('5116', 'Meals and Entertainment', 4);
    CreateGLAccount('5117', 'Travelling', 4);
    CreateGLAccount('5118', 'Professional Fees', 4);
    CreateGLAccount('5119', 'Business Taxes and Licenses', 4);
    CreateGLAccount('5120', 'Charitable Donations', 4);
    CreateGLAccount('5121', 'Courses and Training', 4);
    CreateGLAccount('5122', 'Dues and Memberships', 4);
    CreateGLAccount('5123', 'Magazines and Books', 4);
    CreateGLAccount('5124', 'Promo and Gifts', 4);
    CreateGLAccount('6000', 'Rent on Building', 4);
    CreateGLAccount('6001', 'Business Use of Home', 4);
    CreateGLAccount('6002', 'Electricity', 4);
    CreateGLAccount('6003', 'Insurance', 4);
    CreateGLAccount('6004', 'Water', 4);
    CreateGLAccount('6005', 'Property Taxes', 4);
    CreateGLAccount('7121', 'Depreciation Equipment', 4);
    CreateGLAccount('7130', 'Gain/Loss Disposal of Assets', 4);
    CreateGLAccount('7820', 'Misc Income and Expense', 4);
    CreateGLAccount('9020', 'Gain/Loss Foreign Exchange', 4);
    CreateGLAccount('9110', 'Income Tax Current Year', 4);
    CreateGLAccount('9025', 'Bad Debts', 4);

    tblCurrencyAPGLAccount.value := '2032';
    tblCurrencyAPDiscGLAccount.value := '9030';
    tblCurrencyARGLAccount.value := '1112';
    tblCurrencyARDiscGLAccount.value := '4999';
    tblCurrencyDfltWriteOffGLAccount.value := '4999';
    tblCurrency.post;

    //tblCompanyDefaultPeriodPP.value := 8;   //"Default period" option probably won't be used: rather base it on current date.
    //tblCompanyDefaultPeriodYYYY.value := tblCompanyFiscalYear.value;
    tblCompanyDfltSalesGLAccount.value := '4000';
    tblCompanyDefaultCurrencyID.value := tblCurrencyCurrencyID.value;
    tblCompany.post;

    tblBankBankGLAccount.value := '1006';
    tblBankCurrencyID.value := tblCurrencyCurrencyID.value;
    tblBank.post;

    tblSalesman.insert;
    tblSalesmanSalesmanID.value := 1;
    tblSalesmanLastName.value := 'House Account';
    tblSalesman.post;

    tblCusType.insert;
    tblCusTypeCustomerTypeID.value := 1;
    tblCusTypeTypeName.value := 'General';
    tblCusType.post;

    if tblTaxTaxName.value <> '' then begin
      tblTaxTaxCode.value := 'T';
      tblTaxTaxDescription.value := tblTaxTaxName.value;
      tblTaxTaxGLAccount.value := '2040';
      tblTax.post;
    end;

    frmBS1.tblCompany.Refresh;
    modalResult := mrOK;
    DbiSaveChanges(tblCompany.handle);
    DbiSaveChanges(tblCurrency.handle);
    DbiSaveChanges(tblBank.handle);
    DbiSaveChanges(tblGLAccnt.handle);
    DbiSaveChanges(tblSalesman.handle);
    DbiSaveChanges(tblCusType.handle);
    DbiSaveChanges(tblTax.handle);
  end;
end;

procedure TfrmGettingStarted.btnBackClick(Sender: TObject);
begin
  if panelFinish.visible = true then begin
    panelFinish.visible := false;
    btnNext.caption := '&Next >';
    panelTax.visible := true;
    editTaxName.setfocus;
  end else if panelTax.visible = true then begin
    panelTax.visible := false;
    panelCurrency.visible := true;
    editBankName.setfocus;
  end else if panelCurrency.visible = true then begin
    panelCurrency.visible := false;
    panelCompany.visible := true;
    editCompanyName.setfocus;
    btnBack.enabled := false;
  end;
end;

procedure TfrmGettingStarted.FormShow(Sender: TObject);
begin
  panelCompany.visible := true;
  panelCurrency.visible := false;
  panelFinish.visible := false;
  btnBack.enabled := false;
  btnNext.caption := '&Next >';
  editCompanyName.setfocus;
end;

procedure TfrmGettingStarted.FormCreate(Sender: TObject);
var
  Year, Month, Day: Word;
begin
  tblCompany.DatabaseName := strDatabaseName;
  tblCurrency.DatabaseName := strDatabaseName;
  tblBank.DatabaseName := strDatabaseName;
  tblGLAccnt.DatabaseName := strDatabaseName;
  tblSalesman.DatabaseName := strDatabaseName;
  tblCusType.DatabaseName := strDatabaseName;
  tblTax.DatabaseName := strDatabaseName;
  tblCompany.Active := true;
  tblCurrency.Active := true;
  tblBank.Active := true;
  tblGLAccnt.Active := true;
  tblSalesman.Active := true;
  tblCusType.Active := true;
  tblTax.Active := true;

  tblCompany.Insert;
  tblCompanyCompanyNo.value := 1;
  DecodeDate(Date(), Year, Month, Day);
  tblCompanyFiscalYear.value := Year;
  tblCompanyAPInvPONumbers.value := false;
  tblCompanyAPInvDescriptions.value := false;

  tblCurrency.Insert;
  tblCurrencyCurrencyID.value := 1;
  tblCurrencyCurrencyName.value := 'US Dollars';

  tblBank.Insert;
  tblBankBankID.value := 1;

  tblTax.Insert;
  tblTaxTaxID.value := 1;
end;

procedure TfrmGettingStarted.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

end.

⌨️ 快捷键说明

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