⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bank.cpp

📁 It can be use for low level Bank System Handling.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	/*	HEADER FILES		*/
#include    <conio.h>
#include    <stdio.h>
#include      <dos.h>
#include   <string.h>
#include   <stdlib.h>
#include <iostream.h>
#include       <io.h>
#include  <process.h>
#include    <ctype.h>
/*	RECTANGLE DESIGN HEADER FILE    */
#include      "Box.h"
#include    "Valid.h"

#define MIN 2
#define NUM 5
#define MAX 20

	/*	DEFINE STRUCTURE	*/
	struct bank
	{

	char id[NUM];
	char name[MAX];
	double dep, with, bal;
	int day, month, year;
	int status;

	}b;		//Structure's Variable

	/*	DEFINE FUNCTIONS	*/

	/*	WELCOME SCREEN		*/
void splash();
	/*	LOGIN WINDOW		*/
void password();
	/*	MENUES OF PROGRAM	*/
void check_id(char *,int);
void check_name(char *,int);
void menu();		//	MAIN MENU
void viewmenu();	//	VIEW RECORDS MENU
void searchmenu();	//	SEARCH RECORD MENU
void helpmenu();        //	PROGRAM'S HELP MENU
	/*	DATABASE HANDLING	*/
void add(bank *b);	//	OPENING ACCOUNT
void deposit(bank *b);	//	DEPOSITING MONEY
void withdraw(bank *b);	//	WITHDRAWING MONEY
void view(bank *b);	//	RECORDS NAVIGATOR
void viewall(bank *b);	//	VIEW ALL ACCOUNT LIST
void print(bank *b);	//	PRINT ALL ACCOUNTS INFO
void delet(bank *b);	//	DELETE SPECIFIC RECORDS
void searchid(bank *b);	//	SEARCH ACCOUNT BY NO.
void searchname(bank*b);//	SEARCH ACCOUNT BY NAME
void searchcase(bank*b);//	SEARCH ACCOUNT BY CHARACTER
	/*	HELP FILES		*/
void intro();		//	INTRODUCTION TO PROGRAM
void usage();		//	HOE TO USE PROGRAM
	/*	ABOUT PROGRAM		*/
void about();		//	A NOTE ABOUT THE AUTHOR
	/*	CLOSING THE PROGRAM	*/
void quit();		//	TERMINATING THE PROGRAM

	/*	MAIN FUNCTION		*/
void main()
{

splash();

}

void add(bank *b)
{

FILE *f;
char ch;
b->bal = 0;

	f = fopen("Bank.dat","ab");

	if (f != NULL)
	{
		do
		{
		textcolor(GREEN);
		clrscr();
		_setcursortype(_SOLIDCURSOR); // For Solid cursor.

		box(12,3,69,5);
		gotoxy(31,4);
		textcolor(CYAN + BLINK);
		cprintf("BANK   OF   PAKISTAN");

		box(16,7,65,20);
		textcolor(CYAN);

		gotoxy(29,7);
		cprintf(" ++ OPEN NEW ACCOUNT ++ ");

		gotoxy(27,10);
		cprintf("ACCOUNT NO   : ");

		check_id(b->id, NUM);
		gotoxy(27,12);
		cprintf("ENTER NAME   : ");
		check_name(b->name, MAX);

			 {
			 struct date d;

				   getdate(&d);
				   b->day   = d.da_day;
				   b->month = d.da_mon;
				   b->year  = d.da_year;
			 }

_setcursortype(_NOCURSOR);

		gotoxy(27,14);	cputs("OPENING DATE : ");
		gotoxy(42,14);	cout<<b->day<<"-"<<b->month<<"-"<<b->year;

		gotoxy(27,16);	cprintf("CURR BALANCE : %.00lf",b->bal);

		textcolor(YELLOW);
		gotoxy(19,19);	cputs(b->id);
		gotoxy(28,19);	cputs(b->name);
		gotoxy(48,19);	cprintf("%d-%d-%d",b->day,b->month,b->year);
		gotoxy(62,19);	cprintf("%.00lf",b->bal);

	  fwrite(b, sizeof(struct bank), 1, f);

	  fclose(f);

		textcolor(CYAN);
		gotoxy(18,23);
		cprintf("DO YOU WANT TO ENTER ANOTHER RECORD? [Y]/[N] : ");

	  ch = getche();

		}	while(ch =='Y' || ch == 'y');
	}

	else
	{
		clrscr();
		box(26,12,55,14);
		_setcursortype(_NOCURSOR);
		textcolor(YELLOW + BLINK);
		gotoxy(28,13);
		cputs("*** ERROR OPENING FILE ***");
		getch();
	}

menu();

}

void view(bank *b)
{

FILE *f;
char ch;

	f = fopen("Bank.dat","rb");

//while(ch != 27){

	if(f != NULL)
	{
		clrscr();
		while( fread(b, sizeof(struct bank), 1, f))

			if(b->status == 0)
			{
			//Calling All Records Saved in the File

				textcolor(GREEN);
				clrscr();

				box(12,3,69,5);

				gotoxy(31,4);
				textcolor(CYAN + BLINK);
				cprintf("BANK   OF   PAKISTAN");

				box(16,7,65,20);

				textcolor(CYAN);
				gotoxy(29,7);
				cprintf(" ++ VIEW ALL ACCOUNT ++ ");

				_setcursortype(_NOCURSOR);

				gotoxy(27,10);
				cprintf("ACCOUNT NO   : %s",b->id);
				gotoxy(27,12);
				cprintf("PERSON NAME  : %s",b->name);
				gotoxy(27,14);
				cprintf("OPENING DATE : %d-%d-%d",b->day,b->month,b->year);
				gotoxy(27,16);
				cprintf("CURR BALANCE  : %.00lf",b->bal);

				textcolor(YELLOW);
				gotoxy(19,19);	cputs(b->id);
				gotoxy(26,19);	cputs(b->name);
				gotoxy(46,19);	cprintf("%d-%d-%d",b->day,b->month,b->year);
				gotoxy(59,19);	cprintf("%.00lf",b->bal);

				getch();
			}

			if(b->status == 1)
			{
				clrscr();
				box(26,12,55,14);
				_setcursortype(_NOCURSOR);
				textcolor(YELLOW + BLINK);
				gotoxy(28,13);
				cputs("***  RECORD NOT FOUND  ***");
				getch();
			}
		fclose(f);
	}

	else
	{
		clrscr();
		box(26,12,55,14);
		_setcursortype(_NOCURSOR);
		textcolor(YELLOW + BLINK);
		gotoxy(28,13);
		cputs("*** ERROR OPENING FILE ***");
		getch();
	}  /*
if (ch == 27)
break;
viewmenu();
}            */
viewmenu();

}

void viewall(bank *b)
{

FILE *f;
int r = 11;
double n;

	f = fopen("Bank.dat", "rb");

	if (f != NULL)
	{
		textcolor(GREEN);
		clrscr();

		box(12,2,69,4);

	_setcursortype(_NOCURSOR);

		gotoxy(31,3);
		textcolor(CYAN + BLINK);
		cprintf("BANK   OF   PAKISTAN");

		box(8,7,73,24);

		textcolor(CYAN);
		gotoxy(25,7);
		cprintf(" ++ ALL RECORDS OF DATABASE ++ ");

		textcolor(RED);
		gotoxy(10,9);
cprintf("ACCOUNT NO.     NAME                    OPENING DATE   BALANCE");

n = filelength (fileno(f)) / sizeof(struct bank);

	while ((fread(b, sizeof(struct bank), 1, f) == 1))
	{

	if(b->status == 0)
		{

		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(8,7,73,24);

			textcolor(CYAN);
			gotoxy(25,7);
			cprintf(" ++ ALL RECORDS OF DATABASE ++ ");

			textcolor(RED);
			gotoxy(10,9);
			cprintf("ACCOUNT NO.     NAME                    OPENING DATE   BALANCE");

			r = 11;
			}

			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(65,r);
			cprintf("%.00lf",b->bal);

			r++;
			}
		}
	}

	fclose(f);

	textcolor(YELLOW);
	gotoxy(10,23);
	cputs("END OF RECORDS");

	gotoxy(54,23);
	cputs("TOTAL RECORDS : ");
	cout<<n;

	getch();
	}

	else
	{
		clrscr();
		box(26,12,55,14);
		_setcursortype(_NOCURSOR);
		textcolor(YELLOW + BLINK);
		gotoxy(28,13);
		cputs("*** ERROR OPENING FILE ***");
		getch();
	}

viewmenu();

}

void searchid(bank *b)
{

int i;
char no[NUM];
FILE *f;

textcolor(GREEN);

clrscr();

_setcursortype(_SOLIDCURSOR);

	f = fopen("Bank.dat","rb");

	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(" ++ SEARCH ACCOUNT ++ ");

		gotoxy(24,9);
		cputs("ENTER ACCOUNT NO. TO SEARCH : ");
		check_id(no, NUM);

_setcursortype(_NOCURSOR);

	rewind(f);

	while(fread(b, sizeof(struct bank), 1, f))
	{

	if (strcmp(no, 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);

	 fflush(stdin);
	 getch();
	 }

	}
}

	else
	{
		clrscr();
		box(26,12,55,14);
		_setcursortype(_NOCURSOR);
		textcolor(YELLOW + BLINK);
		gotoxy(28,13);
		cputs("*** ERROR OPENING FILE ***");
		getch();
	}

fclose(f);

searchmenu();

}

void searchname(bank *b)
{

int i;
char nm[MAX];
FILE *f;

textcolor(GREEN);

clrscr();

_setcursortype(_SOLIDCURSOR);

	f = fopen("Bank.dat","rb");

	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(" ++ SEARCH ACCOUNT ++ ");

		gotoxy(18,9);
		cputs("ENTER NAME TO SEARCH : ");
		check_name(nm, MAX);

	_setcursortype(_NOCURSOR);

	rewind(f);

	while(fread(b, sizeof(struct bank), 1, f))
	{

	if (strcmp(nm, b->name) == 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);

	fflush(stdin);
	getch();
		}

	}
}

	else
	{
		clrscr();
		box(26,12,55,14);
		_setcursortype(_NOCURSOR);
		textcolor(YELLOW + BLINK);
		gotoxy(28,13);
		cputs("*** ERROR OPENING FILE ***");
		getch();
	}

fclose(f);

searchmenu();

}

void searchcase(bank *b)
{

char ch[MIN];
int r = 12, m = 0;
FILE *f;

textcolor(GREEN);

clrscr();

_setcursortype(_SOLIDCURSOR);

	f = fopen("Bank.dat","rb");

	if (f != NULL)
	{

	box(12,2,69,4);

		gotoxy(31,3);
		textcolor(CYAN + BLINK);
		cputs("BANK   OF   PAKISTAN");

		box(8,8,73,24);

		textcolor(CYAN);
		gotoxy(27,8);
		cprintf(" ++ ALL MATCHING RESULTS ++ ");

		textcolor(RED);
		gotoxy(10,10);
cprintf("ACCOUNT NO.     NAME                    OPENING DATE   BALANCE");

		textcolor(CYAN);
		gotoxy(22,6);
		cputs("ENTER Ist LETTER OF NAME TO SEARCH : ");
		check_name(ch, MIN);

	rewind(f);

	_setcursortype(_NOCURSOR);

	while (fread(b, sizeof(struct bank), 1, f))
	{

	if(b->name[m] == ch[m])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -