Exemplo n.º 1
0
void deposit_withdraw(int n, int option)
{
	int amt;
	int found=0;
	fstream File;
	File.open("account.dat", ios::binary|ios::in|ios::out);
	if(!File)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	while(!File.eof() && found==0)
	{
		File.read((char*)&ac, sizeof(ac));
		if(ac.retacno()==n)
		{
			ac.show_account();
			if(option==1)
			{
				cout<<"\n\n\tTO DEPOSITE AMOUNT ";
				cout<<"\n\nEnter The amount to be deposited";
				cin>>amt;
				ac.dep(amt);
			}
			if(option==2)
			{
				cout<<"\n\n\tTO WITHDRAW AMOUNT ";
				cout<<"\n\nEnter The amount to be withdraw";
				cin>>amt;
				int bal=ac.retdeposit()-amt;
				if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
					cout<<"Insufficience balance";
				else
					ac.draw(amt);
			}
Exemplo n.º 2
0
void modify_account(int n)
{
	int found=0;
	fstream File;
	File.open("account.dat",ios::binary|ios::in|ios::out);
	if(!File)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	while(!File.eof() && found==0)
	{
		File.read((char*)&ac, sizeof(ac));
		if(ac.retacno()==n)
		{
			ac.show_account();
			cout<<"\n\nEnter The New Details of account"<<endl;
			ac.modify();
		     	int pos=(-1)*static_cast<int>(sizeof(account));
			File.seekp(pos,ios::cur);
			File.write((char*) &ac, sizeof(ac));
			cout<<"\n\n\t Record Updated";
			found=1;
		  }
	}
	File.close();
	if(found==0)
		cout<<"\n\n Record Not Found ";
}
Exemplo n.º 3
0
void delete_account(int n)
{
	ifstream fin;
	ofstream fout;
	fin.open("account.dat",ios::binary);
	if(!fin)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	fout.open("Temp.dat",ios::binary);
	fin.seekg(0,ios::beg);
	while(fin.read((char*)&ac, sizeof(ac)))
	{
		if(ac.retacno()!=n)
		{
			fout.write((char*)&ac, sizeof(ac));
		}
	}
	fin.close();
	fout.close();
	remove("account.dat");
	rename("Temp.dat","account.dat");
	cout<<"\n\n\tRecord Deleted ..";
}
Exemplo n.º 4
0
void display_sp(int n)
{

	int flag=0;
	ifstream fin;
	fin.open("account.dat",ios::binary);
	if(!fin)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	cout<<"\nBALANCE DETAILS\n";
	fin.read((char*)&ac, sizeof(ac));
	while(fin)

	{
		if(ac.retacno()==n)
		{
			ac.show_account();
			flag=1;
		}
	}
	fin.close();
	if(flag==0)
		cout<<"\n\nAccount number does not exist";
}