#include #include #include #include #include #include #define NORMAL 7; class lib { private: FILE *fp,*ft,*fe; int sl; long int entry_no; char nw,ch; struct stud { int roll,sno,sl,dt,mn,yr; char name[30]; char c_c[15]; }i,r,q; struct book { int sno; char name[30]; char auth[30]; char pub[25]; float price; }b; public: int menu(int color,int r,int c,int np,char *menu_list[]); void newentry(); void booklist(); void bookissue(); void issuelist(); void bookreturn(); void returnlist(); void delreturn(); void modifyentry(); void flash(); }; int lib::menu(int color,int r,int c,int np,char *menu_list[]) { int r1=r+(np-1),k=0,i=0,j=1,r2=r; textattr(color);gotoxy(c,r2);cprintf(menu_list[0]); r2++; textattr(919); textcolor(7); for(j=1;jr1) { r=r1-(np-1); i=0; gotoxy(c,r);textattr(color);cprintf(menu_list[i]); } gotoxy(c,r);textattr(color);cprintf(menu_list[i]); break; case 72 : gotoxy(c,r);textattr(919);textcolor(7);cprintf(menu_list[i]); r--; i--; if(r>b.price; flushall(); gotoxy(10,16);cout<<"Do you want to save(Y/N) ? : "; nw=getche(); if(nw!='y') temp--; else fwrite(&b,entry_no,1,fp); gotoxy(10,17);cout<<"Add nw records(Y/N) ? : "; fflush(stdin); nw=getche(); } clrscr(); return; } void lib::booklist() { int c=1; fp = fopen ("DBASE.DAT","rb+"); entry_no=sizeof(b); rewind(fp); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ BOOK LIST ] "); textattr(7); gotoxy(2,7);cout<<"Book No. Title Author Publication Price "; gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; while (fread (&b,entry_no,1,fp) == 1) { flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ BOOKS ] "); textattr(7); gotoxy(2,8+c); cprintf(" %-6d ",b.sno); cprintf(" %-20.20s ",b.name); cprintf(" %-18.18s ",b.auth); cprintf(" %-15.15s",b.pub); cprintf(" %9.2f ",b.price); c++; if(c>11) { c=1; gotoxy(55,20); cout<<"Press key to next"; getch(); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ BOOKS ] "); textattr(7); gotoxy(2,7);cout<<"B.No Title Author Publication Price "; gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; } } gotoxy(60,20);cout<<"End of List"; getch(); clrscr(); return; } void lib::bookissue() { int temp=0,tem=0; fp = fopen ("ISU.DAT","rb+"); if(fp == NULL) { fp = fopen ("ISU.DAT","wb+"); if(fp == NULL) { puts("Can not open file"); exit(0); } } ft=fopen("DBASE.DAT","rb"); entry_no=sizeof(i); fseek(fp,0,SEEK_END); nw='y'; ch='y'; rewind(fp); while(fread(&i,entry_no,1,fp)==1) temp=sl; while(nw=='y') { textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ BOOKS ] "); textattr(7); sl=temp+1; temp++; flushall(); gotoxy(10,11);cout<<"Book_No : "; cin>>i.sno; flushall(); rewind(ft); while(fread(&b,sizeof(b),1,ft)==1) { if (i.sno==b.sno) { tem=i.sno; rewind(fp); while(fread(&i,entry_no,1,fp)==1) { if(tem==i.sno) { gotoxy(2,7);cout<<"-----------------------------------------------------------------------------"; gotoxy(2,8);cout<<"B.No : "<>i.roll; flushall(); gotoxy(10,13);cout<<"Student Name : "; gets(i.name); flushall(); gotoxy(10,14);cout<<"Course Code : "; gets(i.c_c); flushall(); gotoxy(10,15);cout<<"Issue Date : "; cin>>i.dt; gotoxy(28,15);cout<<"-";cin>>i.mn; gotoxy(31,15);cout<<"-";cin>>i.yr; flushall(); gotoxy(10,17);cout<<"Do you want to save(Y/N) ? : "; ch=getche(); if(ch=='y') fwrite(&i,entry_no,1,fp); goto a; } } gotoxy(2,7);cout<<"-----------------------------------------------------------------------------"; gotoxy(2,8);cout<<"BOOK_NO: "<>r.sno; flushall(); rewind(ft); while(fread(&b,sizeof(b),1,ft)==1) { if (r.sno==b.sno) { rewind(fe); while(fread(&i,sizeof(i),1,fe)==1) { if(r.sno==i.sno) { gotoxy(2,7);cout<<"B.No Title Issued To Roll Course Issued_Date "; gotoxy(2,8); cout<<"-----------------------------------------------------------------------------"; gotoxy(2,9); cprintf(" %-6d %-17.17s %-16.16s %-5d %-8.8s%02d-%02d-%02d ",i.sno,b.name,i.name,i.roll,i.c_c,i.dt,i.mn,i.yr); gotoxy(2,10); cout<<"-----------------------------------------------------------------------------"; gotoxy(10,12);cout<<"Roll No : "; cin>>r.roll; flushall(); gotoxy(10,13);cout<<"Student Name : "; gets(r.name); flushall(); gotoxy(10,14);cout<<"Course Code : "; gets(r.c_c); flushall(); gotoxy(10,15);cout<<"Return Date : "; cin>>r.dt; gotoxy(28,15);cout<<"-";cin>>r.mn; gotoxy(31,15);cout<<"-";cin>>r.yr; flushall(); gotoxy(10,16);cout<<"Do you want to save(Y/N) ? : "; ch=getche(); if(ch=='y') { fwrite(&r,entry_no,1,fp); fm=fopen("TEMP.DAT","wb"); rewind(fe); while(fread(&i,sizeof(i),1,fe)==1) { if(r.sno!=i.sno) fwrite(&i,sizeof(i),1,fm); } fclose(fe); fclose(fm); remove("ISU.DAT"); rename("TEMP.DAT","ISU.DAT"); fe=fopen("ISU.DAT","rb+"); } goto a; } } } } gotoxy(2,7); cout<<"-----------------------------------------------------------------------------"; gotoxy(2,8);cout<<"BOOK_NO: "<10) { c=1; gotoxy(55,20);cout<<"Press key to next "; getch(); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ ISSUED BOOK DETAILS ] "); textattr(7); gotoxy(2,7);cout<<"Sl.No. Issued To Roll Course Book_No Title Issur Date "; gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; } } gotoxy(60,20);cout<<"End of List "; getch(); clrscr(); return; } void lib::returnlist() { int c=1; fp = fopen ("RETN.DAT","rb+"); ft = fopen ("DBASE.DAT","rb+"); entry_no=sizeof(r); rewind(fp); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ RETURNED BOOK DETAILS ] "); textattr(7); gotoxy(2,7);cout<<"Sl.No. Retn By Roll Course Book_No Title Retn_Date"; gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; while (fread (&r,entry_no,1,fp) == 1) { flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ RETURNED BOOK DETAILS ] "); textattr(7); gotoxy(2,8+c); cprintf(" %-5d",r.sl); cprintf(" %-16.16s ",r.name); cprintf(" %-3d ",r.roll); cprintf(" %-8.8s ",r.c_c); cprintf(" %-5d ",r.sno); rewind(ft); while(fread(&b,sizeof(b),1,ft)==1) { if (r.sno==b.sno) cprintf(" %-16.16s ",b.name); } cprintf(" %02d-%02d-%02d ",r.dt,r.mn,r.yr); c++; if(c>10) { c=1; gotoxy(55,20); cout<<"Press key to next "; getch(); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ RETURNED BOOK DETAILS ] "); textattr(7); gotoxy(2,7);cout<<"B.No. Retn By Roll Course Book_No Title Retrn_Date"; gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; } } gotoxy(60,20);cout<<"End of List "; getch(); clrscr(); return; } void lib::modifyentry() { int sn; fp=fopen("DBASE.DAT","rb+"); entry_no=sizeof(b); nw='y'; while(nw=='y') { textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ MODIFY ] "); textattr(7); gotoxy(10,8);cout<<"Enter Book_No to Modify: "; cin>>sn; rewind(fp); while(fread(&b,entry_no,1,fp)==1) { if(sn==b.sno) { clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [MODIFY RECORDS] "); textattr(7); gotoxy(2,7);printf("Book_No Book_Name Author sPublication Price "); gotoxy(2,8);cout<<"-----------------------------------------------------------------------------"; gotoxy(2,9);printf(" %-6d %-20.20s %-18.18s %-15.15s%9.2f",b.sno,b.name,b.auth,b.pub,b.price); gotoxy(2,10);cout<<"-----------------------------------------------------------------------------"; gotoxy(10,12);cout<<"Enter new entries: "; gotoxy(10,13);cout<<"Book No : "<>b.price; fflush(stdin); fseek(fp,-entry_no,SEEK_CUR); fwrite(&b,entry_no,1,fp); } else { flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ MODIFY ] "); textattr(7); gotoxy(10,12);cout<<"\t\t\tNO RECORD FOUND... !!"; } } gotoxy(45,19);cout<<" Modify new records(Y/N) ? : "; fflush(stdin); nw=getche(); } clrscr(); fclose(fp); return; } void lib::delreturn() { int sn; fp=fopen("RETN.DAT","rb+"); entry_no=sizeof(r); nw='y'; while(nw=='y') { textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ DELETE ] "); textattr(7); gotoxy(10,8);cout<<"Enter Book No to Delete: "; cin>>sn; ft=fopen("TEMP.DAT","wb"); rewind(fp); while(fread(&r,entry_no,1,fp)==1) { if(sn!=r.sno) fwrite(&r,entry_no,1,ft); } fclose(fp); fclose(ft); remove("RETN.DAT"); rename("TEMP.DAT","RETN.DAT"); fp=fopen("RETN.DAT","rb+"); textbackground(9); clrscr(); flash(); textattr(697); textcolor(692); gotoxy(3,4);cprintf(" [ DELETE ] "); textattr(7); gotoxy(10,12);cout<<"\t\t\tRECORD DELETED... !!"; gotoxy(45,19);cout<<"Delete nw(Y/N) ? : "; fflush(stdin); nw=getche(); } clrscr(); fclose(fp); return; } int main() { lib p,retrn,query,issue; int m,x=9; static char *menu_list[]={"01. BOOK LIST","02. ISSUED BOOK LIST","03. RETURNED BOOKS","04. ISSUE BOOK ","05. RETURN BOOK","06. NEW BOOK ENTRY ","07. MODIFY BOOK ENTRY","08. DELETE RETURN LIST","09. EXIT"}; do { textbackground(9); clrscr(); p.flash(); textcolor(692); textattr(917); textcolor(2); gotoxy(28,21); cprintf("Select Option and Press Enter"); m=p.menu(498,7,30,x,menu_list); gotoxy(70,24); if(m==1) { flushall(); textattr(7); clrscr(); p.booklist(); } if(m==2) { flushall(); textattr(7); clrscr(); issue.issuelist(); } if(m==3) { flushall(); textattr(7); clrscr(); retrn.returnlist(); } if(m==4) { flushall(); textattr(7); clrscr(); issue.bookissue(); } if(m==5) { flushall(); textattr(7); clrscr(); retrn.bookreturn(); } if(m==6) { flushall(); textattr(7); clrscr(); p.newentry(); } if(m==7) { flushall(); textattr(7); clrscr(); p.modifyentry(); } if(m==8) { flushall(); textattr(7); clrscr(); retrn.delreturn(); } if(m==9) { flushall(); textattr(7); clrscr(); exit(0); } }while(m!=9); return 0; }