Sunteți pe pagina 1din 62

CD SHOP MANAGEMENT 1

T ABLE OF CONTENTS

 Acknowledgement

 Certificate

 Requirements

 Header files and their purpose

 Coding 

 Bibliography

BIKRAM BAHADUR
CD SHOP MANAGEMENT 2

A CKNOWLEDGEMENT
Looking   back   at   the   Project   Work,   I   wish   to   express   my

gratitude   to   a   multitude   of   people   who   have   directly   or

indirectly guided and helped me in the successful completion of

the project work.

          I   would   like   to   give   my   sincere   thanks   to

Mr.   NAVIN   Kr.   SINGH  and  Ms.   MOUMITA   DAS

GUPTA  our   Computer   Teachers   for   their   efficient   and

experienced guidance, who had helped me in whatever possible

areas. At last but not least, I would like to thank my parents

and   my   friends   for   their   kind   cooperation   and   their   support.

Without their help it was not possible to accomplish this project.

__________________

BIKRAM BAHADUR
CD SHOP MANAGEMENT 3

BIKRAM BAHADUR
ROLL NO:6615205

CERTIFICATE
This is to certify that BIKRAM  BAHADUR, student of class 

XII of R.L.J.D.M.C DAV PUBLIC SCHOOL has successfully 

completed this project on 

“ CD SHOP MANGEMENT  ”

AISSCE 2013­2014, under the supervision of

Mr. NAVIN KUMAR SINGH.

      _______________________________
Mr. NAVIN KUMAR SINGH
(INTERNAL EXAMINER)
                                                        
                               

       _______________________________
(SIGNATURE OF EXTERNAL EXAMINER)

BIKRAM BAHADUR
CD SHOP MANAGEMENT 4

        ______________________ 
MS. KALYANI NAYAK
(PRINCIPAL)

REQUIREMENTS
 HARDWARE REQUIRED

 Printer, to print the required  
 documents of the project.

  Compact Drive.

  Processor : Pentium IV

  Ram : 64 MB 

  Harddisk : 20 Gb.

 SOFTWARE REQUIRED

 Operating system : Windows  XP.

BIKRAM BAHADUR
CD SHOP MANAGEMENT 5

  Turbo C++,  for execution of 
 program.

  MS Word, for presentations of 
 output.

HEADER FILE & THEIR PURPOSE


1. FSTREAM.H : –
- for file handling, cin and cout.
2. PROCESS.H : –
- for exit() function.
3. CONIO.H : –
- for clrscr() and getch() functions.
4. STDIO.H : –
- for standard I/O operations.
5. STRING.H : –
- for string handling.
6. CTYPE.H : –
- for character handling.
7. IOMANIP.H :–
- for parameterized manipulators.

BIKRAM BAHADUR
CD SHOP MANAGEMENT 6

BIKRAM BAHADUR
CD SHOP MANAGEMENT 7

#include<iostream.h>
#include<fstream.h>
#include<process.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<dos.h>

void edit_cd(void);
void edit_member(void);
void edit_menu(void);
void entry_menu(void);
void list_menu(void);
void cd_records(void);
void introduction(void);

void introduction(void)
{
 clrscr();
 gotoxy(10,5);
 cprintf(" * * * * * * * * * * Welcome to Project * * * * * * * * * * ");
 gotoxy(31,6);
 textcolor(YELLOW);
 cprintf("­­­­­­­­­­­­­­­­­­");
 textcolor(6);
 gotoxy(20,10);
 cputs("COMPILED BY ::");
  gotoxy(30,14);
 cputs(" 1. ASUTOSH SHAW.");

BIKRAM BAHADUR
CD SHOP MANAGEMENT 8

 gotoxy(30,16);
 cputs(" 2. SOURAB KUMAR KESHRI.");
 gotoxy(30,18);
 cputs(" 3. NILOY MONDAL.");
 gotoxy(30,20);
 cputs(" 4. BIKRAM BAHADUR.");
 textcolor(RED);
 gotoxy(10,24);
 cprintf("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
 textcolor(GREEN+BLINK);
 gotoxy(26,30);
 cprintf(" | | CD CAFFE MANAGMENT | | ");
 gotoxy(3,35);
 textcolor(WHITE+BLINK);
 cprintf("PROJECT AT A GLANCE . . . .");
 gotoxy(3,36);
 textcolor(BLUE);
 cprintf("­­­­­­­­­­­­­­­­­­­­­­­­­­­");
 textcolor(YELLOW);
 gotoxy(5,39);
 cprintf("With the help of this project we can maintain records of CD'S 
and MEMBERS.");
 gotoxy(5,41);
 cprintf("One member can issue one CD at a time.If member does not 
return CD within");
 gotoxy(5,43);
 cprintf("15 days, the member have to pay fine of Rs.20/­ per day.");
 textcolor(LIGHTGRAY+BLINK) ;
 gotoxy(49,49);
 cprintf(" Press any key to continue. . .");
 textcolor(RED);
 getch();
}

class MENU

BIKRAM BAHADUR
CD SHOP MANAGEMENT 9

{
 public:
  void main_menu(void);
};

class CD
{
 public:
    void list(void);
    char *cdname(int);
 protected:
    void add_new_cd(int,char tname[33],char tcatagory[6],float,int,int);
    void update_copies(int,int,int);
    void modify(int, char[], char[], float);
    void deletion(void);
    int cd_found(int);
    int cdname_found(char []);
    int recordno(int);
    int available(int);
    char *cat_class(int);
    float cdprice(int);
    int no_of_copies(int);
    int cdcodeof(char[]);
    void display(int);
    int reccount(void);
    void delete_rec(int);
  private:
    int cdcode,copies;
    char name[33],catagory[6];
    float price;
    int avail;
};

class MEMBER
{

BIKRAM BAHADUR
CD SHOP MANAGEMENT 10

 public:
   void list(void) ;
 protected :
   void add_mem(int,int,char[],char[],char[],int,int,int);
   void modify(int,char[],char[],char[]);
   void deletion(void);
   int member_found(int);
   void update_cd(int,int,int,int,int);
   char *membername(int);
   char *memberphone(int);
   char *memberaddress(int);
   int  recordno(int);
   int  lastcode(void);
   int  issued(int);
   int  fine(int);
   void display(int);
   void delete_rec(int);
 private:
   int memcode,cdcode;
   char name[26],phone[10],address[33];
   int dd,mm,yy;
};

class WORKING : public CD, public MEMBER
{
 public :
   void issuecd(void);
   void returncd(void);
   void add_cd(void);
   void add_member(void);
   void modify_cd(void);
   void modify_member(void);
   void delete_cd(void);
   void delete_member(void);
};

BIKRAM BAHADUR
CD SHOP MANAGEMENT 11

class DATE
{
 public :
   void extend_date(int,int,int,int);
   int  diff(int,int,int,int,int,int);
   int  day,mon,year;
};

void DATE :: extend_date(int d1, int m1, int y1, int days)
{
 static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
 for (int i=1; i<=days; i++)
  {
   d1++ ;
   if ((d1 > month[m1­1]) || (y1%4 != 0 && m1 == 2 && d1 > 28))
   {
    d1 = 1 ;
    m1++ ;
   }
   if (m1 > 12)
   {
    m1 = 1 ;
    y1++ ;
   }
  }
  day  = d1 ;
  mon  = m1 ;
  year = y1 ;
}

int DATE::diff(int d1,int m1,int y1,int d2,int m2,int y2)
{
 int days = 0 ;
 if((y2<y1)||(y2==y1 && m2<m1)||(y2==y1 && m2==m1 && d2<d1))

BIKRAM BAHADUR
CD SHOP MANAGEMENT 12

  return days ;
 static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
 while (d1 != d2 || m1 != m2 || y1 != y2)
 {
  days++ ;
  d1++ ;
 if((d1>month[m1­1])||(y1%4 != 0 && m1 == 2 && d1 > 28))
 {
  d1 = 1 ;
  m1++ ;
 }
 if(m1>12)
 {
  m1 = 1 ;
  y1++ ;
 }
}
return days ;
}

void MENU::main_menu(void)
{
 char ch ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" CD  CAFE  MANAGEMENT ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("______________________");
  gotoxy(6,7);
  cprintf(" 1. ADD NEW ENTRY.");
  gotoxy(6,9);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 13

  cprintf(" 2. LIST OF RECORD.");
  gotoxy(6,11);
  cprintf(" 3. EDIT RECORDS.");
  gotoxy(6,13);
  cprintf(" 4. RECORDS OF CD.");
  gotoxy(6,15);
  cprintf(" 0. EXIT.");
  gotoxy(4,16);
  cprintf("______________________");
  gotoxy(4,19);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche() ;
  if (ch == '1')
  {
   entry_menu();
  }
  else if(ch == '2')
  {
   list_menu();
  }
  else if(ch == '3')
  {
   edit_menu();
  }
  else if(ch == '4')
  {
   cd_records() ;
  }
  else if(ch == '0')
  {
   clrscr();
   exit(0);
  }
 }
}

BIKRAM BAHADUR
CD SHOP MANAGEMENT 14

void edit_menu(void)
{
 char ch ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" EDITING EXISTING RECORDS ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("____________________________");
  gotoxy(6,7);
  cprintf(" 1. CD RECORD EDITING.");
  gotoxy(6,9);
  cprintf(" 2. MEMBER RECORD EDITING.");
  gotoxy(6,11);
  cprintf(" 0. EXIT.");
  gotoxy(4,13);
  cprintf("____________________________");
  gotoxy(4,15);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche();
  if (ch=='1')
   edit_cd();
  else if(ch=='2')
   edit_member() ;
  else if(ch=='0')
   break ;
 }
}
void entry_menu(void)
{
 char ch ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 15

 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" RECORDS ENTRY MENU ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("____________________________");
  gotoxy(6,7);
  cprintf(" 1. MEMBERS RECORD ENTRY.");
  gotoxy(6,9);
  cprintf(" 2. CD RECORD ENTRY.");
  gotoxy(6,11);
  cprintf(" 0. EXIT.");
  gotoxy(4,13);
  cprintf("____________________________");
  gotoxy(4,15);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche();
  if(ch=='1')
  {
   WORKING W;
   W.add_member();
  }
  if(ch=='2')
  {
   WORKING W;
   W.add_cd() ;
  }
  if(ch=='0')
   break ;
 }
}

BIKRAM BAHADUR
CD SHOP MANAGEMENT 16

void list_menu(void)
{
 char ch ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" LIST OF RECORDS ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("____________________________");
  gotoxy(6,7);
  cprintf(" 1. CD RECORD LIST.");
  gotoxy(6,9);
  cprintf(" 2. MEMBER RECORD LIST.");
  gotoxy(6,11);
  cprintf(" 0. EXIT.");
  gotoxy(4,13);
  cprintf("____________________________");
  gotoxy(4,15);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche();
  if (ch =='1')
  {
   CD C;
   C.list() ;
  }
  else if(ch=='2')
  {
   MEMBER M;
   M.list() ;
  }
  if(ch=='0')
   break ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 17

 }
}

void cd_records(void)
{
 char ch;
 while (1)
 {
 clrscr();
 gotoxy(4,4);
 textcolor(GREEN+BLINK);
 cprintf(" CD RECORDS MENU ");
 gotoxy(4,5);
 textcolor(WHITE);
 cprintf("____________________________");
 gotoxy(6,7);
 cprintf(" 1. ISSUE CD.");
 gotoxy(6,9);
 cprintf(" 2. RETURN CD.");
 gotoxy(6,11);
 cprintf(" 0. EXIT.");
 gotoxy(4,13);
 cprintf("____________________________");
 gotoxy(4,15);
 cprintf(" ENTER YOUR CHOICE = ");
 ch = getche();
 if(ch=='1')
 {
  WORKING W;
  W.issuecd() ;
 }
 if(ch=='2')
 {
  WORKING W;
  W.returncd();

BIKRAM BAHADUR
CD SHOP MANAGEMENT 18

 }
 if(ch=='0')
  break;
 }
}
void edit_cd(void)
{
 char ch ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" EDIT EXISTING CD RECORDS ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("____________________________");
  gotoxy(6,7);
  cprintf(" 1. MODIFY CD RECORD.");
  gotoxy(6,9);
  cprintf(" 2. DELETE CD RECORD.");
  gotoxy(6,11);
  cprintf(" 0. EXIT.");
  gotoxy(4,13);
  cprintf("____________________________");
  gotoxy(4,15);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche();
  if(ch=='1')
  {
   WORKING W ;
   W.modify_cd() ;
  }
  else if(ch=='2')
  {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 19

   WORKING W;
   W.delete_cd();
  }
  else if(ch=='0')
   break ;
 }
}
void edit_member(void)
{
 char ch ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" EDITING EXISTING MEMBER RECORDS ");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("___________________________________");
  gotoxy(6,7);
  cprintf(" 1. MODIFY MEMBER RECORD.");
  gotoxy(6,9);
  cprintf(" 2. DELETE MEMBER RECORD.");
  gotoxy(6,11);
  cprintf(" 0. EXIT.");
  gotoxy(4,13);
  cprintf("___________________________________");
  gotoxy(4,15);
  cprintf(" ENTER YOUR CHOICE = ");
  ch = getche();
  if(ch == '1')
  {
    WORKING W ;
    W.modify_member() ;
  }

BIKRAM BAHADUR
CD SHOP MANAGEMENT 20

  else if(ch=='2')
  {
   WORKING W ;
   W.delete_member() ;
  }
  else if(ch=='0')
   break ;
 }
}
int CD::cd_found(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int found=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (cdcode == tcode)
  {
   found = 1 ;
   break ;
  }
 }
 file.close() ;
 return found ;
}

int CD::cdname_found(char t1code[33])
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int found=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 21

  if (!strcmpi(name,t1code))
  {
   found = 1 ;
   break ;
  }
 }
 file.close() ;
 return found ;
}

int CD::recordno(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int count=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {
  count++ ;
  if(cdcode==tcode)
  break ;
 }
 file.close() ;
 return count ;
}

int CD::available(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int tavail=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (cdcode == tcode)

BIKRAM BAHADUR
CD SHOP MANAGEMENT 22

  {
   tavail = avail ;
   break ;
  }
 }
 file.close() ;
 return tavail ;
}

int CD::no_of_copies(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int tcopies=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (cdcode == tcode)
  {
   tcopies = copies ;
   break ;
  }
 }
 file.close() ;
 return tcopies ;
}

char *CD::cdname(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 char tname[33] ;
 while (file.read((char *) this, sizeof(CD)))
 {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 23

  if (cdcode == tcode)
  {
   strcpy(tname,name) ;
   break ;
  }
 }
 file.close() ;
 return tname ;
}

char *CD::cat_class(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 char tcatagory[6] ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (cdcode == tcode)
  {
   strcpy(tcatagory,catagory) ;
   break ;
  }
 }
 file.close() ;
 return tcatagory ;
}

float CD::cdprice(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 float tprice=0.0 ;
 while (file.read((char *) this, sizeof(CD)))

BIKRAM BAHADUR
CD SHOP MANAGEMENT 24

 {
  if (cdcode == tcode)
  {
   tprice = price ;
   break ;
  }
 }
 file.close() ;
 return tprice ;
}
 
int CD::cdcodeof(char t1code[33])
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int tcode=0 ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (!strcmpi(name,t1code))
  {
   tcode = cdcode ;
   break ;
  }
 }
 file.close() ;
 return tcode ;
}

int CD::reccount(void)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 int count=0 ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 25

 while (file.read((char *) this, sizeof(CD)))
 {
  count++ ;
 }
 file.close() ;
 return count ;
}

void CD::delete_rec(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 fstream temp ;
 temp.open("temp.dat", ios::out) ;
 file.seekg(0,ios::beg) ;
 while(!file.eof())
 {
  file.read((char *) this, sizeof(CD)) ;
  if ( file.eof() )
   break ;
  if ( cdcode != tcode )
   temp.write((char *) this, sizeof(CD)) ;
 }
 file.close() ;
 temp.close() ;
 file.open("CD.DAT", ios::out) ;
 temp.open("temp.dat", ios::in) ;
 temp.seekg(0,ios::beg) ;
 while ( !temp.eof() )
 {
  temp.read((char *) this, sizeof(CD)) ;
  if ( temp.eof() )
  break ;
  file.write((char *) this, sizeof(CD)) ;
 }

BIKRAM BAHADUR
CD SHOP MANAGEMENT 26

 file.close() ;
 temp.close() ;
}

void CD :: add_new_cd(int tcode,char tname[33], char tcatagory[6],
 float tprice, int tcopies, int tavail)
{
fstream file ;
file.open("CD.DAT", ios::app) ;
cdcode = tcode ;
strcpy(name,tname) ;
strcpy(catagory,tcatagory) ;
price = tprice ;
copies = tcopies ;
avail = tavail ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
}
void CD :: update_copies(int tcode, int tcopies, int tavail)
{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("CD.DAT", ios::out | ios::ate) ;
copies = tcopies ;
avail = tavail ;
int location ;
location = (recno­1) * sizeof(CD) ;
file.seekp(location) ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
}

void CD :: modify(int tcode, char tname[33],
 char tcatagory[6], float tprice)

BIKRAM BAHADUR
CD SHOP MANAGEMENT 27

{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("CD.DAT", ios::out | ios::ate) ;
strcpy(name,tname) ;
strcpy(catagory,tcatagory) ;
price = tprice ;
int location ;
location = (recno­1) * sizeof(CD) ;
file.seekp(location) ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
}
void CD :: display(int tcode)
{
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) this, sizeof(CD)))
 {
  if (cdcode == tcode)
  {
 clrscr();
 gotoxy(4,4);
 textcolor(GREEN+BLINK);
 cprintf(" EXISTING CD RECORDS ");
 gotoxy(4,5);
 textcolor(WHITE);
 cprintf("____________________________");
 gotoxy(6,7);
 cprintf(" 1. CD CODE : ");
 cout<<cdcode;
 gotoxy(6,9);
 cprintf(" 2. CD NAME : ");

BIKRAM BAHADUR
CD SHOP MANAGEMENT 28

 cout<<name;
 gotoxy(6,11);
 cprintf(" 3. CATEGORY : ");
 cout<<catagory;
 gotoxy(6,13);
 cprintf(" 4. PRICE : Rs. ");
 cout<<price;
 gotoxy(6,15);
 cprintf(" 5. No. OF COPIES : ");
 cout<<copies;
 gotoxy(6,17);
 cprintf(" 6. No. OF CD AVALIABLE : ");
 cout<<avail;
 gotoxy(4,18);
 cprintf("____________________________");
 break;
 }
}
file.close() ;
}

void CD :: list(void)
{
 clrscr() ;
 CD C ;
 int row = 8 , found=0, flag=0 ;
 char ch ;
 gotoxy(2,2);
 textcolor(GREEN+BLINK);
 cprintf(" LIST OF CD ");
 gotoxy(1,3);
 textcolor(WHITE);
 cprintf(" ________________________________________________________");
 gotoxy(1,5);
 cout<<" CODE  CD NAME       TYPE PRICE      No. OF CD";

BIKRAM BAHADUR
CD SHOP MANAGEMENT 29

 gotoxy(1,6);
 cprintf(" _______________________________________________________");
 fstream file ;
 file.open("CD.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) this, sizeof(CD)))
 {
  flag = 0 ;
  delay(20) ;
  found = 1 ;
  gotoxy(4,row);  cout<<cdcode;
  gotoxy(8,row);  cout<<name;
  gotoxy(26,row); cout<<catagory;
  gotoxy(37,row); cout<<price;
  gotoxy(52,row); cout<<copies;
  gotoxy(4,row+2);
  textcolor(6+BLINK);
  cprintf(" STATUS : ") ;
  cprintf("%d copies available",avail) ;
  textcolor(WHITE);
  gotoxy(1,11);
  cprintf(" _______________________________________________________");
  if(row==22)
  {
   flag = 1 ;
   row = 6 ;
   gotoxy(40,40);
   cout <<"Press any key to continue ..";
   ch = getch() ;
  if (ch == 27)
   break ;
  clrscr();
  gotoxy(2,2);
  textcolor(GREEN+BLINK);
  cprintf(" LIST OF CD ");

BIKRAM BAHADUR
CD SHOP MANAGEMENT 30

  gotoxy(1,3);
  textcolor(WHITE);
  cprintf(" _______________________________________________________");
  gotoxy(1,5);
  cout<<" CODE  CD CODE    NAME PHONE        ADDRESS";
  gotoxy(1,6);
  cprintf(" _______________________________________________________");
  }
  else
   row = row + 5 ;
 }
 if(!found)
 {
  gotoxy(5,10) ;cout <<"\nRecords not found" ;
 }
 if (!flag)
 {
  gotoxy(49,49);
  textcolor(RED+BLINK);
  cprintf("Press any key to continue...");
  textcolor(WHITE);
  getche() ;
 }
 file.close () ;
}

int MEMBER :: member_found(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)

BIKRAM BAHADUR
CD SHOP MANAGEMENT 31

{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}
int MEMBER :: issued(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int missue=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
missue = cdcode ;
break ;
}
}
file.close() ;
return missue ;
}
int MEMBER :: fine(int mcode)
{
DATE D ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
fstream file ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 32

file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int days, t_fine ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
days = D.diff(dd,mm,yy,d1,m1,y1) ;
t_fine = days * 20 ;
break ;
}
}
file.close() ;
return t_fine ;
}
int MEMBER :: lastcode(void)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int mcode=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
mcode = memcode ;
file.close() ;
return mcode ;
}

char *MEMBER :: membername(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char mname[26] ;
while (file.read((char *) this, sizeof(MEMBER)))

BIKRAM BAHADUR
CD SHOP MANAGEMENT 33

{
if (memcode == mcode)
{
strcpy(mname,name) ;
break ;
}
}
file.close() ;
return mname ;
}
char *MEMBER :: memberphone(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char mphone[10] ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
strcpy(mphone,phone) ;
break ;
}
}
file.close() ;
return mphone ;
}
char *MEMBER :: memberaddress(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char maddress[33] ;
while (file.read((char *) this, sizeof(MEMBER)))
{

BIKRAM BAHADUR
CD SHOP MANAGEMENT 34

if (memcode == mcode)
{
strcpy(maddress,address) ;
break ;
}
}
file.close() ;
return maddress ;
}
int MEMBER :: recordno(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
count++ ;
if (memcode == mcode)
break ;
}
file.close() ;
return count ;
}
void MEMBER :: delete_rec(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )

BIKRAM BAHADUR
CD SHOP MANAGEMENT 35

break ;
if ( memcode != mcode )
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}
void MEMBER :: update_cd(int mcode, int tcode, int d1, int m1, int y1)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )
break ;
if ( memcode == mcode )
{
cdcode = tcode ;
dd = d1 ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 36

mm = m1 ;
yy = y1 ;
temp.write((char *) this, sizeof(MEMBER)) ;
}
else
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}
void MEMBER :: modify(int mcode, char mname[26], char mphone[10],
 char maddress[33])
{
int recno ;
recno = recordno(mcode) ;
fstream file ;
file.open("MEMBER.DAT", ios::out | ios::ate) ;
strcpy(name,mname) ;
strcpy(phone,mphone) ;
strcpy(address,maddress) ;
int location ;
location = (recno­1) * sizeof(MEMBER) ;
file.seekp(location) ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 37

file.write((char *) this, sizeof(MEMBER)) ;
file.close() ;
}
void MEMBER::add_mem(int mcode,int ccode,char mname[26],char 
maddress[33],
char mphone[10],int d1, int m1, int y1)
{
fstream file ;
file.open("MEMBER.DAT", ios::app) ;
memcode = mcode ;
cdcode = ccode ;
strcpy(name,mname) ;
strcpy(address,maddress) ;
strcpy(phone,mphone) ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
file.write((char *) this, sizeof(MEMBER)) ;
file.close() ;
}
void MEMBER :: display(int mcode)
{
 fstream file ;
 file.open("MEMBER.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) this, sizeof(MEMBER)))
 {
  if (memcode == mcode)
  {
   clrscr();
   gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" EXISTING MEMBER RECORDS ");
   gotoxy(4,5);
   textcolor(WHITE);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 38

   cprintf("____________________________");
   gotoxy(6,7);
   cprintf(" 1. MEMBER CODE : ");
   cout<<mcode;
   gotoxy(6,9);
   cprintf(" 2. MEMBER NAME : ");
   cout<<name;
   gotoxy(6,11);
   cprintf(" 3. MEMBER PHONE : ");
   cout<<phone;
   gotoxy(6,13);
   cprintf(" 4. MEMBER ADDRESS : ");
   cout<<address;
   gotoxy(6,15);
   cprintf("____________________________");
   break;
  }
 }
 file.close() ;
}

void MEMBER :: list(void)
{
 clrscr() ;
 CD C ;
 int row = 8 , found=0, flag=0 ;
 char ch ;
 gotoxy(2,2);
 textcolor(GREEN+BLINK);
 cprintf(" LIST OF MEMBERS & CD ISSUED BY THEM.. ");
 gotoxy(1,3);
 textcolor(WHITE);
 cprintf(" _______________________________________________________");
 gotoxy(1,5);
 cout<<" CODE  CD CODE    NAME PHONE        ADDRESS";

BIKRAM BAHADUR
CD SHOP MANAGEMENT 39

 gotoxy(1,6);
 cprintf(" ________________________________________________________");
 fstream file ;
 file.open("MEMBER.DAT", ios::in) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) this, sizeof(MEMBER)))
 {
  flag = 0 ;
  delay(20) ;
  found = 1 ;
  gotoxy(4,row);  cout<<memcode;
  gotoxy(10,row); cout<<cdcode ;
  gotoxy(19,row); cout<<name;
  gotoxy(35,row); cout<<phone;
  gotoxy(50,row); cout<<address;
  gotoxy(4,row+2) ;
  if (cdcode == 0)
  {
   cprintf("ISSUED CD NAME : (Not Issued)");
   cout<<"\n ______________________________________________________";
  }
  else
  {
   cprintf("ISSUED CD NAME : %s",C.cdname(cdcode));
   gotoxy(42,row+2);
   cprintf("Date of return: ") ;
   textcolor(GREEN+BLINK) ;
   cprintf("%d/%d/%d",dd,mm,yy) ;
   textcolor(WHITE);
   gotoxy(1,11);
   cprintf(" ______________________________________________________");

  }
  if(row==22)
  {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 40

   flag = 1 ;
   row = 6 ;
   gotoxy(40,40);
   cout <<"Press any key to continue ..";
   ch = getch() ;
   if (ch == 27)
    break ;
    clrscr() ;
    gotoxy(2,2);
 textcolor(GREEN+BLINK);
 cprintf(" LIST OF EXISTING MEMBERS ");
 gotoxy(1,3);
 textcolor(WHITE);
 cprintf(" ______________________________________________________");
 gotoxy(1,5);
 cout<<" CODE  CD CODE    NAME PHONE        ADDRESS";
 gotoxy(1,6);
 cprintf(" _____________________________________________________");
}
else
row = row + 5 ;
}
if (!found)
{
gotoxy(5,10) ;cout <<"\nRecords not found" ;
}
if (!flag)
{
gotoxy(49,49);
textcolor(RED+BLINK);
cprintf("Press any key to continue...");
textcolor(WHITE);
getche() ;
}
file.close () ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 41

}
void WORKING :: add_cd(void)
{
 if (!reccount())  // MEMBER FUNCTION OF CD
 {
  add_new_cd(0,"null","null",0.0,0,0) ;
  CD::delete_rec(0) ;
 }
 char ch ;
 int tcode, tcopies, tavail ;
 char tname[33], tcatagory[10] ;
 float tprice=0.0 ;
 do
 {
  int found=0, valid=0 ;
  int tc ;
  float t2=0.0 ;
  char t[10], t1[10] ;
  clrscr() ;
  gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" ADDITION OF NEW CD ");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   cprintf(" 1. ENTER CD CODE : ");
   cin>>tcode;
   gotoxy(6,9);
   cprintf(" 2. ENTER CD NAME : ");
   gets(tname);
   gotoxy(6,11);
   cprintf(" 3. ENTER TYPE OF CD : ");
   gets(tcatagory);
   gotoxy(6,13);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 42

   cprintf(" 4. ENTER PRICE OF CD : ");
   cin>>tprice;
   gotoxy(6,15);
   cprintf(" 5. ENTER No. OF CD : ");
   cin>>tcopies;
   gotoxy(4,17);
   cprintf("___________________________________");

 tavail = available(tcode) + tcopies ;
 tcopies = no_of_copies(tcode) + tcopies ;
 do
 {
  gotoxy(5,19);
  cout<<"Do you want to save (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;
 }while (ch != 'Y' && ch != 'N') ;

 if (ch == 'Y')
 {
  add_new_cd(tcode,tname,tcatagory,tprice,tcopies,tavail) ;
 }
 do
 {
  gotoxy(5,21);
  cout <<"Do you want to add more (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;
 }while (ch != 'Y' && ch != 'N') ;
}while (ch == 'Y') ;
}
void WORKING :: add_member(void)
{
 char ch ;
 int mcode, ccode ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 43

 char mname[26], mphone[10], maddress[33] ;
 int d1, m1, y1 ;
 mcode = lastcode() ;
 mcode++ ;
 do
  {
   int valid=0 ;
   clrscr() ;
   gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" ADDITION OF NEW MEMBER ");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   cprintf(" 1. MEMBER CODE : ");
   cout<<mcode;
   gotoxy(6,9);
   cprintf(" 2. ENTER MEMBER NAME : ");
   gets(mname);
   gotoxy(6,11);
   cprintf(" 3. ENTER MEMBER PHONE No. : ");
   gets(mphone);
   gotoxy(6,13);
   cprintf(" 4. ENTER MEMBER ADDRESS : ");
   gets(maddress);
   gotoxy(4,15);
   cprintf("___________________________________");
 do
 {
  gotoxy(5,17);
  clreol();
  cout<<"Do you want to save (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 44

 }while(ch != 'Y' && ch != 'N') ;
 if(ch == 'Y')
 {
  ccode = 0 ;
  d1 = 0 ;
  m1 = 0 ;
  y1 = 0 ;
  add_mem(mcode,ccode,mname,maddress,mphone,d1,m1,y1) ;
  mcode++ ;
 }
 do
 {
  gotoxy(5,19) ; clreol() ;
  cout <<"Do you want to add more (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;
  if (ch == '0')
   return ;
 }while (ch != 'Y' && ch != 'N') ;
 }while (ch == 'Y') ;
}
void WORKING :: issuecd(void)
{
 CD C ;
 MEMBER M ;
 DATE D ;
 char t1code[33], ch ;
 int t2code=0, tcode=0, mcode=0 ;
 int valid ;
 int d1, m1, y1 ;
 struct date d;
 getdate(&d);
 d1 = d.da_day ;
 m1 = d.da_mon ;
 y1 = d.da_year ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 45

 do
 {
  valid = 1 ;
  while (1)
  {
   clrscr();
   gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" ISSUING OF NEW CD ");
   gotoxy(55,4);
   textcolor(RED+BLINK);
   cprintf("Press <ENTER> for HELP.");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   textcolor(6);
   cprintf("TODAY's DATE :: ");
   gotoxy(21,7);
   textcolor(GREEN+BLINK) ;
   cprintf("%d/%d/%d",d1,m1,y1) ;
   gotoxy(4,8);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,11);
   cout<<"ENTER CODE or NAME OF THE CD : " ;
   gets(t1code);
   textcolor(WHITE);
   if (t1code[0] == '0')
    return ;
   if (strlen(t1code) == 0)
    C.list() ;
   else
    break ;
  }

BIKRAM BAHADUR
CD SHOP MANAGEMENT 46

  t2code = atoi(t1code) ;
  tcode = t2code ;
  if((tcode==0&&!cdname_found(t1code))||(tcode!=0&&!cd_found(tcode)))
  {
   valid = 0 ;
   gotoxy(6,13);
   textcolor(6+BLINK);
   cprintf("Record not found ! ! !");
   textcolor(WHITE);
   gotoxy(6,15);
   cout <<"Press <ESC> to exit or any other key to continue..." ;
   ch = getch();
  }
 } while (!valid) ;
 if (tcode == 0)
 tcode = cdcodeof(t1code) ;
 if (!available(tcode))
  {
   gotoxy(6,13);
   cout<<"Sorry ! CD ("<<cdname(tcode)<<") is not available." ;
   gotoxy(6,15);
   cout <<"Kindly issue any other CD" ;
   gotoxy(6,17);
   textcolor(6+BLINK);
   cprintf("See List of CD's Details..");
   getch() ;
   return ;
  }
 do
 {
  valid = 1 ;
  while (1)
  {
   clrscr() ;
   gotoxy(4,4);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 47

   textcolor(GREEN+BLINK);
   cprintf(" ISSUING OF NEW CD ");
   gotoxy(55,4);
   textcolor(RED+BLINK);
   cprintf("Press <ENTER> for HELP.");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   textcolor(6);
   cprintf("TODAY's DATE :: ");
   gotoxy(21,7);
   textcolor(GREEN+BLINK) ;
   cprintf("%d/%d/%d",d1,m1,y1) ;
   gotoxy(4,8);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,11);
   cprintf("Your CD name is : ");
   cout<<cdname(tcode);
   gotoxy(6,13);
   cout<<"ENTER CODE or NAME OF THE MEMBER : " ;
   gets(t1code);
   textcolor(WHITE);
   if (t1code[0] == '0')
    return ;
   if (strlen(t1code) == 0)
    M.list() ;
   else
    break ;
   }
   t2code = atoi(t1code) ;
   mcode = t2code ;
   if (!member_found(mcode) && valid)
   {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 48

    valid = 0;
    gotoxy(6,15);
    textcolor(6+BLINK);
    cprintf("Record not found ! ! !");
    textcolor(WHITE);
    gotoxy(6,17);
    cout <<"Press <ESC> to exit or any other key to continue..." ;
    ch = getch();
   }
 } while (!valid) ;
int tcopies, tavail ;
tcopies = no_of_copies(tcode) ;  // member function of BOOK
tavail  = available(tcode) ­ 1 ;  // member function of BOOK
update_copies(tcode,tcopies,tavail) ;  // member function of BOOK
D.extend_date(d1,m1,y1,15) ;
d1 = D.day ;
m1 = D.mon ;
y1 = D.year ;
update_cd(mcode,tcode,d1,m1,y1) ;  // member function of MEMBER
gotoxy(6,15);
cout<<"\CD is issued to : " <<membername(mcode);
gotoxy(6,17);
textcolor(RED);
cprintf("DATE of RETURN : ");
textcolor(6+BLINK) ;
cprintf("%d/%d/%d",d1,m1,y1) ;
textcolor(WHITE);
getch() ;
}
void WORKING :: returncd(void)
{
 MEMBER M ;
 char t1code[5], ch ;
 int t2code=0, mcode=0, valid ;
 int d1, m1, y1 ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 49

 struct date d;
 getdate(&d);
 d1 = d.da_day ;
 m1 = d.da_mon ;
 y1 = d.da_year ;
 do
 {
 valid = 1 ;
 while (1)
 {
  clrscr() ;
  gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" RETURNING OF ISSUED CD ");
   gotoxy(55,4);
   textcolor(RED+BLINK);
   cprintf("Press <ENTER> for HELP.");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   textcolor(6);
   cprintf("TODAY's DATE :: ");
   gotoxy(21,7);
   textcolor(GREEN+BLINK) ;
   cprintf("%d/%d/%d",d1,m1,y1) ;
   gotoxy(4,8);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,11);
   cout<<"ENTER CODE or NAME OF THE MEMBER : " ;
   gets(t1code);
   textcolor(WHITE);
   if (t1code[0] == '0')
    return ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 50

   if (strlen(t1code) == 0)
    M.list() ;
   else
    break ;
  }
  t2code = atoi(t1code) ;
  mcode = t2code ;
  if (!member_found(mcode) && valid)
  {
   valid = 0 ;
   gotoxy(6,15);
   textcolor(6+BLINK);
   cprintf("Record not found ! ! !");
   textcolor(WHITE);
   gotoxy(6,17);
   cout <<"Press <ESC> to exit or any other key to continue..." ;
   ch = getch();
  }
  if (!issued(mcode) && valid)
  {
   valid = 0 ;
   gotoxy(5,14);
   textcolor(RED+BLINK);
   cprintf("MEMBER have NO CD to return.");
   textcolor(WHITE);
   gotoxy(5,16);
   cout <<"Press <ESC> to EXIT or Any other key to continue..." ;
   ch = getch();
  }
 }while (!valid);
 int ccode, tcopies, tavail ;
 ccode = issued(mcode) ;
 gotoxy(5,13);
 cout<<"Returned CD Code : " <<ccode ;
 gotoxy(5,15);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 51

 cout <<"Returned CD Name : " <<cdname(ccode) ;
 tcopies = no_of_copies(ccode) ;
 tavail = available(ccode) + 1 ;
 long int f ;
 f = fine(mcode) ;
 if (f != 0)
 {
 gotoxy(5,17);
 cout<<"You have to pay a fine of Rs." <<f ;
 gotoxy(5,19);
 textcolor(RED+BLINK);
 cprintf("Please do not DELAY the Return of CD again");
 }
 update_copies(ccode,tcopies,tavail) ;
 update_cd(mcode,0,0,0,0) ;
 gotoxy(5,22);
 cout<<"CD has been returned" ;
 getch() ;
}
void WORKING :: modify_cd(void)
{
 CD C ;
 char t1code[5], tname[33], tcatagory[6], *t1, ch ;
 int t2code=0,tcode=0,valid;
 float tprice=0.0 ;
 do
 {
  valid = 1 ;
   while (1)
   {
   clrscr();
   gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" MODIFICATION OF CD ");
   gotoxy(55,4);

BIKRAM BAHADUR
CD SHOP MANAGEMENT 52

   textcolor(RED+BLINK);
   cprintf("Press <ENTER> for HELP.");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   cout<<"ENTER CODE or NAME OF THE CD : " ;
   gets(t1code);
   textcolor(WHITE);
   if(t1code[0] == '0')
    return ;
   if(strlen(t1code) == 0)
    C.list() ;
   else
   break ;
   }
  t2code = atoi(t1code) ;
  tcode = t2code ;
  if((tcode==0&&!cdname_found(t1code))||(tcode!=0&&!cd_found(tcode)))
  {
   valid = 0 ;
   gotoxy(6,13);
   textcolor(6+BLINK);
   cprintf("Record not found ! ! !");
   textcolor(WHITE);
   gotoxy(6,15);
   cout <<"Press <ESC> to exit or any other key to continue..." ;
   ch = getch();
  }
 } while (!valid) ;
 if (tcode == 0)
  tcode = cdcodeof(t1code) ;
  clrscr() ;
  CD::display(tcode) ;
  do

BIKRAM BAHADUR
CD SHOP MANAGEMENT 53

  {
   gotoxy(5,20);
   cout <<"Do you want to MODIFY this record (y/n) : " ;
   ch = getche() ;
   ch = toupper(ch) ;
   if (ch == '0')
    return ;
  }while (ch != 'Y' && ch != 'N') ;
  if (ch == 'N')
   return ;
  gotoxy(5,22); cout<<" CD NAME  : "; gets(tname);
  gotoxy(5,24); cout<<" CD TYPE  : "; gets(tcatagory);
  gotoxy(5,26); cout<<" CD PRICE : Rs. " ; cin>>tprice;
 do
 {
  gotoxy(5,28);
  cout<<"Do you want to save changes (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;
  if (ch == '0')
   return ;
 } while (ch != 'Y' && ch != 'N') ;
 if(ch == 'N')
  return ;
 CD::modify(tcode,tname,tcatagory,tprice) ;
 gotoxy(5,30);
 textcolor(RED+BLINK);
 cprintf("Record Modified...");
 textcolor(WHITE);
 gotoxy(5,32);
 cprintf("Press any KEY to CONTINUE...");
 getch() ;
}

BIKRAM BAHADUR
CD SHOP MANAGEMENT 54

void WORKING :: modify_member(void)
{
 MEMBER M ;
 char m1code[10], mname[26], mphone[10], maddress[33], ch ;
 int m2code=0, mcode=0 ;
 int valid ;
 do
 {
 valid = 1 ;
   while (1)
   {
   clrscr();
   gotoxy(4,4);
   textcolor(GREEN+BLINK);
   cprintf(" MODIFICATION OF MEMBER ");
   gotoxy(55,4);
   textcolor(RED+BLINK);
   cprintf("Press <ENTER> for HELP.");
   gotoxy(4,5);
   textcolor(WHITE);
   cprintf("___________________________________");
   gotoxy(6,7);
   cout<<"ENTER CODE or NAME OF THE MEMBER : " ;
   gets(m1code);
   m2code = atoi(m1code) ;
   mcode = m2code ;
   textcolor(WHITE);
   if(m1code[0] == '0')
    return ;
   if(strlen(m1code) == 0)
    M.list() ;
   else
   break ;
   }
  if (valid && !member_found(mcode))

BIKRAM BAHADUR
CD SHOP MANAGEMENT 55

  {
   valid = 0 ;
   gotoxy(6,13);
   textcolor(6+BLINK);
   cprintf("Record not found ! ! !");
   textcolor(WHITE);
   gotoxy(6,15);
   cout <<"Press <ESC> to exit or any other key to continue..." ;
   ch = getch();
  }
 } while (!valid) ;
 clrscr() ;
 MEMBER::display(mcode) ;
 do
  {
   gotoxy(5,20);
   cout <<"Do you want to MODIFY this record (y/n) : " ;
   ch = getche() ;
   ch = toupper(ch) ;
   if (ch == '0')
    return ;
  }while (ch != 'Y' && ch != 'N') ;
  if (ch == 'N')
   return ;
  gotoxy(5,22); cout<<" MEMBER NAME    : "; gets(mname);
  gotoxy(5,24); cout<<" MEMBER PHONE   : "; cin>>mphone;
  gotoxy(5,26); cout<<" MEMBER ADDRESS : " ; gets(maddress);
  do
 {
  gotoxy(5,28);
  cout<<"Do you want to save changes (y/n) : " ;
  ch = getche() ;
  ch = toupper(ch) ;
  if (ch == '0')
   return ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 56

 } while (ch != 'Y' && ch != 'N') ;
 if(ch == 'N')
  return ;
 MEMBER::modify(mcode,mname,mphone,maddress) ;
 gotoxy(5,30);
 textcolor(RED+BLINK);
 cprintf("Record Modified...");
 textcolor(WHITE);
 gotoxy(5,32);
 cprintf("Press any KEY to CONTINUE...");
 getch() ;
}
void WORKING :: delete_cd(void)
{
 CD C ;
 char t1code[5], tname[33], tcatagory[6], ch ;
 int t2code=0, tcode=0 ;
 int valid ;
 do
 {
  valid = 1 ;
  while (1)
  {
  clrscr() ;
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" DELETION OF CD ");
  gotoxy(55,4);
  textcolor(RED+BLINK);
  cprintf("Press <ENTER> for HELP.");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("___________________________________");
  gotoxy(6,7);
  cout<<"ENTER CODE or NAME OF THE CD : " ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 57

  gets(t1code);
  textcolor(WHITE);
  if(t1code[0] == '0')
   return ;
  if(strlen(t1code) == 0)
   C.list() ;
  else
   break ;
 }
  t2code = atoi(t1code) ;
  tcode = t2code ;
  if((tcode==0&&!cdname_found(t1code))||(tcode!=0&&!cd_found(tcode)))
  {
   valid = 0 ;
   gotoxy(6,13);
   textcolor(6+BLINK);
   cprintf("Record not found ! ! !");
   textcolor(WHITE);
   gotoxy(6,15);
   cout <<"Press <ESC> to exit or any other key to continue..." ;
   ch = getch();
  }
 } while (!valid) ;
 if (tcode == 0)
  tcode = cdcodeof(t1code) ;
  clrscr() ;
  CD::display(tcode);
  int tavail, tcopies ;
  tavail = available(tcode) ;
  tcopies = no_of_copies(tcode) ;
  if (tavail != tcopies)
   {
    gotoxy(4,20);
    textcolor(6+BLINK);
    cprintf(" Record cannot be deleted . .");

BIKRAM BAHADUR
CD SHOP MANAGEMENT 58

    gotoxy(4,22);
    textcolor(RED+BLINK);
    cprintf(" This CD is issued . .");
    textcolor(WHITE);
    getch() ;
    return ;
   }
   do
  {
   gotoxy(5,18);
   cout <<"Do you want to DELETE this record (y/n) : " ;
   ch = getche() ;
   ch = toupper(ch) ;
   if (ch == '0')
    return ;
  }while (ch != 'Y' && ch != 'N') ;
  if (ch == 'N')
   return ;
   CD::delete_rec(tcode) ;
   gotoxy(5,23);
   textcolor(RED+BLINK);
   cprintf("Record DELETED SUCCESFULLY...");
   textcolor(WHITE);
   gotoxy(5,25);
   cprintf("Press any KEY to CONTINUE...");
   getch() ;
 }
void WORKING :: delete_member(void)
{
 MEMBER M ;
 char m1code[5], mname[26], mphone[10], maddress[33], ch ;
 int m2code=0, mcode=0 ;
 int valid ;
 do
 {

BIKRAM BAHADUR
CD SHOP MANAGEMENT 59

  valid = 1 ;
  while (1)
  {
   clrscr();
  gotoxy(4,4);
  textcolor(GREEN+BLINK);
  cprintf(" DELETION OF MEMBER ");
  gotoxy(55,4);
  textcolor(RED+BLINK);
  cprintf("Press <ENTER> for HELP.");
  gotoxy(4,5);
  textcolor(WHITE);
  cprintf("___________________________________");
  gotoxy(6,7);
  cout<<"ENTER CODE or NAME OF THE MEMBER : " ;
  gets(m1code);
  textcolor(WHITE);
  if(m1code[0] == '0')
   return ;
  if(strlen(m1code) == 0)
   M.list() ;
  else
   break ;
  }
  m2code = atoi(m1code) ;
  mcode = m2code ;
 if (valid && !member_found(mcode))
 {
  valid = 0 ;
  gotoxy(6,13);
  textcolor(6+BLINK);
  cprintf("Record not found ! ! !");
  textcolor(WHITE);
  gotoxy(6,15);
  cout <<"Press <ESC> to exit or any other key to continue..." ;

BIKRAM BAHADUR
CD SHOP MANAGEMENT 60

  ch = getch();
 }
 }while (!valid) ;
 clrscr() ;
 MEMBER::display(mcode) ;
 do
 {
 gotoxy(5,18);
 cout<<"Do you want to DELETE this record (y/n) : " ;
 ch = getche() ;
 ch = toupper(ch) ;
 if (ch == '0')
  return ;
 }while (ch != 'Y' && ch != 'N') ;
 if (ch == 'N')
  return ;
 if(issued(mcode))
 {
  gotoxy(4,20);
  textcolor(6+BLINK);
  cprintf(" Record cannot be deleted . .");
  gotoxy(4,22);
  textcolor(RED+BLINK);
  cprintf(" MEMBER had a CD issued . .");
  textcolor(WHITE);
  getch() ;
  return ;
 }
 MEMBER::delete_rec(mcode) ;
 gotoxy(5,23);
 textcolor(RED+BLINK);
 cprintf("Record DELETED SUCCESFULLY...");
 textcolor(WHITE);
 gotoxy(5,25);
 cprintf("Press any KEY to CONTINUE...");

BIKRAM BAHADUR
CD SHOP MANAGEMENT 61

 getch() ;
}
void main()
{
 introduction() ;
 MENU menu ;
 menu.main_menu() ;
 getch();
}

BIBLIOGRAPHY
The underwritten followings have helped me to accomplish

this COMPUTER SCIENCE (083) project successfully,

informative and proper one.

COMPUTER SCIENCE
(SUMITA ARORA)

COMPUTER SCIENCE
(SARASWATI)

NOTE :

BIKRAM BAHADUR
CD SHOP MANAGEMENT 62

SPECIAL THANKS TO OUR COMPUTER SIR FOR

GIVING THE IDEA OF THE PROJECT AND SOME CODE

TO MAKE THE PROJECT SUCSSESFUL.

BIKRAM BAHADUR

S-ar putea să vă placă și