home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
bank
/
banking.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-08-19
|
7KB
|
221 lines
{ ----------------------------------------------------------------------- }
{ Source file: BANKING.PAS }
{ Application: Bank Manager }
{ Version : 1.0 }
{ Created : 08/19/91 }
{ Updates : }
{ }
{ Description: Maintain bank account activity records. Account types }
{ supported are: CHECKING, SAVINGS, CREDIT CARD, LOAN }
{ Notes : }
{ ----------------------------------------------------------------------- }
program Banking;
uses Strings, WinTypes, WinProcs, WinDos, WObjects,
BankAcc, BankTrn;
{$R BANKING.RES}
const
AppName = 'Bank Manager';
AppMenu = 'BANKMENU';
AppIcon = 'BANKICON';
AppAbout = 'ABOUTDLG';
AccFile = 'BANKACC.DTA';
const
sc_About = 103;
cm_NewAcc = 101;
cm_OpenAcc = 102;
cm_DeleteAcc = 103;
cm_ChooseAcc = 201;
cm_Checking = 202;
cm_Savings = 203;
cm_CreditCrd = 204;
cm_Transfer = 205;
cm_AccBalance= 301;
cm_TransRec = 302;
type
TMyApplication =
object( TApplication)
procedure InitMainWindow; virtual;
end;
PMyWindow = ^TMyWindow;
TMyWindow =
object( TMDIWindow)
{ Overridden methods }
constructor Init( ATitle: PChar; AMenu: HMenu);
destructor Done; virtual;
procedure GetWindowClass( var AWndClass: TWndClass); virtual;
procedure SetupWindow; virtual;
procedure WMDestroy( var Msg: TMessage); virtual wm_First + wm_Destroy;
{ New methods }
procedure Sys103( var Msg: TMessage); virtual wm_First + wm_SysCommand;
procedure Menu101( var Msg: TMessage); virtual cm_First + cm_NewAcc;
procedure Menu102( var Msg: TMessage); virtual cm_First + cm_OpenAcc;
procedure Menu103( var Msg: TMessage); virtual cm_First + cm_DeleteAcc;
procedure Menu201( var Msg: TMessage); virtual cm_First + cm_ChooseAcc;
procedure Menu205( var Msg: TMessage); virtual cm_First + cm_Transfer;
procedure Menu301( var Msg: TMessage); virtual cm_First + cm_AccBalance;
procedure Menu302( var Msg: TMessage); virtual cm_First + cm_TransRec;
procedure Menu2( var Msg: TMessage); virtual cm_First + 2;
end;
{--------------------------------------------------}
{ TMyWindow's method implementations: }
{--------------------------------------------------}
{ Overridden methods }
constructor TMyWindow.Init( ATitle: PChar; AMenu: HMenu);
var
DC: HDC;
begin
TMDIWindow.Init( ATitle, AMenu);
DC := GetDC( HWindow);
Attr.X := 0;
Attr.Y := 0;
Attr.H := GetDeviceCaps( DC, VertRes) - 90;
Attr.W := GetDeviceCaps( DC, HorzRes);
ReleaseDC( HWindow, DC);
end;
destructor TMyWindow.Done;
begin
TMDIWindow.Done;
end;
procedure TMyWindow.GetWindowClass(var AWndClass: TWndClass);
begin
TMDIWindow.GetWindowClass( AWndClass);
AWndClass.hIcon := LoadIcon( HInstance, AppIcon);
end;
procedure TMyWindow.SetupWindow;
var
SysMenu: hMenu;
begin
TMDIWindow.SetupWindow;
SysMenu := GetSystemMenu( HWindow, FALSE);
AppendMenu( SysMenu, mf_Separator, 0, Nil);
AppendMenu( SysMenu, mf_String, sc_About, 'A&bout...');
DrawMenuBar( HWindow);
end;
procedure TMyWindow.WMDestroy( var Msg: TMessage);
begin
TMDIWindow.WMDestroy( Msg);
end;
{ NEW methods }
procedure TMyWindow.Sys103( var Msg: TMessage);
begin
if Msg.WParam = sc_About then
Application^.ExecDialog( New( PDialog, Init( @Self, 'ABOUTDLG')))
else
DefWndProc( Msg);
end;
procedure TMyWindow.Menu101( var Msg: TMessage);
begin
Application^.ExecDialog( New( PAcc, Init( @Self, 'NEWACC')));
end;
procedure TMyWindow.Menu102( var Msg: TMessage);
begin
if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
begin
Application^.ExecDialog( New( PAcc, Init( @Self, 'OLDACC')));
end;
end;
procedure TMyWindow.Menu103( var Msg: TMessage);
var
AccF,
TmpF: file of AccRec;
AccR: AccRec;
begin
if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
if MessageBox( HWindow, 'This account will be deleted. Are you sure?',
'Account Manager', mb_IconQuestion or mb_YesNo) = id_Yes then
begin
assign( AccF, AccFile);
reset( AccF);
assign( TmpF, 'BANKACC.DEL');
rewrite( TmpF);
repeat
read( AccF, AccR);
if StrComp( AccR.AccNum, GAccNum) <> 0 then write( TmpF, AccR);
until FilePos( AccF) = FileSize( AccF);
close( AccF);
close( TmpF);
erase( AccF);
rename( TmpF, AccFile);
end;
end;
procedure TMyWindow.Menu201( var Msg: TMessage);
var
Result: integer;
begin
GMulti := FALSE;
Result := Application^.ExecDialog( New( PGetAcc, Init( @Self, 'CHOOSEACC')));
if Result = id_OK then
Application^.ExecDialog( New( PTransact,
Init( @Self, GAccType, GAccNum, GAccType, GMulti)));
end;
procedure TMyWindow.Menu205( var Msg: TMessage);
begin
Application^.ExecDialog( New( PTransfer, Init( @Self, 'TRANSFER')));
end;
procedure TMyWindow.Menu301( var Msg: TMessage);
begin
if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
begin
Application^.ExecDialog( New( PAccBalance, Init( @Self, 'ACCBAL')));
end;
end;
procedure TMyWindow.Menu302( var Msg: TMessage);
begin
if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
begin
Application^.ExecDialog( New( PTransRep, Init( @Self, 'HISTORY', GAccNum, FALSE)));
end;
end;
procedure TMyWindow.Menu2;
begin
TMDIWindow.Done;
end;
{--------------------------------------------------}
{ TMyApplication's method implementations: }
{--------------------------------------------------}
procedure TMyApplication.InitMainWindow;
begin
MainWindow := New( PMyWindow, Init( AppName, LoadMenu( HInstance, AppMenu)));
end;
{--------------------------------------------------}
{ Main program: }
{--------------------------------------------------}
var
MyApp : TMyApplication;
begin
MyApp.Init( AppName);
MyApp.Run;
MyApp.Done;
end.