LIBRARY MANAGEMENT SYSTEM Version 1.0 (2009-2010)
Computer Science Project
Developed By
Kapil Agarwal Ishan Chawla Neeraj Kumar
Delhi Public School, R.K.Puram, New Delhi
42
Index Sno 1 2 3 4 5 6 7
Description Certificate Introduction Source Code Output Screen Acknowledgements Merits & Limitations Hardware-Software Requirement
42
PageNo 3 4 5 24 40 41 42
Certificate This is to certify that “Library Management System” computer project is developed by Kapil Agarwal, Ishan Chawla and Neeraj Kumar under my supervision in the computer lab of Delhi Public School, R.K.Puram in the session 2009-2010. The work done by them is original.
Mrs. Hema Jain Computer Science Teacher Date: ___________
42
Introduction The project highlights the functioning of a Library Management System. Our original ideas include developing a menu based system to enhance the quality of our project. It stores related data like member details, book details. It is meant to be operated by the person at the reception/librarian. The program can be used to effectively manage the various books present in a library so that information about them can be easily obtained. The user can easily enter information about an entire library of books and retrieve it at his/her own convenience using the various search operations included in the program. The user can also add names and other important information about the members of the library which can also be retrieved whenever required. There is also another feature where the user can later add or delete the existing record of books or members. The user can also, using the program, find out which books have been issued and to whom. The project has been created with utmost intricacy and it is hoped that it would prove to be useful in the long run. 42
Source C++ Code /* Program name : Version : <1.0 (2009-2010)> Filename : Developers : School Name : */ #include #include #include #include #include #include const char TL=218,TR=191,BL=192,BR=217,HL=196,VL=179; void DispCh(int C,int R,char Ch); void AboutUs(); void ModifyTitle(); void ModifyAuthor(); void ModifyPrice(); void ModifyName(); void ModifyAdd(); void ModifyEmail(); void ModifyMob(); void DispCh(int C,int R,char Ch[]); void Color(int TC,int TB); void Recta(int C1,int R1,int C2,int R2); int VMenu(int C,int R,char Men[][15],int Noo); int HMenu(int C,int R,char Men[][15],int Noo); void ShowB(); void ShowM(); void InsertB(); void InsertM(); void SearchBno(); int LastBno(); int LastMno(); void SearchTitle(); void SearchAuthor(); void SearchMno(); void SearchMob(); void SearchEmail(); void SearchName(); void DeleteB(); void DeleteM(); void Issue(); void Return(); void EditMBno(int imno,int ibno); void EditBMno(int imno,int ibno); void NIssueB(); void NIssueM(); void IssueB(); void IssueM();
42
//MAIN CLASS class Book { int Bno; char Title[50]; char Author[50]; int Price; int Mno; public: Book() { Mno=0; } void AddB(int ); void DisplayB(); int RBno() { return Bno; } int RBMno() { return Mno; } char* RTitle() { return Title; } char* RAuthor() { return Author; } void EditTitle() { cout<<"Title : "; gets(Title); } void EditAuthor() { cout<<"Author : "; gets(Author); } void EditPrice() { cout<<"Price : "; cin>>Price; } void IssueBook(int TMno) { Mno=TMno; } }; class Member { int Mno; char Name[50]; char Add[80]; char Email[50]; char Mob[10]; int Bno; public: Member() { Bno=0; } void AddM(int); void DisplayM(); int RMno() { return Mno; } int RMBno() { return Bno; } char* RName() { return Name;} char* REmail() { return Email;} char* RMob() { return Mob;} void EditName() { cout<<"Name : "; gets(Name); } void EditAddress() { cout<<"Address : "; gets(Add); } void EditMob() { cout<<"Mobile no : "; cin>>Mob; } void EditEmail() { cout<<"E-mail : "; gets(Email); } void Issue2Member(int TBno) { Bno=TBno; } }; //Binary file Functions void Book::AddB(int ibno) { Bno=ibno; cout<<"Book No : "<>Price; } void Book::DisplayB() { cout<
42
<>Mob; } void Member::DisplayM() { cout<
42
char S4Menu[][15]={"Books ", "Members ", "About Us", "Quit "}; char S41Menu[][15]={"Issued ", "Non Issued", "Quit "}; char Menu[][15]={"Book ", "Member ", "Utility", "Reports", "Quit "}; AboutUs();getch(); int Quit=0,N,SN,SN1; do { clrscr(); //Display Main Menu1 N=HMenu(1,1,Menu,5),SN; switch (N) { case 0:SN=VMenu(1,2,S1Menu,6); switch(SN) { case 0:clrscr();InsertB();break; case 1:clrscr();ShowB();break; case 2:SN1=VMenu(9,4,S13Menu,4); switch(SN1) { case 0:clrscr();SearchBno();break; case 1:clrscr();SearchTitle();break; case 2:clrscr();SearchAuthor();break; } break; case 3:clrscr();DeleteB();break; case 4:SN1=VMenu(9,6,S15Menu,4); switch(SN1) { case 0:clrscr();ModifyTitle();break; case 1:clrscr();ModifyAuthor();break; case 2:clrscr();ModifyPrice();break; } } getch(); break; case 1:SN=VMenu(11,2,S2Menu,6); switch(SN) { case 0:clrscr();InsertM();break; case 1:clrscr();ShowM();break; case 2:SN1=VMenu(19,4,S23Menu,5); switch(SN1) { case 0:clrscr();SearchMno();break; case 1:clrscr();SearchName();break; case 2:clrscr();SearchMob();break; case 3:clrscr();SearchEmail();break;
42
} break; case 3:clrscr();DeleteM();break; case 4:SN1=VMenu(19,6,S25Menu,5); switch(SN1) { case 0:clrscr();ModifyName();break; case 1:clrscr();ModifyAdd();break; case 2:clrscr();ModifyMob();break; case 3:clrscr();ModifyEmail();break; } break; } getch(); break; case 2:SN=VMenu(21,2,S3Menu,3); switch(SN) { case 0:clrscr();Issue();break; case 1:clrscr();Return();break; } getch(); break; case 3:SN=VMenu(31,2,S4Menu,4); switch(SN) { case 0:SN1=VMenu(40,2,S41Menu,3); switch(SN1) { case 0:clrscr();IssueB();break; case 1:clrscr();NIssueB();break; } break; case 1:SN1=VMenu(40,3,S41Menu,3); switch(SN1) { case 0:clrscr();IssueM();break; case 1:clrscr();NIssueM();break; } break; case 2:AboutUs();break; } getch(); break; case 4:clrscr(); AboutUs(); Quit=1; break; } } while (!Quit); getch(); }
42
//GENRAL FUNCTIONS void DispCh(int C,int R,char Ch) { gotoxy(C,R);cprintf("%c",Ch);//C 1-80 R 1-25 } void DispCh(int C,int R,char Ch[]) { gotoxy(C,R);cprintf("%s",Ch); } void Color(int TC,int TB) { textcolor(TC); textbackground(TB); } void Recta(int C1,int R1,int C2,int R2) { DispCh(C1,R1,TL); DispCh(C2,R1,TR); DispCh(C1,R2,BL); DispCh(C2,R2,BR); for (int i=C1+1;i Move to first option case 79:Sel=Noo-1;break; //End -> Move to Last option case 72:if (Sel==0) //Up -> Checking if already on top Sel=Noo-1; // Move to the last option else // Sel--; // Move one option up break; case 80:if (Sel==Noo-1) //Down -> Checking if already at bottom
42
Sel=0; // Move to the first option else // Sel++; // Move one step down break; case 27:Sel=-1; //Escape-> Getting out of the Menu without valid selection case 13:Exit=1; //Enter-> Getting out of the Menu with current selection } DispCh(C+1,R+Tsel+1,Men[Tsel]);//Redisplaying the non-highlighted option } while (!Exit); return Sel; //Returning the selected value from menu } int HMenu(int C,int R,char Men[][15],int Noo) { int Exit=0,Sel=0; Color(YELLOW,BLUE); for (int i=0;i
42
fil.close(); } void ShowB() { fstream fil; fil.open("Book.dat",ios::binary|ios::in); Book S; cout<>sbno; while (fil.read((char*)&S,sizeof(S)) && (!found)) { if(S.RBno()==sbno) { cout<
42
} } if (found==0) cout<<"Book Not Found"<
} void SearchMno() { int smno,found=0; fstream fil; fil.open("Member.dat",ios::binary|ios::in); Member S; cout<<"Member no : "; cin>>smno; while (fil.read((char*)&S,sizeof(S)) && (!found)) { if(S.RMno()==smno) { cout<
42
void SearchAuthor() { char sauthor[50]; int found=0; fstream fil; fil.open("Book.dat",ios::binary|ios::in); Book S; cout<<"Author : "; gets(sauthor); while (fil.read((char*)&S,sizeof(S)) && (!found)) { if(!strcmpi(S.RAuthor(),sauthor)) { cout<>sbno; while(fil1.read((char*)&S,sizeof(S))) { if(S.RBno()!=sbno) fil2.write((char*)&S,sizeof(S)); else del++; } if(!del) cout<<"Book not found"<
42
cout<<"Enter Member no : "; cin>>smno; while(fil1.read((char*)&S,sizeof(S))) { if(S.RMno()!=smno) fil2.write((char*)&S,sizeof(S)); else del++; } if(!del) cout<<"Member not found"<
} void ModifyTitle() { fstream fil; fil.open("Book.dat",ios::binary|ios::in|ios::out); Book S; int SBno,found=0; cout<<"Enter Book no : "; cin>>SBno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RBno()==SBno) found++; if (found) { S.EditTitle(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Book Not Found"<>SBno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RBno()==SBno) found++; if (found) { S.EditAuthor(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else
42
cout<<"Book Not Found"<>SBno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RBno()==SBno) found++; if (found) { S.EditPrice(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Book Not Found"<
42
cout<<"Mobile no : "; cin>>smob; while (fil.read((char*)&S,sizeof(S)) && (!found)) { if(strcmpi(S.RMob(),smob)==0) { cout<>SMno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RMno()==SMno) found++; if (found) {
42
S.EditName(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Member Not Found"<>SMno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RMno()==SMno) found++; if (found) { S.EditAddress(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Member Not Found"<>SMno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RMno()==SMno) found++; if (found) { S.EditMob(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Member Not Found"<
42
cout<<"Enter Member no : "; cin>>SMno; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RMno()==SMno) found++; if (found) { S.EditEmail(); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } else cout<<"Member Not Found"<>imno; fstream fil1,fil2; fil1.open("Member.dat",ios::binary|ios::in); fil2.open("Book.dat",ios::binary|ios::in); while (fil1.read((char*)&M,sizeof(M)) && !foundm) { if (imno==M.RMno()) { foundm++; if (!M.RMBno()) { cout<<"Enter Book no : "; cin>>ibno; while (fil2.read((char*)&B,sizeof(B)) && foundb==0) { if (ibno==B.RBno()) { foundb++; if (!B.RBMno()) { cout<>ch; switch (ch) { case 'y': case 'Y':cout<<"Book Issued"<
42
else cout<<"Book already issued"<
}
} if (!foundb) cout<<"Not Available"<
} else cout<<"Please return the book issued"<
} } if (!foundm) cout<<"Member not found"<
} void Return() { Member M; Book B; int imno,ibno,N,T,foundm=0,foundb=0,a=0; char ch; cout<<"Enter Member no : "; cin>>imno; fstream fil1,fil2; fil1.open("Member.dat",ios::binary|ios::in); fil2.open("Book.dat",ios::binary|ios::in); while (fil1.read((char*)&M,sizeof(M)) && !foundm) { if (imno==M.RMno()) { foundm++; if (M.RMBno()) { ibno=M.RMBno(); while (fil2.read((char*)&B,sizeof(B)) && !foundb) { if (ibno==B.RBno()) { foundb++; cout<>ch; switch (ch) { case 'y': case 'Y':cout<<"Book Returned"<
42
}
}
} else cout<<"Book not issued"<
} void EditMBno(int imno,int ibno) { fstream fil; fil.open("Member.dat",ios::binary|ios::in|ios::out); Member S; int found=0; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RMno()==imno) found++; if (found) { S.Issue2Member(ibno); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } fil.close(); } void EditBMno(int imno,int ibno) { fstream fil; fil.open("Book.dat",ios::binary|ios::in|ios::out); Book S; int found=0; while(!found && fil.read((char*)&S,sizeof(S))) if (S.RBno()==ibno) found++; if (found) { S.IssueBook(imno); int N=fil.tellg()-sizeof(S); fil.seekp(N); fil.write((char*)&S,sizeof(S)); } fil.close(); } void IssueM() { Member M; fstream fil; fil.open("Member.dat",ios::binary|ios::in);
42
cout<
42
M.DisplayB(); } fil.close(); } int LastMno() { fstream fil; fil.open("Member.dat",ios::binary|ios::in); Member M; int LMno=100; while(fil.read((char*)&M,sizeof(M))) { LMno=M.RMno(); } fil.close(); return LMno; } int LastBno() { fstream fil; fil.open("Book.dat",ios::binary|ios::in); Book B; int LBno=100; while(fil.read((char*)&B,sizeof(B))) { LBno=B.RBno(); } fil.close(); return LBno; } void AboutUs() { clrscr(); gotoxy(27,7); cout<<"LIBRARY MANAGEMENT SYSTEM"<
42
Output Screens
42
42
42
42
42
42
42
42
42
42
42
42
42
42
42
42
Acknowledgements We would like to thank our computer science teachers Mrs. Hema Jain and Mr. Mukesh Kumar who gave their valuable opinions and suggestions and have been instrumental in allowing this project to be completed. Also, we would like to thank the lab assistant who helped us whenever we faced difficulties. Finally, we wish to thank our parents for their love and encouragement, without whom we would never have enjoyed so many opportunities.
42
Merits & Limitations The project has a very basic functional design which can easily accommodate smaller databases. The entered records of books and members can be displayed in a tabular manner, which enables the user to see all the available details. The formatting has to be precise and lengthy elaborations may disrupt the tabular display. Some features, however, enable the project to be extremely user friendly. Any book can be searched for among the many records at one’s own convenience. Book names, member details and other details can be edited using the Modify feature. We can also check which book has been issued. Only those books will be issued which have not been already issued. This makes our project more comprehensive.
42
Hardware & Software Requirement
Hardware Requirement Pentium 3/4/Core 2 Duo/Dual core With at least 256 MB RAM 2 MB free space on Hard Disk Color Monitor/LCD
Operating System MS Windows 98/XP/Vista Turbo C++ 3.0 Compiler
42