/*******************************************************
* MYCPLUS Sample Code - http://www.mycplus.com *
* *
* This code is made available as a service to our *
* visitors and is provided strictly for the *
* purpose of illustration. *
* *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<malloc.h>
#include<dos.h>
#include<fstream.h>
#include<stdlib.h>
#include<string.h>
void intro(void);
int main_menu(void);
void new_account(void);
void new_account_gui(void);
int getaccount_no(char *);
void sav_account(int,char*,int,char*,int,int,int,int,int);
void update_main(char *);
void process(void);
void list_all(void);
void print_it(char*);
void list_all_gui(void);
void trans_menu(void);
int trans_gui(void);
void show_trans(void);
void mod_trans(void);
void see_it(void);
void report(void);
void dep_gui(void);
void deposite(void);
void mod_choice(void);
void withdraw(void);
main(){
intro();
process();
return 0;
}
void process(void){
int option;
option=main_menu();
if(option==1)
new_account();
if(option==2)
list_all();
if(option==3)
trans_menu();
if(option==4)
exit(0);
}
void intro(void){
void *image;
int size;
int dr=9,mode=2;
initgraph(&dr,&mode,"..\\bgi");
size=imagesize(140,140,500,250);
image=malloc(size);
setfillstyle(SOLID_FILL,GREEN);
circle(200,200,50);
floodfill(200,200,WHITE);
setcolor(LIGHTGRAY);
circle(200,200,19);
setcolor(WHITE);
circle(200,200,18);
circle(200,200,49);
circle(200,200,53);
circle(200,200,20);
arc(215,215,350,90,30);
arc(210,182,90,194,30);
arc(180,195,180,300,30);
settextstyle(1,HORIZ_DIR,1);
setcolor(LIGHTGRAY);
outtextxy(270,180,"National Bank");
outtextxy(270,185,"___________________");
outtextxy(270,210,"Of Pakistan Pvt Ltd.");
settextstyle(0,HORIZ_DIR,0);
setcolor(DARKGRAY);
outtextxy(270,240,"COPYRIGHT 2002");
getimage(141,141,499,259,image);
cleardevice();
for(int count=1;count<300;count+=2)
putimage(1+count,100,image,COPY_PUT);
for(int down=0;down<640;++down)
{
delay(5);
line(1,220,1+down,220);
}
setcolor(BLUE);
for(int bottom=0;bottom<300;bottom+=4)
line(1,220+bottom,640,220+bottom);
free(image);
getch();
closegraph();
}
// ----------------- m a i n - m e n u ---------------------
int main_menu(void){
int option;
int size;
int dr=9,mode=2;
initgraph(&dr,&mode,"..\\bgi");
void *main_window,*button_down;
size=imagesize(10,70,251,351);
main_window=malloc(size);
size=imagesize(10,310,251,351);
button_down=malloc(size);
setfillstyle(SOLID_FILL,LIGHTGRAY);
setcolor(DARKGRAY);
rectangle(1,1,640,480);
floodfill(3,3,DARKGRAY);
setcolor(WHITE);
line(1,1,1,480);
line(1,1,640,1);
setcolor(BLUE);
rectangle(3,3,637,15);
setfillstyle(SOLID_FILL,BLUE);
floodfill(5,5,BLUE);
setcolor(DARKGRAY);
rectangle(620,4,635,14);
rectangle(602,4,617,14);
rectangle(585,4,599,14);
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(586,6,DARKGRAY);
floodfill(604,6,DARKGRAY);
floodfill(624,6,DARKGRAY);
setcolor(BLACK);
line(622,6,633,12);
line(633,6,622,12);
rectangle(604,6,615,12);
line(587,12,597,12);
setcolor(WHITE);
line(620,4,620,14);
line(620,4,635,4);
line(602,4,617,4);
line(602,4,602,14);
line(584,4,599,4);
line(584,4,584,14);
outtextxy(8,5,"BANKING SYSTEM");
setcolor(WHITE);
line(5,30,635,30);
line(5,60,635,60);
setcolor(DARKGRAY);
line(5,29,635,29);
line(5,59,635,59);
setcolor(DARKGRAY);
outtextxy(40,40,"B A N K I N G S Y S T E M designed for national bank of pakistan");
rectangle(10,70,200,100);
setcolor(WHITE);
line(9,69,9,99);
line(10,69,200,69);
setcolor(BLACK);
outtextxy(30,80,"M A I N M E N U");
setcolor(DARKGRAY);
rectangle(10,110,250,150);
setcolor(BLACK);
rectangle(10,110,251,151);
setcolor(WHITE);
line(10,110,10,150);
line(10,110,250,110);
setcolor(BLACK);
outtextxy(40,130,"1. Create new account");
setcolor(DARKGRAY);
rectangle(10,160,250,200);
setcolor(BLACK);
rectangle(10,160,251,201);
setcolor(WHITE);
line(10,160,10,200);
line(10,160,250,160);
setcolor(BLACK);
outtextxy(40,180,"2. List all accounts");
setcolor(DARKGRAY);
rectangle(10,210,250,250);
setcolor(BLACK);
rectangle(10,210,251,251);
setcolor(WHITE);
line(10,210,10,250);
line(10,210,250,210);
setcolor(BLACK);
outtextxy(40,230,"3. Show individual info");
setcolor(DARKGRAY);
rectangle(10,260,250,300);
setcolor(BLACK);
rectangle(10,260,251,301);
setcolor(WHITE);
line(10,260,10,300);
line(10,260,250,260);
setcolor(BLACK);
outtextxy(40,280,"4. Quit");
setcolor(LIGHTGRAY);
rectangle(10,310,250,350);
getimage(10,70,251,351,main_window);
setcolor(WHITE);
rectangle(10,310,251,351);
setcolor(DARKGRAY);
line(10,310,10,350);
line(11,311,11,350);
line(10,310,250,310);
line(11,311,250,311);
setcolor(BLACK);
getimage(10,310,251,351,button_down);
cleardevice();
setfillstyle(SOLID_FILL,LIGHTGRAY);
setcolor(DARKGRAY);
rectangle(1,1,640,480);
floodfill(3,3,DARKGRAY);
setcolor(WHITE);
line(1,1,1,480);
line(1,1,640,1);
setcolor(BLUE);
rectangle(3,3,637,15);
setfillstyle(SOLID_FILL,BLUE);
floodfill(5,5,BLUE);
setcolor(DARKGRAY);
rectangle(620,4,635,14);
rectangle(602,4,617,14);
rectangle(585,4,599,14);
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(586,6,DARKGRAY);
floodfill(604,6,DARKGRAY);
floodfill(624,6,DARKGRAY);
setcolor(BLACK);
line(622,6,633,12);
line(633,6,622,12);
rectangle(604,6,615,12);
line(587,12,597,12);
setcolor(WHITE);
line(620,4,620,14);
line(620,4,635,4);
line(602,4,617,4);
line(602,4,602,14);
line(584,4,599,4);
line(584,4,584,14);
outtextxy(8,5,"BANKING SYSTEM");
setcolor(WHITE);
line(5,30,635,30);
line(5,60,635,60);
setcolor(DARKGRAY);
line(5,29,635,29);
line(5,59,635,59);
setcolor(DARKGRAY);
outtextxy(40,40,"B A N K I N G S Y S T E M designed for national bank of pakistan");
putimage(10,70,main_window,COPY_PUT);
char check;
setcolor(BLACK);
check=getch();
if(check==49)
{
putimage(10,110,button_down,COPY_PUT);
outtextxy(40,130,"1. Create new account");
option=1;
delay(600);
}
if(check==50)
{
putimage(10,160,button_down,COPY_PUT);
outtextxy(40,180,"2. List all accounts");
option=2;
delay(600);
}
if(check==51)
{
putimage(10,210,button_down,COPY_PUT);
outtextxy(40,230,"3. Show individual info");
option=3;
delay(600);
}
if(check==52)
{
putimage(10,260,button_down,COPY_PUT);
outtextxy(40,280,"4. Quit");
option=4;
delay(600);
}
free(main_window);
free(button_down);
cleardevice();
closegraph();
return(option);
}
void new_account(void){
int withdraw=0;
int deposit=0;
int account_no=888;
int balance=0;
char address[25];
char name[10]={'D','E','F','A','U','L','T'};
struct date dat;
getdate(&dat);
account_no=getaccount_no(name);
int year=dat.da_year;
int day=dat.da_day;
int month=dat.da_mon;
--account_no;
new_account_gui();
gotoxy(20,9);
cout<<account_no;
gotoxy(42,9);
cout<<day<<" of "<<month<<" "<<year;
gotoxy(40,13);
cout<<" ";
cin>>name;
gotoxy(40,17);
cout<<" ";
cin>>balance;
gotoxy(40,21);
cout<<" ";
cin>>address;
sav_account(account_no,name,balance,address,day,month,year,deposit,withdraw);
cleardevice();
closegraph();
process();
}
int getaccount_no(char *name)
{
char string[10];
int count=0;
int account_no=0;
ifstream pfile("main");
if(pfile==NULL)
{
account_no=2;
pfile.close();
ofstream pfile2("main");
pfile2<<name;
pfile2.close();
return account_no;
}
ifstream pfile3("main");
while(string[0]!=NULL)
{
pfile3>>string;
++count;
}
pfile3.close();
account_no=count;
return account_no;
}
void sav_account(int account_no,char *name,int balance,char *address,int day,int month,int year,int deposit,int withdraw){
ofstream pfile(name);
pfile<<account_no