//DEVELOPED BY AAKASH DEV AND TANMAY VIJAYVARGIYA

//SPECIAL THANKS TO RISHABH PANDEY
//**********************************************************************
//*****************************HEADER FILES******************************
//**********************************************************************
#include <graphics.h>
#include <dos.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <alloc.h>
#include <iomanip.h>

//**********************************************************************
//*****************************GLOBAL VARIABLES ************************
//**********************************************************************
fstream f1,f2,b1,b2;
int choice;

//**********************************************************************
//*****************************CLASS & OBJECTS***************************
//**********************************************************************
class shape
{
void line_hor(int, int, int, char) ;
void line_ver(int, int, int, char) ;
void box(int,int,int,int,char) ;
}s;

void shape :: line_hor(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}

void shape :: line_ver(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}

void shape :: box(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout <<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;

column2-- ;
line_hor(column1,column2,row1,l1) ;
line_hor(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
line_ver(row1,row2,column1,l2) ;
line_ver(row1,row2,column2,l2) ;
}
class accounts // class for bank accounts.
{
char Name[25];
char VerName[25];
int accno;
int pin;
long int balance;
public:
void defaultBank();
void create(int,int);
void view(int);
int returnAccno()
{return accno;}
int returnPin()
{return pin;}
char* returnName()
{return Name;}
long int returnBal()
{return balance;}
int balDeduct(int);
void balPlus(int);
void set(int n)

{accno=n;}
};
void accounts::defaultBank()
{
b1.open("BankAccounts.dat",ios::in);
b1.seekg(0,ios::end);
int q= b1.tellg()/sizeof(accounts);
b1.close();
if(q==0)
{
b1.open("BankAccounts.dat",ios::app);
accounts ac;
ac.accno=1;
strcpy(ac.Name,"Admintrator Aakash");
strcpy(ac.VerName,"Tanmay");
ac.pin=1111;
ac.balance=0;
b1.write((char*)&ac,sizeof(accounts));
b1.close();
}
}
void accounts::create(int x,int y)
{
gotoxy(5,23);
cprintf("Enter Name of Account Holder.");
againName:
gotoxy(x,y);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(x,y);
cprintf("Name: ");

gets(Name);
if(strlen(Name)==0||strlen(Name)>25)
{
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Name should not b BLANK or greater than 25 characters. ");
goto againName;
}
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Enter the Name of the Verifier.");
againVerName:
gotoxy(x,y+1);
cprintf("Verifier Name: ");
gets(VerName);
if(strlen(VerName)==0||strlen(VerName)>25)
{
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Verifier Name should not b BLANK or greater than 25 characters. ");
goto againVerName;
}
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Enter Pin. ");

againPin:
gotoxy(x,y+2);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(x,y+2);
cprintf("pin: ");
cin>>pin;
if(pin>10000||pin<999)
{
gotoxy(5,23);
cprintf("Pin Should be a 4 digit Number.");
goto againPin;
}
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Enter Balance.");
againBal:
gotoxy(x,y+3);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(x,y+3);
cprintf("Balance: ");
cin>>balance;
if(balance<499)
{
gotoxy(5,23);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,23);
cprintf("Balance Should Be greater than equal to 500.");
goto againBal;

}
}
void accounts::view(int y)
{
gotoxy(5,y);
cout<<accno<<setw(36)<<Name<<setw(30)<<balance;
}
int accounts::balDeduct(int price)
{
if(balance<price)
return 0;
else
balance-=price;
return 1;
}
void accounts::balPlus(int price)
{
balance+=price;
}
class transactions //class for transactions in Banking
{
int acno;
int amount;
long int lastBal;
public:
int dd;
int mm;
int yy;
char type;
void getInfo(int acno,char type,int amount,long int last);

void orderTrans(int y);
int returnNo()
{return acno;};
}tra;
void transactions::getInfo(int accno,char Type,int Amount,long int last)
{
struct date d;
getdate(&d);
dd = d.da_day ;
mm = d.da_mon ;
yy = d.da_year ;
acno=accno;
type=Type;
amount=Amount;
lastBal=last;
};
void transactions::orderTrans(int y)
{
gotoxy(3,y);
cout<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(30,y);
cout<<type;
gotoxy(50,y);
cout<<amount;
gotoxy(70,y);
cout<<lastBal;
};
//class for books in Book Shop
class book
{
char name[30];

char authorName[30];
int publishedYear;
char details[3][20];
char category[20];
int bookCode;
int price;
public:
void defaultBooks();
void createBook();
void modify();
void readBook();
int returnBookCode()
{return bookCode;}
char* returnBookName()
{return name;}
char* returnBookCategory()
{return category;}
int returnBookPrice()
{return price;}
void order1(int x,int y)
{
gotoxy(x+9,y);
cout<<bookCode;
gotoxy(x+28,y);

puts(name);
gotoxy(x+51,y);
puts(authorName);
}
void order2(int x,int y)
{
gotoxy(x+9,y);
cout<<bookCode;
gotoxy(x+28,y);
puts(name);
gotoxy(x+51,y);
cout<<price;
}
void setBook(int n)
{bookCode=n;}
};
void book::defaultBooks()
{
f1.open("ABSbooks.dat",ios::in);
f1.seekg(0,ios::end);
int q=f1.tellg()/sizeof(book);
f1.close();
if(q==0)
{
f1.open("ABSbooks.dat",ios::app|ios::out);
book b;
strcpy(b.name,"WHAT YOUNG INDIA WANTS");
strcpy(b.authorName,"CHETAN BHAGAT");
b.publishedYear=2012;
strcpy(b.category,"NON FICTION");
strcpy(b.details[0],"No details availbale");

b.bookCode=1;
b.price=140;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"PROOF OF HEAVEN");
strcpy(b.authorName,"EBEN ALEXANDER");
b.publishedYear=2012;
strcpy(b.category,"RELIGION");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=2;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"STEVE JOBS");
strcpy(b.authorName,"WALTER ISAACSON");
b.publishedYear=2011;
strcpy(b.category,"BIOGRAPHY");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=3;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"THE SECRET");
strcpy(b.authorName,"RHONDA BYRNE");
b.publishedYear=2006;
strcpy(b.category,"LIFESTYLE");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=4;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"THE DAVINCI CODE");
strcpy(b.authorName,"DAN BROWN");
b.publishedYear=2006;

strcpy(b.category,"SUSPENSE");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=5;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"A WALK TO REMEMBER");
strcpy(b.authorName,"NICHOLAS SPARKS");
b.publishedYear=2002;
strcpy(b.category,"ROMANCE");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=6;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"HARRY POTTER SERIES");
strcpy(b.authorName,"J.K. ROWLING");
b.publishedYear=1997;
strcpy(b.category,"FANTASY");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=7;
b.price=2500;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"DIARY OF A YOUNG GIRL");
strcpy(b.authorName,"ANNE FRANK");
b.publishedYear=1993;
strcpy(b.category,"HISTORY");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=8;
b.price=150;
f1.write((char*)&b,sizeof(book));

strcpy(b.name,"THE ALCHEMIST");
strcpy(b.authorName,"PAULO COELHO");
b.publishedYear=1988;
strcpy(b.category,"PHILOSOPHY");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=9;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"FAHRENHEIT 451");
strcpy(b.authorName,"RAY BRADBURY");
b.publishedYear=1951;
strcpy(b.category,"SCIENCE FICTION");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=10;
b.price=150;
f1.write((char*)&b,sizeof(book));
strcpy(b.name,"THE THREE MUSKETEERS");
strcpy(b.authorName,"ALEXANDRE DUMAS");
b.publishedYear=1846;
strcpy(b.category,"CLASSICS");
strcpy(b.details[0],"No Extra Details.");
b.details[1][0]='\0';
b.bookCode=11;
b.price=150;
f1.write((char*)&b,sizeof(book));
f1.close();
}
}
int returnCode(); // function Declartion
void book::createBook()
{

s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Add New Book.") ;
textcolor(WHITE);
textbackground(0);
gotoxy(5,6);
bookCode=returnCode();
cprintf("Book Code: ");
cout<<bookCode;
gotoxy(5,8);
cprintf("Book Name: ");
gets(name);
strcpy(name,strupr(name));
gotoxy(5,9);
cprintf("Author Name: ");
gets(authorName);
strcpy(authorName,strupr(authorName));
gotoxy(5,10);
cprintf("Published Year: ");
cin>>publishedYear;
i=-1;
int f;
do
{
f=1;
gotoxy(5,12);

clreol();
cprintf("Category:");
gotoxy(5,13);
clreol();
s.box(2,2,79,24,218) ;
gotoxy(5,13);
cprintf("(FICTION,NON FICTION,ROMANCE,SUSPENCE
THRILLER,COMEDY,OTHER) :");
gets(category);
strcpy(category,strupr(category));
if(!categoryGood(category))
{
gotoxy(5,15);
cprintf("Category Not Known");
f=0;
}
else
{
gotoxy(5,15);
s.box(2,2,79,24,218) ;
clreol();
}
}while(f!=1);
gotoxy(5,15);
cprintf("Details: ");
do
{
i++;
gotoxy(15,15+i);
gets(details[i]);
}while(details[i][0]);
gotoxy(5,16+i);
cprintf("Price: ");

cin>>price;
gotoxy(5,23);
cprintf("Book Added to Library.");
};

void book::modify()
{
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Add New Book.") ;
textcolor(WHITE);
textbackground(0);
gotoxy(5,4);
//cout<<"Modify Book --->";
gotoxy(5,5);
cprintf("New Book Name: ");
gets(name);
strcpy(name,strupr(name));
gotoxy(5,7);
cprintf("New Author Name: ");
gets(authorName);
strcpy(authorName,strupr(authorName));
gotoxy(5,8);

cprintf("New Published Year: ");
cin>>publishedYear;
i=-1;
int f;
do
{
f=1;
gotoxy(5,9);
clreol();
cprintf("New Category:");
gotoxy(5,10);
cprintf("(FICTION,NON FICTION,ROMANCE,SUSPENCE");
cprintf("THRILLER,COMEDY,OTHER) :");
gets(category);
strcpy(category,strupr(category));
if(!categoryGood(category))
{
gotoxy(5,12);
cprintf("Category Not Known");
f=0;
}
else
{
gotoxy(5,12);
clreol();
}
}while(f!=1);
gotoxy(5,12);
cprintf("Details: ");
do
{
i++;
gotoxy(15,12+i);

gets(details[i]);
}while(details[i][0]);
gotoxy(5,13+i);
cprintf("New Price: ");
cin>>price;
gotoxy(5,15+i);
cprintf("Book Code: ");
cout<<bookCode;
};
void book::readBook()
{
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("READ BOOK") ;
textcolor(WHITE);
textbackground(0);
gotoxy(5,5);
cprintf("Book Code: ");
cout<<bookCode;
gotoxy(5,7);
cout<<name;
gotoxy(5,8);
cprintf("is an awesome book of Category ");

cout<<category;cprintf(" written by "); puts(authorName);
gotoxy(5,9);
cprintf("This book was published in ");cout<<publishedYear;
gotoxy(5,11);
cprintf("This book is available at Apni Book Shop for Rs ");cout<<price<<".";
gotoxy(5,12);
cprintf("Extra Details: ");
i=-1;
do
{
i++;
//cout<<setw(15)<<'\t'<<details[i];
gotoxy(5,12+i);
cout<<details[i];
}while(details[i][0]);
gotoxy(5,14+i);
cprintf("Hurry!!...");
gotoxy(5,23);
textcolor(YELLOW+BLINK);
cprintf("Press Any Key To Proceed.");
textcolor(15);
};
//class for administrator in Book Shop
class adminAccount
{
char password[20];
char secretQuestion[50];
char secretAnswer[50];
public:
void adminCreate();

void adminForgot();
int adminPassCheck(char p[15]);
};

void adminAccount::adminCreate()
{
char passConf[20];
again:
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Admin Account Setup");
textcolor(WHITE);
textbackground(0);

gotoxy(5,6);
cprintf("Password:: ");
strcpy(password,getpass(16,6));
gotoxy(5,8);
cprintf("Conf Password:: ");
strcpy(passConf,getpass(21,8));
if(strcmp(password,passConf)!=0)
{

gotoxy(5,23);
cprintf("PASSWORD DO NOT MATCH..!");
getch();
//gotoxy(3,10);
//system("pause");
goto again;
}
gotoxy(5,9);
cprintf("Enter a Security Question..");
gotoxy(5,15);
cprintf("This Ques will help you to retrieve your password in case you");
cprintf("forgot your");
gotoxy(5,16);
cprintf("password. ");
gets(secretQuestion);
strcpy(secretQuestion,strupr(secretQuestion));
gotoxy(5,18);
cprintf("ANSWER: ");
gets(secretAnswer);
strcpy(secretAnswer,strupr(secretAnswer));
gotoxy(5,23);
cprintf("You Have Successfully Created Admin Account!!");
gotoxy(10,16);
getch();
//system(");
}
adminAccount ad;
void adminAccount::adminForgot()
{
int i=0;
char ans[50];

char passConf[20];
again:
clrscr();
if(i==2)
{
gotoxy(10,3);
cout<<"<LAST CHANCE>";
}
gotoxy(10,5);
cout<<"Q: "<<secretQuestion<<" ?";
gotoxy(2,7);
cout<<"Answer: ";
gets(ans);
strcpy(ans,strupr(ans));
if(strcmp(ans,secretAnswer))
{
i++;
if(i==3)
exit(0);
gotoxy(2,8);
cout<<"<<<< INVALID ANSWER >>>>";
delay(100);
goto again;
}
else
{
remove("ABSadminAccount.dat");
cprintf("Password Has Been Removed.");
}
};

int adminAccount::adminPassCheck(char p[15])
{
int result=0;
if(strcmp(p,password)==0)
result=1;
return result;
};
//CLASS OBJECTS
accounts ac,ac1,ac2;
book b;
adminAccount ad;
transactions tra;

//***********************************************************************
//***************************FUNCTION DECLARATIONS**********************
//***********************************************************************
void gra1(); //WELCOME SCREEN
void gra2(); //TITLE SCREEN
void gra3(); //"TRANSACTION BEING PROCESSED" SCREEN
void gra4(); //"REDIRECTING TO BANK" SCREEN
void gra5(); //"TRANSACTION SUCCESSFUL" SCREEN
void gra6(); //"TRANSACTION FAILED" SCREEN
void gra7(); //"BOOK PURCHASE SUCCESSFUL" SCREEN
void gra8(); //"BOOK PURCHASE FAILED" SCREEN
void credits(); //FUNCTION TO DISPLAY CREDITS
void box(int,int); //To DRAW 3D BOX
void selected(int); //To DRAW A SELECTED BOX
void toggle(int,int); //TOGGLE b/w OPTIONS (BANKING MENU)
void toggle1(int,int); //TOGGLE b/w OPTIONS (CUSTIOMER MENU)
int getChoice(int,int,int); //TO GET CHOICE FROM USER
void createAdmin(); //TO CREATE ADMIN ACCOUNT
void adminLogin(); //ADMIN PASSWORD VERIFICATION
book search1(int n); //SEARCH A BOOK AND RETURN VIA ITS CODE
void writeBook(); //ADD A BOOK TO THE STORE
void todaySalesWrite(); //TO WRITE TODAY SALES
void custoOptions(book); //DISPLAY CUSTOMER OPTIONS
void deleteBook(int); //DELETE A BOOK
void modifyBook(int); //MODIFY A BOOK
void adminOptions(book); //DISPLAY ADMIN OPTIONS
void read1book(int); //DISPLAY SINGLE BOOK
void readBookCategory(int); //READ BOOK VIA CATEGORY
void readAllBook(); //READ ALL BOOK
void readBookName(); //READ BOOK VIA NAME
void myCart(); //DISPLAY BOOK IN CUSTOMER'S CART
void readTodaySales(); //READ TODAT SALES
void factoryReset(); //DELETE .DAT FILES USED IN BOOK SHOP

void adminRocket(); //CONNECT TO ADMIN ROCKET ACCOUNT
int adminMenu(); //DISPLAY ADMIN MENU
int customer(); //DISPLAY CUSTOMER
int userSelect(); //CUSTOMER/ADMIN SELECT MENU
int main_menu(); //BANKING MAIN MENU
char MainMenu(); // BANK/BOOK SHOP SELECT MENU
void writeTrans(int,char,int,long int); //WRITE TRANSACTIONS
void readTrans(int); //READ TRANSACTION
accounts search(int); //SEARCH BANK ACCOUNT
int TransferToAdmin(int); //TRANSFER MONEY TO ADMIN ACCOUNT
int updateBal(int,long int); //UPDATE BALANCE IN ACCOUNT(WITHDRAW/DEPOSIT)
void withdraw(); //WITHDRAW MONEY
void addBal(); //DEPOSIT
void BAL(); //WITHDRAW/DEPOSIT MENU
int balTransfer(int,int,int); //TRANSFER BAL FROM ONE ACCOUNT TO ANOTHER
void write(); //WRITE AN ACCOUNT
void displayBox(); //DRAW BOX
void displayAllAccounts(); //DISPLAY ALL ACCOUNTS IN BANK
void displayAccount(); //DISPLAY 1 ACCOUNT
void Transfer(); // DISPLAY TRANSACTION SCREEN

//***********************************************************************
//***************************MAIN FUNCTION******************************
//***********************************************************************
void main()
{
char check;
int recheck;
clrscr();
ac.defaultBank();
b.defaultBooks();
gra1();
gra2();
do
{
check=MainMenu();
if(toupper(check)=='R')
recheck=main_menu();
else
if(toupper(check)=='A')
recheck=userSelect();
}while(recheck==2);
}

//***********************************************************************
//********************FUNCTION DEFINATIONS ******************************
//***********************************************************************
void writeTrans(int accno,char Type,int Amount,long int last)
{
fstream t;
t.open("transaction.dat",ios::app);
tra.getInfo(accno,Type,Amount,last);
t.write((char*)&tra,sizeof(transactions));
t.close();
};
void readTrans(int accno)
{
fstream t;
int i=0;
t.open("transaction.dat",ios::in);
if(t)
{
while(t.read((char*)&tra,sizeof(transactions)))
{
if(accno==tra.returnNo())
{
tra.orderTrans(7+i);
i++;
}
}
if(i==0)
{
gotoxy(3,8);
cprintf("No transactions");
}

}
else
{
gotoxy(3,8);
cprintf("No Transactions.");
}
t.close();
}
accounts search(int a)
{
int found=0;
b1.open("BankAccounts.dat",ios::in);
if(!b1)
{
clrscr();
cout<<"search error occures....";
getch();
}
else
{
while((b1.read((char*)&ac,sizeof(accounts)))&&found==0)
{
if(ac.returnAccno()==a)
{
found=1;
b1.close();
return ac;
}
}
}
ac.set(0);
b1.close();

return ac;
}
int TransferToAdmin(int amnt)
{
int x=0;
int balTransfer(int,int,int);
clrscr();
int sender,PIN;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Transaction Screen") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,6);
cprintf("Sender's Account No.: ");
cin>>sender;
gotoxy(3,7);
cprintf("Senders's Pin: ");
cin>>PIN;
if(PIN==search(sender).returnPin())
{
gotoxy(3,9);
cprintf("Amount to be Transferred ");
cout<<amnt;
gotoxy(3,11);

cprintf("Transfering Money To Aakash(ADMIN)");
gotoxy(3,13);
cprintf("Transfer Amount..(y/n) ");
char ch=getch();
if(tolower(ch)=='y')
{
gra3();
if(balTransfer(sender,1,amnt))
{
x=1;
gra5();
}
else
gra6();
}
else
{
gotoxy(5,23);
cprintf("Transaction Cancelled.");
}
}
else
{
gotoxy(5,23);
cprintf("Incorrect Pin");
}
return x;
}
int updateBal(int no,long int bal)
{

int x;
b1.open("BankAccounts.dat",ios::in|ios::beg);
b2.open("tempo.dat",ios::app);
while(b1.read((char*)&ac,sizeof(accounts)))
{
if(ac.returnAccno()==no)
x=ac.balDeduct(bal);
b2.write((char*)&ac,sizeof(accounts));
}

b1.close();
b2.close();
remove("BankAccounts.dat");
rename("tempo.dat","BankAccounts.dat");
return x;
}
void withdraw()
{
clrscr();
int no,PIN;
long int bal;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Withdraw Money") ;

textcolor(WHITE);
textbackground(0);
gotoxy(3,7);
cprintf("Account No: ");
cin>>no;
ac=search(no);
if(ac.returnAccno())
{
gotoxy(3,9);
cprintf("Pin: ");
cin>>PIN;
if(ac.returnPin()==PIN)
{
gotoxy(3,10);
cprintf("Welcome ");
cout<<ac.returnName();
gotoxy(3,11);
cprintf("Amount to be Withdrawn: ");
cin>>bal;
long int lastBal=ac.returnBal();
if(updateBal(no,bal))
{
gotoxy(5,23);
cprintf("Money Withdrawn Successfully");
writeTrans(no,'W',bal,lastBal);
}
else
{
gotoxy(3,23);
cprintf("Not Enough Money In Your Account");
}
}
else

{
gotoxy(3,11);
cprintf("Wrong Pin.");
}
}
else
{
gotoxy(3,9);
cprintf("No account found.");
}
getch();
}
void addBal()
{
clrscr();
int no,PIN;
long int bal;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Add Money") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,7);
cprintf("Account No: ");
cin>>no;

ac=search(no);
if(ac.returnAccno())
{
gotoxy(3,9);
cprintf("Pin: ");
cin>>PIN;
if(ac.returnPin()==PIN)
{
gotoxy(3,10);
cprintf("Welcome ");
cout<<ac.returnName();
gotoxy(3,11);
long int lastBal=ac.returnBal();
cprintf("Amount to be Added: ");
cin>>bal;
bal*=-1;
if(updateBal(no,bal))
{
gotoxy(5,23);
cprintf("Money Added Successfully");
bal*=-1;
writeTrans(no,'D',bal,lastBal);
}
else
{
gotoxy(3,23);
cprintf("Error Occured while money transfer");
}
}
else
{
gotoxy(3,11);

cprintf("Wrong Pin.");
}
}
else
{
gotoxy(3,9);
cprintf("No account found.");
}
getch();
}
void BAL()
{
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Balance Update") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,8);
cprintf("(W)Withdraw..");
gotoxy(3,10);
cprintf("(D)Deposit..");
char ch;
int tru=1;
do
{

ch=getch();
ch=toupper(ch);
tru=1;
switch(ch)
{
case 'W':

withdraw();

break;
case 'D':

addBal();

break;
default: tru=0;
}
}while(tru==0);
}
int balTransfer(int a1,int a2,int price)
{
if(search(a1).returnAccno()&&search(a2).returnAccno()&&a1!=a2)
{
b1.open("BankAccounts.dat",ios::in);
remove("tempo.dat");
b2.open("tempo.dat",ios::app);
if(b1)
{
while(b1.read((char*)&ac,sizeof(accounts)))
{
if(ac.returnAccno()==a1)
ac.balDeduct(price);
else
if(ac.returnAccno()==a2)
ac.balPlus(price);
b2.write((char*)&ac,sizeof(accounts));
}

b1.close();
b2.close();
remove("BankAccounts.dat");
rename("tempo.dat","BankAccounts.dat");
return 1;
}
b1.close();
b2.close();
return 0;
}

b1.close();
return 0;
}

void write()
{
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Open New Account") ;
textcolor(WHITE);
textbackground(0);

b1.open("BankAccounts.dat",ios::in);
b1.seekg(0,ios::end);
int q= (b1.tellg()/sizeof(accounts)) + 2;
b1.close();
b1.open("BankAccounts.dat",ios::app);
if(b1)
{
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(3,7) ;
cout <<"Date : "<<d1<<"/" <<m1 <<"/" <<y1 ;
ac.set(q);
gotoxy(3,10);
cprintf("Account #");
cout<<q;
ac.create(3,13);
gotoxy(3,18);
cprintf("Create Account ?...(y/n)");
char ch;
ch=getch();
if(tolower(ch)=='y')
{
if(b1.write((char*)&ac,sizeof(accounts)))
{
gotoxy(3,20);
cprintf("Congratulations,");
gotoxy(3,21);
cprintf("You Have Successfully Became A member of Rocket ");
cprintf("National Bank.");

gotoxy(5,23);
cprintf("Press Any Key To Go Back.");
}
}
else
{
gotoxy(3,20);
cprintf("Account Not Created.");
gotoxy(5,23);
cprintf("Press Any Key To Go Back.");
}
}
b1.close();
getch();
}
void displayBox()
{
s.box(2,1,79,25,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,6,196) ;
s.line_hor(3,78,23,196) ;
textcolor(YELLOW);
gotoxy(30,2);
cprintf("ROCKET NATIONAL BANK");
gotoxy(30,3);
cprintf("====================");
textbackground(WHITE) ;
gotoxy(3,5) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(4,5) ;
cprintf("Account#

Account Holder

Current Balnce ") ;

textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
}
void displayAllAccounts()
{
clrscr();
int flagVar=0;
b1.open("BankAccounts.dat",ios::in|ios::beg);
if(b1)
{
displayBox();
while(1)
{
b1.read((char*)&ac,sizeof(accounts));
if(b1.eof())
break;
flagVar++;
ac.view(6+flagVar);
}
if(flagVar==0)
{
gotoxy(3,7);
cprintf("No Account Found.");
}
else
{
gotoxy(5,24);
cout<<flagVar;
textcolor(WHITE);
cprintf(" Record(s) found.");
}
}

else
{
cprintf("An Error Occured while connecting to file.");
}
b1.close();
getch();
}
void displayAccount()
{
clrscr();
int no,PIN;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Display Account") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,7);
cprintf("Account No: ");
cin>>no;
ac=search(no);
if(ac.returnAccno())
{
gotoxy(3,9);
cprintf("Pin: ");
cin>>PIN;

if(ac.returnPin()==PIN)
{
clrscr();
s.box(2,1,79,25,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,6,196) ;
s.line_hor(3,78,23,196) ;
textcolor(YELLOW);
textbackground(WHITE) ;
gotoxy(3,5) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(3,5) ;
cprintf("Date of Trans
cprintf("Balance") ;

Type

Amount

textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(3,2);
cout<<"Account #";
cout<<ac.returnAccno();
gotoxy(3,3);
cout<<ac.returnName();
gotoxy(50,3);
cprintf("Current Balance :: ");
cout<<ac.returnBal();
readTrans(ac.returnAccno());
}
else
{
gotoxy(3,11);
cprintf("Wrong Pin.");
}

Last ";

}
else
{
gotoxy(3,9);
cprintf("No account found.");
}
getch();
}
void Transfer()
{
clrscr();
int sender,reciver,amnt,PIN;
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Transaction Screen") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,6);
cprintf("Sender's Account No.: ");
cin>>sender;
if(search(sender).returnAccno())
{
gotoxy(3,7);
cprintf("Senders's Pin: ");
cin>>PIN;
if(PIN==search(sender).returnPin())

{
gotoxy(3,9);
cprintf("Reciver's Account No: ");
cin>>reciver;
gotoxy(3,11);
cprintf("Amount to be Transferred");
cin>>amnt;
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Transaction Screen") ;
textcolor(WHITE);
textbackground(0);
gotoxy(3,6);
cprintf("Sender :: ");
puts(search(sender).returnName());
gotoxy(3,7);
cprintf("PIN :: ****");
gotoxy(3,9);
cprintf("Reciver :: ");
puts(search(reciver).returnName());
gotoxy(3,11);
cprintf("Amount :: ");
cout<<amnt;
gotoxy(3,13);

cprintf("Transfer Amount..(y/n) ");
char ch=getch();
if(tolower(ch)=='y')
{
gra3();
if(balTransfer(sender,reciver,amnt))
gra5();
else
gra6();
}
else
{
gotoxy(5,23);
cprintf("Transaction Cancelled.");
}
}
else
{
gotoxy(5,23);
cprintf("Incorrect Pin");
}
}
else
{
gotoxy(5,23);
cprintf("Account Not Found");
getch();
}
}

char MainMenu()
{

clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(4,0,6);
setfillstyle(10,8);
floodfill(1,1,10);
setcolor(14);
outtextxy(150,50,"MAIN MENU");
settextstyle(5,0,4);
setcolor(3);
outtextxy(140,170,"(R) Rocket National Bank");
outtextxy(140,220,"(A) Apni Book Shop");
char ch;
int tru=1;
do
{
tru=1;
ch=getch();
ch=toupper(ch);
switch(ch)
{
case 'R': break;
case 'A': break;
default: tru=0;
}
}while(tru==0);
closegraph();
return ch;
}
void gra1()
{

clrscr();
char msg[33];
int gdriver=DETECT,gmode,errorcode,c1x,c2x,c3x,c4x,c5x,c6x;
initgraph(&gdriver,&gmode,"");
line(50,50,55,80);
line(50,50,45,80);
line(45,160 ,40,175 );
line(55,160 ,60,175 );
line(40,175 ,60,175 );
line(45,178 ,45,200 );
line(50,185 ,50,210 );
line(55,178 ,55,200 );
line(45,178 ,30,200 );
line(55,178 ,70,200 );
setfillstyle(1,6);
int p[8];
p[0]=50;
p[1]=50;
p[2]=45;
p[3]=80;
p[4]=55;
p[5]=80 ;
//p[6]=
fillpoly(3,p);
p[0]=45;
p[1]=80;
p[2]=45;
p[3]=160;
p[4]=55;
p[5]=160;
p[6]=55;
p[7]=80;
setfillstyle(9,4);

fillpoly(4,p);
//

rectangle(30,50,70,210);

int size=imagesize(30,50,70,210);
void far *rocket;
rocket = farmalloc(size);
getimage(30,50,70,210,rocket);
cleardevice();
putimage(10,351,rocket,COPY_PUT);
putimage(580,351,rocket,COPY_PUT);
settextjustify(1,1);
settextstyle(10,0,7);
setcolor(15);
int j=0;
outtextxy(150+j,200,"W");
outtextxy(230+j,200,"E");
outtextxy(290+j,200,"L");
outtextxy(350+j,200,"C");
outtextxy(410+j,200,"O");
outtextxy(470+j,200,"M");
outtextxy(530+j,200,"E");
setcolor(15);
line (320-150,320-13,320+150,320-13);
line (320-150,320+12,320+150,320+12);
line (320-150,320-13,320-150,320+12);
line (320+150,320+12,320+150,320-13);
int s=10,w;
gotoxy(20,23);
cout<<"LOADING . . .";
for (int x1=171,x2=171,y1=308,y2=331,y=1,S=0;x1<470;x1++,x2++,y++,S++)
{
setcolor(4);

line (x1,y1,x2,y2);
w=(x1-169)/3;
for (int i=34; i<=37; i++)
{
gotoxy(i,23) ;
cout <<" " ;
}
gotoxy(34,23); cout<<w<<"%";
if (x2>270) s=8; if (x2>370) s=5;
if (x2==320) delay(100); else
delay(s);
}
delay(800);
for (int i=27; i<=37; i++)
{
gotoxy(i,23) ;
cout <<" " ;
}
gotoxy(28,23);
cout<<"COMPLETE";
setcolor(0);
int k=0;
do
{
p[0]=0;
p[1]=450-k;
p[2]=0;
p[3]=600;
p[4]=700;
p[5]=600;
p[6]=700;
p[7]=450-k;

setfillstyle(1,0);
fillpoly(4,p);
putimage(10,345-k,rocket,COPY_PUT);
putimage(580,345-k,rocket,COPY_PUT);
k+=10;
delay(20);
}while(k<450);
cleardevice();
closegraph();
}
void gra2()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
setcolor(8);
ellipse(320,240,0,360,300,150);
settextstyle(10,0,4);
settextjustify(1,1);
setcolor(5);
outtextxy(320,170,"Rocket Corporation");
delay(250);
settextstyle(4,0,4);
setcolor(20);
outtextxy(320,220,"Presented by");
delay(250);
outtextxy(320,315,"C.J.C.S");
settextstyle(10,0,4);
setcolor(3);
delay(250);

outtextxy(320,265,"Aakash & Tanmay");
if(kbhit())
getch();
for (int stangle=0;!kbhit();stangle++)
{
setcolor(7);
ellipse(320,240,stangle,stangle+20,300,150);
ellipse(320,240,stangle+180,stangle+200,300,150);
delay(9);
setcolor(8);
ellipse(320,240,stangle-1,stangle+19,300,150);
ellipse(320,240,stangle-1+180,stangle+199,300,150);
}
getch();
closegraph();
}
void gra3()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
setfillstyle(5,RED);
floodfill(1,1,RED);
settextstyle(3,0,4);
setcolor(YELLOW);
outtextxy(225,150,"Please Wait....");
outtextxy(100,300,"Transaction is Being Proceeded...");
int i=0;
do
{
setcolor(11);
circle(315,250,30);

setcolor(YELLOW);
arc(315,250,0+i,90+i,30);
setcolor(11);
arc(315,250,90+i,0+i,30);
i+=10;
delay(10);
}while(i!=2500);
closegraph();
}
void gra4()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(3,0,4);
setfillstyle(6,RED);
floodfill(1,1,RED);
setcolor(YELLOW);
outtextxy(225,150,"Please Wait....");
outtextxy(50,300,"Redirecting To Rocket National Bank.");
int i=0;
do
{
setcolor(11);
circle(315,250,30);
setcolor(YELLOW);
arc(315,250,0+i,90+i,30);
setcolor(11);
arc(315,250,90+i,0+i,30);
i+=10;
delay(10);
}while(i!=2500);

closegraph();
}

void gra5()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(7,0,5);
setfillstyle(6,RED);
floodfill(1,1,RED);
setcolor(YELLOW);
outtextxy(220,150,"Transaction");
outtextxy(220,200,"Successful..");
getch();
closegraph();
}
void gra6()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(7,0,5);
setfillstyle(6,RED);
floodfill(1,1,RED);
setcolor(YELLOW);
outtextxy(220,150,"Transaction");
outtextxy(220,200,"Failed.");
getch();
closegraph();
}

void gra7()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(7,0,5);
setfillstyle(6,RED);
floodfill(1,1,RED);
setcolor(YELLOW);
outtextxy(220,150,"Book Purchase");
outtextxy(220,200,"Successful..");
getch();
closegraph();
}
void gra8()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(7,0,5);
setfillstyle(6,RED);
floodfill(1,1,RED);
setcolor(YELLOW);
outtextxy(220,150,"Book Purchase ");
outtextxy(220,200,"Failed.");
getch();
closegraph();
}

int main_menu()

{
void selected(int);
void toggle(int,int);
int choice=1,temp;
char m1[]="1: SEE ACCOUNT

",m2[]="2: LIST OF ACCOUNTS";

char m3[]="3:TRANSACTIONS ", m4[]="4: OPEN NEW ACCOUNT";
char m5[]=" 5:BALANCE UPDATE

",m6[]="Main Menu",m7[]="7: QUIT

static int counter=0;
while(choice!=6||choice!=7)
{
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"..\bgi");
counter++;
setfillstyle(1,7);
floodfill(320,240,1);
settextjustify(1,1);
setcolor(8);
settextstyle(7,0,0);
setusercharsize(27,10,5,3);
if (counter==1)
{
outtextxy(320,35,"B

"); delay(200);

outtextxy(320,35," A

"); delay(200);

outtextxy(320,35," N

"); delay(200);

outtextxy(320,35,"

"); delay(200);

outtextxy(320,35,"
outtextxy(320,35,"

K

I "); delay(200);
N "); delay(200);

outtextxy(320,35,"

G");

for(int i=0,j=640;i<610;i++,j--)
{
sound(2*i);
setcolor(8);
line(i,15,i-570,15);

";

line(j,65,j+570,65); delay(5);
putpixel(i-570,15,7);
putpixel(j+570,65,7);
}
nosound();
}
else
{
setusercharsize(27,12,5,3);
outtextxy(320,35,"B A N K I N G");
setcolor(8);
line(610,15,40,15);
line(600,65,30,65);
}
settextstyle(7,1,5);
outtextxy(90,270,"O P T I O N S");
outtextxy(550,270,"O P T I O N S");
settextstyle(1,0,2);
char ch;
box(1,9);
box(2,7);
box(3,7);
box(4,7);
box(5,7);
box(6,7);
box(7,7);
setcolor(1);
outtextxy(320,90,m1);
setcolor(15);
outtextxy(320,150,m2);
outtextxy(320,210,m3);
outtextxy(320,270,m4);
outtextxy(320,330,m5);

outtextxy(320,390,m6);
outtextxy(320,450,m7);
choice=1;
do
{
temp=choice;
ch=getch();
switch (ch)
{
case 72: if(choice==1)
choice=7;
else
choice--;
toggle(choice,temp);
continue;
case 80: if(choice==7)
choice=1;
else
choice++;
toggle(choice,temp);
continue;
case 27: choice=0;
toggle(choice,temp);
case 13: selected(choice);
delay(500);
}
}while (ch!=13&&ch!=27);
for(int i=320;i>0;i--)
{
if((counter==1)||(choice==0))

sound(3*i);
setcolor(1);
line(320-i,0,320-i,480);
line(320+i,0,320+i,480);
line(0,320-i,640,320-i);
line(0,160+i,640,160+i);
delay(2);
}
nosound();
closegraph();
if (choice == 1)
{
displayAccount();
}
else
if (choice == 2)
{
displayAllAccounts();
}
else
if(choice==3)
{
Transfer();
}
else
if (choice == 4)
{
write();
}
else

if (choice == 5)
BAL();
else
if (choice == 6)
return 2;
else
if (choice == 7)
{
credits();
exit(1);
}
}
return 1;
}
void toggle(int i,int temp)
{
char m1[]="1: SEE ACCOUNT

",m2[]="2: LIST OF ACCOUNTS",

char m3[]="3:TRANSACTIONS ";
char m4[]="4: OPEN NEW ACCOUNT";
char m5[]=" 5:BALANCE UPDATE
char m7[]="7: QUIT

if (i==0)
i=7;
if (temp==0)
temp=7;
box(temp,7);
switch(temp)
{
case 1: box(1,7);
setcolor(15);

";

",m6[]="Main Menu";

outtextxy(320,90,m1);
break;
case 2: box(2,7);
setcolor(15);
outtextxy(320,150,m2);
break;
case 3: box(3,7);
setcolor(15);
outtextxy(320,210,m3);
break;
case 4: box(4,7);
setcolor(15);
outtextxy(320,270,m4);
break;
case 5: box(5,7);
setcolor(15);
outtextxy(320,330,m5);
break;
case 6: box(6,7);
setcolor(15);
outtextxy(320,390,m6);
break;
case 7: box(7,7);
setcolor(15);
outtextxy(320,450,m7);
break;
}
switch(i)
{
case 1: box(1,9);
setcolor(1);
outtextxy(320,90,m1);

break;
case 2: box(2,9);
setcolor(1);
outtextxy(320,150,m2);
break;
case 3: box(3,9);
setcolor(1);
outtextxy(320,210,m3);
break;
case 4: box(4,9);
setcolor(1);
outtextxy(320,270,m4);
break;
case 5: box(5,9);
setcolor(1);
outtextxy(320,330,m5);
break;
case 6: box(6,9);
setcolor(1);
outtextxy(320,390,m6);
break;
case 7: box(7,9);
setcolor(1);
outtextxy(320,450,m7);
break;
}
}
void selected(int i)
{
if(i==0) i=7;
delay(350);
setcolor(0);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);

line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(15);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);
delay(350);
setcolor(15);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(0);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);
}
void box(int i,int color)
{
setcolor(5);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
setfillstyle(1,color);
floodfill(320,60*(i+.5),5);
setcolor(15);
line(180,60*(i+.5)-20,180,60*(i+.5)+20);
line(180,60*(i+.5)-20,460,60*(i+.5)-20);
setcolor(0);
line(460,60*(i+.5)-20,460,60*(i+.5)+20);
line(180,60*(i+.5)+20,460,60*(i+.5)+20);
line(461,60*(i+.5)-20,461,60*(i+.5)+21);
line(180,60*(i+.5)+21,461,60*(i+.5)+21);

}

int getChoice(int x, int y, int no)
{
int n=1,ch1,ch2; char chr=175,chr2=24,chr3=25;
gotoxy(3,1);
cout<<" ";
gotoxy(47,23);
cout<<chr2<<chr3;
textcolor(11);
cprintf(" to <MOVE> <ENTER> to <SELECT>");
gotoxy(x,y);
cout<<chr;
gotoxy(3,1);
do
{
do
{
do
{
ch1=getch();
}while((ch1!=0) && ch1!=13);
if(ch1!=13)
{
do
{
ch2=getch();
}while((ch2!=72) && (ch2!=80) && (ch2!=13));
}
}while((ch1!=0) && (ch2!=72) && (ch1!=13) && (ch2!=80) && (ch2!=13));
if((ch1==0) && (ch2==80))

{
gotoxy(x,y);
cout<<" ";
gotoxy(3,1);
if(n==no)
{
n=1;
y=y-(no-1);
}
else
{
n++;
y++;
}
gotoxy(x,y);
cout<<chr;
gotoxy(3,1);
}
if((ch1==0) && (ch2==72))
{
gotoxy(x,y);
cout<<" ";
gotoxy(3,1);
if(n==1)
{
n=no;
y=y+(no-1);
}
else
{
n--;
y--;
}

gotoxy(x,y);
cout<<chr;
gotoxy(3,1);
}
}while((ch1!=13) && (ch2!=13));
return n;
};
char* getpass(int x,int y )
{
int i=0,j,k; char ch,pas[20];
while(1)
{
j=0;
ch=getch();
k=i;
if(ch==13)
{
pas[i]='\0';
break;
}
pas[i]=ch;
while(j<=k)
{
gotoxy(x+j,y);
cout<<"*";
j++;
}
i++;
}
return pas;
}

int categoryGood(char c[])
{
if(strcmp(c,"FICTION")&&strcmp(c,"NON FICTION")&&strcmp(c,"SUSPENSE
THRILLER")&&strcmp(c,"ROMANCE")&&strcmp(c,"COMEDY")&&strcmp(c,"OTHER"
))
return 0;
else
return 1;
};
void createAdmin()
{
f1.open("ABSadminAccount.dat",ios::out);
clrscr();
ad.adminCreate();
f1.write((char*)&ad,sizeof(adminAccount));
f1.close();
getch();
}
void adminLogin()
{
f1.close();
clrscr();
f1.open("ABSadminaccount.dat",ios::in);
f1.seekg(0,ios::end);
int q= f1.tellg()/sizeof(adminAccount);
f1.close();
if(q==0)
{
int ch;
do
{
gotoxy(20,10);
cprintf("<<< Admin Account Not Found >>>");

gotoxy(20,12);
cprintf("Press enter to Contine...");
ch=getch();
}while(ch!=13);
clrscr();
createAdmin();
}
else
{
f1.open("ABSadminAccount.dat",ios::in);
f1.read((char*)&ad,sizeof(adminAccount));
int chance=3;
char p[15];
again:
clrscr();
if(chance==1)
{
gotoxy(20,8);
cprintf("<<<LAST CHANCE>>>");
}
gotoxy(20,10);
cprintf("PASSWORD: ");
strcpy(p,getpass(30,10));
if(ad.adminPassCheck(p))
{
gotoxy(20,13);
cprintf("Welcome Admin Tanmay ..");
getch();
}
else
{
gotoxy(20,13);

cprintf("<<< Wrong Password >>>");
chance--;
if(chance==0)
{
clrscr();
cout<<"\n\n\n\n\n\t\t\t\tProgram exiting.......";
delay(500);
exit(0);
}
gotoxy(20,15);
cprintf("Forgot PassWord ?");
gotoxy(20,16);
cprintf("Yes");
gotoxy(20,17);
cprintf("No");
choice=getChoice(18,16,2);
if(choice==1)
{
ad.adminForgot();
}
else
goto again;
}
f1.close();
}
}

book search1(int n)
{
fstream f1;

f1.open("ABSbooks.dat",ios::in);
while(f1)
{
f1.read((char*)&b,sizeof(book));
if(b.returnBookCode()==n)
return b;
}
b.setBook(0);
return b;
}
int returnCode()
{
fstream f1;
int i=12;
f1.open("count.dat",ios::in);
if(f1)
{
f1>>i;
i++;
}
f1.close();
f1.open("count.dat",ios::out);
f1<<i;
f1.close();
return i;
}

void writeBook()
{
f1.open("ABSbooks.dat",ios::out|ios::app);
do
{

clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Write Book") ;
textcolor(WHITE);
textbackground(0);
b.createBook();
f1.write((char*)&b,sizeof(book));
getch();
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Write Book") ;
textcolor(WHITE);
textbackground(0);
gotoxy(15,9);
cout<<"Do you want to add more books..";
gotoxy(17,10);
cout<<"Yes";

gotoxy(17,11);
cout<<"No";
choice=getChoice(15,10,2);
}while(choice==1);
f1.close();
}
void todaySalesWrite()
{
f1.open("ABScart.dat",ios::in|ios::beg);
f2.open("ABSsales.dat",ios::app);
while(f1.read((char*)&b,sizeof(book)))
f2.write((char*)&b,sizeof(book));
f1.close();
f2.close();
}
void custoOptions(book b)
{
gotoxy(30,10);
textcolor(YELLOW);
cprintf("Add to Cart...?");
gotoxy(32,12);
cprintf("Y");
gotoxy(32,13);
cprintf("N");
textcolor(WHITE);
gotoxy(33,12);
cprintf("es");
gotoxy(33,13);
cprintf("o/Back");
choice=getChoice(30,12,2);
if(choice==1)

{
f2.open("ABScart.dat",ios::app);
f2.write((char*)&b,sizeof(book));
f2.close();
clrscr();
gotoxy(30,10);
cprintf("<<<< Book Added To Cart >>>>");
gotoxy(16,12);
cprintf("Your Book now can b Purchased From My Cart Menu In Main");
cprintf("Menu..");
getch();
}
}
void deleteBook(int n)
{
clrscr();
int flagVar=0;
clrscr();
gotoxy(32,11);
cout<<"Delete Book....?";
gotoxy(32,12);
cout<<"Yes";
gotoxy(32,13);
cout<<"No";
choice=getChoice(30,12,2);
if(choice==1)
{
f1.open("ABSbooks.dat",ios::in|ios::out);
f2.open("tempo.dat",ios::out);
while(f1.read((char*)&b,sizeof(book)))
{

if(b.returnBookCode()==n)
flagVar=1;
else
f2.write((char*)&b,sizeof(book));
}
}
f1.close();
f2.close();
remove("ABSbooks.dat");
rename("tempo.dat","ABSbooks.dat");
if(flagVar==0)
{
gotoxy(28,15);
cout<<"<<<< Book Could Not Deleted >>>>";
}
else
{
gotoxy(28,15);
cout<<"<<<< Book Successfully Deleted >>>>";
}
getch();
}
void modifyBook(int n)
{
clrscr();
int found=0;
gotoxy(3,1);
cout<<"\nModify Book --->\n\n";
f1.open("ABSbooks.dat",ios::in|ios::beg);
f2.open("ABS.dat",ios::app);
if(f1)

{
while(1)
{
f1.read((char*)&b,sizeof(book));
if(f1.eof())
break;
if(b.returnBookCode()==n)
{
clrscr();
b.modify();
gotoxy(3,20);
cout<<"<<<< Book Updated >>>>";
found=1;
}
f2.write((char*)&b,sizeof(book));
}
f1.close();
f2.close();
remove("ABSbooks.dat");
rename("ABS.dat","ABSbooks.dat");

}
else
cout<<"Error occured while connecting";
getch();
}
void adminOptions(book b)
{
gotoxy(30,10);

textcolor(YELLOW);
cprintf("<< Book Options >>");
gotoxy(32,12);
cprintf("M");
gotoxy(32,13);
cprintf("D");
gotoxy(32,14);
cprintf("B");
textcolor(WHITE);
gotoxy(33,12);
cprintf("odify");
gotoxy(33,13);
cprintf("elete");
gotoxy(33,14);
cprintf("ack");
choice=getChoice(30,12,3);
if(choice==1)
modifyBook(b.returnBookCode());
else
if(choice==2)
deleteBook(b.returnBookCode());
}

void read1book(int n)
{
int flagVar=0;
int n1;
clrscr();
gotoxy(5,3);
cprintf("Enter Book Code of The Of The Book To Be Searched..");
cin>>n1;

clrscr();
b=search1(n1);
if(!b.returnBookCode())
{
gotoxy(3,5);
cout<<"<<< No Book Found >>>";
getch();
}
else
{
b.readBook();
getch();
clrscr();
if(n==2)
custoOptions(b);
else
adminOptions(b);
}
}

void readBookCategory(int n)
{
int flagVar=0,pos[50];
char cate[20];
gotoxy(3,3);
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;

textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK);
textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Read Book By Category") ;
textcolor(WHITE);
textbackground(0);
gotoxy(5,5);
cout<<"Enter Category Of The Book To Be Searched: ";
gets(cate);
clrscr();
f1.open("ABSbooks.dat",ios::in);
if(f1)
{
textcolor(11);
while(1)
{
f1.read((char*)&b,sizeof(book));
if(f1.eof())
break;
if(strcmp(b.returnBookCategory(),strupr(cate))==0)
{
pos[flagVar]= b.returnBookCode();
flagVar++;
b.order1(3,4+flagVar);
}
}
f1.close();
gotoxy(3,2);
cout<<"====================================================+======";
cout<<"======";

gotoxy(3,3);
cout<<"

Book Code

Book Name

Author Name

";

gotoxy(3,4);
cout<<"===========================================================";
cout<<"======";
if(flagVar==0)
{
gotoxy(5,6);
cprintf("No Book Found");
getch();
}
else
{
textcolor(11);
gotoxy(12,5+flagVar);
textcolor(11);
cprintf("BACK");
gotoxy(3,7+flagVar);
cout<<flagVar<<" Result Found!";
choice=getChoice(3,5,flagVar+1);
clrscr();
if(choice!=flagVar+1)
{
b=search1(pos[choice-1]);
f1.read((char*)&b,sizeof(book));
b.readBook();
getch();
clrscr();
if(n==2)
custoOptions(b);
else
adminOptions(b);
}

}
}
}
void readAllBook(int n)
{
clrscr();
fstream f1;
int flagVar=0;
int choice;
int pos[50];
f1.open("ABSbooks.dat",ios::in);
if(!f1)
{
cout<<"\n\t\tErrot!!!...Could Not Open File.";
getch();
}
else
{
gotoxy(3,2);
cout<<"===========================================================";
cout<<"======";
gotoxy(3,3);
cout<<"

Book Code

Book Name

Author Name

";

gotoxy(3,4);
cout<<"===========================================================";
cout<<"======";
while(1)
{
f1.read((char*)&b,sizeof(book));
if(!f1)

break;
pos[flagVar]=b.returnBookCode();
flagVar++;
b.order1(3,4+flagVar);
}
f1.close();
gotoxy(12,5+flagVar);
textcolor(YELLOW);
cprintf("BACK");
textcolor(11);
gotoxy(3,7+flagVar);
cout<<flagVar<<" Book(s) Found!";
if(flagVar)
{
choice=getChoice(3,5,flagVar+1);
clrscr();
if(choice!=flagVar+1)
{
b=search1(pos[choice-1]);
b.readBook();
getch();
clrscr();
if(n==2)
custoOptions(b);
if(n==1)
adminOptions(b);
}
}
}
}
void readBookName(int n)
{

int flagVar=0,pos[50];
fstream f1;
char naam[30];
gotoxy(3,3);
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("Read Book By Name") ;
textcolor(WHITE);
textbackground(0);
gotoxy(5,5);
cout<<"Enter Name Of The Book To Be Searched: ";
gets(naam);
strcpy(naam,strupr(naam));
gotoxy(3,3);
f1.open("ABSbooks.dat",ios::in);
clrscr();
while(1)
{
f1.read((char*)&b,sizeof(book));
if(f1.eof())
break;
if(strcmp(b.returnBookName(),strupr(naam))==0)
{
pos[flagVar]= b.returnBookCode();
flagVar++;

b.order1(3,4+flagVar);
}
}
f1.close();
gotoxy(3,2);
cout<<"===========================================================";
cout<<"======";
gotoxy(3,3);
cout<<"

Book Code

Book Name

Author Name

";

gotoxy(3,4);
cout<<"===========================================================";
cout<<"======";
if(flagVar==0)
{
gotoxy(5,6);
cout<<"<<<< No Book Found >>>>";
getch();
}
else
{
gotoxy(12,5+flagVar);
textcolor(YELLOW);
cprintf("BACK");
textcolor(11);
gotoxy(3,7+flagVar);
cout<<flagVar<<" Result Found!";
choice=getChoice(3,5,flagVar+1);
clrscr();
if(choice!=flagVar+1)
{
b=search1(pos[choice-1]);
b.readBook();
getch();

clrscr();
if(n==2)
custoOptions(b);
else
adminOptions(b);
}
}
}
void myCart()
{
int price[30];
fstream f1;
int flagVar=0;
f1.open("ABScart.dat",ios::in);
f1.seekg(0,ios::end);
int q=f1.tellg();
f1.close();
if(q==-1||q==0)
{
clrscr();
gotoxy(28,12);
cprintf("<<< Your Cart is Empty Boss >>>");
getch();
}
else
{
clrscr();
textcolor(11);
gotoxy(5,2);
cprintf("===========================================================);
cprintf("======");
gotoxy(5,3);

cprintf("

Book Code

Book Name

PRICE (in Rs)

");

gotoxy(5,4);
cprintf("===========================================================);
cprintf("======");
f1.open("ABScart.dat",ios::in);
while(1)
{
f1.read((char*)&b,sizeof(book));
if(f1.eof())
break;
price[flagVar]= b.returnBookPrice();
flagVar++;
b.order2(5,4+flagVar);
}
f1.close();
gotoxy(5,5+flagVar);
cprintf("==========================================================');
cprintf("======");
int S=0,i=0;
while(i<flagVar)
{
S=S+ price[i];
i++;
}
textcolor(YELLOW);
gotoxy(5,7+flagVar);
cprintf("Total Price:");
cout<<S;
gotoxy(10,20);
cprintf("Pay Via ..");
gotoxy(10,22);

cprintf("Rocket Account");
gotoxy(10,23);
cprintf("Cash");
gotoxy(10,24);
cprintf("Discard Books");
choice=getChoice(8,22,3);
if(choice==1)
{
clrscr();
gra4();
int x=TransferToAdmin(S);
if(x==1)
{
gra7();
todaySalesWrite();
}
else
gra8();
}
else
if(choice==2)
{
gra7();
ac=search(1);
long int lastBal=ac.returnBal();
writeTrans(1,'D',S,lastBal);
S*=-1;
updateBal(1,S);
todaySalesWrite();
}
}

remove("ABScart.dat");
}
void readTodaySales()
{
int price[50];
int flagVar=0;
f2.open("ABSsales.dat",ios::in);
f2.seekg(0,ios::end);
flagVar=f2.tellg();
if(flagVar==-1||flagVar==0)
{
clrscr();
cout<<"\n\n\t<<< No book Sold Now Till Now >>>";
}
else
{
clrscr();
flagVar=0;
f2.seekg(0,ios::beg);
gotoxy(3,5);
cout<<"===========================================================";
cout<<"======";
gotoxy(3,6);
cout<<"

Book Code

Book Name

Price (in Rs.) ";

gotoxy(3,7);
cout<<"===========================================================";
cout<<"======";
while(1)
{
f2.read((char*)&b,sizeof(book));

if(f2.eof())
break;
price[flagVar]=b.returnBookPrice();
flagVar++;
b.order2(3,7+flagVar);
}
f2.close();
int s=0;
int i=0;
while(i<flagVar)
{
s=s+price[i];
i++;
}
cout<<"\n\n\t"<<flagVar<<" books Sold. worth "<<s<<" Rs.";
getch();
clrscr();
gotoxy(20,5);
cprintf("(R)RESET");
gotoxy(20,7);
cprintf("(V)View Your Rocket Account?");
gotoxy(20,9);
cprintf("(ANY OTHER KEY)Back");
char cho;
cho=getch();
if(toupper(cho)=='R')
{
remove("ABSsales.dat");
gotoxy(35,15);
textcolor(YELLOW);
cprintf("<<< RESET DONE >>>");
getch();

}
if(toupper(cho)=='V')
{
void adminRocket();
gra4();
adminRocket();
}
}
getch();
}
int userSelect()
{
int check=1;
do
{
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(YELLOW+BLINK) ; textbackground(WHITE) ;
gotoxy(35,3) ;
cprintf("UserSelect") ;
textbackground(0);
gotoxy(34,9);
textcolor(YELLOW);
cprintf("Proceed As --->");

gotoxy(34,10);
cprintf("~~~~~~~~~~~~~~~");
gotoxy(34,11);
textcolor(11);
cprintf("1. Administrator");
gotoxy(34,12);
cprintf("2. Customer");
choice=getChoice(32,11,2);
switch(choice)
{
case 1: check=adminMenu();
break;
case 2: remove("ABScart.dat");
check=customer();
}
}while(check==1);
return check;
}

int customer()
{
char m1[]=" 1:READ ALL BOOKS

",m2[]="2:READ BOOKS BY CATEGORY";

char m3[]=" 3:SEARCH A BOOK ", m4[]=" 4:READ BOOK BY NAME";
char m5[]=" 5:MY CART

",m6[]=" 6:Main Menu",m7[]=" 7:QUIT

static int counter=0;
int choice=1,temp;
while(choice!=6)
{
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"..\bgi");
counter++;

";

choice=1;
setfillstyle(1,7);
floodfill(320,240,1);
settextjustify(1,1);
setcolor(8);
settextstyle(7,0,0);
setusercharsize(27,10,5,3);
if (counter==1)
{
outtextxy(320,35,"W

"); delay(200);

outtextxy(320,35," E

"); delay(200);

outtextxy(320,35," L

"); delay(200);

outtextxy(320,35,"

C

"); delay(200);

outtextxy(320,35,"

O "); delay(200);

outtextxy(320,35,"

M "); delay(200);

outtextxy(320,35,"

E");

for(int i=0,j=640;i<610;i++,j--)
{
sound(2*i);
setcolor(8);
line(i,15,i-570,15);
line(j,65,j+570,65); delay(5);
putpixel(i-570,15,7);
putpixel(j+570,65,7);
}
nosound();
}
else
{
setusercharsize(27,12,5,3);
outtextxy(320,35,"Book Shop ");
setcolor(8);
line(610,15,40,15);

line(600,65,30,65);
}
settextstyle(7,1,5);
outtextxy(90,270,"O P T I O N S");
outtextxy(550,270,"O P T I O N S");
settextstyle(1,0,2);
char ch;
box(1,9);
box(2,7);
box(3,7);
box(4,7);
box(5,7);
box(6,7);
box(7,7);
setcolor(1);
outtextxy(320,90,m1);
setcolor(15);
outtextxy(320,150,m2);
outtextxy(320,210,m3);
outtextxy(320,270,m4);
outtextxy(320,330,m5);
outtextxy(320,390,m6);
outtextxy(320,450,m7);
do
{
temp=choice;
ch=getch();
switch (ch)
{
case 80: if(choice==7)
choice=1;

else
choice++;
toggle1(choice,temp);
continue;
case 72: if(choice==1)
choice=7;
else
choice--;
toggle1(choice,temp);
continue;
case 27: choice=0;
toggle1(choice,temp);
case 13: selected(choice);
delay(500);
}
}while (ch!=13&&ch!=27);
for(int i=320;i>0;i--)
{
if((counter==1)||(choice==0))
sound(3*i);
setcolor(1);
line(320-i,0,320-i,480);
line(320+i,0,320+i,480);
line(0,320-i,640,320-i);
line(0,160+i,640,160+i);
delay(2);
}
nosound();
closegraph();
if (choice == 1)
{

readAllBook(2);
}
else
if (choice == 2)
{
readBookCategory(2);
}
else
if (choice== 3)
{
read1book(2);
}
else
if (choice == 4)
{
readBookName(2);
}
else
if (choice == 5)
myCart();
else
if (choice == 6)
{
return 2;
}
else
if (choice == 7)
{
exit(1);
}

}
return 0;
}
void toggle1(int i,int temp)
{

char m1[]=" 1:READ ALL BOOKS

",m2[]="2:READ BOOKS BY CATEGORY";

char m3[]=" 3:SEARCH A BOOK ";
char m4[]=" 4:READ BOOK BY NAME",m5[]=" 5:MY CART
char m6[]=" 6:Main Menu",m7[]=" 7:QUIT
if (i==0)
i=7;
if (temp==0)
temp=7;
box(temp,7);
switch(temp)
{
case 1: box(1,7);
setcolor(15);
outtextxy(320,90,m1);
break;
case 2: box(2,7);
setcolor(15);
outtextxy(320,150,m2);
break;
case 3: box(3,7);
setcolor(15);
outtextxy(320,210,m3);
break;
case 4: box(4,7);
setcolor(15);

";

";

outtextxy(320,270,m4);
break;
case 5: box(5,7);
setcolor(15);
outtextxy(320,330,m5);
break;
case 6: box(6,7);
setcolor(15);
outtextxy(320,390,m6);
break;
case 7: box(7,7);
setcolor(15);
outtextxy(320,450,m7);
break;
}
switch(i)
{
case 1: box(1,9);
setcolor(1);
outtextxy(320,90,m1);
break;
case 2: box(2,9);
setcolor(1);
outtextxy(320,150,m2);
break;
case 3: box(3,9);
setcolor(1);
outtextxy(320,210,m3);
break;
case 4: box(4,9);
setcolor(1);
outtextxy(320,270,m4);

break;
case 5: box(5,9);
setcolor(1);
outtextxy(320,330,m5);
break;
case 6: box(6,9);
setcolor(1);
outtextxy(320,390,m6);
break;
case 7: box(7,9);
setcolor(1);
outtextxy(320,450,m7);
break;
}
}

void factoryReset()
{
clrscr();
textcolor(1);
cout<<"\n\n\n\t";
cprintf("Program will delete all the records of apni book shop from the ");
cout<<"\n\t";
cprintf("Sysyem...");
delay(300);
cout<<"\n\t";
cprintf("Factory Reset in seconds");
int i=3;
do
{
gotoxy(26,6);
cout<<i;

if(kbhit())
{
char ch=getch();
if(ch==13)
{
i=5;
break;
}
}
i--;
gotoxy(1,1);
sleep(1);
}while(i>=0);
if(i!=5)
{
remove("ABSbooks.dat");
cout<<"\n\n\n\n\n\n\n\t";
cprintf("Books Record Removed!! (ABSbooks.dat removed)");
delay(500);
remove("ABSadminAccount.dat");
b.defaultBooks();
delay(500);
cout<<"\n\n\t";
cprintf("Admin Account Record Removed!!");
cprintf ("ABSadminAccount.dat removed)");
delay(500);
cout<<"\n\n\t";
cprintf("Sales Record Removed!! (sales.dat removed)");
delay(200);
cout<<"\n\n\t";
cprintf("all Files deleted successfully...");
}
else

{
cout<<"\n\n\t";
textcolor(YELLOW);
cprintf("Factory Reset Aborted By User....");
textcolor(1);
}
cout<<"\n\n\t";
system("pause");
}
int adminMenu()
{
adminLogin();
do
{
clrscr();
s.box(2,2,79,24,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,22,196) ;
gotoxy(3,3) ;
textbackground(WHITE);
for (int i=1; i<=76; i++) cprintf(" ");
textbackground(BLACK) ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(29,3) ;
cprintf("ADMINISTRATOR MENU") ;
textcolor(WHITE);
textbackground(0);
gotoxy(30,2);
textcolor(YELLOW);
textcolor(15);
gotoxy(30,5);
cprintf("1. Review All Books");
gotoxy(30,6);

cprintf("2. Review All Books Of A Specific Category");
gotoxy(30,7);
cprintf("3. Search A Book By Its Code");
gotoxy(30,8);
cprintf("4. Search A Book By Its Name");
gotoxy(30,9);
cprintf("5. Write A Book");
gotoxy(30,10);
cprintf("6. View Sales Till Now");
gotoxy(30,11);
textcolor(RED);
cprintf("7. << Factory Reset >>");
gotoxy(30,12);
textcolor(WHITE);
cprintf("8. Go Back To Login Screen");
gotoxy(30,13);
cprintf("9. Main Menu");
gotoxy(30,14);
cprintf("10. Exit");
choice= getChoice(28,5,10);
int t;
switch(choice)
{
case 1: readAllBook(1);
break;
case 2: readBookCategory(1);
break;
case 3: read1book(1);
break;
case 4: readBookName(1);
break;
case 5:

writeBook();

break;

case 6: readTodaySales();
break;
case 7: factoryReset();
break;
case 8: return 1;
case 9: return 2;
case 10: credits();
exit(1);
}
}while(1);
}
void adminRocket()
{
int found=0;
b1.open("BankAccounts.dat",ios::in|ios::beg);
if(b1)
{
while((b1.read((char*)&ac,sizeof(accounts)))&&(!found))
{
clrscr();
if(ac.returnAccno()==1)
{
clrscr();
s.box(2,1,79,25,218) ;
s.line_hor(3,78,4,196) ;
s.line_hor(3,78,6,196) ;
s.line_hor(3,78,23,196) ;
textcolor(YELLOW);
textbackground(WHITE) ;

gotoxy(3,5) ;
for (int i=1; i<=76; i++) cprintf(" ") ;
textbackground(BLACK) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(3,5) ;
cprintf("Date of Trans

Type

Amount

cprintf("Balance") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(3,2);
cout<<"Account #";
cout<<ac.returnAccno();
gotoxy(3,3);
cout<<ac.returnName();
gotoxy(50,3);
cprintf("Current Balance :: ");
cout<<ac.returnBal();
readTrans(ac.returnAccno());
getch();
found=1;
}
if(!found)
{
gotoxy(5,7);
cprintf("Admin Account has Been Not Found");
}
}
}
else
cprintf("Could not connect to Rocket Bank");
getch();
b1.close();
}

Last");

void credits()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd, &gm, "");
settextstyle(1,0,3);
setfillstyle(10,8);
floodfill(1,1,10);
setcolor(10);
outtextxy(50,110,"\"WE CAME TOGETHER FOR A BEGINNING.... ");
outtextxy(50,140,"WE KEPT TOGETHER FOR PROGRESS.....");
outtextxy(50,170,"AND WE WORKED TOGETHER FOR SUCCESS....\"");
delay(3200);
cleardevice();
floodfill(1,1,10);
settextstyle(1,0,3);
outtextxy(10,5,"THE ABSOLUTE APPLAUD FOR THE CREATION OF ");
outtextxy(10,25,"ENDEAVOUR GOES TO ->");
settextstyle(5,0,4);
setcolor(3);
delay(500);
outtextxy(10,50,"Concept And Idea: ");
delay(500);
outtextxy(10,50,"

Aakash & Sonal");

delay(500);
outtextxy(10,100,"Design And Draft: ");
delay(500);
outtextxy(10,100,"

Aakash & Tanmay");

delay(500);
outtextxy(10,150,"Supervision: ");
delay(500);
outtextxy(10,150,"
delay(500);

Sir Vishal Sharma");

outtextxy(10,200,"Coding & Debugging: ");
delay(500);
outtextxy(10,200,"

Aakash & Tanmay");

delay(500);
outtextxy(10,250,"Subject Matter: ");
delay(500);
outtextxy(10,250,"

Anviti");

delay(500);
outtextxy(10,300,"Beta Testers:");
delay(500);
outtextxy(10,300,"

Anviti & Sonal");

delay(500);
outtextxy(10,350,"Extra Effects: ");
delay(500);
outtextxy(10,350,"

Rishab Pandey Jii(seeti bajae)");

outtextxy(10,400,"Thank You Guys..");
delay(3000);
exit(0);
}

Sign up to vote on this title
UsefulNot useful