---------------------------------------------------------------------------------PHP Code:-- Please help me out. I have spent 48hrs nonstop trying to get my this set of programs to work. I have to submit my project on 18-19 this NOV.
-- Basically i want to create a list of menu driven screens allowing the user to navigate through them: allowing him to create/add, delete and seek and display list of members and films rented by a video club.
-- I have created the screens and a screen allowing member to be added to a file(memberz.dat) but can't work around to delete a record and list them.
-- Neither i can coordinate them to work all together. Plzzz help me. This course work will allow me to pass my whole diploma level.
--Have been borrowing bits and pieces from diff. programs. They do work. I also need to enter a current fee charged for hiring a film and calculate any outstanding fee.
I am confused and stucked no way i'll be able to complete. Just have to scroll up and down the screen for days. Well here is what i have done. I would be very grateful to all you ppl. Plzzzz help me out. i have had loads of sample code but can't get them working after modify.
I am using Turbo C++ 3.1 to run them.
here are programs:
---------------------------------------------------------------------------------Code:/* Program Name : mainmenu.cpp Date : 08-Nov-05 Written By : Ramtohul Ravin Purpose : Designing a Member Layout Screen */ #include <stdio.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include "memmenu.h" char menu(void); void backup(void); // MAIN MENU OPTIONS LISTING char menu(void) { char optrtn; clrscr(); drawscreen1(); gotoxy(29,9); printf("* * * MAIN MENU * * *"); gotoxy(10,13); printf("MEMBERS.............................1 "); gotoxy(10,15); printf("FILMS & MOVIES......................2 "); gotoxy(10,17); printf("UTILITY.............................3 "); gotoxy(10,19); printf("EXIT................................4 "); gotoxy(10,23); printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: "); optrtn = getch(); return optrtn; } // CHOICES & CASES DEFINITIONS void main(void) { char option,exit_opt; /* menu and exit option*/ char mem_opt, mov_opt; char back_opt; /* MAIN MENU */ do { do { option = menu(); if (option == '1') // Members Main Menu { member(); getch(); } else if (option == '2') // Movies Main Menu { movie(); getch(); } else if (option == '3') // Utility BackUp { clrscr(); drawscreen1(); gotoxy(20,15); printf("DO YOU WANT TO SAVE THE DETAILS YOU ENTERED?\n\n"); printf("Press 'Y' To CONFIRM, Any Other Key To CANCEL"); back_opt = getch(); flushall(); if (back_opt == 'y' || back_opt =='Y') { clrscr(); backup(); } } else if (option == '4') /* exit option */ { gotoxy(3,25); printf("SURE TO QUIT?, Press 'Y' To Confirm OR Anykey To Cancel"); exit_opt = getch(); flushall(); if (exit_opt == 'y' || exit_opt == 'Y') { clrscr(); drawscreen1(); gotoxy(3,4); printf(">> Exit To system <<\n\n"); exitmenu(); } } else /* user presses an invalid key display msg error */ { gotoxy(3,25); printf("Error: Invalid Keypress! Select An Option Between 1 and 4"); getch(); flushall(); /* clears buffer */ } } while (option > '4' || option < '1' ); } while (option != '`'); /* unlimated loop */ } /***************************************************SAVING & BACKING UP THE ENTRIES TO A FILENAME ***************************************************/ void backup(void) { char filename[20]; char save_opt; int k; FILE *fpt; { gotoxy(1,8); printf("Please Enter the path and filename to save to:"); gotoxy(1,10); printf("Example: c:\\mydbfile.txt"); gotoxy(48,8); /* move cursor back to line 8 */ gets(filename); flushall(); fpt = fopen (filename,"a"); /*open file for appending mode */ if (fpt== NULL) { gotoxy(1,12); fprintf(stderr, "Error opening file %s.",filename); gotoxy(1,25); printf("Database was not saved!"); getch(); exit; } } }
HEADER FILE
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------Code:// Program Name : Memmenu.h // Written by : Ravin // Date : 15-Nov-05 #include <stdio.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include "screeen.h" #define TRUE 1 char member(void); char movie(void); // MEMBERS MAIN MENU OPTIONS LISTING char member(void) { char optrtn; clrscr(); drawscreen1(); gotoxy(24,9); printf("* * * MARINA MEMBERS MENU * * *"); gotoxy(10,13); printf("ADD NEW MEMBERS.....................1 "); gotoxy(10,15); printf("DELETE EXISTING MEMBERS.............2 "); gotoxy(10,17); printf("LIST THEM ALL.......................3 "); gotoxy(10,19); printf("EXIT................................4 "); gotoxy(10,23); printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: "); optrtn = getch(); return optrtn; } // CHOICES & CASES DEFINITIONS /*************************************************** ADDING & CREATING NEW MEMBERS & SET UP NEW DATABASE **************************************************/ // FILMS MAIN MENU OPTION LISTING char movie(void) { char optrtn; clrscr(); drawscreen1(); gotoxy(24,9); printf("* * * MARINA MOVIES MENU * * *"); gotoxy(10,13); printf("ADD NEW MOVIES.....................1 "); gotoxy(10,15); printf("DELETE EXISTING MOVIES.............2 "); gotoxy(10,17); printf("LIST ALL MOVIES....................3 "); gotoxy(10,19); printf("EXIT...............................4 "); gotoxy(10,23); printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: "); optrtn = getch(); return optrtn; }
THIS ONE WORKS FINE
---------------------------------------------------------------------------------
------------------------------------------------------------------------------Code://Program Name : screeen.h //Written By : Ravin RAMTOHUL //Date :15-11-2005 #include <stdio.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include <dos.h> void drawscreen1(void); void drawscreen2(void); void exitmenu(void); //CREATES THE SCREEN LAYOUT FOR MAIN MENU void drawscreen1(void) { struct date d; clrscr(); gotoxy(25,2); printf ("*** THE MARINA MOVIE CLUB ***"); gotoxy(27,4); printf(" NORTHOLT MARINA BRANCH "); gotoxy(5,8); printf("---------------------------------------------------------------------"); gotoxy(5,10); printf("---------------------------------------------------------------------"); /* getdate example */ gotoxy(25,6); getdate(&d); printf("TODAY WE'RE ON THE : %d-%d-%d", d.da_day, d.da_mon, d.da_year); } // CREATES THE SCREEN LAYOUT FOR SUB MENUS FROM MAIN MENU void drawscreen2(void) { struct date d; clrscr(); /* getdate example */ gotoxy(20,7); getdate(&d); printf("TODAY WE'RE ON THE : %d-%d-%d", d.da_day, d.da_mon, d.da_year); gotoxy(25,2); printf(" THE MARINA MOVIE CLUB "); gotoxy(25,3); printf(" NORTHOLT MARINA BRANCH "); } // EOF // ExitMenu function void exitmenu(void) { clrscr(); gotoxy(23,10); printf("Thank you for using this program"); gotoxy(23,11); printf("Coded by: RAMTOHUL RAVIN"); exit(0); }
ADDING A NEW MEMBER AND CREATING A FILE
---------------------------------------------------------------------------------
Code:/* Program Name : Addmem.cpp Date : 08-Nov-05 Written By : Ramtohul Ravin Purpose : Adding a member */ #include <stdio.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include "screeen.h" #define TRUE 1 typedef struct { char surname[40]; int memcode; char name[20]; char street[60]; char town[20]; char postcode[7]; int houseno; long int telno; float currfee; float outfee; } record; record readscreen(record member); void writefile(record member); FILE *fpt; main() { int flag = TRUE; record member; fpt = fopen("memberz.dat", "w"); /* MAIN LOOP */ while (flag) { drawscreen2(); gotoxy(24,5); printf(" ***** MEMBERS PAGE ***** "); gotoxy(12,24); printf("*** Please Enter 'XXX' At --SURNAME-- To Finish ***"); gotoxy(6,9); /* Enter Data For Members */ printf("SURNAME: "); scanf("%s", member.surname); /* Test for Termination */ if (strcmp(member.surname, "XXX") == 0) break; member = readscreen(member); writefile(member); } fclose(fpt); } record readscreen(record member) /* Read Remaining Data */ { gotoxy(42,9); printf("MEMBER CODE: "); scanf("%d", &member.memcode); gotoxy(6,11); printf("NAME: "); scanf("%s", member.name); gotoxy(6,13); printf("HOUSE NO.: "); scanf("%d", &member.houseno); gotoxy(6,17); printf("TOWN: "); scanf("%s", member.town); gotoxy(6,19); printf("POSTCODE: "); scanf("%s", member.postcode); gotoxy(42,17); printf("CONTACT NO.: "); scanf("%d", &member.telno); gotoxy(6,21); printf("Total Fee For The Month: "); scanf(" %2f", &member.currfee); gotoxy(6,23); printf("Outstanding Fee for the Month: "); scanf(" %2f", &member.outfee); gotoxy(6,15); printf("STREET: "); scanf("%s", member.street); return(member); } void writefile(record member) /* write remaining data to a data file */ { fprintf(fpt, " %d\n", member.memcode); fprintf(fpt, " %s\n", member.surname); fprintf(fpt, " %s\n", member.name); fprintf(fpt, " %s\n", member.houseno); fprintf(fpt, " %s\n", member.street); fprintf(fpt, " %s\n", member.town); fprintf(fpt, " %s\n", member.postcode); fprintf(fpt, " %d\n", member.telno); fprintf(fpt, " %2f\n", member.currfee); fprintf(fpt, " %2f\n", member.outfee); return; }



LinkBack URL
About LinkBacks


