home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Menus, StdCtrls, ExtCtrls, DBCtrls, DB, DBTables, Report;
-
- type
- TfmMain = class(TForm)
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- PrinterSetup1: TMenuItem;
- N1: TMenuItem;
- exit1: TMenuItem;
- View1: TMenuItem;
- StockAnalysis1: TMenuItem;
- N2: TMenuItem;
- CustomerAddress1: TMenuItem;
- CustomerCharts1: TMenuItem;
- Help1: TMenuItem;
- About1: TMenuItem;
- Timer1: TTimer;
- MarketBrowser1: TMenuItem;
- Image1: TImage;
- Bevel1: TBevel;
- Database: TDatabase;
- LabTime: TLabel;
- Bevel2: TBevel;
- PSetup: TPrinterSetupDialog;
- procedure Timer(Sender: TObject);
- procedure exit1Click(Sender: TObject);
- procedure MarketBrowser1Click(Sender: TObject);
- procedure CustomerCharts1Click(Sender: TObject);
- procedure CustomerAddress1Click(Sender: TObject);
- procedure StockAnalysis1Click(Sender: TObject);
- procedure PrinterSetup1Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- DBPath: String[127];
- procedure UpdateRSConnect;
- procedure InitRSRUN;
- public
- function DataPath: string;
- end;
-
- var
- fmMain: TfmMain;
-
- implementation
-
- {$R *.DFM}
-
- uses Browser, CstChart, CustInfo, IndChart, About, IniFiles;
-
- procedure TfmMain.UpdateRSConnect;
- const
- TiniFilename = 'RPTSMITH.CON'; { ReportSmith connections file }
- AppConTitle = 'STOCKS';
- ConnectNamesSection = 'ConnectNamesSection';
- ConnectNamesKey = 'ConnectNames';
- StocksSection = 'STOCKS';
- TypeKey = 'Type';
- ServerKey = 'Server';
- TypeVal = 62;
- ServerVal = 'DBASE'; { databases in this application are DBFs }
- DataFilePathKey = 'DataFilePath';
- var
- TempStr,
- ConFile: string[127];
- RSCON: TIniFile;
- begin
- { the ReportSmith CON file is actually an INI file -- assumes in win dir}
- RSCon := TIniFile.Create(TiniFilename);
- TempStr := RSCon.ReadString(ConnectNamesSection, ConnectNamesKey, '');
- if Pos(AppConTitle,TempStr) = 0 then
- begin
- if TempStr <> '' then
- TempStr := TempStr + ',';
- RSCon.WriteString(ConnectNamesSection, ConnectNamesKey, TempStr+AppConTitle);
- end;
- RSCon.WriteInteger(StocksSection, TypeKey, TypeVal);
- RSCon.WriteString(StocksSection, DataFilePathKey, DBpath);
- RSCon.WriteString(StocksSection, ServerKey, ServerVal);
- RSCon.Free;
- end;
-
- procedure TfmMain.InitRSRUN;
- var
- ParamList: TStringList;
- begin
- { get the actual location of the database from the alias or database,
- the path is needed for the reports -- assumes alias is defined }
- ParamList := TStringList.Create;
- try
- Session.GetAliasParams(Database.AliasName, ParamList);
- DBPath := ParamList.Values['PATH'];
- finally
- ParamList.Free;
- end;
- { set up the ReportSmith "connection" identifying the database location }
- UpdateRSConnect;
- end;
-
- procedure TfmMain.FormCreate(Sender: TObject);
- begin
- InitRSRUN;
- end;
-
- procedure TfmMain.Timer(Sender: TObject);
- begin
- LabTime.Caption := DateTimeToStr(Now);
- end;
-
- procedure TfmMain.exit1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TfmMain.MarketBrowser1Click(Sender: TObject);
- begin
- fmMktBrowser.ShowBrowser;
- end;
-
- procedure TfmMain.CustomerCharts1Click(Sender: TObject);
- begin
- fmCustChart.ShowCharts
- end;
-
- procedure TfmMain.CustomerAddress1Click(Sender: TObject);
- begin
- fmCustInfo.Show;
- end;
-
- procedure TfmMain.StockAnalysis1Click(Sender: TObject);
- begin
- fmIndustChart.ShowCharts;
- end;
-
- procedure TfmMain.PrinterSetup1Click(Sender: TObject);
- begin
- PSetup.Execute;
- end;
-
- procedure TfmMain.About1Click(Sender: TObject);
- begin
- fmAboutBox.ShowModal;
- end;
-
- function TfmMain.DataPath: string;
- begin
- DataPath := DBPath;
- end;
-
- end.
-