Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include <time.h>
- #include <stdlib.h>
- #define max 10
- typedef struct employee
- {
- int personal_code;
- char Emp_Name[25];
- char Emp_Title[25];
- }EMPLOYEE;
- EMPLOYEE emp[max];
- typedef struct customer
- {
- float company_code;
- int personal_code;
- int identification_number;
- int reg_confirmation,registration_save;
- char identification_type[20];
- }CUSTOMER;
- CUSTOMER cus[max];
- typedef struct company
- {
- int company_id;
- char company_name[20];
- char contact_person[20];
- int contact_number;
- }COMPANY;
- COMPANY comp[max];
- struct salesdata
- {
- }SALES;
- void Registration();
- void Register1();
- void Update1();
- int RegisterCustomer();
- void RegisterEmployee();
- void RegisterCompany();
- void UpdateCompany();
- void UpdateEmployee();
- void UpdateCustomer();
- void PasswordSystem();
- void Details ();
- void Display();
- void DisplayCustomer();
- void DisplayEmployee();
- void DisplayPurchases();
- void DisplayCredit();
- float Purchase ();
- void menu();
- void pmenu();
- void Credit();
- void search();
- float EightySeven_Code = 8.7;
- float Ninty_Code = 9.0;
- float Diesel_Code =9.5;
- int count=0; //counter for customers
- int count2=0; //counter for employees
- int main ()
- {
- int choice;
- char username[15];
- printf("\t\t\tEagle Energy Jamaica Ltd.\n\n");
- printf(" Welcome, please log in as a manager, cashier or pump attendant:\n");
- scanf("%s",username);
- if ((strcmp(username,"manager")==0))
- {
- menu();
- }
- else if ((strcmp(username,"cashier")==0))
- {
- menu();
- }
- else if ((strcmp(username,"pump")==0))
- {
- pmenu();
- }
- else
- {
- printf("Your input did not match a position, please try again...");
- getch();
- main();
- }
- }
- //THIS PASSWORD SYSTEM WILL GIVE THE USER 3 ATTEMPTS TO ENTER THE CORRECT INFORMATION
- //THE PROGRAM WILL EXIT UPON 3 FAILED ATTEMPTS
- /*void PasswordSystem()
- {
- FILE* file_ptr = NULL;
- char name[20];
- char password[10];
- int attempt,i;
- int id_code;
- char password1[20];
- attempt = i = 0;
- //THE SYSTEM PASSWORD AND USER CAN BE EASILY CHANGED AT LINE 100
- i++;
- printf ("\tYou have 3 attempts, This is attempt # %d\n\n",i);
- printf("Enter SYSTEM username: ");
- scanf("%s",name);
- printf("Enter SYSTEM password: ");
- scanf("%s",password);
- while (((attempt < 3 || strcmp(name, "admin") == 0) && strcmp(password, "pass") == 0))
- {
- if (strcmp(name, "admin") == 0 && strcmp(password, "pass") == 0)
- {
- printf("\n\n\t\tAccess granted\n");
- system ("pause");
- system("cls");
- //EMPLOYEES WILL USE THEIR NAME AS THE PASSWORD(ALL LOWER CASE)
- file_ptr = fopen("EmployeeRegistration.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else {
- printf (" Employee's password is their name\n");
- //fscanf (file_ptr,"%d %s %s \n",&EMPLOYEE.personal_code,EMPLOYEE.Emp_Name,EMPLOYEE.Emp_Title);
- fread (&EMPLOYEE,sizeof(EMPLOYEE),1,file_ptr);
- printf("hi1\n");
- printf("%d %s %s \n",EMPLOYEE.personal_code,EMPLOYEE.Emp_Name,EMPLOYEE.Emp_Title);
- printf("hi2\n");
- printf(" Please enter your employee ID\n");
- scanf ("%d",&id_code);
- printf(" Please enter password\n");
- scanf ("%s",password1);
- while(!feof(file_ptr))
- {
- if((id_code == EMPLOYEE.personal_code) && (strcmp(password1,EMPLOYEE.Emp_Name) == 0))
- {
- printf("access granted...");
- printf("Id confirmed\n");
- system ("pause");
- break;
- system("cls");
- }
- else
- {
- printf("access denied !");
- break;
- }
- }
- }
- }
- else {
- printf (" ");
- }
- }
- fclose(file_ptr);
- attempt++;
- }*/
- void PasswordSystem()
- {
- }
- void menu ()
- {
- int choice;
- system("cls");
- printf (" \t\tEagle Energy System Options \n");
- printf("\n 1) Add & Update");
- printf("\n 2) Display Records");
- printf("\n 3) Search for Customer");
- printf("\n 4) Details");
- printf("\n 0) Quit\n\n");
- scanf ("%d", &choice);
- switch (choice)
- {
- case 1 : Registration(); break;
- case 2 : Display(); break;
- case 3 : break;
- case 4 : Details(); break;
- case 0 : return;
- }
- }
- void pmenu()
- {
- int choice;
- system("cls");
- printf (" \t\tEagle Energy System Options \n");
- printf("\n 1) Sell Petrol");
- printf("\n 2) Search for Customer");
- scanf ("%d", &choice);
- switch (choice)
- {
- case 1: Purchase();break;
- case 2: break;
- default: pmenu(); break;
- }
- pmenu();
- }
- void Registration()
- {
- int registration_choice;
- system("cls");
- printf ("\n\nPlease select an option.\n");
- printf ("1) Register a Customer/Employee.\n");
- printf ("2) Update a Customer/Employee.\n\n");
- scanf("%d", ®istration_choice);
- system("cls");
- switch (registration_choice)
- {
- case 1:
- Register1();
- break;
- case 2:
- Update1();
- break;
- default:
- printf ("You have selected an invalid option.\n");
- }
- return;
- }
- void Register1()
- {
- int registration_choice;
- registration_choice=0;
- printf ("\n\nPlease select an option.\n");
- printf ("1) Register a Customer.\n");
- printf ("2) Register an Employee.\n\n");
- scanf("%d", ®istration_choice);
- switch (registration_choice)
- {
- case 1:
- RegisterCustomer();
- break;
- case 2:
- RegisterEmployee();
- break;
- default:
- printf ("You have selected an invalid option.\n");
- }
- return;
- }
- int RegisterCustomer()
- {
- float company_code;
- int registration_save,reg_confirmation,personal_code,option;
- FILE* file_ptr = NULL;
- personal_code = 0;
- system("cls");
- printf (" We accept PASSPORT, NATIONAL ID and DRIVER's LICENSES\n as form of identification, please enter your ID # then enter the type of \n identification.\n\n");
- printf (" Please enter your Identification Number: ");
- scanf ("%d", &cus[count].identification_number);
- // do{
- printf (" Please select the form of identification: \n");
- printf (" 1. Passport\n");
- printf (" 2. National ID\n");
- printf (" 3. Driver's License'\n");
- scanf ("%d",&option);
- switch(option)
- {
- case 1: strcpy(cus[count].identification_type, "passport");
- break;
- case 2: strcpy(cus[count].identification_type, "national");
- break;
- case 3: strcpy(cus[count].identification_type, "drivers");
- break;
- default: printf(" You have entered an invalid ID type. Please try again..\n");
- RegisterCustomer();
- }
- /* fflush(stdin);
- gets(cus[].identification_type);
- // scanf ("%s", cus[].identification_type);
- if ((strcmp(cus[].identification_type, "passport") == 0) || (strcmp(cus[].identification_type, "national") == 0) || (strcmp(cus[].identification_type, "drivers") == 0))
- {
- printf (" ");
- }
- else
- {
- printf(" You have entered an invalid ID type. Please try again..\n");
- }
- }while((strcmp(cus[].identification_type, "passport") != 0) || (strcmp(cus[].identification_type, "national") != 0) || (strcmp(cus[].identification_type, "drivers") != 0));*/
- do{
- printf ("\n Please enter company code: ");
- scanf ("%f", &cus[count].company_code);
- if ((cus[count].company_code == EightySeven_Code) || (cus[count].company_code == Ninty_Code) || (cus[count].company_code == Diesel_Code))
- {
- break;
- }
- else
- {
- printf(" Invalid company code, please try again.\n");
- }
- }while ((cus[count].company_code != EightySeven_Code) && (cus[count].company_code != Ninty_Code) && (cus[count].company_code != Diesel_Code));
- printf (" Please enter desired identification number: \n");
- scanf ("%d", &cus[count].personal_code);
- printf("\n\n Is this information correct?\n\n");
- printf("Identification number: %d\n", cus[count].identification_number);
- printf("identification type : %s\n",cus[count].identification_type);
- printf("ID : %d\n",cus[count].personal_code);
- printf("Company Code : %.1f\n", cus[count].company_code);
- printf(" \n 1) for Yes \n 2) for No\n");
- scanf ("%d", ®_confirmation);
- switch (reg_confirmation)
- {
- case 1: printf (" Would you like to save employee information ?\n");
- printf(" 1) for Yes \n 2) for No\n");
- scanf ("%d", ®istration_save);
- switch(registration_save)
- {
- case 1: file_ptr = fopen("CustomerRegistration1.dat", "ab");
- //case 1: FILE* file_ptr = fopen("c:\\users\\shawn\\Registration.txt", "a");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else {
- //fprintf (file_ptr,"%s %d %d %f\n",cus[].identification_type,cus[].identification_number,cus[].personal_code,cus[].company_code);
- fwrite(&cus[count], sizeof(CUSTOMER), 1, file_ptr);
- }
- fclose(file_ptr);
- count++;
- menu();
- case 2: return;
- default: printf ("Invalid selection.\n");
- }
- case 2: return 0;
- }
- return personal_code;
- }
- void RegisterEmployee()
- {
- FILE* file_ptr = NULL;
- int personal_code;
- int reg_confirmation,registration_save;
- reg_confirmation = registration_save = personal_code=0;
- do
- {
- system("cls");
- printf(" Please enter employee's desired ID\n ");
- scanf ("%d",&emp[count2].personal_code);
- printf(" Please enter the employee's first name \n ");
- scanf ("%s", emp[count2].Emp_Name);
- printf(" Please enter the employee's job title \n ");
- fflush(stdin);
- gets(emp[count2].Emp_Title);
- printf(" \n\nIs this information correct?\n\n");
- printf("ID : %d\n",emp[count2].personal_code);
- printf("Name : %s\n",emp[count2].Emp_Name);
- printf("Title: %s\n",emp[count2].Emp_Title);
- printf(" \n 1) Yes \n 2) Retry\n 3) Return to main menu..\n");
- scanf ("%d", ®_confirmation);
- }while((reg_confirmation != 1) && (reg_confirmation!=3));
- switch (reg_confirmation)
- {
- case 1: printf (" Would you like to save employee information ?\n");
- printf(" 1) for Yes \n 2) for No\n");
- scanf ("%d", ®istration_save);
- switch(registration_save)
- {
- case 1: file_ptr = fopen("EmployeeRegistration.dat", "ab");
- //case 1: FILE* file_ptr = fopen("c:\\users\\shawn\\Registration.txt", "a");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else {
- // fprintf (file_ptr,"%d %s %s \n",EMPLOYEE.personal_code,EMPLOYEE.Emp_Name,EMPLOYEE.Emp_Title);
- fwrite(&emp[count],sizeof(EMPLOYEE),1, file_ptr);
- }
- fclose(file_ptr);
- count2++;
- case 2: return;
- default: printf ("Invalid selection.\n");
- }
- case 2: return ;
- }
- }
- void Update1()
- {
- int update_choice;
- printf ("\n\nPlease select an option.\n");
- printf ("1) Update a Customer.\n");
- printf ("2) Update an Employee.\n\n");
- scanf("%d", &update_choice);
- switch (update_choice)
- {
- case 1:
- UpdateCustomer();
- break;
- case 2:
- UpdateEmployee();
- break;
- default:
- printf ("You have selected an invalid option.\n");
- }
- return;
- }
- void UpdateCustomer()
- {
- int position=-1, i,code;
- int option, reg_confirmation, registration_save;
- FILE* file_ptr = NULL;
- file_ptr = fopen("CustomerRegistration1.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" Error opening file..\n");
- }
- else
- {
- fread(&cus[count],sizeof(CUSTOMER),1,file_ptr);
- printf("Please enter the personal code for the record you want to change: ");
- scanf("%d",&code);
- for(i=0;i<count;i++)
- {
- if(code==cus[i].personal_code)
- position=i;
- }
- if(position==-1)
- {
- printf("Record not found!");
- menu();
- }
- else
- {
- printf (" Please enter your Identification Number: ");
- scanf ("%d", &cus[position].identification_number);
- printf (" Please select the form of identification: \n");
- printf (" 1. Passport\n");
- printf (" 2. National ID\n");
- printf (" 3. Driver's License'\n");
- scanf ("%d",&option);
- switch(option)
- {
- case 1: strcpy(cus[position].identification_type, "passport");
- break;
- case 2: strcpy(cus[position].identification_type, "national");
- break;
- case 3: strcpy(cus[position].identification_type, "drivers");
- break;
- default: printf(" You have entered an invalid ID type. Please try again..\n");
- // RegisterCustomer();
- }
- do
- {
- printf ("\n Please enter company code: ");
- scanf ("%f", &cus[position].company_code);
- if ((cus[position].company_code == EightySeven_Code) || (cus[position].company_code == Ninty_Code) || (cus[position].company_code == Diesel_Code))
- {
- break;
- }
- else
- {
- printf(" Invalid company code, please try again.\n");
- }
- }while ((cus[position].company_code != EightySeven_Code) && (cus[position].company_code != Ninty_Code) && (cus[position].company_code != Diesel_Code));
- printf (" Please enter desired identification number: \n");
- scanf ("%d", &cus[position].personal_code);
- printf("\n\n Is this information correct?\n\n");
- printf("Identification number: %d\n",cus[position].identification_number);
- printf("identification type : %s\n",cus[position].identification_type);
- printf("ID : %d\n",cus[position].personal_code);
- printf("Company Code : %.1f\n",cus[position].company_code);
- printf(" \n 1) for Yes \n 2) for No\n");
- scanf ("%d", ®_confirmation);
- switch (reg_confirmation)
- {
- case 1: printf (" Would you like to save employee information ?\n");
- printf(" 1) for Yes \n 2) for No\n");
- scanf ("%d", ®istration_save);
- switch(registration_save)
- {
- case 1: file_ptr = fopen("CustomerRegistration1.dat", "ab");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else
- {
- //fprintf (file_ptr,"%s %d %d %f\n",cus[].identification_type,cus[].identification_number,cus[].personal_code,cus[].company_code);
- fwrite(&cus[position], sizeof(CUSTOMER), 1, file_ptr);
- }
- fclose(file_ptr);
- default: printf ("Invalid selection.\n");
- }
- }
- }
- }
- fclose(file_ptr);
- }
- void UpdateEmployee()
- {
- int position=-1, i, code;
- int option, reg_confirmation, registration_save;
- FILE* file_ptr = NULL;
- file_ptr = fopen("EmployeeRegistration.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" Error opening file..\n");
- }
- else
- {
- fread(&emp[count2],sizeof(EMPLOYEE),1,file_ptr);
- printf("Please enter the personal code for the record you want to change: ");
- scanf("%d",&code);
- for(i=0;i<count;i++)
- {
- if(code==emp[i].personal_code)
- position=i;
- }
- if(position==-1)
- {
- printf("Record not found!");
- menu();
- }
- else
- {
- do
- {
- //system("cls");
- printf(" Please enter employee's desired ID\n ");
- scanf ("%d",&emp[position].personal_code);
- printf(" Please enter the employee's first name \n ");
- scanf ("%s", emp[position].Emp_Name);
- printf(" Please enter the employee's job title \n ");
- fflush(stdin);
- gets(emp[position].Emp_Title);
- printf(" \n\nIs this information correct?\n\n");
- printf("ID : %d\n",emp[position].personal_code);
- printf("Name : %s\n",emp[position].Emp_Name);
- printf("Title: %s\n",emp[position].Emp_Title);
- printf(" \n 1) Yes \n 2) Retry\n 3) Return to main menu..\n");
- scanf ("%d", ®_confirmation);
- }while((reg_confirmation != 1) && (reg_confirmation!=3));
- switch (reg_confirmation)
- {
- case 1: printf (" Would you like to save employee information ?\n");
- printf(" 1) for Yes \n 2) for No\n");
- scanf ("%d", ®istration_save);
- switch(registration_save)
- {
- case 1: file_ptr = fopen("EmployeeRegistration.dat", "ab");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else
- {
- fwrite(&emp[count],sizeof(EMPLOYEE),1, file_ptr);
- }
- fclose(file_ptr);
- case 2: return;
- default: printf ("Invalid selection.\n");
- }
- case 2: return ;
- }
- }
- }
- fclose(file_ptr);
- getch();
- }
- float Purchase()
- {
- int sale_identification_number, i;
- int purchase_decision,gas_choice;
- int id_code=-1;
- char petrol_name[12];
- int pump_number;
- float amount_per_gallon , amount_sold , value_of_sale ,cost,Diesel,NINTY,EIGHTYSEVEN;
- char identification_type1[10];
- int identification_number1,personal_code1;
- float company_code1;
- time_t rawtime;
- struct tm * timeinfo;
- personal_code1 = company_code1 = identification_number1 = 0;
- system ("cls");
- time ( &rawtime );
- timeinfo = localtime ( &rawtime );
- cost = gas_choice = sale_identification_number = pump_number = amount_per_gallon = amount_sold = value_of_sale = 0;
- srand (time(NULL));
- sale_identification_number = rand()%1000;
- Diesel = 101.71;
- NINTY = 99.81;
- EIGHTYSEVEN = 115.21;
- printf ("Please select the type of gas you would like to purchase \n");
- printf ("\n1) Diesel");
- printf ("\n2) Ninty");
- printf ("\n3) Eighty Seven");
- printf ("\n>>: ");
- scanf ("%d", &gas_choice);
- if (gas_choice ==1)
- {
- amount_per_gallon = Diesel;
- strcpy(petrol_name,"Diesel");
- }
- if (gas_choice ==2)
- {
- amount_per_gallon = NINTY;
- strcpy(petrol_name,"Ninty");
- }
- if (gas_choice ==3)
- {
- amount_per_gallon = EIGHTYSEVEN;
- strcpy(petrol_name,"Eighty Seven");
- // printf ("hi");
- }
- fflush(stdin);
- printf ("Please enter customer's ID Code:");
- scanf("%d",&id_code);
- FILE *fp = NULL;
- fp = fopen("CustomerRegistration1.dat", "rb");
- if(fp== NULL)
- {
- printf("Error Acessing file");
- }
- else
- {
- while(!feof(fp))
- {
- //fscanf(fp,"%d", &id);
- fscanf (fp,"%s %d %d %f\n",identification_type1,&identification_number1,&personal_code1,&company_code1);
- if (id_code==identification_number1)
- {
- printf("Id confirmed\n");
- system ("pause");
- getch();
- system("cls");
- break;
- }
- }
- if (id_code==-1)
- {
- printf ("\nID Not found, please try again or register.");
- return;
- }
- fclose(fp);
- }
- printf ("\nPlease enter the amount of gallons being purchased\n");
- scanf ("%f",&amount_sold);
- value_of_sale = (amount_per_gallon * amount_sold);
- FILE* file_ptr = NULL;
- file_ptr = fopen("purchases.dat","a+");
- fprintf(file_ptr,"%d %d %s %d %f %f %s",sale_identification_number,id_code,petrol_name,(int)amount_sold,amount_per_gallon,value_of_sale,asctime(timeinfo));
- fclose(file_ptr);
- printf ("Would you like to print a reciept or start again ? Please enter 1 or 2");
- printf ("\n1) Start again");
- printf ("\n2) Print Reciept \n");
- scanf ("%d", &purchase_decision);
- if (purchase_decision == 1)
- {
- Purchase();
- }
- else if (purchase_decision == 2)
- {
- system("cls");
- }
- printf ("\t\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t\t176 Port Royal Street, Kingston\n");
- printf ("\t\t\t\t\tBranch 9.5\n\n");
- printf ("The transaction number is: %d \n", sale_identification_number);
- printf ("Eagle Energy ID :");
- printf (" \nCustomer ID :%d",id_code);
- //printf (" \nPetrol Name :%s",petrol_name);
- printf (" \nPetrol Name : %s",petrol_name);
- printf (" \nAmount sold in Gallons :%d Gal.",(int)amount_sold);
- printf (" \nCost Per Gallon :%.3f",amount_per_gallon);
- printf (" \nTotal Cost :%.3f",value_of_sale);
- printf (" \nThis purchase was made on:%s", asctime(timeinfo));
- cost = value_of_sale;
- system("pause");
- return cost;
- }
- void Display()
- {
- int displaychoice;
- displaychoice = 0;
- printf(" What data would you like to display ?\n");
- printf ("1)Customer Information\n");
- printf ("2)Employee Information\n");
- printf ("3)Purchase Information\n");
- printf ("4)Credit Information\n");
- scanf("%d",&displaychoice);
- switch (displaychoice)
- {
- case 1 : DisplayCustomer();
- break;
- case 2 : DisplayEmployee();
- break;
- case 3 : DisplayPurchases();
- break;
- case 4 : DisplayCredit();
- break;
- }
- }
- void DisplayCustomer()
- {
- FILE* file_ptr = NULL;
- file_ptr = fopen("CustomerRegistration1.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- }
- else
- {
- int i;
- system("cls");
- printf ("\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t Customer Information\n\n");
- for(i=0;i<count;i++)
- {
- printf("Identification number: %d\n", cus[i].identification_number);
- printf("Identification type : %s\n",cus[i].identification_type);
- printf("ID : %d\n",cus[i].personal_code);
- printf("Company Code : %.1f\n\n", cus[i].company_code);
- }
- }
- fclose(file_ptr);
- getch();
- }
- void DisplayEmployee()
- {
- FILE* file_ptr = NULL;
- file_ptr = fopen("EmployeeRegistration.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" File does not exist\n");
- getch();
- }
- else
- {
- int i;
- system("cls");
- printf ("\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t Employee Information\n\n");
- for(i=0;i<count;i++)
- {
- printf("ID : %d\n",emp[i].personal_code);
- printf("Name : %s\n",emp[i].Emp_Name);
- printf("Title: %s\n",emp[i].Emp_Title);
- }
- }
- getch();
- fclose(file_ptr);
- }
- void DisplayPurchases()
- {
- FILE *file_get = NULL;
- char temp[5][25];
- struct purchase_info{
- int sale_id,code,sold;
- char name[7],thetime [50];
- float gallon,sale;
- } purchases;
- printf("-------------------------------------------------------------------\n");
- printf("| Purchases |\n");
- printf("-------------------------------------------------------------------\n\n");
- file_get = fopen("purchases.dat","r");
- if(file_get == NULL){
- printf("File not found");
- return;
- }
- else
- {
- while(!feof(file_get)){
- fscanf(file_get,"%d %d %s %d %f %f %s %s %s %s %s",&purchases.sale_id,&purchases.code,purchases.name,&purchases.sold,&purchases.gallon,&purchases.sale,temp[0],temp[1],temp[2],purchases.thetime,temp[4]);
- printf ("\t\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t\t176 Port Royal Street, Kingston\n");
- printf ("\t\t\t\t\tBranch 9.5\n\n");
- printf ("The transaction number is: %d \n", purchases.sale_id);
- printf ("Eagle Energy ID :");
- printf (" \nCustomer ID :%d",purchases.code);
- printf (" \nPetrol Name : %s",purchases.name);
- printf (" \nAmount sold in Gallons :%d Gal.",purchases.sold);
- printf (" \nCost Per Gallon :%.2f",purchases.gallon);
- printf (" \nTotal Cost :%.2f",purchases.sale);
- printf (" \nThis purchase was made on:%s", purchases.thetime);
- printf ("\n----------------------------------------------------------------------------\n");
- }
- }
- fclose(file_get);
- system("pause");
- }
- //THIS FUNCTION IS DISPLAY THE RELEVANT DETAILS OF THE COMPANY
- void Details()
- {
- system("cls");
- printf ("\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t176 Port Royal Street, Kingston\n");
- printf ("\t\t\t\tBranch 9.5\n");
- printf ("\t\t\t 904-3921 / 904-3922\n\n\n");
- printf ("Javaughn Jordan - Supervisor\n");
- printf ("Duvaun Clacken- Assistant Supervisor\n");
- printf ("Jhevante Mcdonald - Managing Director\n");
- printf ("Tami-Ann Russell - Executive Director\n\n");
- system ("pause");
- }
- void DisplayCredit()
- {
- FILE *file_get = NULL;
- FILE *file_get2 = NULL;
- int id_num = 0;
- float costt=0.0;
- int id_num2 = 0;
- float costt2=0.0;
- char temp[10][25];
- float total_cost = 0.0;
- printf("-------------------------------------------------------------------\n");
- printf("| Credit |\n");
- printf("-------------------------------------------------------------------\n\n");
- file_get = fopen("credit.dat","r");
- if(file_get == NULL){
- printf("File not found");
- return;
- }
- else{
- while(!feof(file_get)){
- fscanf(file_get,"%d %d %s %d %f %f %s %s %s %s %s",&id_num,temp[0],temp[1],temp[2],temp[3],&costt,temp[4],temp[5],temp[6],temp[7],temp[8],temp[9]);
- file_get2= fopen("credit.dat","r");
- while(!feof(file_get2)){
- fscanf(file_get,"%d %s %s %s %s %f %s %s %s %s %s",&id_num2,temp[0],temp[1],temp[2],temp[3],&costt2,temp[4],temp[5],temp[6],temp[7],temp[8],temp[9]);
- if(id_num == id_num2 ){
- total_cost = total_cost + costt2;
- }
- printf ("\t\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t\t176 Port Royal Street, Kingston\n");
- printf ("\t\t\t\t\tBranch 9.5\n\n");
- printf (" \nCustomer ID :%d",id_num);
- printf ("Total Credit: %d \n",total_cost);
- total_cost=0.0;
- fclose(file_get2);
- }
- fclose(file_get);
- system("pause");
- }
- //THIS FUNCTION IS DISPLAY THE RELEVANT DETAILS OF THE COMPANY
- void Details()
- {
- system("cls");
- printf ("\t\t\tEagle Energy Jamaica Limited\n");
- printf ("\t\t\t176 Port Royal Street, Kingston\n");
- printf ("\t\t\t\tBranch 9.5\n");
- printf ("\t\t\t 904-3921 / 904-3922\n\n\n");
- printf ("Javaughn Jordan - Supervisor\n");
- printf ("Duvaun Clacken- Assistant Supervisor\n");
- printf ("Jhevante Mcdonald - Managing Director\n");
- printf ("Tami-Ann Russell - Executive Director\n\n");
- system ("pause");
- }
- void search()
- {
- int position=-1, i,code;
- FILE* file_ptr = NULL;
- file_ptr = fopen("CustomerRegistration1.dat", "rb");
- if (file_ptr == NULL)
- {
- printf (" Error opening file..\n");
- }
- else
- {
- fread(&cus[count],sizeof(CUSTOMER),1,file_ptr);
- printf("Please enter the personal code for the record you want to search for: ");
- scanf("%d",&code);
- for(i=0;i<count;i++)
- {
- if(code==cus[i].personal_code)
- position=i;
- }
- if(position==-1)
- {
- printf("Record not found!");
- menu();
- }
- else
- {
- printf("Identification number: %d\n",cus[position].identification_number);
- printf("identification type : %s\n",cus[position].identification_type);
- printf("ID : %d\n",cus[position].personal_code);
- printf("Company Code : %.1f\n",cus[position].company_code);
- }
- }
- system("pause");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement