You are on page 1of 52

M  


This is to certify that Mr. "  of
Department  
    Semester ²
  Session ² Registration number ²
Mhas successfully completed his
project on  
  
under
thesupervision and guidance of Mr. PHILIP SAMUEL .

___________________
Dated :____________ Project Incharge

Place : kochi





1
  ! "


At the outset, we thank God almighty for making our endeavor


a success. We also express our gratitude to D# "  $

% , Head of the Department for providing us with
adequate facilities, ways and means by which we were able to
complete this project.

We express our sincere gratitude to our Project Guide Mr.


Rohit J Markus,Orionis Academy for his constant support and
valuable suggestions without which the successful completion
of this project would not have been possible.

We express our immense pleasure and thankfulness to all the


teachers and staff of the Department of Information
Technology, CUSAT for their cooperation and support.

Last but not the least, we thank all others, and especially our
classmates and our family members who in one way or another
helped us in the successful completion of this work.

2
Contents
1.mIntroduction4 - 5
2.mSoftware Requirement Specification
m Purpose of document 6
m Scope7
m Objective7 - 8
m Budget8
m Technology used8 - 9
m Overview of solution9
m Milestones9 -10
m Business objective10
m Constraints10
m Features and services11
m Assumption /Risk assessment11-12
m Functional specification12
m Infrastructure 12
m Server / solution 12
m Client platform 13
m Non functional requirement 13
m Software quality attributes 13 -14
m Technical challenges 14
3.mData flow diagram 15 -16
4.mForms 17 -28
5.mAsp codes 29 -50
6.mConclusion 51
7.mBibiliography 52

3
 "% 

As the name suggests Library Management System will deal


in all the requirements needed for managing libraries. It will
deal with the process of maintaining data about the books and
many other things as well as transactions, which are taking
place in the library with respect to the issue and return of the
books.

This solution helps the administrator to accomplish his tasks


at ease. This solution is an online library management system,
which lets users sign-up to the library initially and then sign-
in every time they want to find some item in the library. The
user can also maintain and edit his profile details.

It also lets administrators manage the library from their


desktop. They can monitor any item, its stock and other

4
related information. A user can sign-in and search for items,
borrow items if they are present in the library. All details of
the user are stored in the database, which eases pressure on
the administrator about defaulters. The administrator can
block or remove the defaulters from the library. The user need
not visit the library every time to find an item; instead, he/she
can search items from his/her own PC/laptop. Reports can also
be generated for individual items or for number of defaulters
and the number of transactions for an item or by a user.








5
 ! &%

$  
m
åmPurpose of this Document :
This is the Software Requirements Specification for the
Library Management System. The purpose of this document is
to convey the functional and performance requirements of the
product as specified by the feasibility study and requirement
analysis conducted by the developer. Primarily, this document
ensures that the software requirements of the product are
properly understood by the programmer/developer as specified
by the clients. To create software for managing the products
inside the company and publishing the product details to the
world using a web application.

6
åmScope :

The objective of the Library Management is to create a central,


functional website which contains the details of all the books
available in the library, so that it can be searched by the users
who visit the site .Mainly there are two classes of users ²
administration and Library Members(students).Admin can use
all the links to perform the operation for the receiving and
lending of the books and keep all the details of the books and
the respective students who has taken the book. User can go
through all the links available to him/her. The system shall
require a user to login , in order to see the details of his own
and the issued books . It will ask the user for the following
information ² username and password. Website keeps the
details of registered users and books on their database.

åmObjective :
Objective of the project is to create a library management
system which sorts the administrators and students
separately. It empowers each with different levels of privileges.
Users and administrators are allowed to search and lend/take
books from the library. It also sorts the items in the library
and lets administrator to monitor items/members and also

7
generate graphical reports for them. Administrator can even
deny membership to them if the rules are not followed strictly.
 

åmBUDGET :
Budget would include initial setup of the server that would
include a system as a server and one system for
browsing/searching the library. Using many more systems for
browsing may affect the budget of the solution implementer.


åmTECHNOLOGY'
ümASP.NET 2.0
ASP.NET is a server side scripting technology that
enables scripts (embedded in web pages) to be executed
by an Internet server. ASP.NET is a part of the
Microsoft .NET framework, and a powerful tool for
creating dynamic and interactive web pages.

ümASP.NET is a Microsoft Technology


ümASP stands for Active Server Pages
ümASP.NET is a program that runs inside IIS
ümIIS (Internet Information Services) is Microsoft's Internet
server
ümIIS comes as a free component with Windows servers
ümIIS is also a part of Windows 2000 and XP Professional

ümSQL Server 2005 Express edition


SQL is a standard language for accessing and manipulating databases.

8
ümSQL stands for Structured Query Language
ümSQL lets you access and manipulate databases
ümSQL is an ANSI (American National Standards Institute)
standard

ümWindows XP Professional Edition


All the above listed softwares are either freeware or trial version
software. Certain features which these lacks may be successfully
executed using a licensed version of the same set of softwares. Hence
this affects the budget of a solution developer.

åmOVERVIEW OF SOLUTION :
The users and administrators can create their accounts based
on different privileges. They can lend borrow books in library
based on their privileges. Administrator sorts, edits the items
in the library. By using this solution, managing/maintaining
the server becomes easy. The interface provides more
information and saves time. This is much more accurate than
a librarian updating the fields manually. The database is
updated after every transaction and leaves no user fooled
about the status of availability of an item.

åmMilestones'
ümAnalyzing solutions and finding possible entities.
ümDesigning the user interface.
ümPrototyping the project.

9
ümCreating data base tables and establishing relationships
with the user interface.
ümCode the user authentications, search algorithms and other
special features.
ümTesting the solution and bettering it.
ümImplementing the solution and also documenting it#

åmBusiness Objectives :
ümTo provide a reliable solution.
ümBetter interfaces to make transactions easier.
ümTo help users get accurate search results in no-time.
ümTo make the solution available to every library present.
ümTo improve solution based on feedback from the solution
audience.


åmConstraints :
Constraint Known impact Issues :-

1. Non-availability of licensed softwares. Lesser number of


features generated from limited trial wares.

Developer may find difficulties in creating the solution.

2. User must have basic knowledge of computers. User finds it


difficult to use the computer. Solution cannot be exploited
properly#


10


åmFeatures and Services :


Features of the library management are as follows:-
Registration - Allows users to sign up for accessing the library.
Managing the library - Allows administrators to update,
view/edit book details and also categorize them into different
categories based on type.

Search facility - Users including the administrators can check


for books if it is available or not . Administrator can also check
the members if any one has taken the book or not.

Monitor members- Administrator can monitor members too


and also view details or can even deny membership to
defaulters.

åmAssumption / Risk assessment :


Assumptions support the base of the solution. Assumptions
include :-

ümLibrary houses a certain minimum number of copies of the


same book for sake of many borrowers.
ümLibrary uses original books.
ümLibrary server is not overloaded and is maintained
throughout the year.
ümLibrary restricts the maximum number of borrowable items
for different users.
ümLibrary server runs a version of Windows operating system.

11
ümClient systems support .NET Framework.
ümUser has basic computer knowledge and knows how to
search/find information in the internet.
ümUser has a decent internet speed to run the online solution.

åmFunctional specification:
Initially when the solution is host in the server, administrator
accounts are setup. These administrators manage the server.
First time users can carry on with simple search but those who
want to borrow books need to sign-up for this facility. They can
then sign-in anytime for searching, borrowing or returning
books. They can also view their profile pages.

åmInfrastructure :
Infrastructure plays an important role in this type of server-
client computing. Both server and client require a minimum
amount of configuration to run the implementation.

åmServer/Solution:
Platform Server must run a WINDOWS OS which supports IIS so that
the website can be deployed. The server must also be capable of running
Visual studio and SQL Server for database management.

12
åmClient Platform :
Client system must run a windows operating system. It must
run browsers which support .NET framework like Internet
Explorer or Mozilla Firefox.

åmNon functional requirement:


Performance Requirements :-

The user must have a system which is capable of running a


Windows operating system released after Windows 98/XP, i.e.
it requires a minimum of 256 MB RAM.
Software requirements'

Front end: ASP.NET

Back end: SQL Server

Security Requirements :-
The users are authenticated with their register numbers and
passwords. The password can be changed anytime by the user to
improve security.

åmSoftware Quality Attributes :

The interface is such that the user can learn from looking at
the menus. Help files will also be provided with the solution.
Use of .NET 2.0 has improved reliability and major

13
improvement in functionality which makes it more adaptable
and flexible.

åmTechnical Challenges :
ümReal-time searching algorithms.
ümGridview is available for the user used to check book details
online and retrieve it for the user.
ümUsing AJAX Controls for various features.
ümIntricacies in databases are not known.

14
Ú  !" 


 Library Management
User
User
System

Level - I

Book
Admin Login Table book
registration

Lending
Lending
table

Lending
Returning
table

Student Student
registration record

15
Level - II

Lending
Student Login Available
table
book

Student Student
profile record

16
 '
åm Loginpage:

This is the home page of OnlineLibrary.com There are two


parts of login interface. One is Administrator Login and the
other is user·s Login. The login id and password is fixed for
Administrator. Administrators have full access on the system
like insertion, modification, deletion etc. The homepage
restricts the entry of unauthorizedmembers andon entering

17
correct username and password, valid members are navigated
to homepage.


åm Home page :

This is the home page viewed when admin logins. It consists of


several links like homepage, Book registration, Member
registration, Book availability, Lending process, Returning

18
process, Lended books. The Homepage also contain a list of
rules regarding decorum of library. Admin can navigate to
corresponding page just by clicking on the specified links.

This is the home page viewed when valid members logins. It


consists of several links like homepage, Book availability,
Member profile. The Homepage also contain a list of rules

19
regarding decorum of library. Members can navigate to
corresponding page just by clicking on the specified links.

åm Book registration :

In this page all details i.e. (Book Name, Book Code, Author
Name, Publisher, Category and Price) regarding the books can
be inserted and saved through

Submit button. Clear button is used to clear all the textboxes


and dropdown lists. If the admin want to update any details of

20
any book that is already available in database then he just
need to click Edit button. On clicking Editbutton a grid view
will appear with select option through which he can select the
required book and all the details regarding that book is itself
filled in the respective text boxes. Then the field he wants to
change he can update through Update button.

åm Member registration :

In this page all details i.e. (Student Name, User Name,


Password, Retype Password, Registration Number, Course,
Batch, Address and Contact Number) regarding the Students

21
can be inserted and saved through Submit button. Clear
button is used to clear all the textboxes and dropdown lists. If
the admin want to update any details of any Student that is
already available in database then he just need to click Edit
button. On clicking Edit button a grid view will appear with
select option through which he can select the required Student
and all the details regarding that Student is itself filled in the
respective text boxes. Then the field he wants to change he can
update through Update button.

åm Book availability :

22
This page consists of a grid view which lists all the books
available in the library along with their respective book code.

åm Lending process :

23
This page is used to save details regarding the student, the
book and the date of issue, in the database with the help of
Save button. During page load the date of issue is considered
to be today·s date but the admin is also provided the calendar
through which he can select any date. As soon as admin select
any student then side by side a grid view is also shown which
lists all the books that have been current issued against that
student. Clear button is used to clear all the text boxes. Admin
can also update any lending record just by clicking on the
student in the grid view.

24
åm Returning process :

This page is used to save details regarding the student, the


book the date of issue and the fine, in the database with the
help of Save button.During page load the date of return is
considered to be today·s date but the admin is also provided
the calendar through which he can select any date. Fine is also
calculated and is displayed in the fine text box. . As soon as

25
admin select any student then side by side a grid view is also
shown which lists all the books that have been current issued
against that student. Clear button is used to clear all the text
boxes. Admin can also update any returning record just by
clicking on the student in the grid view. Actual date of
returning is after fourteen days of date of issue.

åm Lended books:

This page consists of grid view which shows all the books that
have been lended along with other details like Book code,
Author, Student name, Registration number, course, Batch,
Date of issue.

26
åm Student profile :

This page is loaded when any valid member logins and then in
homepage clicks the link of student profile. In this page all the
details about him is given in the corresponding text boxes. This
page consist a grid view also which lists all the books that have
been issued on his name. This page is provided so that the
valid members can also keep records about their membership
and can also see which all books have been issued on their

27
name. But the members are not given the provision to change
any record as all the text boxes are in the read only mode.

 $M " 

åm Login page :

28
using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

publicpartialclasslibs_Pages_LoginPage : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

protectedvoid Login_Authenticate(object sender, AuthenticateEventArgs e)


{
StringBuilder stbSQL = newStringBuilder();
stbSQL.AppendFormat("SELECT Id,Type FROM LoginRecord WHERE
UserName='{0}' AND Password='{1}'", Login1.UserName, Login1.Password);
DataTableReader dr = CGeneral.Read(Convert.ToString(stbSQL));
if (dr.Read())
{
if(!dr.IsDBNull(0))
{
Int32 int32Id = dr.GetInt32(0);
Int32 int32Type = dr.GetInt32(1);
Session["UserId"] = int32Id;
Session["UserType"] = int32Type;
Response.Redirect("~/libs/Pages/Home/HomePage.aspx");

}
else
{
e.Authenticated = false;
}

29
}
}
}
m
m
m

åm Member registration :m
m
m
using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

publicpartialclasslibs_Pages_Member_Registration : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

}
protectedvoid CustomValidatorCourse_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (DropDownListCourse.SelectedValue == "-1")
args.IsValid = false;
}

protectedvoid Submit_Click(object sender, EventArgs e)


{
String strStudentName,strRegistrationNumber,
strAddress,strContactNumber,strUserName,strPassword ;
StringBuilder stbSQL = newStringBuilder();
strStudentName = TextBoxStudentName.Text;
strRegistrationNumber=TextBoxRegistrationNumber.Text;

30
Int32 int32Course = Convert.ToInt32(DropDownListCourse.SelectedValue);
int int32Batch = Convert.ToInt32( DropDownListBatch.SelectedValue);
strAddress = TextBoxAddress.Text;
strContactNumber = TextBoxContactNumber.Text;
strUserName = TextBoxUserName.Text;
strPassword = TextBoxPassword.Text;
Int32 int32Id = CGeneral.GetNextId("LoginRecord", "Id");

stbSQL.Append("INSERT INTO
LibraryStudentRecord(Id,StudentName,RegistrationNumber,Course,Batch,Address
,ContactNumber)");
stbSQL.AppendFormat("Values({0},'{1}','{2}',{3},{4},'{5}','{6}')", int32Id,
strStudentName, strRegistrationNumber, int32Course, int32Batch, strAddress,
strContactNumber);
CGeneral.Execute(stbSQL.ToString());
StringBuilder stbSQL1 = newStringBuilder();
stbSQL1.Append("INSERT INTO
LoginRecord(Id,UserName,Password,Type) ");
stbSQL1.AppendFormat("Values('{0}','{1}','{2}',2)", int32Id, strUserName,
strPassword);
CGeneral.Execute(stbSQL1.ToString());
clear();

}
protectedvoid clear()
{
TextBoxStudentName.Text = " ";
TextBoxAddress.Text = " ";
TextBoxContactNumber.Text = " ";
TextBoxRegistrationNumber.Text = " ";
DropDownListCourse.SelectedIndex = 0;
TextBoxUserName.Text = " ";
TextBoxPassword.Text = " ";
TextBoxRetypePassword.Text = " ";
DropDownListBatch.SelectedIndex = 0;
ButtonEdit.Visible = true;
ButtonSubmit.Visible = true;
GridViewLibraryStudentRecord.Visible = false;
ButtonUpdate.Visible = false;
}
protectedvoid Clear_Click(object sender, EventArgs e)
{
clear();
}

31
protectedvoid CustomValidatorBatch_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListBatch.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid ButtonEdit_Click(object sender, EventArgs e)
{
GridViewLibraryStudentRecord.Visible = true;
}
protectedvoid ButtonUpdate_Click(object sender, EventArgs e)
{
int Id = (int)Session["Id"];
String strStudentName, strRegistrationNumber, strAddress, strContactNumber,
strUserName, strPassword, strCourse;
StringBuilder stbSQL = newStringBuilder();
StringBuilder stbSQL2 = newStringBuilder();
strStudentName = TextBoxStudentName.Text;
strRegistrationNumber = TextBoxRegistrationNumber.Text;
stbSQL2.AppendFormat("SELECT Id FROM LibraryStudentRecord WHERE
RegistrationNumber='{0}' AND Id!={1}",strRegistrationNumber,Id);
CGeneral.Read(stbSQL2.ToString());
if(CGeneral.RecordExists==false)
{
strCourse = DropDownListCourse.SelectedValue;
int int32Batch = Convert.ToInt32(DropDownListBatch.SelectedValue);
strAddress = TextBoxAddress.Text;
strContactNumber = TextBoxContactNumber.Text;
strUserName = TextBoxUserName.Text;
strPassword = TextBoxPassword.Text;
stbSQL.AppendFormat("UPDATE LibraryStudentRecord SET
StudentName='{0}',RegistrationNumber='{1}',Course='{2}',", strStudentName,
strRegistrationNumber, strCourse);
stbSQL.AppendFormat("Batch={0},Address='{1}',ContactNumber='{2}'",
int32Batch, strAddress, strContactNumber);
stbSQL.AppendFormat(" WHERE Id={0}", Id);
CGeneral.Execute(stbSQL.ToString());
StringBuilder stbSQL1 = newStringBuilder();
stbSQL1.AppendFormat("UPDATE LOginRecord SET
UserName='{0}',Password='{1}'", strUserName, strPassword);
stbSQL1.AppendFormat(" WHERE Id={0}", Id);
CGeneral.Execute(stbSQL1.ToString());
GridViewLibraryStudentRecord.Visible = false;
ButtonSubmit.Visible = true;

32
ButtonEdit.Visible = true;
GridViewLibraryStudentRecord.DataBind();
clear();
}

else
{
Label1.Visible = true;

}
}
protectedvoid GridViewLibraryStudentRecord_SelectedIndexChanged(object
sender, EventArgs e)
{
string strid = GridViewLibraryStudentRecord.SelectedDataKey.Value.ToString();
Session["Id"] =Convert.ToInt32(strid);
DataTableReader dr = CGeneral.Read("SELECT
Id,StudentName,RegistrationNumber,Course,Batch,Address,ContactNumber
FROM LibraryStudentrecord WHERE Id="+strid );

if (dr.Read())
{
TextBoxStudentName.Text = dr.GetString(1);
TextBoxRegistrationNumber.Text = dr.GetString(2);
DropDownListCourse.SelectedValue = dr.GetInt32(3).ToString();
DropDownListBatch.SelectedValue = dr.GetInt32(4).ToString();
TextBoxAddress.Text = dr.GetString(5);
TextBoxContactNumber.Text = dr.GetString(6);
DataTableReader dr1 = CGeneral.Read("SELECT UserName,Password FROM
LoginRecord WHERE Id=" + strid);
if (dr1.Read())
{
TextBoxUserName.Text = dr1.GetString(0);
TextBoxPassword.Text = dr1.GetString(1);
TextBoxRetypePassword.Text = dr1.GetString(1);
}
}

ButtonSubmit.Visible = false;
ButtonEdit.Visible = false;

33
ButtonUpdate.Visible = true;

}
m
m

åm Book registration :

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

publicpartialclassLibs_Pages_Member_registration : System.Web.UI.Page
{
privatevoid Clear()
{

TxtBookName.Text = " ";


TxtBookCode.Text = " ";
TxtPublisher.Text = " ";
TxtAuthor.Text = " ";
DropDownListCategory.SelectedIndex = 0;
TxtPrice.Text = " ";
Label7.Visible = false;
GridViewBook.DataBind();
}
protectedvoid Page_Load(object sender, EventArgs e)
{

34
}

protectedvoid butSave_Click(object sender, EventArgs e)


{
string strBookName, strBookCode, strAuthor, strPublisher, strPrice, strCategory;
strBookName = TxtBookName.Text;
strBookCode = TxtBookCode.Text;
strAuthor = TxtAuthor.Text;
strPublisher = TxtPublisher.Text;
strCategory=DropDownListCategory.SelectedValue;
strPrice = TxtPrice.Text;
String strSQL=String.Format("Select * from Tablebook where [Book
Code]='{0}'",TxtBookCode.Text);
CGeneral.Read(strSQL);
if(CGeneral.RecordExists==false)
{

Int32 int32Id = CGeneral.GetNextId("Tablebook", "Id");


StringBuilder stbSQL = newStringBuilder();
stbSQL.Append("INSERT into Tablebook(Id,[Book Name] ,[Book
Code],Author,Publisher,Category,Price)");

stbSQL.AppendFormat("VALUES({0},'{1}','{2}','{3}','{4}',{5},{6})",int32Id,strBookNam
e, strBookCode, strAuthor, strPublisher,strCategory, strPrice);
CGeneral.Execute(stbSQL.ToString());
GridViewBook.DataBind();
GridViewBook.Visible = true;
Clear();

}
else
{
Label7.Visible=true;
TxtBookName.Text = " ";
TxtBookCode.Text = " ";
TxtAuthor.Text = " ";
TxtPublisher.Text = " ";
DropDownListCategory.SelectedIndex = 0;
TxtPrice.Text = " ";
}

35
}
protectedvoid Button5_Click(object sender, EventArgs e)
{
TxtBookName.Text = " ";
TxtBookCode.Text = " ";
TxtAuthor.Text = " ";
TxtPublisher.Text = " ";
DropDownListCategory.SelectedIndex = 0;
TxtPrice.Text = " ";
}
protectedvoid ButEdit_Click(object sender, EventArgs e)
{
GridViewBook.DataBind();
GridViewBook.Visible = true;

protectedvoid ButtonClear_Click(object sender, EventArgs e)


{
TxtBookName.Text = " ";
TxtBookCode.Text = " ";
TxtAuthor.Text = " ";
TxtPublisher.Text = " ";
DropDownListCategory.SelectedIndex = 0;
TxtPrice.Text = " ";
ButSubmit.Visible = true;
ButEdit.Visible = true;

ButUpdate.Visible = false;
}
protectedvoid GridViewBook_SelectedIndexChanged(object sender, EventArgs e)
{
string strid = GridViewBook.SelectedDataKey.Value.ToString();
Session["Id"] = Convert.ToInt32(strid);
DataTableReader dr = CGeneral.Read("SELECT Id,[Book Name],[Book
Code],Author,Publisher,Category,price FROM Tablebook WHERE Id=" + strid);
if (dr.Read())
{
TxtBookName.Text = dr.GetString(1);
TxtBookCode.Text = dr.GetString(2);
TxtAuthor.Text = dr.GetString(3);
TxtPublisher.Text = dr.GetString(4);

36
DropDownListCategory.SelectedValue = dr.GetInt32(5).ToString();
TxtPrice.Text = dr.GetDecimal(6).ToString();

ButSubmit.Visible = false;
ButEdit.Visible = false;
GridViewBook.Visible = false;

ButUpdate.Visible = true;

}
protectedvoid ButUpdate_Click(object sender, EventArgs e)
{
String strBookName, strBookCode, strAuthor, strPublisher, strCategory, strPrice;
StringBuilder stbSQL = newStringBuilder();
strBookName = TxtBookName.Text;
strBookCode = TxtBookCode.Text;
strAuthor = TxtAuthor.Text;
strPublisher = TxtPublisher.Text;
strCategory = DropDownListCategory.SelectedValue;
int int32Batch = Convert.ToInt32(DropDownListCategory.SelectedValue);
strPrice = TxtPrice.Text;
String strSQL = String.Format("Select * from Tablebook where [Book Code]='{0}'",
TxtBookCode.Text);
CGeneral.Read(strSQL);
if (CGeneral.RecordExists == false)
{

stbSQL.AppendFormat("UPDATE Tablebook SET [Book Name]='{0}',[Book


Code]='{1}',Author='{2}',Publisher='{3}',Category='{4}',Price='{5}' ", strBookName,
strBookCode, strAuthor, strPublisher, strCategory, strPrice);
Int32 Id = (int)Session["Id"];
stbSQL.AppendFormat("WHERE Id={0}", Id);

CGeneral.Execute(stbSQL.ToString());
GridViewBook.Visible = false;
ButSubmit.Visible = true;
ButEdit.Visible = true;
Clear();
ButUpdate.Visible = false;
}

37
else
{
Label7.Visible = true;

protectedvoid ButtonDelete_Click(object sender, EventArgs e)


{
StringBuilder stbsql = newStringBuilder();
string strBookId=GridViewBook.SelectedDataKey.Value.ToString();
stbsql.AppendFormat("DELETE FROM Tablebook WHERE Id={0}",
strBookId);
CGeneral.Execute(stbsql.ToString());
Clear();
ButSubmit.Visible = true;
ButEdit.Visible = true;
ButUpdate.Visible = false;
}
}

åm Lending page :

using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

publicpartialclasslibs_Pages_LendingPage : System.Web.UI.Page

38
{
privatevoid ShowLendingsOfStudent(Int32 prm_int32StudentId)
{
StringBuilder stbSQL = newStringBuilder();

stbSQL.Append("SELECT
LendingTable.Id,LibraryStudentRecord.StudentName,[Book Name],[Book Code] ,");
stbSQL.Append(" convert(varchar,LendingTable.DateOfIssue,105) as 'Date of
Issue' ");
stbSQL.Append(" FROM Tablebook INNER JOIN LendingTable ON
Tablebook.Id=LendingTable.BookId ");
stbSQL.Append(" INNER JOIN LibraryStudentRecord ON
LibraryStudentRecord.Id=LendingTable.StudentId ");
stbSQL.AppendFormat(" WHERE LendingTable.Type=1 AND
LendingTable.StudentId={0}", prm_int32StudentId);
SqlDsLendings.SelectCommand = stbSQL.ToString();
GridViewStudent.DataBind();

protectedvoid Page_Load(object sender, EventArgs e)


{

if (!IsPostBack)
{
TextBoxDateOfIssue.Text = DateTime.Now.ToShortDateString();
Calendar1.SelectedDate = DateTime.Now;
}
}
protectedvoid DropDownListRegistrationNumber_SelectedIndexChanged(object
sender, EventArgs e)
{
DropDownListStudentName.SelectedValue
=DropDownListRegistrationNumber.SelectedValue ;

ShowLendingsOfStudent(Convert.ToInt32(DropDownListRegistrationNumber.Selec
tedValue));
GridViewStudent.Visible = true;
}
protectedvoid DropDownListStudentName_SelectedIndexChanged(object sender,
EventArgs e)
{

39
DropDownListRegistrationNumber.SelectedValue =
DropDownListStudentName.SelectedValue;

ShowLendingsOfStudent(Convert.ToInt32(DropDownListStudentName.SelectedVal
ue));
GridViewStudent.Visible = true;
}
protectedvoid DropDownListBookCode_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownListBookName.SelectedValue =
DropDownListBookCode.SelectedValue;
}
protectedvoid DropDownListBookName_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownListBookCode.SelectedValue =
DropDownListBookName.SelectedValue;
}
protectedvoid ChooseDate_click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protectedvoid Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBoxDateOfIssue.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
}
protectedvoid ButtonSave_Click(object sender, EventArgs e)
{

if (GridViewStudent.Rows.Count < 3)
{
String strStudentId, strBookId;
Int32 int32Id = CGeneral.GetNextId("LendingTable", "Id");
DateTime DateOfIssue = Calendar1.SelectedDate;
strStudentId = DropDownListRegistrationNumber.SelectedValue;
strBookId = DropDownListBookCode.SelectedValue;
StringBuilder stbsql1=newStringBuilder();
stbsql1.AppendFormat("SELECT Id FROM LendingTable WHERE
BookId={0} AND Type=1",strBookId);
CGeneral.Read(stbsql1.ToString());
if (CGeneral.RecordExists == false)
{

40
StringBuilder stbsql = newStringBuilder();
stbsql.Append("INSERT INTO
LendingTable(Id,StudentId,BookId,DateOfIssue,Type)");
stbsql.AppendFormat("Values({0},{1},{2},'{3}',{4})", int32Id,
Convert.ToInt32(strStudentId), Convert.ToInt32(strBookId), DateOfIssue, 1);
CGeneral.Execute(stbsql.ToString());
GridViewStudent.Visible = false;
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;
GridViewStudent.Visible = false;
TextBoxDateOfIssue.Text = " ";
ButtonSave.Visible = true;
ButtonClear.Visible = true;
ButtonUpdate.Visible = true;
LabelExtraBook.Visible = false;
DropDownListBookCode.DataBind();
DropDownListBookName.DataBind();
}
else
{
LabelExtraBook.Text = "SOORY! somebody has just taken the book";
LabelExtraBook.Visible = true;
}

}
else
{
LabelExtraBook.Visible = true;
}

}
protectedvoid GridViewStudent_SelectedIndexChanged(object sender, EventArgs e)
{
string strLendingId = GridViewStudent.SelectedDataKey.Value.ToString();
StringBuilder stbsql = newStringBuilder();
stbsql.Append("SELECT BookId,DateOfIssue FROM LendingTable ");
stbsql.AppendFormat("WHERE Id={0} ",Convert.ToInt32(strLendingId));
DataTableReader dr = CGeneral.Read(stbsql.ToString());
if (dr.Read())
{
DropDownListBookCode.SelectedValue = Convert.ToString(dr.GetInt32(0));

41
DropDownListBookName.SelectedValue = Convert.ToString(dr.GetInt32(0));
TextBoxDateOfIssue.Text = dr.GetDateTime(1).ToString("dd/MM/yyyy");
}
GridViewStudent.Visible = false;
ButtonSave.Visible = false;
ButtonDelete.Visible = true;
ButtonUpdate.Visible = true;

}
protectedvoid ButtonUpdate_Click(object sender, EventArgs e)
{

String strStudentId, strBookId;


Int32
int32Id=Convert.ToInt32(GridViewStudent.SelectedDataKey.Value.ToString());
DateTime DateOfIssue =Convert.ToDateTime(TextBoxDateOfIssue.Text);
strStudentId = DropDownListRegistrationNumber.SelectedValue;
strBookId = DropDownListBookCode.SelectedValue;
StringBuilder stbsql1=newStringBuilder();
stbsql1.AppendFormat("SELECT Id FROM LendingTable WHERE
BookId={0} AND Type=1",strBookId);
CGeneral.Read(stbsql1.ToString());
if (CGeneral.RecordExists == false)
{

StringBuilder stbSQL = newStringBuilder();


stbSQL.AppendFormat("UPDATE LendingTable SET
BookId={0},StudentId={1},DateOfIssue='{2}' ", strBookId.ToString(),
strStudentId.ToString(), DateOfIssue);
stbSQL.AppendFormat(" WHERE Id={0}", int32Id);
CGeneral.Execute(stbSQL.ToString());
GridViewStudent.Visible = false;
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
GridViewStudent.Visible = false;
TextBoxDateOfIssue.Text = " ";
ButtonSave.Visible = true;
ButtonClear.Visible = true;
ButtonUpdate.Visible = true;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;
LabelExtraBook.Visible = false;
DropDownListBookCode.DataBind();
DropDownListBookName.DataBind();

42
}
else
{
LabelExtraBook.Text = "SOORY! this book has been taken";
LabelExtraBook.Visible = true;
}

}
protectedvoid CustomValidatorRegistrationNumber_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListRegistrationNumber.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid CustomValidatorBookCode_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListBookCode.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid CustomValidatorStudentName_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListStudentName.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid CustomValidatorBookName_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListBookName.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid ButtonClear_Click(object sender, EventArgs e)
{
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
GridViewStudent.Visible = false;
TextBoxDateOfIssue.Text = " ";
ButtonSave.Visible = true;
ButtonClear.Visible = true;
ButtonUpdate.Visible = true;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;
LabelExtraBook.Visible = false;

43
DropDownListBookCode.DataBind();
DropDownListBookName.DataBind();
}
protectedvoid ButtonDelete_Click(object sender, EventArgs e)
{
StringBuilder stbsql = newStringBuilder();
stbsql.AppendFormat("DELETE FROM LendingTable WHERE
Id={0}",GridViewStudent.SelectedDataKey.Value.ToString());
CGeneral.Execute(stbsql.ToString());

åm Returning page :

using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

publicpartialclasslibs_Pages_ReturningPage : System.Web.UI.Page
{
privatevoid FineCalculation()
{
DateTime dtmLendingDate = Convert.ToDateTime(TextBoxDateOfIssue1.Text);
DateTime dtmReturningDate = Convert.ToDateTime(TextBoxDateOfReturn.Text);
DateTime dtmActualReturningDate = dtmLendingDate.AddDays(14);
TextBoxActualDateOfReturning.Text =
dtmActualReturningDate.ToShortDateString();
if (dtmActualReturningDate < dtmReturningDate)

44
{
TimeSpan tsDateDifference = dtmReturningDate - dtmActualReturningDate;
TextBoxFine.Text = (tsDateDifference.Days * 0.25).ToString();

}
else
{
TextBoxFine.Text = "0";
}

privatevoid ShowLendingsOfStudent(Int32 prm_int32StudentId)


{
StringBuilder stbSQL = newStringBuilder();
stbSQL.Append("SELECT
LendingTable.Id,LibraryStudentRecord.StudentName,[Book Name],[Book Code] ,");
stbSQL.Append(" convert(varchar,LendingTable.DateOfIssue,105) as 'Date of
Issue' ");
stbSQL.Append(" FROM Tablebook INNER JOIN LendingTable ON
Tablebook.Id=LendingTable.BookId ");
stbSQL.Append(" INNER JOIN LibraryStudentRecord ON
LibraryStudentRecord.Id=LendingTable.StudentId ");
stbSQL.AppendFormat(" WHERE LendingTable.Type=1 AND
LendingTable.StudentId={0}", prm_int32StudentId);
SqlDsLendings.SelectCommand = stbSQL.ToString();
GridViewStudent.DataBind();

}
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBoxDateOfReturn.Text = DateTime.Now.ToShortDateString();
}
}
protectedvoid DropDownListRegistrationNumber_SelectedIndexChanged(object
sender, EventArgs e)
{
DropDownListStudentName.SelectedValue
=DropDownListRegistrationNumber.SelectedValue ;

45
ShowLendingsOfStudent(Convert.ToInt32(DropDownListRegistrationNumber.Selec
tedValue));
GridViewStudent.Visible = true;
}
protectedvoid DropDownListStudentName_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownListRegistrationNumber.SelectedValue =
DropDownListStudentName.SelectedValue;

ShowLendingsOfStudent(Convert.ToInt32(DropDownListStudentName.SelectedVal
ue));
GridViewStudent.Visible = true;
}
protectedvoid DropDownListBookCode_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownListBookName.SelectedValue =
DropDownListBookCode.SelectedValue;
}
protectedvoid DropDownListBookName_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownListBookCode.SelectedValue =
DropDownListBookName.SelectedValue;
}
protectedvoid ChooseDate_click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protectedvoid Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBoxDateOfReturn.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
FineCalculation();
}
protectedvoid GridViewStudent_SelectedIndexChanged(object sender, EventArgs e)
{
string strLendingId = GridViewStudent.SelectedDataKey.Value.ToString();
StringBuilder stbsql = newStringBuilder();
stbsql.Append("SELECT BookId,DateOfIssue FROM LendingTable ");
stbsql.AppendFormat("WHERE Id={0} ",Convert.ToInt32(strLendingId));
DataTableReader dr = CGeneral.Read(stbsql.ToString());

46
if (dr.Read())
{
DropDownListBookCode.SelectedValue = Convert.ToString(dr.GetInt32(0));
DropDownListBookName.SelectedValue = Convert.ToString(dr.GetInt32(0));
TextBoxDateOfIssue1.Text = dr.GetDateTime(1).ToString("dd/MM/yyyy");
}

FineCalculation();
}
protectedvoid ButtonUpdate_Click(object sender, EventArgs e)
{
String strStudentId, strBookId;
Int32
int32Id=Convert.ToInt32(GridViewStudent.SelectedDataKey.Value.ToString());
DateTime DateOfIssue =Convert.ToDateTime(TextBoxDateOfIssue1.Text);
strStudentId = DropDownListRegistrationNumber.SelectedValue;
strBookId = DropDownListBookCode.SelectedValue;
StringBuilder stbSQL = newStringBuilder();
stbSQL.AppendFormat("UPDATE LendingTable SET
BookId={0},StudentId={1},DateOfIssue='{2}' ", strBookId.ToString(),
strStudentId.ToString(), DateOfIssue);
stbSQL.AppendFormat(" WHERE Id={0}", int32Id);
CGeneral.Execute(stbSQL.ToString());
GridViewStudent.Visible = false;
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
GridViewStudent.Visible = false;
TextBoxDateOfIssue1.Text = " ";
ButtonClear.Visible = true;
ButtonSave.Visible = true;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;

}
protectedvoid CustomValidatorRegistrationNumber_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListRegistrationNumber.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid CustomValidatorBookCode_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListBookCode.SelectedValue) == -1)

47
args.IsValid = false;
}
protectedvoid CustomValidatorStudentName_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListStudentName.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid CustomValidatorBookName_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (Convert.ToInt32(DropDownListBookName.SelectedValue) == -1)
args.IsValid = false;
}
protectedvoid ButtonClear_Click(object sender, EventArgs e)
{
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
GridViewStudent.Visible = false;
TextBoxDateOfIssue1.Text = " ";
TextBoxFine.Text = " ";
TextBoxActualDateOfReturning.Text = " ";
TextBoxDateOfReturn.Text = " ";
ButtonClear.Visible = true;
ButtonSave.Visible = true;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;
}
protectedvoid ButtonSave_Click1(object sender, EventArgs e)
{
String strStudentId, strBookId;
DateTime DateOfIssue = Calendar1.SelectedDate;
strStudentId = DropDownListRegistrationNumber.SelectedValue;
strBookId = DropDownListBookCode.SelectedValue;
StringBuilder stbsql = newStringBuilder();
stbsql.AppendFormat("UPDATE LendingTable SET Type=2 WHERE Id={0} ",
GridViewStudent.SelectedDataKey.Value.ToString());
CGeneral.Execute(stbsql.ToString());
GridViewStudent.Visible = false;
DropDownListStudentName.SelectedIndex = 0;
DropDownListBookName.SelectedIndex = 0;
DropDownListBookCode.SelectedIndex = 0;
DropDownListRegistrationNumber.SelectedIndex = 0;
GridViewStudent.Visible = false;

48
TextBoxDateOfIssue1.Text = " ";
ButtonClear.Visible = true;
ButtonSave.Visible = true;
TextBoxFine.Text = " ";
TextBoxActualDateOfReturning.Text = " ";
TextBoxDateOfReturn.Text = " ";
GridViewStudent.DataBind();
}
}

åm Member profile :

using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
publicpartialclasslibs_Pages_StudentProfile : System.Web.UI.Page
{
privatevoid ShowLendingsOfStudent(Int32 prm_int32StudentId)
{
StringBuilder stbSQL = newStringBuilder();
stbSQL.Append("SELECT
LendingTable.Id,LibraryStudentRecord.StudentName,[Book Name],[Book Code] ,");
stbSQL.Append(" convert(varchar,LendingTable.DateOfIssue,105) as 'Date of
Issue' ");
stbSQL.Append(" FROM Tablebook INNER JOIN LendingTable ON
Tablebook.Id=LendingTable.BookId ");
stbSQL.Append(" INNER JOIN LibraryStudentRecord ON
LibraryStudentRecord.Id=LendingTable.StudentId ");
stbSQL.AppendFormat(" WHERE LendingTable.Type=1 AND
LendingTable.StudentId={0}", prm_int32StudentId);

49
SqlDsLendings.SelectCommand = stbSQL.ToString();
GridViewStudent.DataBind();
}
protectedvoid Page_Load(object sender, EventArgs e)
{
Int32 int32UserId = (Int32)Session["UserId"];
ShowLendingsOfStudent(int32UserId);
StringBuilder stbsql = newStringBuilder();
stbsql.AppendFormat("SELECT
StudentName,RegistrationNumber,Course.Name,Batch,Address,ContactNumber
FROM LibraryStudentRecord ");
stbsql.AppendFormat(" INNER JOIN Course ON
Course.Id=LibraryStudentRecord.Course ");
stbsql.AppendFormat(" WHERE LibraryStudentRecord.Id={0}", int32UserId);
DataTableReader dr = CGeneral.Read(stbsql.ToString());
if (dr.Read())
{
TextBoxStudentName.Text = dr.GetString(0);
TextBoxRegistrationNumber.Text = dr.GetString(1);
TextBoxCourse.Text = dr.GetString(2);
TextBoxBatch.Text = dr.GetInt32(3).ToString();
TextBoxAddress.Text = dr.GetString(4);
TextBoxContactNumber.Text = dr.GetString(5);
}
}
}

M  %  

üm After we have completed the project we are sure the problems in the
existing system would overcome. The ´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 SQL Server 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

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

üm 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.

üm 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.

(  $ 

ümThe complete reference ASP.NET


BY: Herbert Schildt

ümMastering Visual Basic 6.0

51
ümMSDN Help


52

You might also like