Professional Documents
Culture Documents
Smart Library Management System: Bachelor of Technology in Computer Science
Smart Library Management System: Bachelor of Technology in Computer Science
A PROJECT REPORT
ON
By
SUHEL CHAUHAN
PANKAJ KUMAR
1
Acknowledgements
We are extremely grateful and remain indebted to our guide MR.
SHUBHASHISH GOWAMI for being a source of inspiration and for his constant support
in the Design, Implementation and Evaluation of the project. We are thankful to them for
their constant constructive criticism and invaluable suggestions, which benefited us a lot
while developing the project on “SMART LIBRARY MANAGEMENT SYSTEM”.
He has been a constant source of inspiration and motivation for hard work. He has been
very co-operative throughout this project work. Through this column, it would be our
utmost pleasure to express our warm thanks to him for their encouragement, co-operation
and consent without which we mightn’t be able to accomplish this project.
We also express our gratitude to Mr. SHUBHASHISH GOSWAMI for providing
us the infrastructure to carry out the project and to all staff members who were directly and
indirectly instrument in enabling us to stay committed for the project.
Suhel Chauhan
Pankaj Kumar
2
Abstract
complete information about the library. We can enter the record of new books and retrieve
the details of books available in the library. We can issue the books to the students and
maintain their records and can also check how many books are issued and stock available in
the library.
Throughout the project the focus has been on presenting information and comments
in an easy and intelligible manner. The project is very useful for those who want to know
about Library Management System.
In the last, we gratefully acknowledge and express our gratitude to all staff members
and friends who supported us in preparing this project
3
TABLE OF CONTENTS
1.Introduction
1.1 Purpose………………………………………………………………………6
1.2 Scope………………………………………………………………………....6
1.3 Technology used………………………………..............................................6
1.4 Assumptions………………………………………………………………….6
1.5 Overview ………………………………………………………….. ………..6
1.6 Functionality………………………………………………………………….6
2. C#
2.1 Introduction to C#............................................................................................7
2.2 Feature of C#....................................................................................................7
2.3 Application of C#............................................................................................7
2.4 Data Types…………………………………………………………………....8
3. Overall Description
3.1 Product Perspective…………………………………………………………..9
3.2 Product Feature………………………………………………….....................9
3.3 User Classes and Characteristics…………………………………………......10
3.4 Operating Environment……………………………………………………....10
3.5 Design and implementation constraints……………………….......................10
3.6 User Documentations………………………………………………………...10
3.7 Assumptions and Dependencies……………………………………………...10
4. Database-Storage
4.1 Description…………………………………………………………………...11
4.2 Stimulus/Response………………………………………………. …………..11
4.3 Functional Requirement………………………………………………………12
4.4 Non-Functional Requirement…………………………………………………13
4.5Other Functional requirement………………………………………………... 13
5 Table Design ……………………………………………………… 15
6 Implementation……………………………………………………...17
7. CONCLUSION …………………………………………………….72
8. BIBLIOGRAPHY…………………………………………………...73
4
LIST OF FIGURES AND TABLES
Figure 1
Figure of login screen………………………………………………..17
Figure 2
Figure of actions……………………………………………………...23
Figure 3
Figure of search and issue books…………………………………….28
Figure 4
Figure of return book…………………………………………………36
Figure 5
Figure of add category of books……………………………………...43
Figure 6
Figure of add or remove books……………………………………….48
Figure 7
Figure of register a new user…………………………………………61
Figure 8
Figure of change password…………………………………………...67
5
INTODUCTION
The Library Management System is designed & developed for a receipt and issuance of
books in the library along with the student’s details. The books received in the library are
entered in Books Entry form and the new student is entered in the student entry form. When
the student wants to get the desired book the same is issued on the availability basis to the
student. The issuance and due date for the returning of the book is also entered into the
Book Issue form under third menu Book Issue.
1.1 Purpose
The purpose of this application are as follows :
The software is for automation of library.
It provides following facilities to
Operator :
Can enter details related to a particular book.
Can provide membership to members.
Admin :
Can read and write information about any member.
Can update, create, delete the record of membership as per requirement and
implementation plants.
1.2 Scope
The different areas where we can use this application are :
Any education institute can make use of it for providing information about author,
content of the available books.
It can be used in offices and modifications can be easily done according to
requirements.
1.4 Assumptions
This application is used to convert the manual application to the online application.
Customized data will be used in this application.
User does not have right to enter information about books.
1.5 Overview :
Project is related to library management which provides reading services to its
members. Any person can become a member of the library by filling a prescribed form.
They can get the book issued, so that they cab take home and return them.
6
1.6 Functionality :
Membership.
Keeps the track of issues and submission of books .
C#
2.1 Introduction to C#
4. The #( hash symbol) in musical notations is used to refer to a sharp note and is called
“Sharp”, thus C# is pronounced as “C Sharp”.
2.2 Features of C#
1. C# uses VB’s approach to form design, dragging control’s from a tool box, dropping
them onto forms and writing event handles for them.
-Simple
-Object oriented
3. Type Safe
4. Versionable
5. Compatible
6. Flexible
7. Interoperable
2.3 Application of C#
1. It can be used for a variety of applications that are supported by a .NET platform.
7
2. Console applications
3. Windows applications
4. Developing windows controls
5. Developing ASP.NET projects
6. Creating web controls
7. Creating web services
8. Developing .Net component library
Value types: Contains data. Built-in data types, such as int, char, and float are
value types.
8
Overall Description
9
Can take the book returned from students
Librarian who will be acting as the controller and he will have all the privileges of an
administrator.
10
Database – Storage
4.1 Description
Proposed Database is intended to store, retrieve, update, and manipulate information related
to library which include :
1 Search/Issue Books
2 Return Books
3 Manage Categories
4 Add/Remove Books
5 Change Password
Responses for Administrator: The administrator can Login and Logout. When the
Administrator Logs into the Library system. The system will check for validity of login .If
the Login and password are valid, the response to this action is the administrator will be able
to modify, view, add, deleting and all other functions that can be performed on the database.
11
4.3.1 Interface Requirements
This section describes how the software interfaces with other software products or users
for input or output.
4.3.1.1UserInterfaces
Describes how this product interfaces with the user.
GUI
Describes the graphical user interface if present. This section should include a set
of screen dumps or mockups to illustrate user interface features.
1 Description
The interface must be customizable by the administrator
2 Criticality
This issue is essential to the overall system. All the modules provided with
the software must fit into this graphical user interface and accomplish to the
standard defined.
3 Technicalissues
In order to satisfy this requirement the design should be simple and all the
different interfaces should follow a standard template. There will be the
possibility of changing colors and images, plus switching between interfaces
with the minimum impact for the users.
4 Risks
To reduce the circumstances under which this requirement might not able to
be satisfied, all the designers must have been developed window forms
previously and they must be aware of XML restriction and implementations
before starting the designing. In order to reduce the probability of this
occurrence the entire design team will be trained in basic XML development.
5 Dependencies with other requirements
All user interfaces should be able to interact with the user management
module and a part of the interface must be dedicated to the login/logout
12
module
Database: SQL Server.
13
The Quality of the database is maintained in such a way so that it can be very user friendly
to the users of the database.
14
TABLE DESIGN
Issue : Table
15
Field Name Data Type
S.No
.
1 Id Number
2 Roll_no Number
3 Name Text
4 Branch Text
Book : Table
IMPLEMENTATION
Login Screen
17
/* code for login form */
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Library_Management
{
18
private System.Windows.Forms.Label lblUser;
private System.Windows.Forms.Label lblpwd;
private System.Windows.Forms.TextBox txtuser;
private System.Windows.Forms.TextBox txtpwd;
private System.Windows.Forms.Button btnRegister;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;
public MainForm()
{
InitializeComponent();
this.Load+=new EventHandler(MainForm_Load);
19
this.lblpwd.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblpwd.ForeColor =
System.Drawing.SystemColors.ControlText;
this.lblpwd.Location = new System.Drawing.Point(61,
154);
this.lblpwd.Name = "lblpwd";
this.lblpwd.TabIndex = 2;
this.lblpwd.Text = "Password";
this.txtuser.Location = new System.Drawing.Point(184,
106);
this.txtuser.MaxLength = 20;
this.txtuser.Name = "txtuser";
this.txtuser.TabIndex = 1;
this.txtuser.Text = "";
this.txtpwd.Location = new System.Drawing.Point(184,
154);
this.txtpwd.MaxLength = 8;
this.txtpwd.Name = "txtpwd";
this.txtpwd.PasswordChar = '*';
this.txtpwd.TabIndex = 3;
this.txtpwd.Text = "";
this.btnRegister.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.btnRegister.ForeColor =
System.Drawing.SystemColors.ControlText;
this.btnRegister.Location = new System.Drawing.Point(40,
226);
this.btnRegister.Name = "btnRegister";
this.btnRegister.TabIndex = 4;
this.btnRegister.Text = "&Register";
this.btnRegister.Click += new
System.EventHandler(this.btnRegister_Click);
this.btnLogin.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnLogin.ForeColor =
System.Drawing.SystemColors.ControlText;
this.btnLogin.Location = new System.Drawing.Point(135,
226);
this.btnLogin.Name = "btnLogin";
this.btnLogin.TabIndex = 5;
this.btnLogin.Text = "&Login";
this.btnLogin.Click += new
System.EventHandler(this.btnLogin_Click);
this.btnExit.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnExit.ForeColor =
System.Drawing.SystemColors.ControlText;
this.btnExit.Location = new System.Drawing.Point(230,
226);
this.btnExit.Name = "btnExit";
this.btnExit.TabIndex = 6;
20
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.label1.Font = new System.Drawing.Font("Microsoft
Sans Serif", 10.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(72, 46);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 23);
this.label1.TabIndex = 7;
this.label1.Text = "Library Management System";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(344, 295);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.btnRegister);
this.Controls.Add(this.txtpwd);
this.Controls.Add(this.txtuser);
this.Controls.Add(this.lblpwd);
this.Controls.Add(this.lblUser);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "MainForm";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Login";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
MainForm frmLogin = new MainForm();
frmLogin.ShowDialog();
}
21
bool IsSuccesfulLogin = false;
try
{
IsSuccesfulLogin =
Globals.ValidateId(txtuser.Text,txtpwd.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!IsSuccesfulLogin)
{
MessageBox.Show("Please Enter Valid User
Name/Password Combination","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
txtpwd.Text = "";
txtuser.Text = "";
txtuser.Focus();
return;
}
else
{
Globals.UserName = txtuser.Text;
Globals.Password = txtpwd.Text;
// Launch Action Form
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
private void btnRegister_Click(object sender, System.EventArgs
e)
{
RegisterUser regUser = new RegisterUser();
this.Close();
this.Dispose();
regUser.ShowDialog();
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
this.Dispose();
Application.Exit();
}
22
{
if(!Globals.PopulateAppData())
{
MessageBox.Show("DB Config File
Missing","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
}
}
}
Actions
If user logon with valid id and password he gets action screen
Manage Categories and Add/Remove Books is available for admin user which exists in
system after installation. As of now no new user created will be admin.
23
/* code for Actions */
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Library_Management
{
public class Actions : System.Windows.Forms.Form
{
24
private System.Windows.Forms.GroupBox grpActions;
private System.Windows.Forms.RadioButton rdoSearchBooks;
private System.Windows.Forms.RadioButton rdoReturn;
private System.Windows.Forms.RadioButton rdoCategory;
private System.Windows.Forms.RadioButton rdoAddBooks;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.RadioButton rdoChgPwd;
private System.Windows.Forms.Label lblWelcome;
private System.ComponentModel.Container components = null;
public Actions()
{
InitializeComponent();
}
25
273);
this.grpActions.TabIndex = 0;
this.grpActions.TabStop = false;
this.grpActions.Text = "Actions";
this.rdoChgPwd.Location = new System.Drawing.Point(32,
224);
this.rdoChgPwd.Name = "rdoChgPwd";
this.rdoChgPwd.Size = new System.Drawing.Size(256, 24);
this.rdoChgPwd.TabIndex = 4;
this.rdoChgPwd.Text = "Change Password";
this.rdoAddBooks.Location = new System.Drawing.Point(32,
176);
this.rdoAddBooks.Name = "rdoAddBooks";
this.rdoAddBooks.Size = new System.Drawing.Size(256,
24);
this.rdoAddBooks.TabIndex = 3;
this.rdoAddBooks.Text = "Add/Remove Books";
this.rdoCategory.Location = new System.Drawing.Point(32,
128);
this.rdoCategory.Name = "rdoCategory";
this.rdoCategory.Size = new System.Drawing.Size(256,
24);
this.rdoCategory.TabIndex = 2;
this.rdoCategory.Text = "Manage Categories";
this.rdoReturn.Location = new System.Drawing.Point(32,
80);
this.rdoReturn.Name = "rdoReturn";
this.rdoReturn.Size = new System.Drawing.Size(256, 24);
this.rdoReturn.TabIndex = 1;
this.rdoReturn.Text = "Return Books";
this.rdoSearchBooks.Checked = true;
this.rdoSearchBooks.Location = new
System.Drawing.Point(32, 32);
this.rdoSearchBooks.Name = "rdoSearchBooks";
this.rdoSearchBooks.Size = new System.Drawing.Size(256,
24);
this.rdoSearchBooks.TabIndex = 0;
this.rdoSearchBooks.TabStop = true;
this.rdoSearchBooks.Text = "Search/Issue Books";
this.btnOk.Location = new System.Drawing.Point(41, 328);
this.btnOk.Name = "btnOk";
this.btnOk.TabIndex = 1;
this.btnOk.Text = "&Ok";
this.btnOk.Click += new
System.EventHandler(this.btnOk_Click);
this.btnExit.Location = new System.Drawing.Point(229,
328);
this.btnExit.Name = "btnExit";
this.btnExit.TabIndex = 3;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.btnCancel.Location = new System.Drawing.Point(135,
328);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "&Cancel";
26
this.btnCancel.Click += new
System.EventHandler(this.btnCancel_Click);
this.lblWelcome.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblWelcome.Location = new System.Drawing.Point(16,
16);
this.lblWelcome.Name = "lblWelcome";
this.lblWelcome.Size = new System.Drawing.Size(312, 23);
this.lblWelcome.TabIndex = 7;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(344, 359);
this.Controls.Add(this.lblWelcome);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.grpActions);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Actions";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Actions";
this.Load += new System.EventHandler(this.Actions_Load);
this.grpActions.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
27
{
SearchBooks srch = new SearchBooks();
srch.ShowDialog();
}
if(rdoReturn.Checked)
{
ReturnBook ret = new ReturnBook();
ret.ShowDialog();
}
if(rdoAddBooks.Checked)
{
AddBooks add = new AddBooks();
add.ShowDialog();
}
if(rdoCategory.Checked)
{
Category cat = new Category();
cat.ShowDialog();
}
if(rdoChgPwd.Checked)
{
ChangePassword pwd = new ChangePassword();
pwd.ShowDialog();
}
}
}
}
Search/Issue Books
Search/Issue Books screen accessed from actions screen, in this screen search and issue is
done. First user enters the criteria for book searching and a book is successfully find than
user can select the book he wishes to get issued in grid and get it issued.
28
Maximum number of books allowed for issue is 3
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
29
using System.Windows.Forms;
using System.Data;
namespace Library_Management
{
public class SearchBooks : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Label lblBookName;
private System.Windows.Forms.Label lblCat;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Label lblAvailable;
private System.Windows.Forms.Button btnIssue;
private System.Windows.Forms.Label lblNote;
private System.Windows.Forms.Button btnReturn;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.TextBox txtBook;
private System.Windows.Forms.TextBox txtCat;
private int SelecetedBook = -1;
private System.ComponentModel.Container components = null;
public SearchBooks()
{
InitializeComponent();
dataGrid1.MouseUp+=new
MouseEventHandler(dataGrid1_MouseUp);
btnIssue.Enabled = false;
}
30
this.btnExit = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
this.lblBookName.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblBookName.Location = new System.Drawing.Point(24,
39);
this.lblBookName.Name = "lblBookName";
this.lblBookName.TabIndex = 0;
this.lblBookName.Text = "Book Name";
this.lblCat.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblCat.Location = new System.Drawing.Point(24, 85);
this.lblCat.Name = "lblCat";
this.lblCat.TabIndex = 2;
this.lblCat.Text = "Category";
this.dataGrid1.Anchor =
((System.Windows.Forms.AnchorStyles)
((((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16,
312);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.PreferredColumnWidth = 94;
this.dataGrid1.Size = new System.Drawing.Size(416, 149);
this.dataGrid1.TabIndex = 2;
this.groupBox1.Controls.Add(this.txtCat);
this.groupBox1.Controls.Add(this.txtBook);
this.groupBox1.Controls.Add(this.lblBookName);
this.groupBox1.Controls.Add(this.lblCat);
this.groupBox1.Location = new System.Drawing.Point(16,
72);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(416, 144);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Search Criteria-Enter Atleaset
One Criteria";
this.txtCat.Location = new System.Drawing.Point(216,
85);
this.txtCat.Name = "txtCat";
this.txtCat.Size = new System.Drawing.Size(168, 20);
this.txtCat.TabIndex = 3;
this.txtCat.Text = "";
this.txtBook.Location = new System.Drawing.Point(216,
39);
this.txtBook.Name = "txtBook";
31
this.txtBook.Size = new System.Drawing.Size(168, 20);
this.txtBook.TabIndex = 1;
this.txtBook.Text = "";
this.btnSearch.Location = new System.Drawing.Point(360,
232);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 24);
this.btnSearch.TabIndex = 1;
this.btnSearch.Text = "&Search";
this.btnSearch.Click += new
System.EventHandler(this.btnSearch_Click);
this.lblAvailable.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblAvailable.Location = new
System.Drawing.Point(22, 288);
this.lblAvailable.Name = "lblAvailable";
this.lblAvailable.Size = new System.Drawing.Size(408,
23);
this.lblAvailable.TabIndex = 5;
this.lblAvailable.Text = "Books Available For Issue
(Please select 1 book for issue)";
this.btnIssue.Location = new System.Drawing.Point(184,
472);
this.btnIssue.Name = "btnIssue";
this.btnIssue.Size = new System.Drawing.Size(72, 24);
this.btnIssue.TabIndex = 3;
this.btnIssue.Text = "&Issue";
this.btnIssue.Click += new
System.EventHandler(this.btnIssue_Click);
this.lblNote.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblNote.Location = new System.Drawing.Point(18,
16);
this.lblNote.Name = "lblNote";
this.lblNote.Size = new System.Drawing.Size(408, 40);
this.lblNote.TabIndex = 7;
this.lblNote.Text = "Note:If Multiple Selection Criteria
Are Entered Result Displayed Will Be Retrieve" +
"d Using And Condition ";
this.lblNote.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter;
this.btnReturn.Location = new System.Drawing.Point(272,
472);
this.btnReturn.Name = "btnReturn";
this.btnReturn.Size = new System.Drawing.Size(72, 24);
this.btnReturn.TabIndex = 4;
this.btnReturn.Text = "&Actions";
this.btnReturn.Click += new
System.EventHandler(this.btnReturn_Click);
this.btnExit.Location = new System.Drawing.Point(360,
472);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 24);
this.btnExit.TabIndex = 5;
32
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(444, 519);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnReturn);
this.Controls.Add(this.lblNote);
this.Controls.Add(this.btnIssue);
this.Controls.Add(this.lblAvailable);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.dataGrid1);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "SearchBooks";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Search/Issue Books";
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
33
{
DataSet ds =
Globals.SearchBook(txtBook.Text,txtCat.Text);
if(ds !=null && ds.Tables[0].Rows.Count > 0)
{
DataView dw = new DataView(ds.Tables[0]);
dw.AllowEdit = false;
dw.AllowDelete = false;
dw.AllowNew = false;
dataGrid1.CaptionText = "Available Books";
dataGrid1.DataSource = dw;
btnIssue.Enabled = true;
dataGrid1.Select(0);
SelecetedBook = 0;
}
else
{
MessageBox.Show("No book found for entered
search criteria","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
btnIssue.Enabled = false;
dataGrid1.DataSource = null;
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
}
}
else
{
dataGrid1.Select(ht.Row);
SelecetedBook = ht.Row;
}
34
}
private void btnIssue_Click(object sender, System.EventArgs e)
{
if(Convert.ToInt32(Globals.UsersList[Globals.UserName])
== Globals.NUMBER_OF_BOOKS_ALLOWED)
{
MessageBox.Show("You already have 3 books issued.
Please return one of them to get requested book issued" ,"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
DialogResult dr = MessageBox.Show("You have requested
for book " + dataGrid1[SelecetedBook,0] + " authored by " +
dataGrid1[SelecetedBook,1] + ". Are you sure you want this book?","Library
Management",MessageBoxButtons.YesNo);
if(dr == DialogResult.No)
return;
bool IsSuccess = false;
try
{
if(!
Globals.ValidateBook(dataGrid1[SelecetedBook,0].ToString(),dataGrid1[Selec
etedBook,1].ToString(),dataGrid1[SelecetedBook,3].ToString()))
{
MessageBox.Show("Selected book is already
issued to you","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
IsSuccess =
Globals.IssueBook(dataGrid1[SelecetedBook,0].ToString(),dataGrid1[Selecete
dBook,1].ToString(),dataGrid1[SelecetedBook,3].ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!IsSuccess)
{
MessageBox.Show("Some error has occured","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
MessageBox.Show("Book Issued
Succesfully.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
Globals.UsersList[Globals.UserName] =
35
Convert.ToInt32(Globals.UsersList[Globals.UserName]) + 1;
Globals.BookList[dataGrid1[SelecetedBook,0].ToString() + "~" +
dataGrid1[SelecetedBook,1].ToString() + "#" +
dataGrid1[SelecetedBook,3].ToString()] =
Convert.ToInt32(Globals.BookList[dataGrid1[SelecetedBook,0].ToString() +
"~" + dataGrid1[SelecetedBook,1].ToString() + "#" +
dataGrid1[SelecetedBook,3].ToString()]) - 1;
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
}
Return Books
Return book shows all books issued to user and user can select book that he wishes to return
36
/* code for return form */
using System;
using System.Drawing;
37
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Library_Management
{
public class ReturnBook : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblSelect;
private System.Windows.Forms.ComboBox cmbreturn;
private System.Windows.Forms.Button btnreturn;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnAction;
private System.Windows.Forms.TextBox txtAuthor;
private System.Windows.Forms.TextBox txtCat;
private Hashtable IDTable = new Hashtable();
private Hashtable BookDetail = new Hashtable();
public ReturnBook()
{
InitializeComponent();
this.cmbreturn.SelectedIndexChanged+=new
EventHandler(cmbreturn_SelectedIndexChanged);
38
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblSelect.Location = new System.Drawing.Point(16,
24);
this.lblSelect.Name = "lblSelect";
this.lblSelect.Size = new System.Drawing.Size(248, 24);
this.lblSelect.TabIndex = 0;
this.lblSelect.Text = "Select Book To Be Returned";
this.cmbreturn.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbreturn.Location = new System.Drawing.Point(16,
64);
this.cmbreturn.Name = "cmbreturn";
this.cmbreturn.Size = new System.Drawing.Size(256, 21);
this.cmbreturn.TabIndex = 1;
this.btnreturn.Location = new System.Drawing.Point(22,
182);
this.btnreturn.Name = "btnreturn";
this.btnreturn.Size = new System.Drawing.Size(80, 24);
this.btnreturn.TabIndex = 4;
this.btnreturn.Text = "&Return";
this.btnreturn.Click += new
System.EventHandler(this.btnreturn_Click);
this.btnExit.Location = new System.Drawing.Point(198,
182);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 24);
this.btnExit.TabIndex = 6;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.btnAction.Location = new System.Drawing.Point(114,
182);
this.btnAction.Name = "btnAction";
this.btnAction.Size = new System.Drawing.Size(72, 24);
this.btnAction.TabIndex = 5;
this.btnAction.Text = "&Actions";
this.btnAction.Click += new
System.EventHandler(this.btnAction_Click);
this.txtAuthor.Location = new System.Drawing.Point(16,
104);
this.txtAuthor.Name = "txtAuthor";
this.txtAuthor.ReadOnly = true;
this.txtAuthor.Size = new System.Drawing.Size(176, 20);
this.txtAuthor.TabIndex = 2;
this.txtAuthor.Text = "";
this.txtCat.Location = new System.Drawing.Point(16,
143);
this.txtCat.Name = "txtCat";
this.txtCat.ReadOnly = true;
this.txtCat.Size = new System.Drawing.Size(176, 20);
this.txtCat.TabIndex = 3;
this.txtCat.Text = "";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 223);
this.Controls.Add(this.txtCat);
this.Controls.Add(this.txtAuthor);
this.Controls.Add(this.btnExit);
39
this.Controls.Add(this.btnAction);
this.Controls.Add(this.btnreturn);
this.Controls.Add(this.cmbreturn);
this.Controls.Add(this.lblSelect);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "ReturnBook";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Return Book";
this.Load += new
System.EventHandler(this.ReturnBook_Load);
this.ResumeLayout(false);
}
#endregion
40
break;
}
}
Bookindex = SelectedIds.IndexOf("~");
if(Bookindex!=-1)
{
BookId = SelectedIds.Substring(0,Bookindex);
BookIssueId =
SelectedIds.Substring(Bookindex + 1, SelectedIds.Length - (Bookindex +
1));
}
IsSuccess =
Globals.ReturnBook(Convert.ToInt32(BookId),Convert.ToInt32(BookIssueId));
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!IsSuccess)
{
MessageBox.Show("Some error has occured","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
MessageBox.Show("Book Returned
Succesfully.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
Globals.UsersList[Globals.UserName] =
Convert.ToInt32(Globals.UsersList[Globals.UserName]) - 1;
Globals.BookList[cmbreturn.SelectedItem.ToString()
+ "~" + txtAuthor.Text + "#" + txtCat.Text] =
Convert.ToInt32(Globals.BookList[cmbreturn.SelectedItem.ToString() +
"~" + txtAuthor.Text + "#" + txtCat.Text]) + 1;
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
41
{
btnreturn.Enabled = true;
int count = ds.Tables[0].Rows.Count - 1;
for(int i =0 ;i< ds.Tables[0].Rows.Count;i++)
{
BookDetail.Add(i,ds.Tables[0].Rows[i]
[2].ToString() + "~" + ds.Tables[0].Rows[i][3].ToString() + "#" +
ds.Tables[0].Rows[i][4].ToString());
IDTable.Add(count,ds.Tables[0].Rows[i]
[0].ToString() + "~" + ds.Tables[0].Rows[i][1].ToString());
count--;
}
}
else
{
MessageBox.Show("No book Issued","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
btnreturn.Enabled = false;
return;
}
if(BookDetail!=null && BookDetail.Count > 0)
{
IDictionaryEnumerator myEnumerator =
BookDetail.GetEnumerator();
while(myEnumerator.MoveNext())
{
string Key = myEnumerator.Value.ToString();
int Bookindex = Key.IndexOf("~");
if(Bookindex!=-1)
{
string BookTitle =
Key.Substring(0,Bookindex);
cmbreturn.Items.Add(BookTitle);
}
}
}
}
cmbreturn.SelectedIndex = cmbreturn.Items.Count - 1;
}
string Value =
myEnumerator.Value.ToString();
int Bookindex = Value.IndexOf("~");
if(Bookindex!=-1)
{
string BookTitle =
Value.Substring(0,Bookindex);
42
if(!
BookTitle.Equals(cmbreturn.SelectedItem.ToString()))
continue;
Value= Value.Substring(Bookindex + 1,
Value.Length - (Bookindex + 1));
int Categoryindex =
Value.IndexOf("#");
string AuthorName =
Value.Substring(0 , Categoryindex);
string CategoryName =
Value.Substring(Categoryindex + 1, Value.Length - (Categoryindex +1));
txtAuthor.Text = AuthorName;
txtCat.Text = CategoryName;
}
// }
}
}
}
}
Add category
43
/* code for add Category form */
using System;
44
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Library_Management
{
public class Category : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblCat;
private System.Windows.Forms.TextBox txtCatName;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnAction;
private System.Windows.Forms.Button btnAdd;
private System.ComponentModel.Container components = null;
public Category()
{
InitializeComponent();
}
45
this.txtCatName.Size = new System.Drawing.Size(264, 20);
this.txtCatName.TabIndex = 2;
this.txtCatName.Text = "";
this.lblName.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblName.Location = new System.Drawing.Point(14,
48);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(264, 24);
this.lblName.TabIndex = 1;
this.lblName.Text = "Category Name";
this.btnExit.Location = new System.Drawing.Point(186,
128);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 24);
this.btnExit.TabIndex = 5;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.btnAction.Location = new System.Drawing.Point(110,
128);
this.btnAction.Name = "btnAction";
this.btnAction.Size = new System.Drawing.Size(72, 24);
this.btnAction.TabIndex = 4;
this.btnAction.Text = "A&ctions";
this.btnAction.Click += new
System.EventHandler(this.btnAction_Click);
this.btnAdd.Location = new System.Drawing.Point(34,
128);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(72, 24);
this.btnAdd.TabIndex = 3;
this.btnAdd.Text = "&Add";
this.btnAdd.Click += new
System.EventHandler(this.btnAdd_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnAction);
this.Controls.Add(this.lblName);
this.Controls.Add(this.txtCatName);
this.Controls.Add(this.lblCat);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Category";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Add Category";
this.ResumeLayout(false);
}
#endregion
46
private void btnAction_Click(object sender, System.EventArgs
e)
{
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
Globals.CategoryList.Add(Globals.CategoryList.Count + 1,
txtCatName.Text);
this.Close();
47
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
}
}
48
Add books or remove books
For adding there should be at least one category
Books can be removed, all books in system are shown in Remove books section user can
use Remove button to remove books after setting Quantity to be removed of book
selected.
using System;
using System.Drawing;
using
System.Collections;
using
System.ComponentModel;
using
System.Windows.Forms;
namespace
Library_Management
{
public class
AddBooks :
System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Label lblAuthor;
private System.Windows.Forms.Label lblcat;
private System.Windows.Forms.Label lblQty;
49
private System.Windows.Forms.TextBox txtTitle;
private System.Windows.Forms.TextBox txtAuthor;
private System.Windows.Forms.TextBox txtQty;
private System.Windows.Forms.ComboBox cmbCat;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnAction;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.GroupBox grpAdd;
private System.Windows.Forms.GroupBox grpRemove;
private System.Windows.Forms.Label lblRemBook;
private System.Windows.Forms.ComboBox cmbRemoveBook;
private System.Windows.Forms.Label lblAvlQty;
private System.Windows.Forms.TextBox txtAvailQty;
private System.Windows.Forms.TextBox txtRemQty;
private System.Windows.Forms.Label lblRemQty;
private System.Windows.Forms.Button btnRemove;
private System.Windows.Forms.TextBox txtViewAuthor;
private System.Windows.Forms.Label lblViewAuthor;
private System.Windows.Forms.TextBox txtViewCat;
private System.Windows.Forms.Label lblViewCat;
private System.ComponentModel.Container components = null;
private Hashtable _BookList = new Hashtable();
public AddBooks()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
50
this.grpRemove = new System.Windows.Forms.GroupBox();
this.txtViewCat = new System.Windows.Forms.TextBox();
this.lblViewCat = new System.Windows.Forms.Label();
this.txtViewAuthor = new System.Windows.Forms.TextBox();
this.lblViewAuthor = new System.Windows.Forms.Label();
this.txtRemQty = new System.Windows.Forms.TextBox();
this.lblRemQty = new System.Windows.Forms.Label();
this.txtAvailQty = new System.Windows.Forms.TextBox();
this.lblAvlQty = new System.Windows.Forms.Label();
this.cmbRemoveBook = new
System.Windows.Forms.ComboBox();
this.lblRemBook = new System.Windows.Forms.Label();
this.btnRemove = new System.Windows.Forms.Button();
this.grpAdd.SuspendLayout();
this.grpRemove.SuspendLayout();
this.SuspendLayout();
this.lblTitle.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblTitle.Location = new System.Drawing.Point(24,
21);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(112, 24);
this.lblTitle.TabIndex = 0;
this.lblTitle.Text = "Book Title";
this.lblAuthor.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblAuthor.Location = new System.Drawing.Point(24,
61);
this.lblAuthor.Name = "lblAuthor";
this.lblAuthor.Size = new System.Drawing.Size(112, 24);
this.lblAuthor.TabIndex = 2;
this.lblAuthor.Text = "Author Name";
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblcat.Location = new System.Drawing.Point(24,
101);
this.lblcat.Name = "lblcat";
this.lblcat.Size = new System.Drawing.Size(112, 24);
this.lblcat.TabIndex = 4;
this.lblcat.Text = "Category";
this.lblQty.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblQty.Location = new System.Drawing.Point(24,
141);
this.lblQty.Name = "lblQty";
this.lblQty.Size = new System.Drawing.Size(112, 24);
this.lblQty.TabIndex = 6;
this.lblQty.Text = "Quantity";
this.txtTitle.Location = new System.Drawing.Point(160,
21);
this.txtTitle.Name = "txtTitle";
this.txtTitle.Size = new System.Drawing.Size(176, 20);
this.txtTitle.TabIndex = 1;
this.txtTitle.Text = "";
51
this.txtAuthor.Location = new System.Drawing.Point(160,
61);
this.txtAuthor.Name = "txtAuthor";
this.txtAuthor.Size = new System.Drawing.Size(176, 20);
this.txtAuthor.TabIndex = 3;
this.txtAuthor.Text = "";
this.txtQty.Location = new System.Drawing.Point(160,
141);
this.txtQty.Name = "txtQty";
this.txtQty.Size = new System.Drawing.Size(176, 20);
this.txtQty.TabIndex = 7;
this.txtQty.Text = "";
this.cmbCat.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCat.Location = new System.Drawing.Point(160,
101);
this.cmbCat.Name = "cmbCat";
this.cmbCat.Size = new System.Drawing.Size(176, 21);
this.cmbCat.TabIndex = 5;
this.btnExit.Location = new System.Drawing.Point(224,
528);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 24);
this.btnExit.TabIndex = 5;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
this.btnAction.Location = new System.Drawing.Point(136,
528);
this.btnAction.Name = "btnAction";
this.btnAction.Size = new System.Drawing.Size(72, 24);
this.btnAction.TabIndex = 4;
this.btnAction.Text = "A&ctions";
this.btnAction.Click += new
System.EventHandler(this.btnAction_Click);
this.btnAdd.Location = new System.Drawing.Point(296,
195);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(72, 24);
this.btnAdd.TabIndex = 1;
this.btnAdd.Text = "&Add";
this.btnAdd.Click += new
System.EventHandler(this.btnAdd_Click);
this.grpAdd.Controls.Add(this.txtTitle);
this.grpAdd.Controls.Add(this.txtQty);
this.grpAdd.Controls.Add(this.txtAuthor);
this.grpAdd.Controls.Add(this.lblQty);
this.grpAdd.Controls.Add(this.cmbCat);
this.grpAdd.Controls.Add(this.lblTitle);
this.grpAdd.Controls.Add(this.lblAuthor);
this.grpAdd.Controls.Add(this.lblcat);
this.grpAdd.Location = new System.Drawing.Point(15, 14);
this.grpAdd.Name = "grpAdd";
this.grpAdd.Size = new System.Drawing.Size(352, 170);
this.grpAdd.TabIndex = 0;
this.grpAdd.TabStop = false;
this.grpAdd.Text = "Add Books";
52
this.grpRemove.Controls.Add(this.txtViewCat);
this.grpRemove.Controls.Add(this.lblViewCat);
this.grpRemove.Controls.Add(this.txtViewAuthor);
this.grpRemove.Controls.Add(this.lblViewAuthor);
this.grpRemove.Controls.Add(this.txtRemQty);
this.grpRemove.Controls.Add(this.lblRemQty);
this.grpRemove.Controls.Add(this.txtAvailQty);
this.grpRemove.Controls.Add(this.lblAvlQty);
this.grpRemove.Controls.Add(this.cmbRemoveBook);
this.grpRemove.Controls.Add(this.lblRemBook);
this.grpRemove.Location = new System.Drawing.Point(15,
227);
this.grpRemove.Name = "grpRemove";
this.grpRemove.Size = new System.Drawing.Size(352, 245);
this.grpRemove.TabIndex = 2;
this.grpRemove.TabStop = false;
this.grpRemove.Text = "Remove Books";
this.txtViewCat.Location = new System.Drawing.Point(159,
72);
this.txtViewCat.Name = "txtViewCat";
this.txtViewCat.ReadOnly = true;
this.txtViewCat.Size = new System.Drawing.Size(176, 20);
this.txtViewCat.TabIndex = 3;
this.txtViewCat.Text = "";
this.lblViewCat.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblViewCat.Location = new System.Drawing.Point(17,
72);
this.lblViewCat.Name = "lblViewCat";
this.lblViewCat.Size = new System.Drawing.Size(112, 32);
this.lblViewCat.TabIndex = 2;
this.lblViewCat.Text = "Category";
this.txtViewAuthor.Location = new
System.Drawing.Point(160, 116);
this.txtViewAuthor.Name = "txtViewAuthor";
this.txtViewAuthor.ReadOnly = true;
this.txtViewAuthor.Size = new System.Drawing.Size(176,
20);
this.txtViewAuthor.TabIndex = 5;
this.txtViewAuthor.Text = "";
this.lblViewAuthor.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblViewAuthor.Location = new
System.Drawing.Point(18, 116);
this.lblViewAuthor.Name = "lblViewAuthor";
this.lblViewAuthor.Size = new System.Drawing.Size(112,
32);
this.lblViewAuthor.TabIndex = 4;
this.lblViewAuthor.Text = "Author Name";
this.txtRemQty.Location = new System.Drawing.Point(160,
195);
this.txtRemQty.Name = "txtRemQty";
this.txtRemQty.Size = new System.Drawing.Size(176, 20);
53
this.txtRemQty.TabIndex = 9;
this.txtRemQty.Text = "";
this.lblRemQty.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblRemQty.Location = new System.Drawing.Point(20,
195);
this.lblRemQty.Name = "lblRemQty";
this.lblRemQty.Size = new System.Drawing.Size(112, 40);
this.lblRemQty.TabIndex = 8;
this.lblRemQty.Text = "Quantity To Be Removed Of Book
Selected ";
this.txtAvailQty.Location = new
System.Drawing.Point(160, 155);
this.txtAvailQty.Name = "txtAvailQty";
this.txtAvailQty.ReadOnly = true;
this.txtAvailQty.Size = new System.Drawing.Size(176,
20);
this.txtAvailQty.TabIndex = 7;
this.txtAvailQty.Text = "";
this.lblAvlQty.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblAvlQty.Location = new System.Drawing.Point(20,
155);
this.lblAvlQty.Name = "lblAvlQty";
this.lblAvlQty.Size = new System.Drawing.Size(112, 32);
this.lblAvlQty.TabIndex = 6;
this.lblAvlQty.Text = "Quantity Available Of Book
Selected ";
this.cmbRemoveBook.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbRemoveBook.Location = new
System.Drawing.Point(160, 32);
this.cmbRemoveBook.Name = "cmbRemoveBook";
this.cmbRemoveBook.Size = new System.Drawing.Size(176,
21);
this.cmbRemoveBook.TabIndex = 1;
this.cmbRemoveBook.SelectedIndexChanged += new
System.EventHandler(this.cmbRemoveBook_SelectedIndexChanged);
this.lblRemBook.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblRemBook.Location = new System.Drawing.Point(20,
32);
this.lblRemBook.Name = "lblRemBook";
this.lblRemBook.Size = new System.Drawing.Size(112, 21);
this.lblRemBook.TabIndex = 0;
this.lblRemBook.Text = "Book Title";
this.btnRemove.Location = new System.Drawing.Point(296,
481);
this.btnRemove.Name = "btnRemove";
this.btnRemove.Size = new System.Drawing.Size(72, 24);
this.btnRemove.TabIndex = 3;
this.btnRemove.Text = "&Remove";
this.btnRemove.Click += new
54
System.EventHandler(this.btnRemove_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(386, 567);
this.Controls.Add(this.btnRemove);
this.Controls.Add(this.grpRemove);
this.Controls.Add(this.grpAdd);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnAction);
this.Controls.Add(this.btnAdd);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "AddBooks";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Add/Remove Books";
this.Load += new
System.EventHandler(this.AddBooks_Load);
this.grpAdd.ResumeLayout(false);
this.grpRemove.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
55
}
else
{
bool isNumber = isNumeric(txtQty.Text,
System.Globalization.NumberStyles.Integer);
if(!isNumber)
{
MessageBox.Show("Please Enter Quantity of
books in numeric format","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
}
bool IsSuccesfulAdd = false;
bool isNewEntry = true;
try
{
int iCatId = 0;
if(Globals.CategoryList!=null &&
Globals.CategoryList.Count > 0)
{
IDictionaryEnumerator myEnumerator =
Globals.CategoryList.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
if(cmbCat.SelectedItem.Equals(myEnumerator.Value))
{
iCatId =
Convert.ToInt32(myEnumerator.Key);
break;
}
}
}
else
{
MessageBox.Show("Please add a category
first","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
IsSuccesfulAdd =
Globals.AddBook(txtTitle.Text,txtAuthor.Text,iCatId,Convert.ToInt32(txtQty
.Text),ref isNewEntry);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
56
if(!IsSuccesfulAdd)
{
MessageBox.Show("Please check the book data
entered","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
MessageBox.Show("Book(s) succesfully
added.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
if(Globals.BookList.ContainsKey(txtTitle.Text +
"~" + txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString()))
Globals.BookList[txtTitle.Text + "~" +
txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString()] =
Convert.ToInt32(Globals.BookList[txtTitle.Text + "~" + txtAuthor.Text +
"#" + cmbCat.SelectedItem.ToString()]) + Convert.ToInt32(txtQty.Text);
else
{
Globals.BookList.Add(txtTitle.Text + "~" +
txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString(),txtQty.Text);
}
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
private bool isNumeric(string val,
System.Globalization.NumberStyles NumberStyle)
{
Double result;
return
Double.TryParse(val,NumberStyle,System.Globalization.CultureInfo.CurrentCu
lture,out result);
}
57
return;
}
if(txtRemQty.Text.Equals(""))
{
MessageBox.Show("Please Enter Quantity of books in
numeric format","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
bool isNumber = isNumeric(txtRemQty.Text,
System.Globalization.NumberStyles.Integer);
if(!isNumber)
{
MessageBox.Show("Please Enter Quantity of
books in numeric format","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
}
if(Convert.ToInt32(txtRemQty.Text) >
Convert.ToInt32(txtAvailQty.Text))
{
MessageBox.Show("Quantity of books to be removed
should be less than available quantity","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
bool IsSucessFulRemove = false;
try
{
IsSucessFulRemove =
Globals.RemoveBook(cmbRemoveBook.SelectedItem.ToString(),Convert.ToInt32(t
xtRemQty.Text),txtViewAuthor.Text,txtViewCat.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!IsSucessFulRemove)
{
MessageBox.Show("Please check the book data
entered","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
MessageBox.Show("Book(s) succesfully
removed.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
58
// Launch Action Form
int BooksLeft = Convert.ToInt32(txtAvailQty.Text)
- Convert.ToInt32(txtRemQty.Text);
if(BooksLeft == 0)
Globals.BookList.Remove(cmbRemoveBook.SelectedItem.ToString() + "~"
+ txtViewAuthor.Text + "#" + txtViewCat.Text);
else
Globals.BookList[cmbRemoveBook.SelectedItem.ToString() + "~" +
txtViewAuthor.Text + "#" + txtViewCat.Text] = BooksLeft;
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
cmbCat.SelectedIndex = 0;
}
if(Globals.BookList!=null && Globals.BookList.Count > 0)
{
IDictionaryEnumerator myEnumerator =
Globals.BookList.GetEnumerator();
int ComboIndex = 0;
while ( myEnumerator.MoveNext() )
{
string Key = myEnumerator.Key.ToString();
int Bookindex = Key.IndexOf("~");
if(Bookindex!=-1)
{
string BookTitle =
Key.Substring(0,Bookindex);
cmbRemoveBook.Items.Add(BookTitle);
Key = Key.Substring(Bookindex + 1,
Key.Length - (Bookindex + 1));
int Categoryindex = Key.IndexOf("#");
string AuthorName = Key.Substring(0 ,
Categoryindex);
string CategoryName =
Key.Substring(Categoryindex + 1, Key.Length - (Categoryindex +1));
_BookList.Add(ComboIndex,AuthorName +
"~" + CategoryName + "#" + myEnumerator.Value.ToString());
59
ComboIndex++;
}
}
cmbRemoveBook.SelectedIndex = 0;
}
if(cmbRemoveBook.SelectedIndex.Equals(myEnumerator.Key))
{
string Value =
myEnumerator.Value.ToString();
int Authorindex = Value.IndexOf("~");
if(Authorindex!=-1)
{
string AuthorName =
Value.Substring(0,Authorindex);
txtViewAuthor.Text = AuthorName;
Value = Value.Substring(Authorindex +
1, Value.Length - (Authorindex + 1));
int Categoryindex =
Value.IndexOf("#");
string CategoryName =
Value.Substring(0 , Categoryindex);
string AvailQty =
Value.Substring(Categoryindex + 1, Value.Length - (Categoryindex +1));
txtViewCat.Text = CategoryName;
txtAvailQty.Text = AvailQty;
break;
}
}
}
}
}
}
60
Register a new user
61
/* code for new user register */
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Library_Management
{
public class RegisterUser : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnClear;
62
private System.Windows.Forms.Button btnRegister;
private System.Windows.Forms.TextBox txtpwd;
private System.Windows.Forms.TextBox txtuser;
private System.Windows.Forms.Label lblpwd;
private System.Windows.Forms.Label lblUser;
private System.Windows.Forms.TextBox txtConfirm;
private System.Windows.Forms.Label lblConfirm;
private System.ComponentModel.Container components = null;
public RegisterUser()
{
InitializeComponent();
63
this.btnClear.Name = "btnClear";
this.btnClear.TabIndex = 7;
this.btnClear.Text = "&Clear";
this.btnClear.Click += new
System.EventHandler(this.btnClear_Click);
this.btnRegister.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.btnRegister.Location = new System.Drawing.Point(39,
222);
this.btnRegister.Name = "btnRegister";
this.btnRegister.TabIndex = 6;
this.btnRegister.Text = "&Register";
this.btnRegister.Click += new
System.EventHandler(this.btnRegister_Click);
this.txtpwd.Location = new System.Drawing.Point(183,
126);
this.txtpwd.Name = "txtpwd";
this.txtpwd.PasswordChar = '*';
this.txtpwd.TabIndex = 3;
this.txtpwd.Text = "";
this.txtuser.Location = new System.Drawing.Point(183,
77);
this.txtuser.Name = "txtuser";
this.txtuser.TabIndex = 1;
this.txtuser.Text = "";
this.lblpwd.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblpwd.Location = new System.Drawing.Point(60,
126);
this.lblpwd.Name = "lblpwd";
this.lblpwd.TabIndex = 2;
this.lblpwd.Text = "Password";
this.lblUser.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblUser.Location = new System.Drawing.Point(60,
77);
this.lblUser.Name = "lblUser";
this.lblUser.TabIndex = 0;
this.lblUser.Text = "User Name";
this.txtConfirm.Location = new System.Drawing.Point(183,
175);
this.txtConfirm.Name = "txtConfirm";
this.txtConfirm.PasswordChar = '*';
this.txtConfirm.TabIndex = 5;
this.txtConfirm.Text = "";
this.lblConfirm.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblConfirm.Location = new System.Drawing.Point(60,
175);
this.lblConfirm.Name = "lblConfirm";
this.lblConfirm.TabIndex = 4;
64
this.lblConfirm.Text = "Confirm Password";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(342, 323);
this.Controls.Add(this.txtConfirm);
this.Controls.Add(this.txtpwd);
this.Controls.Add(this.txtuser);
this.Controls.Add(this.lblConfirm);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnClear);
this.Controls.Add(this.btnRegister);
this.Controls.Add(this.lblpwd);
this.Controls.Add(this.lblUser);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "RegisterUser";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Register User";
this.ResumeLayout(false);
}
#endregion
65
if(txtConfirm.Text.Equals(""))
{
MessageBox.Show("Please Confirm Password","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(!txtConfirm.Text.Equals(txtpwd.Text))
{
MessageBox.Show("Password not confirmed","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
bool IsSuccesfulRegister = false;
try
{
IsSuccesfulRegister =
Globals.RegisterUser(txtuser.Text,txtpwd.Text);;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!IsSuccesfulRegister)
{
MessageBox.Show("This user already exists. Please
enter some other user name","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
txtuser.Text = "";
txtpwd.Text = "";
txtConfirm.Text = "";
txtuser.Focus();
return;
}
else
{
MessageBox.Show("User succesfully
registered.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
Globals.UsersList.Add(txtuser.Text,0);
Globals.UserName = txtuser.Text;
Globals.Password = txtpwd.Text;
Globals.isSystemUser = false;
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
66
}
}
67
/* code for changing password */
using System;
68
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Library_Management
{
public class ChangePassword : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblOld;
private System.Windows.Forms.Label lblConfirm;
private System.Windows.Forms.Label lblNew;
private System.Windows.Forms.TextBox txtOld;
private System.Windows.Forms.TextBox txtNew;
private System.Windows.Forms.TextBox txtConfirm;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnCancel;
private System.ComponentModel.Container components = null;
public ChangePassword()
{
InitializeComponent();
69
this.lblConfirm.Name = "lblConfirm";
this.lblConfirm.Size = new System.Drawing.Size(136, 23);
this.lblConfirm.TabIndex = 4;
this.lblConfirm.Text = "Confirm New Password";
this.lblNew.Location = new System.Drawing.Point(20, 89);
this.lblNew.Name = "lblNew";
this.lblNew.TabIndex = 2;
this.lblNew.Text = "New Password";
this.txtOld.Location = new System.Drawing.Point(173,
45);
this.txtOld.MaxLength = 8;
this.txtOld.Name = "txtOld";
this.txtOld.PasswordChar = '*';
this.txtOld.TabIndex = 1;
this.txtOld.Text = "";
this.txtNew.Location = new System.Drawing.Point(172,
85);
this.txtNew.MaxLength = 8;
this.txtNew.Name = "txtNew";
this.txtNew.PasswordChar = '*';
this.txtNew.TabIndex = 3;
this.txtNew.Text = "";
this.txtConfirm.Location = new System.Drawing.Point(172,
125);
this.txtConfirm.MaxLength = 8;
this.txtConfirm.Name = "txtConfirm";
this.txtConfirm.PasswordChar = '*';
this.txtConfirm.TabIndex = 5;
this.txtConfirm.Text = "";
this.btnSave.Location = new System.Drawing.Point(65,
205);
this.btnSave.Name = "btnSave";
this.btnSave.TabIndex = 6;
this.btnSave.Text = "&Save";
this.btnSave.Click += new
System.EventHandler(this.btnSave_Click);
this.btnCancel.Location = new System.Drawing.Point(153,
205);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 7;
this.btnCancel.Text = "&Cancel";
this.btnCancel.Click += new
System.EventHandler(this.btnCancel_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.txtConfirm);
this.Controls.Add(this.txtNew);
this.Controls.Add(this.txtOld);
this.Controls.Add(this.lblNew);
this.Controls.Add(this.lblConfirm);
this.Controls.Add(this.lblOld);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)
(resources.GetObject("$this.Icon")));
70
this.MaximizeBox = false;
this.Name = "ChangePassword";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Change Password";
this.ResumeLayout(false);
}
#endregion
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
71
return;
}
if(isSuccess)
{
Globals.Password = txtNew.Text;
MessageBox.Show("Password Changed","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}
}
}
}
72
CONCLUSION
After we have completed the project we are sure the problems in the existing system would
overcome. The “SMART LIBRARY MANAGEMENT SYSTEM” process made
computerized to reduce human errors and to increase the efficiency. The main focus of this
project is to lessen human efforts. The maintenance of the records is made efficient, as all
the records are stored in the ACCESS database, through which data can be retrieved easily.
The navigation control is provided in all the forms to navigate through the large amount of
records. If the numbers of records are very large then user has to just type in the search
string and user gets the results immediately. The editing is also made simpler. The user has
to just type in the required field and press the update button to update the desired field.
The Books and Students are given a particular unique id no. So that they can be accessed
correctly and without errors. Our main aim of the project is to get the correct information
about a particular student and books available in the library.
The problems, which existed in the earlier system, have been removed to a large extent. And
it is expected that this project will go a long way in satisfying users requirements. The
computerization of the Library Management will not only improves the efficiency but will
also reduce human stress thereby indirectly improving human recourses.
73
BIBLIOGRAPHY
.Black Book C#
.MSDN Help
74