User:A.M.M.F.MUNSIRA/sandbox

= Index Number : 2019T00458 - Escape C=

Deposit function - main task
void deposit

{

int choice;

system("cls");

header;

FILE *oldaccrec;

FILE *newaccrec;

oldaccrec=fopen("userrecord.dat","r");

newaccrec=fopen("newuserrecord.dat","w");

printf("\n\n\t\tENTER CUSTOMER ACCOUNT NUMBER: ");

scanf("%ld",&tradeposit.accno);

while(fscanf(oldaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",&addacc.accno,&addacc.fname,&addacc.lname,&addacc.type,&addacc.dob,&addacc.address,&addacc.tel,&addacc.balance)!=EOF)

{

if(addacc.accno==tradeposit.accno)

{

printf("\t\tENTER THE AMOUNT YOU WANT TO DEPOSIT: ");

scanf("%f",&tradeposit.balance);

addacc.balance+=tradeposit.balance;

fprintf(newaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",addacc.accno,addacc.fname,addacc.lname,addacc.type,addacc.dob,addacc.address,addacc.tel,addacc.balance);

printf("\n\t\tYour Money Successfully Deposited!\n\n");

FILE *dipfile;

dipfile=fopen("_DepositRecord.txt","a+");

fprintf(dipfile,"Time- %s\t\tDate- %s\t\tAccNo- %ld\t\tAmount- %f\n",gettime,getdate,tradeposit.accno,tradeposit.balance);

fclose(dipfile);

count++;

}

else

{

fprintf(newaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",addacc.accno,addacc.fname,addacc.lname,addacc.type,addacc.dob,addacc.address,addacc.tel,addacc.balance);

}

}

fclose(oldaccrec);

fclose(newaccrec);

remove("userrecord.dat");

rename("newuserrecord.dat","userrecord.dat");

Tryagain:

printf("\n\t\tEnter 1 to go Main Menu or Enter 0 to Exit");

scanf("%d",&choice);

if(choice==1)

{

AnotherTransaction;

}

else if(choice==0)

{

closesys;

}

else

{

goto Tryagain;

}

}

Get current balance - sub task
void balance

{

int choice;

system("cls");

header;

printf("\n\t\t\t\t\t    BALANCE INQUIRY SYSTEM");

FILE *oldaccrec;

oldaccrec=fopen("userrecord.dat","r");

printf("\n\n\t\tENTER CUSTOMER ACCOUNT NUMBER: ");

scanf("%ld",&balanceinquiry.accno);

while(fscanf(oldaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",&addacc.accno,&addacc.fname,&addacc.lname,&addacc.type,&addacc.dob,&addacc.address,&addacc.tel,&addacc.balance)!=EOF)

{

if(addacc.accno==balanceinquiry.accno)

{

printf("\n\t\tACCOUNT NO\t\t: %ld\n",addacc.accno);

printf("\t\tCUSTOMER NAME\t\t: %s %s\n",addacc.fname,addacc.lname);

printf("\t\tCURRENT BALANCE IS LKR.%f\n\n",addacc.balance);

}

}

fclose(oldaccrec);

Tryagain3:

printf("\n\t\tNo record more!");

printf("\n\t\tEnter 1 to go Main Menu or Enter 0 to Exit");

scanf("%d",&choice);

if(choice==1)

{

AnotherTransaction;

}

else if(choice==0)

{

closesys;

}

else

{

goto Tryagain3;

}

}

Edit Account Holder's details - sub task
void edit_customer_info

{

system("cls");

header;

int choice,choice1;

printf("\n\t\t\t\t\tEDIT CUSTOMER DETAILS \n\n");

FILE *oldaccrec;

FILE *newaccrec;

oldaccrec=fopen("userrecord.dat","r");

newaccrec=fopen("newuserrecord.dat","w");

printf("\t\tEnter Account No: ");

scanf("%ld",&editcustomerinfo.accno);

while(fscanf(oldaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",&addacc.accno,&addacc.fname,&addacc.lname,&addacc.type,&addacc.dob,&addacc.address,&addacc.tel,&addacc.balance)!=EOF)

{

if(addacc.accno==editcustomerinfo.accno)

{

printf("\t\tENTER ACCOUNT HOLDER's FIRST NAME: ");

scanf("%s",&editcustomerinfo.fname);

printf("\t\tENTER ACCOUNT HOLDER's LAST NAME: ");

scanf("%s",&editcustomerinfo.lname);

printf("\t\tENTER ADDRESS: ");

scanf("%s",&editcustomerinfo.address);

printf("\t\tENTER MOBILE NUMBER: ");

scanf("%s",&editcustomerinfo.tel);

fprintf(newaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",addacc.accno,editcustomerinfo.fname,editcustomerinfo.lname,addacc.type,addacc.dob,editcustomerinfo.address,editcustomerinfo.tel,addacc.balance);

printf("\n\t\tData Updated Successfully!\n\n");

}

else

{

fprintf(newaccrec,"%ld\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\n",addacc.accno,addacc.fname,addacc.lname,addacc.type,addacc.dob,addacc.address,addacc.tel,addacc.balance);

}

}

printf("\t\tInvalid Account No or No Record Found!");

fclose(oldaccrec);

fclose(newaccrec);

remove("userrecord.dat");

rename("newuserrecord.dat","userrecord.dat");

Tryagain8:

printf("\n\n\t\tEnter 1 to go Main Menu or Enter 0 to Exit");

scanf("%d",&choice);

if(choice==1)

{

AnotherTransaction;

}

else if(choice==0)

{

closesys;

}

else

{

goto Tryagain8;

}

}