Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 74

 

A PROJECT REPORT
ON

SMART LIBRARY MANAGEMENT SYSTEM


Submitted in partial fulfillment of the award of the degree of

Bachelor of Technology in Computer Science

By

SUHEL CHAUHAN

KUMAR AKASH RANJAN

PANKAJ KUMAR

MOHAN SINGH PANWAR

Under the Supervision of

Mr. SHUBHASHISH GOSWAMI

Department of Computer Science


DBIT, DEHRADUN
2010

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

Kumar Akash Ranjan

Pankaj Kumar

Mohan Singh Panwar

2
Abstract

This project of “SMART LIBRARY MANAGEMENT SYSTEM” of gives us the

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.3 Technology Used :


Front End :Microsoft Visual Studio.Net 2008
Back End : Microsoft SQL Server 2005.

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#

1. C# is pure object oriented language like Java.

2. C# is first component oriented language.

3. It was developed by M.S. Corp., USA in 2000.

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”.

5. It combines the concept of C, power of C++, elegance of Java and productivity of


VB, besides having new features to support component oriented programming.

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.

2. Some Key Features of C# are –

-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

2.4 Data Types

The memory allocated to variables is referred to in the following ways:

Value types: Contains data. Built-in data types, such as int, char, and float are
value types.

Reference types: Contains address referring to a block of memory. Data types,


such as string and class are reference types.

8
Overall Description

3.1 Product Perspective

The proposed Library Management System which is being developed by Innovative


Library Management Solutions team is Smart Library Management System. This
System will provide a search functionality to facilitate the search of resources. This
search will be based on various categories viz. book name . Also Advanced Search
feature is provided in order to search various categories simultaneously. Further the
library staff personnel can add/update/remove the resources and the resource users
from the system.
The University of Ballarat has various campuses distributed across Australia. Further
each branch is managed individually and locally by that branch library staff. The
System should reflect and support this decentralized structure. A provision should
further be allowed to add a branch. The System will also have an ADMIN who has
full-fledged rights with regards to managing resources across branches – such as
transferring books across these branches. The users can know the number of
available books, information about their account etc.,

 3.2 Product Features

There is single user who will be using this product:

   Librarian who will be acting as the administrator

  The features that are available to the Librarian are:

   A librarian can issue a book to the student.

   Can view The different categories of books available in the Library

   Can view the List of books available in each category

9
   Can take the book returned from  students

   Add books and their information of the books to the database

   Edit the information of the existing books.

   Can check the report of the issued Books.

  Can access all the accounts of the students.

3.3 User Classes and Characteristics


There is only one user for the product. Usually this smart product is visited by admin for
different reasons:

 Librarian who will be acting as the controller and he will have all the privileges of an
administrator.

3.4 Operating Environment


The product will be operating in windows environment.

3.5 Design and Implementation Constraints


The Product is developed using ASP. The backend database for this SQL Server. The
product is accomplished with login facility so that specific function is available to admin.

3.6 User Documentation


The product will include user manual. The user manual will include product overview,
complete configuration of the used software (such as SQL server), technical details, backup
procedure and contact information which will include email address. There will be no online
help for the product at this moment. The databases will be created in the Microsoft SQL
server 2005

3.7 Assumptions and Dependencies


The product needs following third party product.
 
      Microsoft SQL server to store the database.
      ASP to develop the Product

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

4.2 Stimulus / Response Sequences

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.

4.3 Functional Requirements


This section gives the list of Functional and non functional requirements which are
applicable to the Library Management System.

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

4.4 Non Functional Requirements


4.4.1 User Interfaces             
4.4.2. Hardware Interfaces

             Operating System: Windows 9x/xp  ,Windows ME or upgrade any version

    Processor: Pentium  3.0 GHz or higher

          RAM: 256 Mb or more

        Hard Drive: 10 GB or more

4. 4.3. Software Interfaces

            Database: SQL Server.

         Application: ASP (Active Server Pages)

4.5 Other Nonfunctional Requirements

4.5.1 Performance Requirements


The proposed system that we are going to develop will be used as the Chief performance
system within the different campuses of the college which interact with the college staff and
students. Therefore, it is expected that the database would perform functionally all the
requirements that are specified by the college.

4.5.2 Safety Requirements


 The database may get crashed at any certain time due to virus or operating system failure.
Therefore, it is required to take the database backup

4.5.3 Security Requirements


We are going to develop secured database for the college .There is encryption and
decryption for security purpose. It means if the user is an administrator then he can be able
to modify the data, delete, append etc.,

Software Quality Attributes

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.

4.5.4 Hardware Constraints


The system requires a database in order to store persistent data. The database should have
backup capabilities.

4.5.5 Software Constraints


The development of the system will be constrained by the availability of required software
such as database and development tools.

4.5.6 Design Constraints


The system must be designed to allow gui usability. That is, the system must be designed in
such a way that will be easy to use and visible on most of the gui based system.

14
TABLE DESIGN

Lib User: Table

 Field Name Data Type


S No
1 User_id Number
2 Total_limit Number
3 Books_left Text
4 Status Text
  

Issue  : Table

 Field Name Data Type


S.No
.
1 Bno Number
2 Id Number
3 Issue_date Date/time
4 Due_date Date/time
5 Copies_available Number
 User : Table

15
 Field Name Data Type
S.No
.
1 Id Number
2 Roll_no Number
3 Name Text
4 Branch Text

 Book : Table

 Field Name Data Type


S.No
.
1 B_no Number
2 ISBN Number
3 Subject Text
4 Name Text
5 Author Text
6 Publisher Text
7 Editor Number
8 Copies Number
9 Cost Number
 Issue_return : Table

  

 Field Name Data Type


S.No
.
1 B_no Number
2 Id Number
3 Issue_date Date/Time
4 Due_date Date/Time
16
5 Return_date Date/time
6 Fine Number
7 Copies_available Number
 

                                    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
{

public class MainForm : System.Windows.Forms.Form


{

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);

protected override void Dispose( bool disposing )


{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(MainForm));
this.lblUser = new System.Windows.Forms.Label();
this.lblpwd = new System.Windows.Forms.Label();
this.txtuser = new System.Windows.Forms.TextBox();
this.txtpwd = new System.Windows.Forms.TextBox();
this.btnRegister = new System.Windows.Forms.Button();
this.btnLogin = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.lblUser.BackColor =
System.Drawing.SystemColors.Control;
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.ForeColor =
System.Drawing.SystemColors.ControlText;
this.lblUser.Location = new System.Drawing.Point(61,
106);
this.lblUser.Name = "lblUser";
this.lblUser.TabIndex = 0;
this.lblUser.Text = "User Name";

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();
}

private void btnLogin_Click(object sender, System.EventArgs e)


{
if(txtuser.Text.Equals(""))
{
MessageBox.Show("Please Enter User Name","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtpwd.Text.Equals(""))
{
MessageBox.Show("Please Enter Password","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}

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();
}

private void MainForm_Load(object sender, EventArgs e)


{
try

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.

Admin user available in system at start is admin with password as 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();
}

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Actions));
this.grpActions = new System.Windows.Forms.GroupBox();
this.rdoChgPwd = new System.Windows.Forms.RadioButton();
this.rdoAddBooks = new
System.Windows.Forms.RadioButton();
this.rdoCategory = new
System.Windows.Forms.RadioButton();
this.rdoReturn = new System.Windows.Forms.RadioButton();
this.rdoSearchBooks = new
System.Windows.Forms.RadioButton();
this.btnOk = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.lblWelcome = new System.Windows.Forms.Label();
this.grpActions.SuspendLayout();
this.SuspendLayout();
this.grpActions.Controls.Add(this.rdoChgPwd);
this.grpActions.Controls.Add(this.rdoAddBooks);
this.grpActions.Controls.Add(this.rdoCategory);
this.grpActions.Controls.Add(this.rdoReturn);
this.grpActions.Controls.Add(this.rdoSearchBooks);
this.grpActions.Location = new System.Drawing.Point(16,
40);
this.grpActions.Name = "grpActions";
this.grpActions.Size = new System.Drawing.Size(312,

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

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
Application.Exit();
}

private void btnCancel_Click(object sender, System.EventArgs


e)
{
Globals.UserName = "";
Globals.Password = "";
this.Close();
this.Dispose();
MainForm frmLogin = new MainForm();
frmLogin.ShowDialog();
}

private void btnOk_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
if(rdoSearchBooks.Checked)

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();

}
}

private void Actions_Load(object sender, System.EventArgs e)


{
lblWelcome.Text = "Welcome " + Globals.UserName;
if(Globals.isSystemUser)
{
rdoAddBooks.Enabled = true;
rdoCategory.Enabled = true;
}
else
{
rdoAddBooks.Enabled = false;
rdoCategory.Enabled = false;
}
}

}
}

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

/* code for search/issue book */

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;
}

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(SearchBooks));
this.lblBookName = new System.Windows.Forms.Label();
this.lblCat = new System.Windows.Forms.Label();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtCat = new System.Windows.Forms.TextBox();
this.txtBook = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.lblAvailable = new System.Windows.Forms.Label();
this.btnIssue = new System.Windows.Forms.Button();
this.lblNote = new System.Windows.Forms.Label();
this.btnReturn = new System.Windows.Forms.Button();

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

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
Application.Exit();
}

private void btnReturn_Click(object sender, System.EventArgs


e)
{
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}

private void btnSearch_Click(object sender, System.EventArgs


e)
{
if(txtBook.Text.Equals("") && txtCat.Text.Equals(""))
{
MessageBox.Show("Please enter atleast one of
search criteria","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
try

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;
}
}

private void dataGrid1_MouseUp(object sender, MouseEventArgs


e)
{
DataGrid.HitTestInfo ht = dataGrid1.HitTest(e.X,e.Y);
int row = ht.Row;
if(row == -1 && SelecetedBook == -1)
{
dataGrid1.Select(0);
SelecetedBook = 0;
}
else if(row == -1 && SelecetedBook !=-1)
{
dataGrid1.Select(SelecetedBook);

}
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();

private System.ComponentModel.Container components = null;

public ReturnBook()
{
InitializeComponent();
this.cmbreturn.SelectedIndexChanged+=new
EventHandler(cmbreturn_SelectedIndexChanged);

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(ReturnBook));
this.lblSelect = new System.Windows.Forms.Label();
this.cmbreturn = new System.Windows.Forms.ComboBox();
this.btnreturn = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnAction = new System.Windows.Forms.Button();
this.txtAuthor = new System.Windows.Forms.TextBox();
this.txtCat = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.lblSelect.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,

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

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
Application.Exit();
}

private void btnAction_Click(object sender, System.EventArgs


e)
{
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}

private void btnreturn_Click(object sender, System.EventArgs


e)
{
bool IsSuccess=false;
try
{
string selIndex =
cmbreturn.SelectedIndex.ToString();
string BookIssueId= "";
string BookId= "";
string SelectedIds= "";
int Bookindex = -1;
IDictionaryEnumerator myEnumerator =
IDTable.GetEnumerator();
while(myEnumerator.MoveNext())
{
if
(selIndex.Equals(myEnumerator.Key.ToString()))
{
SelectedIds =
myEnumerator.Value.ToString();

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();

}
}

private void ReturnBook_Load(object sender, System.EventArgs


e)
{
DataSet ds = Globals.PopulateReturnBooks();
if(ds !=null && ds.Tables[0].Rows.Count > 0)

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;
}

private void cmbreturn_SelectedIndexChanged(object sender,


EventArgs e)
{
IDictionaryEnumerator myEnumerator =
BookDetail.GetEnumerator();
while( myEnumerator.MoveNext() )
{

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();
}

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Category));
this.lblCat = new System.Windows.Forms.Label();
this.txtCatName = new System.Windows.Forms.TextBox();
this.lblName = new System.Windows.Forms.Label();
this.btnExit = new System.Windows.Forms.Button();
this.btnAction = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
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(13, 16);
this.lblCat.Name = "lblCat";
this.lblCat.Size = new System.Drawing.Size(264, 24);
this.lblCat.TabIndex = 0;
this.lblCat.Text = "Add New Category";
this.txtCatName.Location = new System.Drawing.Point(16,
88);
this.txtCatName.Name = "txtCatName";

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();
}

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
Application.Exit();
}

private void btnAdd_Click(object sender, System.EventArgs e)


{
if(txtCatName.Text.Equals(""))
{
MessageBox.Show("Please Enter a category
","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
bool isSuccesfulAddition = false;
try
{
isSuccesfulAddition =
Globals.AddCategory(txtCatName.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
this.Dispose();
Application.Exit();
return;
}
if(!isSuccesfulAddition)
{
MessageBox.Show("This category already exists.
Please enter some other category","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
MessageBox.Show("Category succesfully
entered.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);

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.

/* code fro add/remove books


*/

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 );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(AddBooks));
this.lblTitle = new System.Windows.Forms.Label();
this.lblAuthor = new System.Windows.Forms.Label();
this.lblcat = new System.Windows.Forms.Label();
this.lblQty = new System.Windows.Forms.Label();
this.txtTitle = new System.Windows.Forms.TextBox();
this.txtAuthor = new System.Windows.Forms.TextBox();
this.txtQty = new System.Windows.Forms.TextBox();
this.cmbCat = new System.Windows.Forms.ComboBox();
this.btnExit = new System.Windows.Forms.Button();
this.btnAction = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.grpAdd = new System.Windows.Forms.GroupBox();

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

private void btnAction_Click(object sender, System.EventArgs


e)
{
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}

private void btnAdd_Click(object sender, System.EventArgs e)


{
if(txtTitle.Text.Equals(""))
{
MessageBox.Show("Please Enter Book Title","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtAuthor.Text.Equals(""))
{
MessageBox.Show("Please Enter Author
Name","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtQty.Text.Equals(""))
{
MessageBox.Show("Please Enter Quantity of books in
numeric format","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;

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);
}

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
this.Dispose();
Application.Exit();
}

private void btnRemove_Click(object sender, System.EventArgs


e)
{
if(cmbRemoveBook.Items.Count == 0)
{
MessageBox.Show("No books available to be
removed","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);

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();
}

private void AddBooks_Load(object sender, System.EventArgs e)


{
if(Globals.CategoryList!=null &&
Globals.CategoryList.Count > 0)
{
IDictionaryEnumerator myEnumerator =
Globals.CategoryList.GetEnumerator();
while ( myEnumerator.MoveNext() )
cmbCat.Items.Add(myEnumerator.Value);

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;
}

private void cmbRemoveBook_SelectedIndexChanged(object sender,


System.EventArgs e)
{
IDictionaryEnumerator myEnumerator =
_BookList.GetEnumerator();
while( myEnumerator.MoveNext() )
{

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();

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(RegisterUser));
this.btnCancel = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.btnRegister = new System.Windows.Forms.Button();
this.txtpwd = new System.Windows.Forms.TextBox();
this.txtuser = new System.Windows.Forms.TextBox();
this.lblpwd = new System.Windows.Forms.Label();
this.lblUser = new System.Windows.Forms.Label();
this.txtConfirm = new System.Windows.Forms.TextBox();
this.lblConfirm = new System.Windows.Forms.Label();
this.SuspendLayout();
this.btnCancel.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnCancel.Location = new System.Drawing.Point(229,
222);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 8;
this.btnCancel.Text = "C&ancel";
this.btnCancel.Click += new
System.EventHandler(this.btnCancel_Click);
this.btnClear.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnClear.Location = new System.Drawing.Point(134,
222);

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

private void btnCancel_Click(object sender, System.EventArgs


e)
{
this.Close();
this.Dispose();
MainForm frmLogin = new MainForm();
frmLogin.ShowDialog();
}

private void btnClear_Click(object sender, System.EventArgs e)


{
txtuser.Text = "";
txtpwd.Text = "";
txtConfirm.Text = "";
}

private void btnRegister_Click(object sender, System.EventArgs


e)
{
if(txtuser.Text.Equals(""))
{
MessageBox.Show("Please Enter User Name","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtpwd.Text.Equals(""))
{
MessageBox.Show("Please Enter Password","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}

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
}
}

Change user password

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();

protected override void Dispose( bool disposing )


{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(ChangePassword));
this.lblOld = new System.Windows.Forms.Label();
this.lblConfirm = new System.Windows.Forms.Label();
this.lblNew = new System.Windows.Forms.Label();
this.txtOld = new System.Windows.Forms.TextBox();
this.txtNew = new System.Windows.Forms.TextBox();
this.txtConfirm = new System.Windows.Forms.TextBox();
this.btnSave = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
this.lblOld.Location = new System.Drawing.Point(20, 45);
this.lblOld.Name = "lblOld";
this.lblOld.TabIndex = 0;
this.lblOld.Text = "Old Password";
this.lblConfirm.Location = new System.Drawing.Point(20,
133);

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

private void btnCancel_Click(object sender, System.EventArgs


e)
{
this.Close();
this.Dispose();
Actions act = new Actions();
act.ShowDialog();
}

private void btnSave_Click(object sender, System.EventArgs e)


{
if(txtOld.Text.Equals("") || txtNew.Text.Equals("") ||
txtConfirm.Text.Equals(""))
{
MessageBox.Show("All required data is not entered
by you.","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtOld.Text != Globals.Password)
{
MessageBox.Show("Old password entered is not
correct","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(txtNew.Text != txtConfirm.Text)
{
MessageBox.Show("Password confirmation is not
correct","Library
Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
bool isSuccess = false;
try
{
isSuccess =
Globals.ChangePassword(Globals.UserName,txtNew.Text);

}
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

You might also like