1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
void main() {
system("color 8a");
SYSTEMTIME t;
int choice, txnCode;
/*TARBANK Logo
printf("\n\ ========== __ ~~~~> ~~~~>\n");
printf("\n\||===||===|| / \ | @@ > | @@ >\n");
printf("\n\ || / /_ \ | @ > | >\n");
printf("\n\ || / /__\ \ | << | <<\n");
printf("\n\ || / / \ \ | \ \ | @@ >\n");
printf("\n\ || /_/ \_\ | \ \ |___ >\n");
*/
//Display Today's Date and Time
GetLocalTime(&t);
printf("\t\tDate! Today is %d/%d/%d and \n\
it's %d:%d:%d now.\n\n", t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);
printf("\t\tCustomer:Press 1\n");
printf("\t\tManager:Press 2\n\n");
printf("\t\tYour choice: ");
scanf("%d", &choice);
if(choice == 1) {
fptr1 = fopen("Customer.txt", "r");
fptr2 = fopen("Customer_temp.txt", "w");
//Check if customer.txt can be opened or not
if(fptr1 == NULL || fptr2 == NULL) {
printf("ERROR in opening file!Try again.....");
exit(-1);
}
//Randomly generate ATM No.(6-10)
srand(time(NULL));
atm = (rand() % 5) + 6;
//Display ATM No.
printf("ATM No: %d\n", atm);
//Prompt and read user's A/C No.
printf("\t\tPlease enter your A/C No:\t\t_____\b\b\b\b\b");
scanf("%s", &temp.accNo);
fflush(stdin);
//Prompt and read user's PIN No.
printf("\t\tPlease enter your PIN No:\t\t_____\b\b\b\b\b");
scanf("%s",temp.PIN);
fflush(stdin);
//Read customer.txt
while(!feof(fptr1)) {
for(int i = 0; i < 10; i++) {
fscanf(fptr1, "%[^|]|%[^|]|%[^|]|%c|%[^|]|%[^|]|%[^|]|%d|%d%d%d%d%d%d",
&customer[i].accNo, &customer[i].PIN, &customer[i].name, &customer[i].gender,
&customer[i].address, &customer[i].state, &customer[i].contact,
&customer[i].balance, &customer[i].lastTxn.date, &customer[i].lastTxn.month, &customer[i].lastTxn.year,
&customer[i].lastTxn.hr, &customer[i].lastTxn.min, &customer[i].lastTxn.sec);
//Check if the results match(update is pending)
if(strcmp(temp.accNo, customer[i].accNo) == 0 && strcmp(temp.PIN, customer[i].PIN) == 0) {
customerCode = i;
strcpy(temp.name, customer[i].name);
temp.balance = customer[i].balance;
temp.gender = customer[i].gender;
strcpy(temp.address, customer[i].address);
strcpy(temp.state, customer[i].state);
strcpy(temp.contact, customer[i].contact);
temp.lastTxn.year = customer[i].lastTxn.year;
temp.lastTxn.month = customer[i].lastTxn.month;
temp.lastTxn.date = customer[i].lastTxn.date;
temp.lastTxn.hr = customer[i].lastTxn.hr;
temp.lastTxn.min = customer[i].lastTxn.min;
temp.lastTxn.sec = customer[i].lastTxn.sec;
}
}
}
printf("\n");
printf("Name: %s\n\n", temp.name);
printf("Balance: RM%d\n\n", temp.balance);
printf("Last Transaction Date: %d/%d/%d %d:%d:%d\n\n", temp.lastTxn.date, temp.lastTxn.month, temp.lastTxn.year,
temp.lastTxn.hr, temp.lastTxn.min, temp.lastTxn.sec);
|