Documente Academic
Documente Profesional
Documente Cultură
OOAD Project On
“Library Management System ”
Submitted by:
Singh Kuldeep Omprakash
T.Y.B.Sc (COMPUTER SCIENCE)
Project Guide:
Prof. Ms. Danila Pahuja
AFFILLIATED TO:
UNIVERSITY OF MUMBAI
2016-2017
Library
Management
System
Project by,
- Kuldeep Singh
B. Project Documentation
1. Program Source Code 56
2. Data Entry Screens 201
C. Validations
1. Test Case 207
2. Test Data 210
3. Test Results 212
System
Documentation
ACKNOWLEDGEMENT
It gives me great pleasure in presenting this project report. Its
justification will never sound good if I do not express my vote of thanks
to our C.H.M. College and respective Principal. I would also like to
thank our coordinator Mrs.RitikaSachdev for her timely support in this
completion of this project.
I thank our internal project guide Mrs. Danila Pahuja, who has
done a lot to keep this project systematically and on schedule. I am
thankful for their valuable guidance to every stage of the project. Finally,
I would thank to all others, who give there extended support to complete
this project.
SYNOPSIS
Organizational Overview:
Objectives
The project aims and objectives that will be achieved after
completion of this project are discussed in this subchapter. The aims
and objectives are as follows:
In our existing system all the transaction of book are done manually,
so taking more time for transaction like borrowing a book or returning a
book and also for searching a book.
Another major disadvantage is that preparing a list of borrowed and
available books in the library will take more time, currently it is doing as
one day process for verifying all records so after conducting the
feasibility study we decides to make manual library computerized
Advantages
GUI: It does provide better GUI.
Search: details become comparatively easy.
Increase Work Speed: Due to Automation of some part of System
work speed will increase and it is time saving.
Time Saving: It takes less time to store new Information and
Retrieve require information from database System. In this system
all details of Information placed separately. It reduce the lot of
paper work and maintains all details computerized.
Facility: It is very easy to access and retain the information about
books,students etc.
Flexibility: The database is flexible and can be easily modified
when some changes in the system require.
Security: The system informs the administrator every login and
logout any authorized person is given access it keeps all records
safely or save from any accident like burning and water damage.
Accuracy: Computerized system will be accurate enough to
provide minimum errors to perform any number of calculation and
also this provide to remove the problem which may present in the
system.
User-Friendly: The system s user friendly software will create a
flexible and can for table environment and it leads to make
everything more and beneficial.
Reduce-Error: Due to computerized there is less possibility of
error.
Loss Of Data: Tampering or loss of data is avoided.
Economical: Due to minimal error and work delay proposed
system can be economically helpful.
User-friendly: The system should be user-friendly .The software
will create a flexible and can for table environment and it leads to
make everything more whole some and beneficial.
Event List
An occurrence at specific time of place that can be described and is worth
remembering is known as event.
It is used in system analysis and designing.
Types Of Event
There are three types of events to consider when using decomposition technique to
identify some event.
External:
Outside the system.
Initiated by external agent or Actor.
Temporal:
Occurs as a result of reaching point in name.
Based on system deadlines.
State:
Something inside the system triggers the
processing end.
Event List
1. Admin logs into System
2. Admin adds details of books
3. Admin update details of books
4. Admin deletes details of books
5. Users search for books.
6. Users checks book details
7. Users adds student details
8. Users update student details
9. Users delete student details
10. Student issues the book
11. Student returns the book
12. Users checks if books are returned in the given return date
13. Users take fine if book return date is expire
14. Admin places the orders for book stock
15. Supplier supplies the book stock
16. Admin generates reports
Event Table
A table that lists events in tabular format that is in rows and key pieces of
information about each event in columns.
2 Admin add Delete, add Admin Changes in New staff add Staff
/update/delete & modify staffs details delete update
Staff the staff by admin
details
3 Admin add Delete, add Admin Changes in New student Student
/update/delete & modify students add delete
Student the student details update by
details admin
4 Admin add Delete, add, Admin Changing in New customer Supplier
/Update /delete & modify supplier add delete
supplier the supplier details update by
details admin
5 User creating New User User New user New Entry User
login entry Logged In
6 User search for Search User Searching for Book searched User
books books the book
7 User select and Select and User Issuing the Book Issued Student
issue book issue book book
9 User collects Collect the Student Collecting the Fine Collected User
the fine fine fine
11 Admin places Order the Admin Ordering the Books ordered Supplie
the order for book books r
books
1. LogIn
2. Student_Details
3. Supplier_Details
4. Book_Details
5. User_Details
7. Staff_Details
8. Order_Details
The 2 main components of use case diagram are use case and actor.
Diagrams:-
Actor:-
An actor represents a user or another system will interact with the system that you are
modeling.
Use Case:-
A use case is an external view of the system that represents some action that might
perform in order to complete a task.
System Boundary:-
A System boundary defines a scope of what system will be. A system cannot have
infinite functionality a system boundary defines the limitation of system.
Admin
User
Book
Reports
Admin Subsystem:-
a) Admin creates the new account and logins into the account.
b) Admin can add staff details.
c) Admin can update staff details.
d) Admin can delete staff details.
e) Admin can check staff details.
f) Admin can display staff details.
g) Admin can generate reports.
Student Subsystem:-
a) When a new student turns up for inquiry or for issuing book, admin adds
his/her details, if required.
b) If an existing student has made changes in personal details then admin
update his/her record.
c) If a student ‘s record not required and has not places any order, then admin
deletes his/her records.
d) If admin want to check for the detail of a student, he can do so by selecting
the id or Name of the student.
Supplier Subsystem:-
a) When admin order book from a new supplier, then admin add his/her
details.
b) If an existing supplier has made changes in contact detail, then admin
updates in existing control.
c) If supplier no longer exists nor admin has purchased any product from
him, admin deletes his record.
d) If admin wants to check for the details of a supplier he can do so by
selecting the ID or name of the supplier.
Issue Subsystem:-
a) When student comes for issuing book, his/her record is searched.
b) If a new student comes then the new record is created.
c) Admin selects the appropriate book name and book details then select
book id from the available book id.
d) Issue date is generated and book is given to customer.
e) Book status and details are stored in database.
Return Subsystem:-
a) When student comes for returning book, his/her record is searched.
b) If student is returning book on given return date, then book is returned.
c) If student is not returning book on given return date, then fine is collected
then book is returned.
d) Book status and details are stored in database
Sr No Activity Entities
1 2 3 4 5 6 7
1 Admin account is C
created
2 Admin logs into R
system
3 Admin adds book C
details
4 Admin adds supplier C
details
5 User account is C
created
6 User logs into system R
7 User adds student C
details
8 User searches books R
9 User select books R
10 User issues books U
11 User update book U
details
12 User collects books RU
13 User collects fine R
14 Student pays fine R
Entities:
1) Account
2) Book
3) Services
4) Transaction
Activity Diagram
Merge
2
Class Diagram
Class diagrams are widely used to describe the types of objects used in
system and their relationship. Class diagrams models class structure and contents
using design elements such as classes & packages and objects.
Object Diagram
Object diagram are same as that of class diagram. Instead they contain the values in
place of data types.
The object diagram describes 3 different perspectives when designing a system. This
perspective becomes evident as the system is created & helps solidify the design.
Sequence/Collaboration Diagram
Sequence diagram demonstrates the behavior of the objects in a use- case
by describing the objects and the messages they pass. The diagrams are read left to
right & descending.
Represents objects
activation.
State Diagram
c) Each diagram usually represents objects of single class and track the
different state of its object through the system.
Diagram:-
State Diagram
Activity
Transitions
Admin
Student
Component Diagram
c) The dependencies between the components show how changes made to one
component may affect each other components in the system.
e) Component diagram can also show the interface used by the component to
communicate with each other.
Diagram:-
Deployment Diagram
Diagram:-
Package Diagram
In addition to standard UML dependency relationship there are two special types
dependcies defined between packages:
Package Import
Package Merge
A package imports a relationship between an import namespace and a package
indicating that importing namespace adds the names of members an unlabeled
dependency between two packages an interpreted as a package import
relationship. In this relationship elements within the target package will be
imported in source package.
Menu Tree
Login:
Forgot Password
Create new account
Change password
Main:
Add and Manage
Supplier
Staff
Book
Others
Activities:
Book issue and return
Generate fine if applicable
Pays fine
Administrative:
Book issue/return report
Supplier report
Book Report
Search:
Supplier
Book Details
Student:
Register
Issue
Return
Form Listing:
About :-This Form show about the shop and developer name & warnig.
Book issue:- This Form is used to add the book issue details.
Book return:- This Form is used to add the book return details.
Report Listing
1. Book
2. Staff
3. Registration
4. Supplier
5. Student
6. Newspaper
7. BookIssueStaff
Project by: Kuldeep Singh | 1053 Page 53
Library Management System
8. BookIssueStaff
9. Course
Fields Datatypes Constraints
CourseName varchar(50) Primary Key
10. Course
Fields Datatypes Constraints
DepartmentName varchar(50) Primary Key
11. Return_staff
Fields Datatypes Constraints
TransactionID varchar(50) Primary Key
ReturnID varchar(50) Not Null
ReturnDate date Not Null
Fine numeric Not Null
12. Return_staff
Fields Datatypes Constraints
TransactionID varchar(50) Primary Key
ReturnID varchar(50) Not Null
ReturnDate date Not Null
Fine numeric Not Null
13. JournalAndMagazines
Fields Datatypes Constraints
ID varchar(50) Primary Key
JM_Name Varchar(50) Not null
Project
Source code
frmLogin.vb
Imports System.Data.SqlClient
Public Class Frmlogin
Login = myReader(Login)
End If
If Login = Nothing Then
MsgBox("Login is Failed...Try again !", MsgBoxStyle.Critical, "Login Denied")
txtUsername.Clear()
txtPassword.Clear()
txtUsername.Focus()
Else
ProgressBar1.Visible = True
ProgressBar1.Maximum = 5000
ProgressBar1.Minimum = 0
ProgressBar1.Value = 4
ProgressBar1.Step = 1
For i = 0 To 5000
ProgressBar1.PerformStep()
Next
Me.Hide()
frmMain.lblUser.Text = txtUsername.Text
frmMain.Show()
End If
myCommand.Dispose()
myConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub Frmlogin_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub linkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
linkLabel1.LinkClicked
Me.Hide()
frmChangePassword.Show()
frmChangePassword.cmbUserType.Text = ""
frmChangePassword.UserName.Text = ""
frmChangePassword.OldPassword.Text = ""
frmChangePassword.NewPassword.Text = ""
frmChangePassword.ConfirmPassword.Text = ""
frmChangePassword.cmbUserType.Focus()
End Sub
Private Sub linkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
linkLabel3.LinkClicked
Me.Hide()
frmPasswordRecovery.Show()
End Sub
frmSplash.vb
Public Class frmSplash
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
ProgressBar1.Visible = True
ProgressBar1.Value = ProgressBar1.Value + 2
If (ProgressBar1.Value = 10) Then
Label3.Text = "Reading modules.."
ElseIf (ProgressBar1.Value = 20) Then
Label3.Text = "Turning on modules."
ElseIf (ProgressBar1.Value = 40) Then
Label3.Text = "Starting modules.."
ElseIf (ProgressBar1.Value = 60) Then
Label3.Text = "Loading modules.."
ElseIf (ProgressBar1.Value = 80) Then
Label3.Text = "Done Loading modules.."
ElseIf (ProgressBar1.Value = 100) Then
frmLogin.Show()
Timer1.Enabled = False
Me.Hide()
End If
End Sub
End Class
frmPasswordRecovery.vb
imports System.Net.Mail
Imports System.Data.SqlClient
Public Class frmPasswordRecovery
Frmlogin.txtPassword.Text = ""
Frmlogin.cmbUserType.Text = ""
Frmlogin.cmbUserType.Focus()
End Sub
End Sub
End Class
frmPasswordRecovery.vb
Imports System.Data.SqlClient
Public Class frmChangePassword
Dim rdr As SqlDataReader = Nothing
Dim con As SqlConnection = Nothing
Dim cmd As SqlCommand = Nothing
Dim ck As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
If Len(Trim(ConfirmPassword.Text)) = 0 Then
MessageBox.Show("Please confirm new password", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ConfirmPassword.Focus()
Exit Sub
End If
If NewPassword.TextLength < 5 Then
MessageBox.Show("The New Password Should be of Atleast 5 Characters",
"Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
NewPassword.Text = ""
ConfirmPassword.Text = ""
NewPassword.Focus()
Exit Sub
ElseIf NewPassword.Text <> ConfirmPassword.Text Then
MessageBox.Show("Password do not match", "Input error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
NewPassword.Text = ""
OldPassword.Text = ""
ConfirmPassword.Text = ""
OldPassword.Focus()
Exit Sub
ElseIf OldPassword.Text = NewPassword.Text Then
MessageBox.Show("Password is same..Re-enter new password", "Input
error", MessageBoxButtons.OK, MessageBoxIcon.Error)
NewPassword.Text = ""
ConfirmPassword.Text = ""
NewPassword.Focus()
Exit Sub
End If
con = New SqlConnection(ck)
con.Open()
Dim co As String = "update Registration set password = '" &
NewPassword.Text & "'where username='" & UserName.Text & "' and password = '"
& OldPassword.Text & "' and usertype='" & cmbUserType.Text & "'"
cmd = New SqlCommand(co)
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
MessageBox.Show("Successfully changed", "Password",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Hide()
Frmlogin.Show()
Frmlogin.cmbUserType.Text = ""
Frmlogin.txtUsername.Text = ""
Frmlogin.txtPassword.Text = ""
Frmlogin.cmbUserType.Focus()
Else
MessageBox.Show("invalid user name or password", "input error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
UserName.Text = ""
NewPassword.Text = ""
OldPassword.Text = ""
ConfirmPassword.Text = ""
UserName.Focus()
End If
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub ChangePassword_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Hide()
Frmlogin.Show()
Frmlogin.cmbUserType.Text = ""
frmLogin.txtUsername.Text = ""
frmLogin.txtPassword.Text = ""
Frmlogin.cmbUserType.Focus()
End Sub
End Class
frmMain.vb
Public Class frmMain
Private Sub RegistrationToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles RegistrationToolStripMenuItem.Click
frmRegistration.Show()
End Sub
frmNewsPaper.Hide()
frmBookIssueRecord1.Hide()
frmBookIssueRecord_Staff1.Hide()
frmSupplierRecord.Hide()
frmBookIssueRecord1.Hide()
frmBookIssueRecord_Staff1.Hide()
frmBookReturnRecord_Student1.Hide()
frmBookReturnRecord_Staff1.Hide()
Frmlogin.Show()
Frmlogin.cmbUserType.Text = ""
Frmlogin.txtUsername.Text = ""
Frmlogin.txtPassword.Text = ""
Frmlogin.ProgressBar1.Visible = False
Frmlogin.cmbUserType.Focus()
End Sub
Private Sub BookReturnToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles BookReturnToolStripMenuItem.Click
frmBookReturn.Show()
End Sub
Private Sub SearchToolStripMenuItem1_Click(sender As Object, e As EventArgs)
Handles SearchToolStripMenuItem1.Click
frmBookRecord.Show()
End Sub
Private Sub CourseToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles CourseToolStripMenuItem.Click
frmCourse.Show()
End Sub
Private Sub DepartmentToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles DepartmentToolStripMenuItem.Click
frmDepartment.Show()
End Sub
Private Sub BooksToolStripMenuItem1_Click(sender As Object, e As EventArgs)
Handles BooksToolStripMenuItem1.Click
frmBookEntry.Show()
End Sub
Private Sub StudentsToolStripMenuItem1_Click(sender As Object, e As
EventArgs) Handles StudentsToolStripMenuItem1.Click
frmStudent.Show()
End Sub
Private Sub FacultiesToolStripMenuItem1_Click(sender As Object, e As
EventArgs) Handles FacultiesToolStripMenuItem1.Click
frmStaff.Show()
End Sub
Private Sub SuppliersToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles SuppliersToolStripMenuItem.Click
frmSupplier.Show()
End Sub
Private Sub RegistrationToolStripMenuItem1_Click(sender As Object, e As
EventArgs) Handles RegistrationToolStripMenuItem1.Click
frmRegistration.Show()
End Sub
Private Sub LoginDetailsToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles LoginDetailsToolStripMenuItem.Click
frmLoginDetails.Show()
End Sub
Private Sub JournalsToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles JournalsToolStripMenuItem.Click
frmJournalsAndMagzines.Show()
End Sub
Private Sub NewPapersToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles NewPapersToolStripMenuItem.Click
frmNewsPaper.Show()
End Sub
Private Sub BooksIssueToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles BooksIssueToolStripMenuItem.Click
frmBookIssue.Show()
End Sub
Private Sub BooksReturnToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles BooksReturnToolStripMenuItem.Click
frmBookReturn.Show()
End Sub
Private Sub MasterEntryToolStripMenuItem2_Click(sender As Object, e As
EventArgs) Handles MasterEntryToolStripMenuItem2.Click
frmBookRecord.Show()
End Sub
Private Sub StudentsToolStripMenuItem5_Click(sender As Object, e As
EventArgs) Handles StudentsToolStripMenuItem5.Click
frmBookIssueRecord1.Show()
frmBookIssueRecord1.Reset()
End Sub
Private Sub StaffsToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles StaffsToolStripMenuItem.Click
frmBookIssueRecord_Staff1.Show()
frmBookIssueRecord_Staff1.Reset()
End Sub
Private Sub StudentsToolStripMenuItem6_Click(sender As Object, e As
EventArgs) Handles StudentsToolStripMenuItem6.Click
frmBookReturnRecord_Student1.Show()
frmBookReturnRecord_Student1.Reset()
End Sub
Private Sub StaffsToolStripMenuItem1_Click(sender As Object, e As EventArgs)
Handles StaffsToolStripMenuItem1.Click
frmBookReturnRecord_Staff1.Show()
frmBookReturnRecord_Staff1.Reset()
End Sub
Private Sub StudentsToolStripMenuItem3_Click(sender As Object, e As
EventArgs) Handles StudentsToolStripMenuItem3.Click
frmStudentRecord1.Show()
End Sub
frmRegistration.vb
Imports System.Data
Imports System.Data.SqlClient
Public Class frmRegistration
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim reader As SqlDataReader = Nothing
Dim table As DataTable
Dim adaptar As SqlDataAdapter
Dim dt As New DataTable
Dim str As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
Sub Reset()
If con.State = ConnectionState.Open Then
con.Close()
End If
txtContactNo.Text = ""
txtEmailID.Text = ""
txtName.Text = ""
txtPassword.Text = ""
txtUsername.Text = ""
cmbUserType.Text = ""
txtUsername.Focus()
btnSave.Enabled = True
btnUpdate_record.Enabled = False
btnDelete.Enabled = False
If con.State = ConnectionState.Open Then
con.Close()
End If
End Sub
Private Sub frmRegistration_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Getdata()
End Sub
End If
If cmbUserType.Text = "" Then
MessageBox.Show("Please select user type", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
cmbUserType.Focus()
Return
End If
If txtPassword.Text = "" Then
MessageBox.Show("Please enter password", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
txtPassword.Focus()
Return
End If
If txtName.Text = "" Then
MessageBox.Show("Please enter name", "Error", MessageBoxButtons.OK,
MessageBoxIcon.[Error])
txtName.Focus()
Return
End If
If txtContactNo.Text = "" Then
MessageBox.Show("Please enter contact no.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
txtContactNo.Focus()
Return
End If
Return
End If
con = New SqlConnection(str)
con.Open()
Dim cb As String = "insert into Registration VALUES ('" & txtUsername.Text
& "','" & cmbUserType.Text & "','" & txtPassword.Text & "','" & txtName.Text &
"','" & CInt(txtContactNo.Text) & "','" & txtEmailID.Text & "','" & Date.Now & "')"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteReader()
con.Close()
con.Open()
Dim cb1 As String = "insert into Users(Username) VALUES ('" &
txtUsername.Text & "')"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteReader()
con.Close()
MessageBox.Show("Successfully Registered", "User",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnSave.Enabled = False
Getdata()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message,
"Insert Records")
End Try
End Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub DeleteRecord()
Try
If cmbUserType.Text = "admin" Or cmbUserType.Text = "Admin" Then
MessageBox.Show("Admin account can not be deleted", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
txtPassword.Focus()
Return
End If
If txtName.Text = "" Then
MessageBox.Show("Please enter name", "Error", MessageBoxButtons.OK,
MessageBoxIcon.[Error])
txtName.Focus()
Return
End If
If txtContactNo.Text = "" Then
MessageBox.Show("Please enter contact no.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
txtContactNo.Focus()
Return
End If
If txtEmailID.Text = "" Then
MessageBox.Show("Please enter email id", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
txtEmailID.Focus()
Return
End If
con.ConnectionString = str
con.Open()
cmd.Connection = con
cmd.CommandText = "update registration set username='" &
txtUsername.Text & "', usertype='" & cmbUserType.Text & "',password='" &
txtPassword.Text & "',contactno='" & txtContactNo.Text & "',email='" &
txtEmailID.Text & "',name='" & txtName.Text & "' where username='" &
txtUName.Text & "'"
cmd.ExecuteNonQuery()
cmd.ExecuteReader()
con.Close()
MessageBox.Show("Successfully updated", "User Info",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
Getdata()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message,
"Insert Records")
End Try
End Sub
End Class
frmBookEntry.vb
Option Strict On
Imports System.Data.SqlClient
Public Class frmBookEntry
Dim rdr As SqlDataReader
Dim dtable As DataTable
Dim con As SqlConnection
Sub AutocompleteJointAuthors()
Try
con = New SqlConnection(cs)
con.Open()
Dim cmd As New SqlCommand("SELECT distinct JointAuthors FROM
Book", con)
Dim ds As New DataSet()
Dim da As New SqlDataAdapter(cmd)
da.Fill(ds, "ds")
Dim col As New AutoCompleteStringCollection()
Dim i As Integer = 0
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("JointAuthors").ToString())
Next
txtJointAuthor.AutoCompleteSource = AutoCompleteSource.CustomSource
txtJointAuthor.AutoCompleteCustomSource = col
txtJointAuthor.AutoCompleteMode = AutoCompleteMode.Suggest
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub AutocompleteAuthor()
Try
con = New SqlConnection(cs)
con.Open()
Dim cmd As New SqlCommand("SELECT distinct Author FROM Book",
con)
Dim ds As New DataSet()
Dim i As Integer = 0
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("PlaceOfPublisher").ToString())
Next
txtPlaceOfPublisher.AutoCompleteSource =
AutoCompleteSource.CustomSource
txtPlaceOfPublisher.AutoCompleteCustomSource = col
txtPlaceOfPublisher.AutoCompleteMode = AutoCompleteMode.Suggest
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub AutocompleteAccessionNo()
Try
con = New SqlConnection(cs)
con.Open()
Dim cmd As New SqlCommand("SELECT distinct AccessionNo FROM
Book", con)
Dim ds As New DataSet()
Dim da As New SqlDataAdapter(cmd)
da.Fill(ds, "ds")
Dim col As New AutoCompleteStringCollection()
Dim i As Integer = 0
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("AccessionNo").ToString())
Next
txtAccessionNo.AutoCompleteSource = AutoCompleteSource.CustomSource
txtAccessionNo.AutoCompleteCustomSource = col
txtAccessionNo.AutoCompleteMode = AutoCompleteMode.Suggest
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub frmBookEntry_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
fillDepartment()
fillSubject()
fillSupplier()
AutocompleteAccessionNo()
AutocompleteBookTitle()
AutocompleteJointAuthors()
AutocompletePlaceOfPublisher()
AutocompletePublisher()
AutocompleteAuthor()
End Sub
If Len(Trim(txtPlaceOfPublisher.Text)) = 0 Then
MessageBox.Show("Please enter place of publisher", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtPlaceOfPublisher.Focus()
Exit Sub
End If
If Len(Trim(txtNoOfBooks.Text)) = 0 Then
MessageBox.Show("Please enter no. of books", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtNoOfBooks.Focus()
Exit Sub
End If
If Len(Trim(txtAlmiraPosition.Text)) = 0 Then
MessageBox.Show("Please enter almira position", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtAlmiraPosition.Focus()
Exit Sub
End If
If Len(Trim(txtPrice.Text)) = 0 Then
MessageBox.Show("Please enter price", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtPrice.Focus()
Exit Sub
End If
If (txtReference.Text = "") Then
txtReference.Text = CType(0, String)
End If
If Len(Trim(cmbSupplierName.Text)) = 0 Then
MessageBox.Show("Please select supplier", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
cmbSupplierName.Focus()
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim ct As String = "select AccessionNo from Book where AccessionNo='" &
txtAccessionNo.Text & "'"
cmd = New SqlCommand(ct)
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
MessageBox.Show("Accession no. already exists", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtAccessionNo.Text = ""
txtAccessionNo.Focus()
If Not rdr Is Nothing Then
rdr.Close()
End If
Exit Sub
End If
con.Open()
Dim cq As String = "delete from Book where AccessionNo= '" &
txtAccessionNo.Text & "'"
cmd = New SqlCommand(cq)
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
MessageBox.Show("Successfully deleted", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
fillSubject()
Reset()
Else
MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
fillSubject()
AutocompleteAccessionNo()
AutocompleteBookTitle()
AutocompleteJointAuthors()
AutocompletePlaceOfPublisher()
AutocompletePublisher()
AutocompleteAuthor()
Reset()
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
If Len(Trim(cmbSupplierName.Text)) = 0 Then
MessageBox.Show("Please select supplier", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
cmbSupplierName.Focus()
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Book set AccessionNo='" & txtAccessionNo.Text
& "', BookTitle='" & txtBookTitle.Text & "',Author='" & txtAuthor.Text &
"',JointAuthors='" & txtJointAuthor.Text & "',Subject='" & cmbSubject.Text &
"',Department='" & cmbDepartment.Text & "',Barcode='" & txtBarcode.Text &
"',ISBN='" & txtISBN.Text & "',Volume='" & txtVolume.Text & "',Edition='" &
txtEdition.Text & "',ClassNo='" & txtClassNo.Text & "',Publisher='" &
txtPublisherName.Text & "',PlaceOfPublisher='" & txtPlaceOfPublisher.Text &
"',CD='" & txtCD.Text & "',PublishingYear='" & txtPublishingYear.Text &
"',Reference=" & txtReference.Text & ",NoOfBooks=" & txtNoOfBooks.Text &
",AlmiraPosition='" & txtAlmiraPosition.Text & "',Price=" & txtPrice.Text &
",BillDate='" & dtpBillDate.Text & "',Remarks='" & txtRemarks.Text &
"',SupplierName='" & cmbSupplierName.Text & "' where AccessionNo='" &
TextBox1.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully updated", "Book Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
fillSubject()
AutocompleteAccessionNo()
AutocompleteBookTitle()
AutocompleteJointAuthors()
AutocompletePlaceOfPublisher()
AutocompletePublisher()
AutocompleteAuthor()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
frmBookRecord1.vb
Imports System.Data.SqlClient
Imports Excel = Microsoft.Office.Interop.Excel
Public Class frmBookIssueRecord1
Sub Reset()
txtBookName.Text = ""
txtBookName1.Text = ""
txtStudentName.Text = ""
cmbStudentName.Text = ""
cmbStudentName1.Text = ""
dtpDateFrom.Text = Today
dtpDateTo.Text = Today
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
DateTimePicker3.Text = Today
DateTimePicker4.Text = Today
DateTimePicker5.Text = Today
DateTimePicker6.Text = Today
DateTimePicker7.Text = Today
DateTimePicker8.Text = Today
DataGridView1.DataSource = Nothing
End Sub
Sub fillStudentName()
Try
cmbStudentName.DataSource = Nothing
cmbStudentName1.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct Studentname
FROM Student,BookIssue_Student where
Student.StudentID=BookIssue_Student.StudentID", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbStudentName.DisplayMember = "StudentName"
cmbStudentName.DataSource = dtable
cmbStudentName.SelectedIndex = -1
cmbStudentName1.DisplayMember = "StudentName"
cmbStudentName1.DataSource = dtable
cmbStudentName1.SelectedIndex = -1
Catch ex As Exception
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
Try
con = New SqlConnection(cs)
con.Open()
cmd = New SqlCommand("SELECT TransactionID as [Transaction ID],
IssueDate as [Issue Date], DueDate as [Due Date], Book.AccessionNo as [Accession
No],BookTitle as [Book Title],Author,Subject,ISBN,Edition,Student.StudentID as
[Student ID],StudentName as [Student Name],Course,Student.Department, Status
from Book,BookIssue_Student,Student where
Book.AccessionNo=BookIssue_Student.AccessionNo and
BookIssue_Student.StudentID=Student.StudentID and DueDate Between '" &
DateTimePicker2.Text & "' and '" & DateTimePicker1.Text & "' and BookTitle like '"
& txtBookName1.Text & "%' order by DueDate desc ", con)
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "BookIssue_Student")
myDA.Fill(myDataSet, "Book")
myDA.Fill(myDataSet, "Student")
DataGridView1.DataSource =
myDataSet.Tables("BookIssue_Student").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Book").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Student").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
DataGridView1.DataSource = myDataSet.Tables("Student").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Sub
frmStudent.vb
Option Strict On
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct
RTRIM(Coursename) FROM Course", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbCourse.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbCourse.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillDepartment()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct
RTRIM(Departmentname) FROM Department", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbDepartment.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbDepartment.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub frmStudent_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
fillCourse()
fillDepartment()
End Sub
txtTempAddress.Text & "','" & txtPermanentAddress.Text & "','" & dtpDOB.Text &
"','" & txtPhoneNo.Text & "','" & txtMobileNo.Text & "','" & txtEmail.Text &
"',@image,'" & gender & "')"
cmd = New SqlCommand(cb)
cmd.Connection = con
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(Picture.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@image", SqlDbType.VarBinary)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "insert into StudentList(StudentID) VALUES('" &
txtStudentID.Text & "')"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb2 As String = "insert into Cards_student(StudentID,Status) VALUES('"
& txtStudentID.Text & "','No')"
cmd = New SqlCommand(cb2)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb3 As String = "insert into NoDues_Student(StudentID,Status)
VALUES('" & txtStudentID.Text & "','No')"
cmd = New SqlCommand(cb3)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully saved", " Student Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnSave.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
txtTempAddress.Text = ""
txtPermanentAddress.Text = ""
cmbCourse.Text = ""
dtpDOB.Text = CType(Today, String)
cmbDepartment.Text = ""
Picture.Image = My.Resources.photo
rbMale.Checked = False
rbFemale.Checked = False
btnSave.Enabled = True
btnDelete.Enabled = False
btnUpdate_record.Enabled = False
txtStudentName.Focus()
End Sub
End If
If Len(Trim(txtRollNo.Text)) = 0 Then
MessageBox.Show("Please enter class roll no.", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtRollNo.Focus()
Exit Sub
End If
If Len(Trim(txtReceiptNo.Text)) = 0 Then
MessageBox.Show("Please enter receipt no.", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtReceiptNo.Focus()
Exit Sub
End If
If Len(Trim(txtTempAddress.Text)) = 0 Then
MessageBox.Show("Please enter temporary address", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtTempAddress.Focus()
Exit Sub
End If
If Len(Trim(txtPermanentAddress.Text)) = 0 Then
MessageBox.Show("Please enter permanent address", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtPermanentAddress.Focus()
Exit Sub
End If
If Len(Trim(txtMobileNo.Text)) = 0 Then
MessageBox.Show("Please enter mobile no.", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtMobileNo.Focus()
Exit Sub
End If
cmd.Connection = con
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(Picture.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@image", SqlDbType.VarBinary)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully updated", " Student Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
e.Handled = True
End If
End Sub
frmStudentRecord.vb
Imports System.Data.SqlClient
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillCourse()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct RTRIM(Course)
FROM Student", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbCourse.Items.Clear()
cmbCourse1.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbCourse.Items.Add(drow(0).ToString())
cmbCourse1.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillDepartment()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct
RTRIM(Department) FROM Student", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbDepartment.Items.Clear()
cmbDepartment1.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbDepartment.Items.Add(drow(0).ToString())
cmbDepartment1.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Try
con = New SqlConnection(cs)
con.Open()
cmd = New SqlCommand("SELECT StudentID as [Student ID], StudentName
as [Student Name],Gender, LastName as [Last Name], Course, Department,
Stu_Session as [Session], ClassRollNo as [Class Roll No], CautionMoneyReceiptNo
as [Caution Money Receipt No], TemporaryAddress as [Temporary Address],
PermanentAddress as [Permanent Address], DOB, PhoneNo as [Phone No],
MobileNo as [Mobile No], Email as [Email ID], Photo from Student where Course= '"
& cmbCourse.Text & "' order by StudentName", con)
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "Student")
DataGridView1.DataSource = myDataSet.Tables("Student").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
cmbCourse1.Text = ""
cmbDepartment1.Text = ""
cmbSession.Text = ""
GetData()
End Sub
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal - 1
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal - 1
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
frmStaff.vb
Option Strict On
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
End Sub
Private Sub frmStudent_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
fillDepartment()
End Sub
Dim cq As String = "delete from Staff where StaffID = '" & txtStaffID.Text &
"'"
cmd = New SqlCommand(cq)
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
MessageBox.Show("Successfully deleted", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Reset()
Else
MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Reset()
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub Reset()
txtStaffID.Text = ""
txtContactNo.Text = ""
txtEmail.Text = ""
txtLastName.Text = ""
txtMobileNo.Text = ""
txtPermanentAddress.Text = ""
txtPhoneNo.Text = ""
txtStaffName.Text = ""
txtTempAddress.Text = ""
txtPermanentAddress.Text = ""
dtpDateOfJoining.Text = CType(Today, String)
dtpDOB.Text = CType(Today, String)
cmbDepartment.Text = ""
Picture.Image = My.Resources.photo
rbMale.Checked = False
rbFemale.Checked = False
btnSave.Enabled = True
btnDelete.Enabled = False
btnUpdate_record.Enabled = False
txtStaffName.Focus()
End Sub
gender = rbFemale.Text
End If
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Staff set Staffname='" & txtStaffName.Text &
"',LastName='" & txtLastName.Text & "',DateOfJoining='" & dtpDateOfJoining.Text
& "',Department='" & cmbDepartment.Text & "',TemporaryAddress='" &
txtTempAddress.Text & "',PermanentAddress='" & txtPermanentAddress.Text &
"',DOB='" & dtpDOB.Text & "',PhoneNo='" & txtPhoneNo.Text & "',MobileNo='" &
txtMobileNo.Text & "',Email='" & txtEmail.Text & "',Photo=@image,Gender='" &
gender & "' where StaffID= '" & txtStaffID.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(Picture.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@image", SqlDbType.VarBinary)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully updated", " Staff Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
frmStaffRecord.vb
Imports System.Data.SqlClient
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Sub fillDepartment()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
End Sub
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal - 1
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal - 1
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
DataGridView1.DataSource = myDataSet.Tables("Staff").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
frmBookIssue.vb
Imports System.Data.SqlClient
Imports System.Security.Cryptography
Imports System.Text
Public Class frmBookIssue
Try
Dim RowsAffected As Integer = 0
con = New SqlConnection(cs)
con.Open()
Dim cq As String = "delete from BookIssue_Student where TransactionID = '"
& txtTransactionID.Text & "'"
cmd = New SqlCommand(cq)
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
MessageBox.Show("Successfully deleted", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Reset()
Else
MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Reset()
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Public Sub DeleteRecord1()
Try
Dim RowsAffected As Integer = 0
con = New SqlConnection(cs)
con.Open()
Dim cq As String = "delete from BookIssue_Staff where TransactionID = '" &
txtTransactionID1.Text & "'"
cmd = New SqlCommand(cq)
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
MessageBox.Show("Successfully deleted", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Reset1()
Else
MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Reset1()
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillANo()
Try
cmbAccessionNo.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct AccessionNo
FROM Book", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbAccessionNo.DisplayMember = "AccessionNo"
cmbAccessionNo.DataSource = dtable
cmbAccessionNo.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillANo1()
Try
cmbAccessionNo1.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct AccessionNo
FROM Book ", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbAccessionNo1.DisplayMember = "AccessionNo"
cmbAccessionNo1.DataSource = dtable
cmbAccessionNo1.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
frmStudentRecord3.Show()
frmStudentRecord3.txtStudentName.Text = ""
frmStudentRecord3.cmbCourse.Text = ""
frmStudentRecord3.cmbDepartment.Text = ""
frmStudentRecord3.cmbCourse1.Text = ""
frmStudentRecord3.cmbDepartment1.Text = ""
frmStudentRecord3.cmbSession.Text = ""
frmStudentRecord3.GetData()
End Sub
Try
If (cmbStudentID.Text = "") Then
MessageBox.Show("Please retrieve student id", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
cmbStudentID.Focus()
Exit Sub
End If
If (txtStudentName.Text = "") Then
MessageBox.Show("Please retrieve student name", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtStudentName.Focus()
Exit Sub
End If
If Len(Trim(cmbAccessionNo.Text)) = 0 Then
MessageBox.Show("Please select accession no.", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
cmbAccessionNo.Focus()
Exit Sub
End If
If Len(Trim(txtBookTitle.Text)) = 0 Then
MessageBox.Show("Please retrieve book title", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtBookTitle.Focus()
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim ct As String = "select NoOfBooks from Book where AccessionNo='" &
cmbAccessionNo.Text & "' and NoOfBooks <=0"
cmd = New SqlCommand(ct)
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
MessageBox.Show("Book is not available for issue", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Reset()
If Not rdr Is Nothing Then
rdr.Close()
End If
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Bookissue_student set IssueDate=#" &
dtpIssueDate.Text & "#,DueDate=#" & dtpDueDate.Text & "#,AccessionNo='" &
cmbAccessionNo.Text & "',StudentID= '" & cmbStudentID.Text & "' where
TransactionID='" & txtTransactionID.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
If (cmbAccessionNo.Text <> TextBox1.Text) And (txtStatus.Text = "Issued")
Then
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "Update book set NoOfBooks = NoOfBooks + 1
where AccessionNo='" & TextBox1.Text & "'"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb2 As String = "Update book set NoOfBooks = NoOfBooks - 1 where
AccessionNo='" & cmbAccessionNo.Text & "'"
cmd = New SqlCommand(cb2)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
End If
MessageBox.Show("Successfully updated", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
If Len(Trim(txtBookTitle.Text)) = 0 Then
MessageBox.Show("Please retrieve book title", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtBookTitle.Focus()
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim ct As String = "select NoOfBooks from Book where AccessionNo='" &
cmbAccessionNo.Text & "' and NoOfBooks <=0"
cmd = New SqlCommand(ct)
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
MessageBox.Show("Book is not available for issue", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Reset()
If Not rdr Is Nothing Then
rdr.Close()
End If
Exit Sub
End If
dtpDueDate.Text = dtpIssueDate.Value.Date.AddDays(4)
txtTransactionID.Text = "T-" & GetUniqueKey(6)
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "insert into Bookissue_Student(TransactionID, IssueDate,
DueDate, AccessionNo, StudentID, Status) VALUES('" & txtTransactionID.Text &
"','" & dtpIssueDate.Text & "','" & dtpDueDate.Text & "','" & cmbAccessionNo.Text
& "','" & cmbStudentID.Text & "','Issued')"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "Update book set NoOfBooks = NoOfBooks-1 where
AccessionNo='" & cmbAccessionNo.Text & "'"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully issued", "Book", MessageBoxButtons.OK,
MessageBoxIcon.Information)
txtTransactionID.Text = ""
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillStudentID()
Try
cmbStudentID.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct StudentID
FROM Student ", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbStudentID.DisplayMember = "StudentID"
cmbStudentID.DataSource = dtable
cmbStudentID.SelectedIndex = -1
Catch ex As Exception
If Len(Trim(cmbAccessionNo1.Text)) = 0 Then
MessageBox.Show("Please select accession no.", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
cmbAccessionNo1.Focus()
Exit Sub
End If
If Len(Trim(txtBookTitle1.Text)) = 0 Then
MessageBox.Show("Please retrieve book title", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
txtBookTitle1.Focus()
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim ct As String = "select NoOfBooks from Book where AccessionNo='" &
cmbAccessionNo1.Text & "' and NoOfBooks <=0"
cmd = New SqlCommand(ct)
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
MessageBox.Show("Book is not available for issue", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Reset()
If Not rdr Is Nothing Then
rdr.Close()
End If
Exit Sub
End If
dtpDueDate1.Text = dtpIssueDate1.Value.Date.AddDays(4)
txtTransactionID1.Text = "T-" & GetUniqueKey(6)
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "insert into Bookissue_Staff(TransactionID, IssueDate,
DueDate, AccessionNo, StaffID, Status) VALUES('" & txtTransactionID1.Text &
"','" & dtpIssueDate1.Text & "','" & dtpDueDate1.Text & "','" &
cmbAccessionNo1.Text & "','" & cmbStaffID.Text & "','Issued')"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "Update book set NoOfBooks = NoOfBooks-1 where
AccessionNo='" & cmbAccessionNo1.Text & "'"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully issued", "Book", MessageBoxButtons.OK,
MessageBoxIcon.Information)
txtTransactionID.Text = ""
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Sub
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
txtStaffName.Text = rdr("StaffName").ToString()
txtDepartment1.Text = rdr("Department").ToString()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Next
Return result.ToString()
End Function
Sub Reset()
txtStudentID.Text = ""
dtpReturnDate.Text = Today
txtTransactionID.Text = ""
txtAuthor.Text = ""
txtBookTitle.Text = ""
txtCategory.Text = ""
txtDepartment.Text = ""
txtEdition.Text = ""
txtISBN.Text = ""
txtCourse.Text = ""
txtStudentName.Text = ""
txtAccessionNo.Text = ""
dtpDueDate.Text = ""
dtpIssueDate.Text = ""
txtFine.Text = ""
btnSave.Enabled = True
btnDelete.Enabled = False
btnUpdate_record.Enabled = False
End Sub
Sub Reset1()
txtStaffID.Text = ""
txtTransactionID1.Text = ""
dtpReturnDate1.Text = Today
txtAuthor1.Text = ""
txtBookTitle1.Text = ""
txtCategory1.Text = ""
txtDepartment1.Text = ""
txtEdition1.Text = ""
txtISBN1.Text = ""
txtStaffName.Text = ""
txtAccessionNo1.Text = ""
dtpDueDate1.Text = ""
dtpIssueDate1.Text = ""
txtFine1.Text = ""
btnSave1.Enabled = True
btnDelete1.Enabled = False
btnUpdate1.Enabled = False
End Sub
Private Sub btnNewRecord1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewRecord1.Click
Reset1()
End Sub
Private Sub btnNewRecord_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewRecord.Click
Reset()
End Sub
End Try
End Sub
Else
txtFine1.Text = 0
End If
End Sub
txtTransactionID1.Focus()
Exit Sub
End If
If (dtpReturnDate1.Value.Date < dtpDueDate1.Value.Date) Then
MessageBox.Show("Return date can not be less than due date", "Input
Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
dtpReturnDate1.Focus()
Exit Sub
End If
If txtFine1.Text = "" Then
txtFine1.Text = 0
End If
txtReturnID1.Text = "R-" & GetUniqueKey(6)
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "insert into return_Staff(ReturnID, TransactionID,
ReturnDate, Fine) VALUES('" & txtReturnID1.Text & "','" & txtTransactionID1.Text
& "','" & dtpReturnDate1.Text & "'," & txtFine1.Text & ")"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "Update book set NoOfBooks = NoOfBooks+1 where
AccessionNo='" & txtAccessionNo1.Text & "'"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb2 As String = "Update bookIssue_staff set Status = 'Returned' where
AccessionNo='" & txtAccessionNo1.Text & "'"
cmd = New SqlCommand(cb2)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully returned", "Book",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnSave1.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Try
If MessageBox.Show("Do you really want to delete this record?",
"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.Yes Then
DeleteRecord()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Return_student set TransactionID='" &
txtTransactionID.Text & "',ReturnDate='" & dtpReturnDate.Text & "',Fine='" &
txtFine.Text & "' where ReturnID='" & txtReturnID.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
If (txtAccessionNo.Text <> TextBox1.Text) Then
con = New SqlConnection(cs)
con.Open()
Dim cb1 As String = "Update book set NoOfBooks = NoOfBooks - 1 where
AccessionNo='" & TextBox1.Text & "'"
cmd = New SqlCommand(cb1)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb2 As String = "Update book set NoOfBooks = NoOfBooks + 1
where AccessionNo='" & txtAccessionNo.Text & "'"
cmd = New SqlCommand(cb2)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb3 As String = "Update bookIssue_student set Status = 'Returned'
where AccessionNo='" & txtAccessionNo.Text & "'"
cmd = New SqlCommand(cb3)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cb4 As String = "Update bookIssue_student set Status = 'Issued' where
AccessionNo='" & TextBox1.Text & "'"
cmd = New SqlCommand(cb4)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
End If
MessageBox.Show("Successfully updated", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
btnUpdate_record.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
frmBookRecord.vb
Project by: Kuldeep Singh | 1053 Page 145
Library Management System
Imports System.Data.SqlClient
Imports Excel = Microsoft.Office.Interop.Excel
Public Class frmBookRecord
Dim rdr As SqlDataReader = Nothing
Dim dtable As DataTable
Dim con As SqlConnection = Nothing
Dim adp As SqlDataAdapter
Dim ds As DataSet
Dim cmd As SqlCommand = Nothing
Dim dt As New DataTable
Dim gender As String
Dim cs As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
rowsTotal = dataGridView1.RowCount - 1
colsTotal = dataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = dataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = dataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
rowsTotal = dataGridView2.RowCount - 1
colsTotal = dataGridView2.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = dataGridView2.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = dataGridView2.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
rowsTotal = dataGridView3.RowCount - 1
colsTotal = dataGridView3.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = dataGridView3.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = dataGridView3.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
rowsTotal = dataGridView4.RowCount - 1
colsTotal = dataGridView4.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = dataGridView4.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = dataGridView4.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
rowsTotal = DataGridView5.RowCount - 1
colsTotal = DataGridView5.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView5.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView5.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
rowsTotal = DataGridView6.RowCount - 1
colsTotal = DataGridView6.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView6.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView6.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
Try
con = New SqlConnection(cs)
con.Open()
cmd = New SqlCommand("SELECT AccessionNo as [Accession No],
BookTitle as [Book Title], Author, JointAuthors as [Joint Authors], Subject,
Department, Barcode, ISBN, Volume, Edition, ClassNo as [Class No], Publisher,
PlaceOfPublisher as [Place Of Publisher], CD,PublishingYear as [Publishing Year],
Reference, NoOfBooks, AlmiraPosition as [Almira Position], Price, BillDate as [Bill
Date],SupplierName,Remarks from book where Author like '" & txtAuthor.Text &
"%' order by BookTitle", con)
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "Book")
dataGridView2.DataSource = myDataSet.Tables("Book").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Try
End Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Try
End Sub
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbBookTitle.DisplayMember = "BookTitle"
cmbBookTitle.DataSource = dtable
cmbBookTitle.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillAuthor()
Try
cmbAuthor.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct Author FROM
Book where Author is not null", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbAuthor.DisplayMember = "Author"
cmbAuthor.DataSource = dtable
cmbAuthor.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillAccessionNo()
Try
cmbAccessionNo.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct AccessionNo
FROM Book where AccessionNo is not null", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbAccessionNo.DisplayMember = "AccessionNo"
cmbAccessionNo.DataSource = dtable
cmbAccessionNo.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillPOP()
Try
cmbPOP.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct
PlaceOfPublisher FROM Book where PlaceOfPublisher is not null", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbPOP.DisplayMember = "PlaceOfPublisher"
cmbPOP.DataSource = dtable
cmbPOP.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Sub fillDepartment()
Try
cmbDepartment.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct Department
FROM Book where Department is not null", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbDepartment.DisplayMember = "Department"
cmbDepartment.DataSource = dtable
cmbDepartment.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub frmBookRecord_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
fillAccessionNo()
fillAuthor()
fillBookTitle()
fillDepartment()
fillPOP()
fillSubject()
fillReferenceBook()
Clear()
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
Private Sub DataGridView6_RowPostPaint(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles
DataGridView6.RowPostPaint
Dim strRowNumber As String = (e.RowIndex + 1).ToString()
Dim size As SizeF = e.Graphics.MeasureString(strRowNumber, Me.Font)
If DataGridView6.RowHeadersWidth < Convert.ToInt32((size.Width + 20))
Then
DataGridView6.RowHeadersWidth = Convert.ToInt32((size.Width + 20))
End If
Dim b As Brush = SystemBrushes.ControlText
e.Graphics.DrawString(strRowNumber, Me.Font, b, e.RowBounds.Location.X +
15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2))
End Sub
End Sub
End Sub
End If
Dim rowsTotal, colsTotal As Short
Dim I, j, iC As Short
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.WaitCursor
Dim xlApp As New Excel.Application
Try
Dim excelBook As Excel.Workbook = xlApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet =
CType(excelBook.Worksheets(1), Excel.Worksheet)
xlApp.Visible = True
rowsTotal = DataGridView7.RowCount - 1
colsTotal = DataGridView7.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView7.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView7.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
Exit Sub
End If
Dim rowsTotal, colsTotal As Short
Dim I, j, iC As Short
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.WaitCursor
Dim xlApp As New Excel.Application
Try
Dim excelBook As Excel.Workbook = xlApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet =
CType(excelBook.Worksheets(1), Excel.Worksheet)
xlApp.Visible = True
rowsTotal = DataGridView8.RowCount - 1
colsTotal = DataGridView8.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView8.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView8.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
frmLoginDetails.vb
Imports System.Data.SqlClient
Public Class frmLoginDetails
Dim rdr As SqlDataReader = Nothing
Dim con As SqlConnection = Nothing
Sub Reset()
txtBookName.Text = ""
txtBookName1.Text = ""
txtStaffName.Text = ""
cmbStaffName.Text = ""
cmbStaffName1.Text = ""
dtpDateFrom.Text = Today
dtpDateTo.Text = Today
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
DateTimePicker3.Text = Today
DateTimePicker4.Text = Today
DateTimePicker5.Text = Today
DateTimePicker6.Text = Today
DateTimePicker7.Text = Today
DateTimePicker8.Text = Today
DataGridView1.DataSource = Nothing
End Sub
Sub fillStaffName()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct
RTRIM(Staffname) FROM Staff,BookIssue_Staff where
Staff.StaffID=BookIssue_Staff.StaffID", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbStaffName.Items.Clear()
cmbStaffName1.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbStaffName.Items.Add(drow(0).ToString())
cmbStaffName1.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub frmBookIssueRecord_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
fillStaffName()
End Sub
myDA.Fill(myDataSet, "BookIssue_Staff")
myDA.Fill(myDataSet, "Book")
myDA.Fill(myDataSet, "Staff")
DataGridView1.DataSource =
myDataSet.Tables("BookIssue_Staff").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Book").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Staff").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
DataGridView1.DataSource =
myDataSet.Tables("BookIssue_Staff").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Book").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Staff").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Sub
End Sub
frmBookReturnRecord_Staff.vb
Imports System.Data.SqlClient
Imports Excel = Microsoft.Office.Interop.Excel
Public Class frmBookReturnRecord_Staff
Dim rdr As SqlDataReader = Nothing
Dim dtable As DataTable
Dim con As SqlConnection = Nothing
Dim adp As SqlDataAdapter
Dim ds As DataSet
Dim cmd As SqlCommand = Nothing
Dim dt As New DataTable
Dim gender As String
Dim cs As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
Sub Reset()
txtBookName.Text = ""
txtStaffName.Text = ""
cmbStaffName.Text = ""
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
dtpDateFrom.Text = Today
dtpDateTo.Text = Today
DateTimePicker3.Text = Today
DateTimePicker4.Text = Today
DateTimePicker7.Text = Today
DateTimePicker8.Text = Today
DataGridView1.DataSource = Nothing
End Sub
Sub fillStaffName()
Try
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
myDA.Fill(myDataSet, "Return_Staff")
DataGridView1.DataSource =
myDataSet.Tables("Return_Staff").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
myDA.Fill(myDataSet, "Staff")
myDA.Fill(myDataSet, "Return_Staff")
DataGridView1.DataSource =
myDataSet.Tables("BookIssue_Staff").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Book").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Staff").DefaultView
DataGridView1.DataSource =
myDataSet.Tables("Return_Staff").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Sub
frmBookReturnRecord_Student.vb
Imports System.Data.SqlClient
Imports Excel = Microsoft.Office.Interop.Excel
Public Class frmBookReturnRecord_Student
Dim rdr As SqlDataReader = Nothing
Dim dtable As DataTable
Dim con As SqlConnection = Nothing
Dim adp As SqlDataAdapter
Dim ds As DataSet
Dim cmd As SqlCommand = Nothing
Dim dt As New DataTable
Dim gender As String
Sub Reset()
txtBookName.Text = ""
txtStudentName.Text = ""
cmbStudentName.Text = ""
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
dtpDateFrom.Text = Today
dtpDateTo.Text = Today
DateTimePicker3.Text = Today
DateTimePicker4.Text = Today
DateTimePicker7.Text = Today
DateTimePicker8.Text = Today
DataGridView1.DataSource = Nothing
End Sub
Sub fillStudentName()
Try
cmbStudentName.DataSource = Nothing
Dim CN As New SqlConnection(cs)
CN.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct Studentname
FROM Student,BookIssue_Student,Return_Student where
Student.StudentID=BookIssue_Student.StudentID and
BookIssue_Student.TransactionID=Return_Student.TransactionID", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbStudentName.DisplayMember = "StudentName"
cmbStudentName.DataSource = dtable
cmbStudentName.SelectedIndex = -1
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub frmBookIssueRecord_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
fillStudentName()
End Sub
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Rows("1:1").Font.FontStyle = "Bold"
.Rows("1:1").Font.Size = 12
.Cells.Columns.AutoFit()
.Cells.Select()
.Cells.EntireColumn.AutoFit()
.Cells(1, 1).Select()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
'RELEASE ALLOACTED RESOURCES
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
xlApp = Nothing
End Try
End Sub
Between '" & DateTimePicker4.Text & "' and '" & DateTimePicker3.Text & "' and
StudentName= '" & cmbStudentName.Text & "' order by ReturnDate desc ", con)
Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "BookIssue_Student")
myDA.Fill(myDataSet, "Book")
myDA.Fill(myDataSet, "Student")
myDA.Fill(myDataSet, "Return_Student")
DataGridView1.DataSource =
myDataSet.Tables("BookIssue_Student").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Book").DefaultView
DataGridView1.DataSource = myDataSet.Tables("Student").DefaultView
DataGridView1.DataSource =
myDataSet.Tables("Return_Student").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Sub
frmCourse.vb
Option Strict On
Imports System.Data.SqlClient
Public Class frmCourse
Dim con As SqlConnection = Nothing
Dim cmd As SqlCommand = Nothing
Dim rdr As SqlDataReader
Dim cs As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
Sub Reset()
txtCourseName.Text = ""
btnSave.Enabled = True
btnUpdate_record.Enabled = False
btnDelete.Enabled = False
txtCourseName.Focus()
End Sub
Public Sub GetData()
Try
Try
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Course set Coursename='" &
txtCourseName.Text & "' where Coursename='" & TextBox1.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteReader()
MessageBox.Show("Successfully updated", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
GetData()
btnUpdate_record.Enabled = False
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
End Class
frmCourse.vb
Option Strict On
Imports System.Data.SqlClient
Public Class frmCourse
Dim con As SqlConnection = Nothing
Dim cmd As SqlCommand = Nothing
Dim rdr As SqlDataReader
Dim cs As String = "Data Source=.\SQLEXPRESS;Initial
Catalog=LibraryDatabase;Integrated Security=True"
Sub Reset()
txtCourseName.Text = ""
btnSave.Enabled = True
btnUpdate_record.Enabled = False
btnDelete.Enabled = False
txtCourseName.Focus()
End Sub
Public Sub GetData()
Try
con = New SqlConnection(cs)
con.Open()
cmd = New SqlCommand("SELECT CourseName from Course order by
Coursename", con)
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
DataGridView1.Rows.Clear()
While (rdr.Read() = True)
DataGridView1.Rows.Add(rdr(0))
End While
con.Close()
Catch ex As Exception
Try
con = New SqlConnection(cs)
con.Open()
Dim ct As String = "select Coursename from course where Coursename='" &
txtCourseName.Text & "'"
cmd = New SqlCommand(ct)
cmd.Connection = con
rdr = cmd.ExecuteReader()
If rdr.Read Then
MessageBox.Show("Course Name Already Exists", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Reset()
If Not rdr Is Nothing Then
rdr.Close()
End If
Exit Sub
End If
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "insert into Course(Coursename) VALUES ('" &
txtCourseName.Text & "')"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteReader()
MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK,
MessageBoxIcon.Information)
GetData()
btnSave.Enabled = False
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Try
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "update Course set Coursename='" &
txtCourseName.Text & "' where Coursename='" & TextBox1.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.ExecuteReader()
Data Entry
Screens
Login Forms :
Home Form :
Supplier Form :
Test Cases,
Test Results
And
Test Data
Software testing can be stated as the process of validating and verifying that a
computer program/application/product:
The basic objective to write test case is to validate testing coverage for the
application.
Test Cases bring some sort of standardization and minimize the ad-hoc approach in
testing.
Test Cases
Expected Valid username and valid password
Results :
Reports
Layout
Book Reports :
Student Reports :
Staff Reports :
References
&
Bibliography
References
College Practical
Integrated Approach to Software Engineering
URLs
http://stackoverflow.com/
https://www.codeproject.com
https://msdn.microsoft.com/