📄 bank.cpp
字号:
{
if(r == 22)
{
textcolor(YELLOW);
gotoxy(10,23);
cprintf("PRESS ANY KEY TO CONTINUE...");
getch();
textcolor(GREEN);
clrscr();
box(12,2,69,4);
gotoxy(31,3);
textcolor(CYAN + BLINK);
cprintf("BANK OF PAKISTAN");
box(6,8,73,24);
textcolor(CYAN);
gotoxy(25,8);
cprintf(" ++ ALL MATCHING RESULTS ++ ");
textcolor(RED);
gotoxy(10,10);
cprintf("ACCOUNT NO. NAME OPENING DATE BALANCE");
r = 12;
}
else
{
textcolor(CYAN);
gotoxy(12,r);
cputs(b->id);
gotoxy(26,r);
cputs(b->name);
gotoxy(50,r);
cprintf("%d-%d-%d",b->day,b->month,b->year);
gotoxy(66,r);
cprintf("%.00lf",b->bal);
r++;
}
}
}
fclose(f);
textcolor(YELLOW);
gotoxy(10,23);
cputs("END OF RECORDS");
getch();
}
else
{
clrscr();
box(26,12,55,14);
_setcursortype(_NOCURSOR);
textcolor(YELLOW + BLINK);
gotoxy(28,13);
cputs("*** ERROR OPENING FILE ***");
getch();
}
searchmenu();
}
void delet(bank *b)
{
int i;
char del[NUM];
char ch;
FILE *f, *fd;
textcolor(GREEN);
clrscr();
_setcursortype(_SOLIDCURSOR);
f = fopen("Bank.dat","rb");
fd = fopen("Temp.dat","wb");
if (f != NULL)
{
box(12,3,69,5);
gotoxy(31,4);
textcolor(CYAN + BLINK);
cputs("BANK OF PAKISTAN");
box(16,7,65,22);
textcolor(CYAN);
gotoxy(30,7);
cputs(" ++ DELETE ACCOUNT ++ ");
gotoxy(24,9);
cputs("ENTER ACCOUNT NO. TO DELETE : ");
check_id(del, NUM);
_setcursortype(_NOCURSOR);
while(fread(b, sizeof(struct bank), 1, f))
{
if (strcmp(del, b->id)== 0)
{
i++;
gotoxy(27,12);
cprintf("ACCOUNT NO : %s",b->id);
gotoxy(27,14);
cprintf("PERSON NAME : %s",b->name);
gotoxy(27,16);
cprintf("OPENING DATE : %d-%d-%d",b->day,b->month,b->year);
gotoxy(27,18);
cprintf("CURR BALANCE : %.00lf",b->bal);
textcolor(YELLOW);
gotoxy(19,21); cputs(b->id);
gotoxy(26,21); cputs(b->name);
gotoxy(46,21); cprintf("%d-%d-%d",b->day,b->month,b->year);
gotoxy(59,21); cprintf("%.00lf",b->bal);
gotoxy(24,23);
cputs("ARE U SURE U WANT TO DELETE ? :- ");
ch = getche();
}
}
if (ch == 'Y' || ch == 'y')
{
gotoxy(28,24); textcolor(YELLOW);
cprintf("RECORD DELETED SUCCESSFULY");
getch();
}
else if (ch == 'N'|| ch == 'n')
menu();
rewind(f);
while(fread(b, sizeof(struct bank), 1, f) == 1)
{
if (strcmp(del, b->id) != 0)
fwrite(b, sizeof(struct bank), 1, fd);
}
fclose(f);
fclose(fd);
remove("Bank.dat");
rename("Temp.dat","Bank.dat");
menu();
}
else
{
clrscr();
box(26,12,55,14);
_setcursortype(_NOCURSOR);
textcolor(YELLOW + BLINK);
gotoxy(28,13);
cputs("*** ERROR OPENING FILE ***");
getch();
}
menu();
}
void deposit(bank *b)
{
int i;
char dp[NUM];
FILE *f, *fm;
textcolor(GREEN);
clrscr();
_setcursortype(_SOLIDCURSOR);
f = fopen("Bank.dat","rb");
fm = fopen("Temp.dat","wb");
if (f != NULL)
{
box(12,3,69,5);
gotoxy(31,4);
textcolor(CYAN + BLINK);
cputs("BANK OF PAKISTAN");
box(16,7,65,22);
textcolor(CYAN);
gotoxy(30,7);
cputs(" ++ DEPOSIT MONEY ++ ");
gotoxy(24,9);
cputs("ENTER ACCOUNT NO. TO DEPOSIT : ");
check_id(dp, NUM);
rewind(f);
while(fread(b, sizeof(struct bank), 1, f))
{
if (strcmp(dp, b->id) == 0)
{
i++;
gotoxy(27,12);
cprintf("ACCOUNT NO : %s",b->id);
gotoxy(27,14);
cprintf("PERSON NAME : %s",b->name);
gotoxy(27,16);
cputs("DEPOSIT MONEY : ");
cin>>b->dep;
b->bal = b->bal + b->dep;
gotoxy(27,18);
cprintf("BALANCE NOW : %.00lf",b->bal);
_setcursortype(_NOCURSOR);
textcolor(YELLOW);
gotoxy(19,21); cputs(b->id);
gotoxy(26,21); cputs(b->name);
gotoxy(46,21); cprintf("%.00lf",b->dep);
gotoxy(59,21); cprintf("%.00lf",b->bal);
fflush(stdin);
getch();
}
fwrite(b, sizeof(struct bank), 1 ,fm);
}
fclose(f);
fclose(fm);
remove("Bank.dat");
rename("Temp.dat","Bank.dat");
}
else
{
clrscr();
box(26,12,55,14);
_setcursortype(_NOCURSOR);
textcolor(YELLOW + BLINK);
gotoxy(28,13);
cputs("*** ERROR OPENING FILE ***");
getch();
}
menu();
}
void withdraw(bank *b)
{
int i;
char wt[NUM];
FILE *f, *fm;
textcolor(GREEN);
clrscr();
_setcursortype(_SOLIDCURSOR);
f = fopen("Bank.dat","rb");
fm = fopen("Temp.dat","wb");
if (f != NULL)
{
box(12,3,69,5);
gotoxy(31,4);
textcolor(CYAN + BLINK);
cputs("BANK OF PAKISTAN");
box(16,7,65,22);
textcolor(CYAN);
gotoxy(31,7);
cputs(" ++ WITHDRAW MONEY ++ ");
gotoxy(24,9);
cputs("ENTER ACCOUNT NO. TO WITHDRAW : ");
check_id(wt, NUM);
rewind(f);
while(fread(b, sizeof(struct bank), 1, f))
{
if (strcmp(wt, b->id)== 0)
{
gotoxy(27,12);
cprintf("ACCOUNT NO : %s",b->id);
gotoxy(27,14);
cprintf("PERSON NAME : %s",b->name);
gotoxy(27,16);
cputs("WITHDRAW MONEY : ");
cin>>b->with;
if (b->with > b->bal)
{
menu();
}
else
{
b->bal = b->bal - b->with;
gotoxy(27,18);
cprintf("BALANCE NOW : %.00lf",b->bal);
_setcursortype(_NOCURSOR);
textcolor(YELLOW);
gotoxy(19,21); cputs(b->id);
gotoxy(26,21); cputs(b->name);
gotoxy(46,21); cprintf("%.00lf",b->with);
gotoxy(59,21); cprintf("%.00lf",b->bal);
}
fflush(stdin);
getch();
}
fwrite(b, sizeof(struct bank), 1, fm);
}
fclose(f);
fclose(fm);
remove("Bank.dat");
rename("Temp.dat","Bank.dat");
}
else
{
clrscr();
box(26,12,55,14);
_setcursortype(_NOCURSOR);
textcolor(YELLOW + BLINK);
gotoxy(28,13);
cputs("*** ERROR OPENING FILE ***");
getch();
}
menu();
}
void splash()
{
textcolor(GREEN);
clrscr();
_setcursortype(_NOCURSOR); // To disable the cursor.
box(12,3,69,5);
gotoxy(31,4);
textcolor(CYAN + BLINK);
cprintf("BANK OF PAKISTAN");
box(12,9,69,18);
gotoxy(35,10);
textcolor(CYAN + BLINK);
cprintf("* WELCOME *");
gotoxy(24,13);
textcolor(RED);
cprintf("PROGRAMMED BY : ");
gotoxy(16,16);
cprintf("COPYRIGHTS :-");
textcolor(YELLOW);
gotoxy(44,13);
cprintf("MUHAMMAD WASIF");
gotoxy(30,17);
cprintf("HAJVERI PROGRAMMARS [PVT] LIMITED");
delay(3000);
password();
}
/* ***: LOGIN WINDOW OF PROGRAM :*** */
void password()
{
char pass[10] = {"wasijaved"}; // Password of the Program.
char p[10]; // Variable for the Password.
char ps;
char ch;
int i = 0, c = 45;
textcolor(GREEN);
clrscr();
box(12,3,69,5);
gotoxy(31,4);
textcolor(CYAN + BLINK);
cprintf("BANK OF PAKISTAN");
box(16,8,65,22);
gotoxy(30,9);
textcolor(CYAN + BLINK);
cprintf("WELCOME MUHAMMAD WASIF");
box(16,11,65,13);
textcolor(CYAN);
gotoxy(38,12);
cprintf("LOGIN");
gotoxy(28,16);
textcolor(9);
cprintf("ENTER PASSWORD : ");
textcolor(RED);
_setcursortype(_SOLIDCURSOR); // To Show Solid cursor.
while(i <= 9 || ps !='\r')
{
ps = getche();
gotoxy(c,16);
cprintf("*");
if (ps == '\r')
break;
else
{
p[i] = ps;
c++;
i++;
}
if (i > 12) break;
}
p[i] = '\0';
_setcursortype(_NOCURSOR); // To disable the cursor.
if(strcmp(p,pass) == 0)
{
gotoxy(28,18);
textcolor(YELLOW + BLINK);
cprintf("YOU ARE SUCCESSFULY LOGIN... ");
delay(3000);
menu();
}
else
{
gotoxy(27,18);
cprintf("SORRY! ACCESS DENIED..... ");
gotoxy(27,20);
cprintf("LET'S TRY AGAIN [Y]/[N] : ");
ch = getche();
}
if (ch == 'Y'|| ch == 'y')
password();
else if (ch == 'N'|| ch == 'n')
exit(0);
}
void menu()
{
char *ch[] = {"ADD NEW ACCOUNT","DEPOSIT MONEY","WITHDRAW MONEY",
"VIEW ACCOUNTS","DELETE ACCOUNT","SEARCH ACCOUNT",
"** HELP **","** EXIT **"};
int a;
int d = 1;
char choice;
textcolor(GREEN);
clrscr();
box(26,3,55,5);
textcolor(CYAN + BLINK);
gotoxy(28,4);
cprintf("+++BANK OF PAKISTAN+++");
box(26,6,55,8);
gotoxy(33,7);
textcolor(CYAN);
cprintf("***** MENU *****");
box(26,9,55,20);
for(int i=0;i<8;i++)
{
gotoxy(35,11+i);
textcolor(9);
cprintf(" %s ",ch[i]);
}
_setcursortype(_NOCURSOR);
textcolor(GREEN);
gotoxy(25,22);
cputs("================================");
gotoxy(25,24);
cputs("================================");
while(1)
{
kee:
for(a = 1; a <= 8; ++a)
{
if(a == d)
{
if (d == 1)
{
textcolor(RED); gotoxy(37,11);cprintf("ADD NEW ACCOUNT");
textcolor(CYAN);gotoxy(30,11); cputs("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -