Book store Black Book - Dinesh48

126
1 Book Store Management PROJECT REPORT ON BOOK STORE MANAGEMENT Submitted By- Ms. AMRITA SINGH Under the Guidance of Mrs. Dhatri Vinjamuri And Mrs. Neha Samuel Submitted to S.K. College of science and commerce Plot no.31, sector 25, Nerul(e),Navi Mumbai 2010-2011

Transcript of Book store Black Book - Dinesh48

Page 1: Book store Black Book - Dinesh48

1

Book Store Management

PROJECT REPORT ON

BOOK STORE MANAGEMENT

Submitted By-

Ms. AMRITA SINGH

Under the Guidance of

Mrs. Dhatri Vinjamuri

And

Mrs. Neha Samuel

Submitted to

S.K. College of science and commerce

Plot no.31, sector 25, Nerul(e),Navi Mumbai

2010-2011

Page 2: Book store Black Book - Dinesh48

2

Book Store Management

Project Report Submitted to

S.K. COLLEGE OF SCIENCE & COMMERCE

Plot No.31, Sector 25,Seawoods, Navi Mumbai - 400706.

Project Report OnBook Store Management

SUBMITTED BY COLLEGE GUIDEMS. AMRITA SINGH Mrs. NEHA SAMUEL

(T.Y.C.S.) 2011-12

Page 3: Book store Black Book - Dinesh48

3

Book Store Management

EXTERNAL EXAMINER: DATE:

PREFACE

This project is developed with an aim to achieve computerization of Shop, For time saving & Helping self.

This software provide help in effective management of Purchase & Sales with additional features of security and increase & Decrease date inconsistency. The following documentation Provides an insight of the existing “BOOK SHOP MANAGEMENT” with a scope for further expansion in future.

This report depicts the information use for the system development. For detail information scope of the project along with table design and Screen Layouts are provided.

Although this report is prepared with utmost care, there may be errors for the project and is subjected to further enhancements.

AMRITA SINGH.

Page 4: Book store Black Book - Dinesh48

4

Book Store Management

ACKNOWLEDGEMENT

I take this opportunity to thank all those who have been directly or indirectly related to my project.

I would like to thank to our project guide Mrs. NEHA SAMUEL for his constant source of inspiration. I am grateful to our coordinator Mrs. DHATARI VINJAMURI for her encouragement and suggestions on my project. I sincerely thank to our entire professor from (Computer Department) of our COLLEGE for their continued support.

I look forward in comments which are welcomed by me from students and teachers.

Page 5: Book store Black Book - Dinesh48

5

Book Store Management

INDEX:

SR. NO. CONTENTS PAGE NO.

01

PRELIMINARY INVESTIGATION

• ORGANIZATIONAL OVERVIEW • DESCRIPTION OF THE SYSTEM • LIMITATION OF PRESENT SYSTEM • PROPOSED SYSTEM• FEASIBILITY STUDY• GANTT CHART

7-16

02

SYSTEM ANALYSIS

• STACK HOLDER• FACT FINDING TECHNIQUES • EVENT TABLE• USE CASE DIAGRAM • ERD DIAGRAM• ACTIVITY DIAGRAM• CLASS DIAGRAM• SEQUENCE DIAGRAM• COLLABORATION DIAGRAM

17-29

03 SYSTEM DESIGN

• Converting ERD to Tables • Component Diagram• Package Diagram• Deployment Diagram• System flow chart• Structure chart(Program level & System level)

30-36

04

SYSTEM CODING

• Menu Tree• List of tables with attributes and constraints• Validations• Test Cases, Test Data and Test Results• Screen Layouts & Report Layouts

37-123

05 SYSTEM IMPLEMENTATION 124-125 06 FUTURE ENHANCEMENTS 126-127 07 CONCLUSION

Page 6: Book store Black Book - Dinesh48

6

Book Store Management

07 REFERENCES AND BIBLIOGRAPHY 128-129

1

Preliminary Investigation

Page 7: Book store Black Book - Dinesh48

7

Book Store Management

Organization overview &

Introduction:

This system “Inventory system” has been developed by Ms. AMRITA SINGH as an academic project for the Computer Science Department of S.K. College of Science & Commerce as a part of the T.Y. BSc Computer Science Course.

This system was created with a lot of anticipation towards mastering the basics of system creation .It was designed in such a way so as to help us make use of basic technologies like Visual Studio and MS SQL .It has used the concepts of maintaining a uniform system structure and during the process of creating this system an honest effort has been made towards creating a professional system in the future.

Page 8: Book store Black Book - Dinesh48

8

Book Store Management

Description of the System:

During the past several decade’s personnel function has been transformed from a relatively obscure record keeping staff to central and top level management function. There are many factors that have influenced this transformation like technological advances, professionalism, and general recognition of human beings as most important resources.

A computer based management system is designed to handle the entire

primary Information required to calculate monthly statements. Separate

database is maintained to handle all the details required for the correct

statement calculation and generation.

This project intends to introduce more user friendliness in the various

activities such as record updating, maintenance, and searching.

The searching of record has been made quite simple as all the details of

the Book can be obtained by simply keying in the identification of those

Books.

Similarly, record maintenance and updating can also be accomplished by

using the identification of the Book with all the details being

automatically generated. These details are also being promptly

automatically updated in the Master files thus keeping the record

absolutely up-to-date.

Page 9: Book store Black Book - Dinesh48

9

Book Store Management

The entire information has maintained in the database or Files and

whoever wants to retrieve can’t retrieve, only authorization user can

retrieve the necessary information which can be easily is accessible from

the file.

Limitations of the Present System:

The present system has several shortcomings that are as follows:-

In Present system each and every record is maintains in registers, so

there will be lot of redundancy in maintain book records.

Also there is no security due to all records are maintain in register.

Modification of one record causes to other records related to that record,

so work becomes very critical, so some time data loss will be ocular.

Storage of information is costly.

Require knowledge about this system.

More time required for reading & adding records in register

Searching any old record of any job done or damaged required more

time due to critical system of register.

Page 10: Book store Black Book - Dinesh48

10

Book Store Management

Proposed System:

This system computerized all the requirements of the owner. It will give the owner the feature of maintaining all the profiles of its customer, Suppliers, the Product in which the owner deals in, the companies of whose product the owner sells. It gives the user the functionality of searching stock without manually checking it as stock entries are updated throughout the sales and purchase transaction. It also keeps track of the enquiries made in the owner by various people.

OBJECTIVES

1) Data management.

2) Data retrieval at will.

3) Data modification.

4) Save time thereby increasing performance.

5) Reducing work process time.

6) Provide various report facility.

7) Cost effective and less manpower required.

Page 11: Book store Black Book - Dinesh48

11

Book Store Management

Advantages of The Proposed System:

This system uses MS SQL as data base which is strong and secure

database for proposed system.

The proposed system empowers the user with a new computer based

system by reducing the efforts of data maintenance.

The proposed developed according to the user specification hence it is a

user-centered system.

This system provides a facility to generate a bill as soon as the customer

purchases a product.

If the customer has not paid the full payment then there is a facility to

check the balance amount that has to be paid by the customer.

Page 12: Book store Black Book - Dinesh48

12

Book Store Management

Limitation of the Proposed System :

The system prepared is competent but we cannot say that it is a perfect

system. This system like any other system has some flaws &

shortcomings in it. They are as follows:

This system is semi-functional. This means that the system covers the

manipulation related to the record only.

Only one person can use the system.

There would be high rate & better quality of performance.

System requirementsSystem requirements

Hardware and software requirements:

The least hardware requirements are:

1) Minimum 2 GB HDD space2) Pentium or Celeron based processor

Page 13: Book store Black Book - Dinesh48

13

Book Store Management

3) 128 MB RAM

The least software requirements are:

1) Operating system: - Windows XP, Windows7.

2) Front-end Tool: - Visual studio 2008.

3) Back-end Tool: - MS SQL Server 2005.

4) Report Generation: - Crystal Report Basic.

FEASIBILITY STUDY

Every project would be feasible, if provided with

unlimited resources and unlimited time. But unfortunately, the

development of computer-based system of book is more likely plagued

by a security of resources and difficult time constraint. It is both

necessary and prudent to evaluate the feasibility of the project at the

earliest possible time. During software engineering we concentrate our

attention on four primary area of interest. The techniques used in

conducting an initial investigation and feasibility study are very similar

but the objectives are not so.

The major objectives of feasibility study are to further define the

problem and to determine the best way to solve it. The typical primary

objectives are:

Page 14: Book store Black Book - Dinesh48

14

Book Store Management

• A centralized database will be developed.

• Runtime operating decision-making will be eliminated.

• Unnecessary control procedure will be automated.

• The minimum of paper work should be produced.

• The output produced by the system should be in a usable format

Gantt chart:

I planned my project according to the Gantt chart as follows:

Sr. No.

Task Start Finish Duration(in Days)

Page 15: Book store Black Book - Dinesh48

15

Book Store Management

1 Understanding current system

15-06-2011 22-06-2011 07

2 Problem definition 23-06-2011 30-06-2011 07

3 Information gathering 1-07-2011 15-07-2011 15

4 System Analysis 16-7-2011 31-07-2011 16

5 Database design 1-08-2011 31-08-2011 306 Form design 01-09-2011 30-09-2011 307 Coding 01-10-2011 30-11-2011 60

8 Modification of forms 01-12- 2011 16-12-2011 16

9 Testing 24-12-2011 15-01-2012 20

10 Implementation 16-01-2012 10-02-2012 24

2

Page 16: Book store Black Book - Dinesh48

16

Book Store Management

System Analysis

STAKE HOLDERS

A corporate stake holder is a party that can affect or be affected by

the actions of the business as a whole.

TYPES OF STAKE HOLDERS:

Internal stake holder

Page 17: Book store Black Book - Dinesh48

17

Book Store Management

Internal stake holders-Market (or primary)Stake holders are those that

are engaged in economic transactions with the business.

External stake holders-

Non market(or secondary) stake holders are those who although they do

not engaged in direct economic exchange with the business are

affected by or can affect its actions.

Owner

The owner of the admission system needs to keep a check on

everything which is visiting admission system about each and every

registration and viewing and making changes i.e. update, delete etc. this is

one of the important issue to be handled . Book should be updated

regularly as if the new book comes in to avoid any mistake.

FACT FINDING TECHNIQUES:

Page 18: Book store Black Book - Dinesh48

18

Book Store Management

The system referred is the “Inventory system” that deals with the bills of the customer & supplier. The following are the fact-finding techniques, which were followed:

1) Going through all the existing documentation, files, registers:

I went through all the files and registers in which the supplier’s details were kept. I also referred the handmade bills and receipts. From this I traced out the history, which was required for the existing system to be implemented.

2) Research and site visit:

I visited the shop several times, which was very important for gathering the details about the items stored in the shop and the how the bill is generated.

3) Observation:

By visiting the shop I observed how the manual process is been taking place. Through observation I was able to see what exactly is to be done.

4) Questionnaires:

Questionnaires are the special purpose documents that allowed me to collect information and opinions from respondents. Through questionnaires it was possible to know the requirements of the respondent.

5) Interviews:

Through interviews it was possible for me to collect information from the respondent face-to-face

Event Table

Page 19: Book store Black Book - Dinesh48

19

Book Store Management

List of events gathered during analysis are entered in event table. An event table includes rows and columns representing events and their details respectively.

TRIGGER:

Trigger an occurrence that tells the system that has occurred, either the arrival of data needing or of a point in time

SOURCE:

SOURCE An external agent or actor that supplies data to the system.

ACTIVITY:

ACTIVITY Behavior that the system performs when an event occurs

RESPONSE:

RESPONSE An output produced by the system that goes to a destination.

DESTINATION:

DESTINATION An external agent or actor that receives data from the system

Page 20: Book store Black Book - Dinesh48

20

Book Store Management

EVENT TRIGGER SOURCE ACTIVITY RESPONSE DESTINATION

AdminLogin

Request username &Password

Admin Validate username & password

Confirmation Saved

Admin

Add anEmployee

Employee Details

Employee Add employee details

Information saved

Employee

UpdateEmployee

Update employee

Employee Update employee

Update Information

Employee

Add Books Booksdetails and add in inventory

Books Add Book and in inventory

Information saved

Books

Update Inventory

Update Book Book Update quantity

Information updated

Inventory Master

Generate bill Create bill Bill Calculate bill amount

Bill generated

Bill Master

Save Bill Save Bill Bill Save Bill Information saved

Bill Master

Print Bill Generate and print

Bill Print bill Take print of Bill

Bill master

Salary Report Add Salary details

Employee Report Saved

View Report

Employee

Use Case Diagram

Page 21: Book store Black Book - Dinesh48

21

Book Store Management

The use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as "actors" and the processes are called "use cases." The use case diagram shows which actors interact with each use case.

Books Details

Employee Details

Add Book detail

Search for Books

Delete Books

DetailAdministrator

Update Books Detail

Page 22: Book store Black Book - Dinesh48

22

Book Store Management

Invoice Detail

Page 23: Book store Black Book - Dinesh48

23

Book Store Management

Entity Relationship Diagram

ER-Diagram

Represent Data Entity.

Represent connection.

Represent the relationship.

Shows One to Many Relations.1 M

1M Shows Many to One Relation.

Symbols used in Entity-Relationship Diagram are as follows:

Connect two Entities or One to One Relation

Page 24: Book store Black Book - Dinesh48

24

Book Store Management

An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database.

Activity Diagram:

Page 25: Book store Black Book - Dinesh48

25

Book Store Management

The process flows in the system are captured in the activity diagram. Similar to a state diagram, an activity diagram also consists of activities, actions, transitions, initial and final states, and guard conditions.

Admin

Page 26: Book store Black Book - Dinesh48

26

Book Store Management

Employee

Page 27: Book store Black Book - Dinesh48

27

Book Store Management

Class Diagram

The class diagram is used to refine the use case diagram and define a detailed

design of the system. The class diagram classifies the actors defined in the use case

diagram into a set of interrelated classes. The relationship or association between the

classes can be either an "is-a" or "has-a" relationship. Each class in the class diagram may

be capable of providing certain functionalities.

Page 28: Book store Black Book - Dinesh48

28

Book Store Management

Sequence Diagram

A sequence diagram represents the interaction between different objects in the

system. The important aspect of a sequence diagram is that it is time-ordered. This means

that the exact sequence of the interactions between the objects is represented step by step.

Different objects in the sequence diagram interact with each other by passing "messages".

Page 29: Book store Black Book - Dinesh48

29

Book Store Management

COLLABORATION DIAGRAMA collaboration diagram, also called a communication diagram or interaction

diagram, is an illustration of the relationships and interactions among software objects in the Unified Modeling Language.

Page 30: Book store Black Book - Dinesh48

30

Book Store Management

3

System design

Page 31: Book store Black Book - Dinesh48

31

Book Store Management

CONVERTING ERD TO TABLES:

1. Employee 2.Book Details

3. Bill Receipt 4.Emp Salary

Page 32: Book store Black Book - Dinesh48

32

Book Store Management

Component Diagram

The component diagram represents the high-level parts that make up the system.

This diagram depicts, at a high level, what components form part of the system and how

they are interrelated. A component diagram depicts the components culled after the

system has undergone the development or construction phase.

Page 33: Book store Black Book - Dinesh48

33

Book Store Management

Package Diagram A package diagram in the Unified Modeling Language depicts

the dependencies between the packages that make up a model. Package diagrams can use packages containing use cases to illustrate the functionality of a software system

Page 34: Book store Black Book - Dinesh48

34

Book Store Management

Deployment DiagramThe deployment diagram captures the configuration of the runtime elements of the

application. This diagram is by far most useful when a system is built and ready to be deployed.

Page 35: Book store Black Book - Dinesh48

35

Book Store Management

System Flow Chart:A systems flow chart shows the key inputs and outputs associated with the program.

The shape of the symbols indicates the types of input or output devices.

BOOK

SHOP MANAGEMENT

SYSTEM

BOOK

DATABASE

INVENTORY

DATABASE

BILL

DATABASE

EMPLOYEE

DATABASE

MAINTAIN BOOK DETAILS

MAINTAIN INVENTORY

DETAILS

MAINTAIN EMPLOYEE

DETAILS

INVENTORYREPORT

BILL

REPORT

EMPLOYEE

REPORT

BOOK

REPORT

BILL CREATION PROGRAM

Page 36: Book store Black Book - Dinesh48

36

Book Store Management

STRUCTURE CHARTA Structure Chart (SC) in software engineering and organizational theory, is a chart which shows the breakdown of a system to its lowest manageable levels. They are used in structured programming to arrange program modules into a tree. Each module is represented by a box, which contains the module's name.

Page 37: Book store Black Book - Dinesh48

37

Book Store Management

4.

System Coding

Page 38: Book store Black Book - Dinesh48

38

Book Store Management

Menu Tree

BOOK SHOP MANAGEMENT SYSTEM

Book

ReportsBill

InventoryTools & Utilities

BOOK SHOP MANAGEMENT SYSTEM

Add Book

Update Book

DeleteBook

Show allBook

Calculator UpdateInventory

Show Inventorystatus

Generate Bill

BookInfo

Inventory Info

SearchBook

Employee

Search Employee

AddEmployee

Update Employee

Delete Employee

Exit

Employee Employee

Daily Sales ssSSsSales

Daily Sales

Monthly Sales SsLASales ssSSsSales

Monthly Sales

SalesSales

Print BillPrint Bill

Change Password

Exit

File

Page 39: Book store Black Book - Dinesh48

39

Book Store Management

Database Tables:

List of tables with attributes and constraints:

Table Name: UserMaster

Key Field Name Field Type Field Size Description

* Primary key username varchar 50 Users name

password varchar 50 User password

Table Name: Employee

Table Name: Employee Designation

Key Field Name Field Type Field Size Description

Key Field Name Field Type Field Size Description

* Primary key EmployeeId numeric (18,0) Employee ID

EmployeeName varchar 50 Employee Name

DesignationId number (18,0) Employee Designation ID

Salary numeric (18,2) Employee Salary

Dateofbirth datetime Employee Date of Birth

Address varchar 500 Employee Address

Status varchar 50 Employee Status

Page 40: Book store Black Book - Dinesh48

40

Book Store Management

* Primary Key DesignationId numeric (18,0) Employee Designation ID

Type varchar 50 Employee Designation Type

Table Name: Book Master

Key Field Name Field Type Field Size Description

* Primary Key

BookID numeric (18,0) Book ID

BookName varchar 50 Book Name

Batch No varchar 50 Book Batch Number

price numeric (7,2) Book Price

manuDate datetime Book Manufacturing Date

Expiry date datetime Book Expiry Date

Table Name: Inventory Master

Key Field Name Field Type Field Size Description

* Primary Key

InventoryId numeric (18,0) Inventory ID

BookId numeric (18,0) Book Id

Quantity numeric (18,0) Inventory Quantity

Table Name: Purchased Item

Page 41: Book store Black Book - Dinesh48

41

Book Store Management

Key Field Name Field Type Field Size Description

* Primary Key SrNo numeric (18,0) Bill Serial Number

BillID numeric (18,0) Bill ID

BookID numeric (18,0) Book ID

Quantity numeric (18,0) Total Book Quantity

Price numeric (18,0) Book Price

Table Name: Bill Master

Key Field Name Field Type Field Size Description

* Primary Key BillID numeric (18,0) Bill ID

BillOwner varchar 50 Bill Owner Name

BillDate datetime Bill Date

Total numeric (18,2) Total Amount

Validation

Page 42: Book store Black Book - Dinesh48

42

Book Store Management

There are many approaches to software testing. Reviews, walkthroughs, or inspections are considered as static testing, whereas actually executing programmed code with a given set of test cases is referred to as dynamic testing. Static testing can be (and unfortunately in practice often is) omitted. Dynamic testing takes place when the program itself is used for the first time (which is generally considered the beginning of the testing stage). Dynamic testing may begin before the program is 100% complete in order to test particular sections of code (modules or discrete functions). Typical techniques for this are either using stubs/drivers or execution from a debugger environment. For example, spreadsheet programs are, by their very nature, tested to a large extent interactively ("on the fly"), with results displayed immediately after each calculation or text manipulation.

White box testing is when the tester has access to the internal data structures and algorithms including the code that implement these.

Types of white box testing

The following types of white box testing exist:

API testing (application programming interface) - testing of the application using public and private APIs

Code coverage - creating tests to satisfy some criteria of code coverage (e.g., the test designer can create tests to cause all statements in the program to be executed at least once)

Fault injection methods - improving the coverage of a test by introducing faults to test code paths

Test coverage

White box testing methods can also be used to evaluate the completeness of a test suite that was created with black box testing methods. This allows the software team to examine parts

Page 43: Book store Black Book - Dinesh48

43

Book Store Management

of a system that are rarely tested and ensures that the most important function points have been tested.

Two common forms of code coverage are:

Function coverage, which reports on functions executed Statement coverage, which reports on the number of lines executed to complete the

testThey both return code coverage metric, measured as a percentage.

Page 44: Book store Black Book - Dinesh48

44

Book Store Management

Table Validations

Form Valid Data In Valid Data

Add Book All Field are Compulsory Empty Fields in animal name, or field are not selected

Add Employee All Field are Compulsory Empty Fields, numbers in employee name number or alphabets in salary.

Generate bill All Field are Compulsory Empty Fields, or fields are not selected

Control Valid Data In Valid Data

Price name Text box

34,37,999,1234,12 or any number but not more than four digit.

44562,s34534,rs44,$451 etc

Employee Name Text box

Rocky,jocky,finel 21542,roni,@make;

Page 45: Book store Black Book - Dinesh48

45

Book Store Management

Coding for validation

For Only Alphabets

If Char.IsLetter(e.KeyChar) Or Asc(e.KeyChar) = 127 Or Asc(e.KeyChar) = 8 Or Asc(e.KeyChar) = 11 Or Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 32 Then e.Handled = False Else e.Handled = True End If

For Only Numbers

Private Function validatFields() As Boolean If Not IsNumeric(TextBox4.Text.Trim) Then MsgBox("Price must be a number") Return False End If Return True End Function

Page 46: Book store Black Book - Dinesh48

46

Book Store Management

Test Case

The forms were tested for their functionality and error messages are displayed wherever the input does not meet the required requirements

Login form giving error message.

If any invalid user want to take entry into the system then this form restrict him from entering into the system. By entering invalid username or password it gives an error message

Add Book Form gives an error message.

Add Book form gives an error message if valid data entry is not done. For example, Price

should be numeric.

Update Book Form gives error message

Update Book form gives an error message if valid data entry is not done. For example, if no

book is selected then it gives an error message ‘Please select Book’.

Page 47: Book store Black Book - Dinesh48

47

Book Store Management

Screen layouts and report layout

Splash Screen:

login Screen:

Page 48: Book store Black Book - Dinesh48

48

Book Store Management

Project Main Screen:

Change Password Forms:

Page 49: Book store Black Book - Dinesh48

49

Book Store Management

Add Book Screen:

update book Screen:

Page 50: Book store Black Book - Dinesh48

50

Book Store Management

delete book Screen:

Search book Screen:

Page 51: Book store Black Book - Dinesh48

51

Book Store Management

update inventory Screen:

Show Book Status:

Page 52: Book store Black Book - Dinesh48

52

Book Store Management

Add employee Screen:

Search employee Screen:

Page 53: Book store Black Book - Dinesh48

53

Book Store Management

Update employee Screen

Page 54: Book store Black Book - Dinesh48

54

Book Store Management

delete employee Screen:

Generate bill Screen:

Page 55: Book store Black Book - Dinesh48

55

Book Store Management

Employee Salary Screen:

Book Report Screen:

Page 56: Book store Black Book - Dinesh48

56

Book Store Management

Employee Report Screen:

Daily Sales Report Screen:

Page 57: Book store Black Book - Dinesh48

57

Book Store Management

Monthly Sales Report Screen:

Bill Print SCREEN:

Page 58: Book store Black Book - Dinesh48

58

Book Store Management

Book Status:

Available book:

Page 59: Book store Black Book - Dinesh48

59

Book Store Management

Project profile:

Page 60: Book store Black Book - Dinesh48

60

Book Store Management

Codings of sreen Layouts

Coding for Splash screen:

Public Class splpane1

Private Sub splpane1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True Timer1.Interval = 50 End Sub

Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Increment(2) If ProgressBar1.Value >= 100 Then Dim f As New LoginForm Me.Hide() f.Show()

Timer1.Enabled = False End If End Sub

Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

End SubEnd Class

Page 61: Book store Black Book - Dinesh48

61

Book Store Management

Coding for login screen:

Imports System.Data.SqlClientImports System.TextImports System.Security.CryptographyImports System.ThreadingImports System.Configuration

Public Class LoginForm Dim constr As String

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub Private Sub login() Try Dim myConnection As New SqlConnection(constr) Dim encPassword As String = PasswordTextBox.Text.Trim() myConnection.Open() Dim command As New SqlCommand("select roleID from UserMaster where username='" + UsernameTextBox.Text.Trim() + "' and password='" + encPassword + "'", myConnection) Dim objrdr As SqlDataReader = command.ExecuteReader()

'MsgBox(i) If objrdr.Read Then ' System.Windows.Forms.MessageBox.Show("Welcome!") Dim role As Integer = objrdr(0) command.Dispose() myConnection.Close() Me.Hide() Dim objMain As New Main(encPassword, role) objMain.ShowDialog() Else PasswordTextBox.Text = "" MsgBox("I Don't know who r u?")

End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.Close() End Sub

Private Sub LoginForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Hide() SplashScreen.Show() SplashScreen.Update() Thread.Sleep(5000) SplashScreen.Close() Me.Visible = True

Page 62: Book store Black Book - Dinesh48

62

Book Store Management

Me.UsernameTextBox.Text = "admin" Me.PasswordTextBox.Focus() 'If ConfigurationManager.ConnectionStrings.Count > 0 Then constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString ' End If End Sub

Private Sub PasswordTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles PasswordTextBox.KeyPress If Asc(e.KeyChar) = 13 Then login() End If End Sub

Private Sub UsernameTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles UsernameTextBox.KeyPress If Asc(e.KeyChar) = 13 Then login() End If End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click login() End Sub

Private Sub LogoPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogoPictureBox.Click

End SubEnd Class

Page 63: Book store Black Book - Dinesh48

63

Book Store Management

Coding for main screen:

Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration

Public Class Main

Dim constr As String Dim password As String Dim role As Integer

Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click Dispose(True) End Sub

Private m_ChildFormNumber As Integer

Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click

Dim obj As SearchBookDialog = New SearchBookDialog(1) obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Private Sub AddBookToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddBookToolStripMenuItem.Click

Dim obj As AddBook = New AddBook obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub Private Sub AddBook() Dim myConnectionn As SqlConnection = Nothing Dim command As SqlCommand = Nothing Try myConnectionn = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnectionn.Open() command = New SqlCommand("insert into bookMaster") Catch ex As Exception

End Try End Sub

Page 64: Book store Black Book - Dinesh48

64

Book Store Management

Private Sub Main_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dispose(True) End Sub

Private Sub ShowAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowAllToolStripMenuItem.Click

Dim obj As ViewAllBookForm = New ViewAllBookForm obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub SearchToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchToolStripMenuItem1.Click

Dim obj As SearchBookDialog = New SearchBookDialog obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click

Dim obj As UpdateInventoryForm = New UpdateInventoryForm obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub ShowInventoryStatusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowInventoryStatusToolStripMenuItem.Click Dim obj As Inventory = New Inventory obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Private Sub GenerateBillToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateBillToolStripMenuItem.Click Dim obj As GenerateBill = New GenerateBill obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Private Sub PrintBillToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Dim obj As PrintBill = New PrintBill

Page 65: Book store Black Book - Dinesh48

65

Book Store Management

'obj.MdiParent = Me 'obj.StartPosition = FormStartPosition.CenterScreen 'obj.Show() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) Application.Exit() End Sub

Private Sub BookInfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookInfoToolStripMenuItem.Click

Dim obj As AllBookReportForm1 = New AllBookReportForm1 obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub InventoryInfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryInfoToolStripMenuItem.Click

Dim obj As InventoryReportForm1 = New InventoryReportForm1 obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click Dim obj As AboutBox = New AboutBox obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Private Sub SearchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchToolStripMenuItem.Click

Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog() obj.StartPosition = FormStartPosition.CenterScreen obj.MdiParent = Me obj.Show()

Page 66: Book store Black Book - Dinesh48

66

Book Store Management

End Sub Private Sub closeAll() For Each frm As Form In Me.MdiChildren frm.Close() Next End Sub Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click

Dim obj As AddEmployeeForm = New AddEmployeeForm() obj.StartPosition = FormStartPosition.CenterScreen obj.MdiParent = Me obj.Show()

End Sub

Private Sub UpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateToolStripMenuItem.Click

closeAll() Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog(1) obj.StartPosition = FormStartPosition.CenterScreen obj.MdiParent = Me obj.Show()

End Sub

Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click

closeAll() Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog(2) obj.StartPosition = FormStartPosition.CenterScreen obj.MdiParent = Me obj.Show()

End Sub

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

Dim obj As AddBook = New AddBook obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click Dim obj As Inventory = New Inventory obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

Page 67: Book store Black Book - Dinesh48

67

Book Store Management

End Sub

Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click

Dim obj As AddEmployeeForm = New AddEmployeeForm() obj.StartPosition = FormStartPosition.CenterScreen obj.MdiParent = Me

End Sub

Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click Dim obj As GenerateBill = New GenerateBill obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub Private Sub CallSystem() Dim objsystem As SystemLibrary.System = New SystemLibrary.System Dim constr As String = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim strpath As String Dim array As ArrayList = New ArrayList() array.Add("BillMaster") array.Add("Employee") array.Add("EmployeeDesignation") array.Add("InventoryMaster") array.Add("BookMaster") array.Add("PurchasedItem") array.Add("UserMaster") strpath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) objsystem.writeFile(strpath & "\vss.bin") objsystem.ReadFile(strpath & "\vss.bin", constr, array) End Sub Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click

Dim obj As UpdateBook = New UpdateBook obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub ChangePasswordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangePasswordToolStripMenuItem.Click Dim obj As UsersDialog = New UsersDialog(password) obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Public Sub New()

' This call is required by the Windows Form Designer. InitializeComponent()

Page 68: Book store Black Book - Dinesh48

68

Book Store Management

' Add any initialization after the InitializeComponent() call. CallSystem() End Sub Public Sub New(ByVal password As String, ByVal role As Integer)

' This call is required by the Windows Form Designer. InitializeComponent()

' Add any initialization after the InitializeComponent() call. Me.password = password Me.role = role CallSystem() End Sub

Private Sub EmployeeReportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmployeeReportToolStripMenuItem.Click

Dim obj As EmployeeReportForm = New EmployeeReportForm obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub DailySalesReportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DailySalesReportToolStripMenuItem.Click

Dim obj As DailySalesReportForm = New DailySalesReportForm obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub MonthlyReportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MonthlyReportToolStripMenuItem.Click

Dim obj As MonthlySalesReportForm = New MonthlySalesReportForm obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show()

End Sub

Private Sub PrintBillToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintBillToolStripMenuItem.Click Dim obj As PrintBill = New PrintBill() obj.MdiParent = Me obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Page 69: Book store Black Book - Dinesh48

69

Book Store Management

End Class

Coding for user dialog:

Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration

Public Class UsersDialog Dim constr As String Dim pwd As String Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click 'MsgBox(UserComboBox.SelectedItem.ToString) Dim obj As New UpdateUserForm(UserComboBox.SelectedItem.ToString, pwd) obj.MdiParent = Me.MdiParent obj.StartPosition = FormStartPosition.CenterScreen obj.Show() Me.Hide() End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub

Private Sub UsersDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Dim dbreader As SqlDataReader = Nothing

Try myConnection = New SqlConnection(constr) myConnection.Open() command = New SqlCommand("select username from usermaster", myConnection) dbreader = command.ExecuteReader While dbreader.Read UserComboBox.Items.Add(dbreader(0)) End While UserComboBox.SelectedIndex = 0 Catch ex As Exception MsgBox(ex.Message) End Try

End Sub

Public Sub New()

' This call is required by the Windows Form Designer.

Page 70: Book store Black Book - Dinesh48

70

Book Store Management

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub Public Sub New(ByVal pwd As String)

' This call is required by the Windows Form Designer. InitializeComponent()

' Add any initialization after the InitializeComponent() call. Me.pwd = pwd End SubEnd Class

Coding for update user dialog:

Imports System.Data.SqlClientImports System.ConfigurationImports System.TextImports System.Security.Cryptography

Public Class UpdateUserForm Dim user As String Dim constr As String Dim obj As String Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub

Private Sub UpdateUserForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load UserTextBox.Text = user constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString End Sub

Public Sub New()

' This call is required by the Windows Form Designer. InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub Public Sub New(ByRef user As String, ByVal pwd As String)

' This call is required by the Windows Form Designer. InitializeComponent()

' Add any initialization after the InitializeComponent() call. Me.user = user Me.obj = pwd End Sub

Page 71: Book store Black Book - Dinesh48

71

Book Store Management

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If validateFields() Then Try Dim myConnection As New SqlConnection(constr) Dim encPassword As String = PasswordTextBox.Text.Trim() myConnection.Open() Dim command As SqlCommand = New SqlCommand("update usermaster set password='" & encPassword & "'", myConnection) Dim i As Integer = command.ExecuteNonQuery If i > 0 Then MsgBox("Updated!") command.Dispose() myConnection.Close() Me.Close() Else MsgBox("Failed!") End If Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub Private Function validateFields() As Boolean If UserTextBox.Text.Trim.Length = 0 Then MsgBox("User name can not be empty!") Return False End If If TextBox1.Text.Trim.Length = 0 Then MsgBox("old Password should not be empty!") Return False End If If PasswordTextBox.Text.Trim.Length = 0 Then MsgBox("Password and confirm password doesnot match!") Return False End If If ConfirmPasswordTextBox.Text.Trim.Length = 0 Then MsgBox("Password and confirm password doesnot match!") Return False End If If Not PasswordTextBox.Text.Trim = ConfirmPasswordTextBox.Text.Trim Then MsgBox("Password and confirm password doesnot match!") Return False End If If Not obj = TextBox1.Text.Trim Then MsgBox("You are not correct user to change password!") Return False End If Return True End FunctionEnd Class

Page 72: Book store Black Book - Dinesh48

72

Book Store Management

Coding for add book:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class AddBook Dim constr As String Private Sub AddBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim id As Integer = MiscUtilityClass.getID("bookmaster", "bookid") 'TextBox1.Enabled = False 'TextBox1.Text = id Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "MM/dd/yyyy" Me.DateTimePicker2.Format = DateTimePickerFormat.Custom Me.DateTimePicker2.CustomFormat = "MM/dd/yyyy" Me.DateTimePicker2.MinDate = Date.Now End Sub Private Function validateFields() As Boolean If Not IsNumeric(TextBox4.Text.Trim) Then MsgBox("Price must be a number") Return False End If Return True End Function Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click saveBook() End Sub Private Sub saveBook() 'MsgBox(DateTimePicker1.Value) 'MsgBox(DateTimePicker2.Value) If validatFields() Then Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Dim trans As SqlTransaction = Nothing Try myConnection = New SqlConnection(constr) myConnection.Open() trans = myConnection.BeginTransaction

Page 73: Book store Black Book - Dinesh48

73

Book Store Management

command = New SqlCommand("insert into bookmaster(BookName,BatchNo,price,manuDate,Expirydate) values('" & TextBox2.Text.Trim & "','" & TextBox3.Text.Trim & "','" & Val(TextBox4.Text.Trim) & "','" & DateTimePicker1.Value.ToString("MM/dd/yyyy") & "','" & DateTimePicker2.Value.ToString("MM/dd/yyyy") & "')", myConnection, trans) Dim i As Integer = command.ExecuteNonQuery If i > 0 Then MsgBox("Book Added Successfully!") trans.Commit() command.Dispose() myConnection.Close() Me.Close() Else MsgBox("Failed to add Book!") End If Catch ex As Exception trans.Rollback() MsgBox(ex.Message) End Try End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub

Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged

End Sub

Private Sub DateTimePicker2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DateTimePicker2.KeyPress If Asc(e.KeyChar) = 13 Then saveBook() End If End Sub

Private Sub TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If Asc(e.KeyChar) = 13 Then saveBook() End If End Sub

Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress If Asc(e.KeyChar) = 13 Then saveBook() End If If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False

Page 74: Book store Black Book - Dinesh48

74

Book Store Management

End If

End Sub

Private Sub DateTimePicker1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DateTimePicker1.KeyPress If Asc(e.KeyChar) = 13 Then saveBook() End If End Sub

Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress If Asc(e.KeyChar) = 13 Then saveBook() End If End Sub Private Function validatFields() As Boolean

If TextBox2.Text.Trim.Length = 0 Then MsgBox("book Name is Required!") Return False End If

If TextBox3.Text.Trim.Length = 0 Then MsgBox("Batch no is Required!") Return False End If If TextBox4.Text.Trim.Length = 0 Then MsgBox("price is Required!") Return False End If If DateTimePicker1.Value.ToString("MM/dd/yyyy") = DateTimePicker2.Value.ToString("MM/dd/yyyy") Then MsgBox("Manufacturing and Expiry date can not be same!") Return False End If

Return True

End FunctionEnd Class

Page 75: Book store Black Book - Dinesh48

75

Book Store Management

Coding for update book:

Imports System.Data.SqlClientImports System.Configuration

Public Class UpdateBook Private Sub UpdateBook()

If validateFields() Then Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Dim command2 As SqlCommand = Nothing Dim quantity As Integer = 0 If CType(ComboBox1.SelectedItem, BookClass).ExpiryDate > Date.Now Then quantity = getQuantity(CType(ComboBox1.SelectedItem, BookClass).BookID) End If Dim query2 As String = "update inventoryMaster set quantity=" & quantity & " where bookID=" & CType(ComboBox1.SelectedItem, BookClass).BookID Dim d1 As Date = Date.Parse(DateTimePicker1.Value) Try myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open() command = New SqlCommand("update bookmaster set batchno='" & TextBox3.Text.Trim & "',price=" & Val(TextBox4.Text.Trim) & ",manudate='" & d1.ToString("MM/dd/yyyy") & "',expirydate='" & DateTimePicker2.Value.ToString("MM/dd/yyyy") & "' where bookid=" & CType(ComboBox1.SelectedItem, BookClass).BookID, myConnection) command2 = New SqlCommand(query2, myConnection) Dim i As Integer = command.ExecuteNonQuery Dim j As Integer = command2.ExecuteNonQuery If i + j > 1 Then MsgBox("Book Updated successfully!") Me.Close() End If Catch ex As Exception MsgBox(ex.Message) End Try End If

Page 76: Book store Black Book - Dinesh48

76

Book Store Management

End Sub Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click UpdateBook()

End Sub Private Function getQuantity(ByVal id As Integer) As Integer

Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing ComboBox1.Items.Add("select Book") Dim quantity As Integer = 0 Try myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open() command = New SqlCommand("select quantity from inventorymaster where bookID=" & id, myConnection) Dim dbreader = command.ExecuteReader() While dbreader.Read quantity = dbreader(0) End While dbreader.Close() command.Dispose() myConnection.Close() Catch ex As Exception MsgBox(ex.Message) End Try Return quantity End Function Private Sub UpdateBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing ComboBox1.Items.Add("select Book") Try myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open() command = New SqlCommand("select bookid,bookname,expirydate from bookmaster", myConnection) Dim dbreader As SqlDataReader = command.ExecuteReader While dbreader.Read Dim obj As BookClass = New BookClass obj.BookID = dbreader(0) obj.BookName = dbreader(1) obj.ExpiryDate = dbreader(2) ComboBox1.Items.Add(obj) End While command.Dispose() myConnection.Close() Catch ex As SqlException MsgBox("Sql Exception") MsgBox(ex.Message) End Try ComboBox1.SelectedIndex = 0 Catch ex As Exception MsgBox(ex.Message) End Try

Page 77: Book store Black Book - Dinesh48

77

Book Store Management

Me.DateTimePicker2.MinDate = Date.Now End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex > 0 Then TextBox1.Text = CType(ComboBox1.SelectedItem, BookClass).BookID End If End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub Private Function validateFields() As Boolean If ComboBox1.SelectedIndex = 0 Then MsgBox("Please select Book") Return False End If If TextBox3.Text.Trim.Length = 0 Then MsgBox("Batch Number is required!") Return False End If If TextBox4.Text.Trim.Length = 0 Then MsgBox("Price is required!") Return False End If If Not IsNumeric(TextBox4.Text.Trim) Then MsgBox("Price must be number!") Return False End If If DateTimePicker1.Value.ToString("MM/dd/yyyy") = DateTimePicker2.Value.ToString("MM/dd/yyyy") Then MsgBox("Manufacturing and Expiry date can not be same!") Return False End If Return True End Function Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress If Asc(e.KeyChar) = 13 Then UpdateBook() End If End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress If Asc(e.KeyChar) = 13 Then UpdateBook() End If If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then

Page 78: Book store Black Book - Dinesh48

78

Book Store Management

e.Handled = False End If End Sub

Private Sub DateTimePicker1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DateTimePicker1.KeyPress

If Asc(e.KeyChar) = 13 Then UpdateBook() End If

End Sub

Private Sub DateTimePicker2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DateTimePicker2.KeyPress If Asc(e.KeyChar) = 13 Then UpdateBook() End If End Sub

End Class

Coding for delete book:

Imports System.GlobalizationImports System.Data.SqlClientImports System.Configuration

Public Class DeleteBook Dim del As SearchBookDialog Public Sub New()

InitializeComponent()

End Sub Public Sub New(ByRef obj As BookClass, ByRef del As SearchBookDialog)

InitializeComponent() TextBox1.Text = obj.BookID TextBox2.Text = obj.BookName TextBox3.Text = obj.BatchNo TextBox4.Text = obj.Price Dim myDTFI As DateTimeFormatInfo = New DateTimeFormatInfo() myDTFI.ShortDatePattern = "dd\MM\yyyy" Dim dt As DateTime = DateTime.Parse(obj.ManufacturingDate, myDTFI) Dim dt2 As DateTime = DateTime.Parse(obj.ExpiryDate, myDTFI)

Page 79: Book store Black Book - Dinesh48

79

Book Store Management

DateTimePicker1.Value = dt DateTimePicker2.Value = dt2 Me.del = del

End Sub

Private Sub DeleteBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" Me.DateTimePicker2.Format = DateTimePickerFormat.Custom Me.DateTimePicker2.CustomFormat = "dd/MM/yyyy" End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub

Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Dim command2 As SqlCommand = Nothing Try myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open()

command = New SqlCommand("delete from bookmaster where bookid=" & TextBox1.Text.Trim, myConnection) Dim j As Integer = command.ExecuteNonQuery() command2 = New SqlCommand("delete from inventorymaster where bookid=" & TextBox1.Text.Trim, myConnection) Dim i As Integer = command2.ExecuteNonQuery()

command.Dispose() myConnection.Close() del.action(True) Me.Close() Catch ex As Exception

MsgBox(ex.Message) End Try

End sub

End Class

Page 80: Book store Black Book - Dinesh48

80

Book Store Management

Coding for search book:

Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration

Public Class SearchBookDialog Dim constr As String Dim whoiscalling As Integer Dim obj As UpdateInventoryForm Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click If CriteriaValue.Text.Trim.Length > 0 Then action() End If

End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub

Private Sub SearchBookDialog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CriteriaKey.Items.Clear() CriteriaKey.Items.Add("BookID") CriteriaKey.Items.Add("BookName") CriteriaKey.Items.Add("BatchNo") CriteriaKey.Items.Add("Price") constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString action(True) End Sub

Page 81: Book store Black Book - Dinesh48

81

Book Store Management

Private Sub CriteriaKey_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CriteriaKey.SelectedIndexChanged CriteriaValue.Text = "" End Sub Public Sub action() Dim objcon As SqlConnection = Nothing Dim query As String = "select p.bookID,p.bookName,p.BatchNo,p.Price,convert(varchar(20),p.manudate,103) as ManufacturingDate,convert(varchar(20),p.expirydate,103) as ExpiryDate,i.quantity from bookmaster p left join inventorymaster i on p.bookid=i.bookid where " If IsNumeric(CriteriaValue) Then query = query & " p.convert(varchar(100)," & CriteriaKey.SelectedItem.ToString & ")like '" & CriteriaValue.Text.Trim & "%'" Else query = query & "p." & CriteriaKey.SelectedItem.ToString & " like '" + CriteriaValue.Text.Trim + "%'" End If Try objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table As New DataTable objda.Fill(table) DataGridView1.DataSource = table Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub getCurrentItemFromTable() Dim row As Integer = DataGridView1.CurrentRow.Index

Dim objbook As BookClass = New BookClass objbook.BookID = Val(DataGridView1.Item(0, row).Value.ToString) objbook.BookName = DataGridView1.Item(1, row).Value.ToString objbook.BatchNo = DataGridView1.Item(2, row).Value.ToString objbook.Price = DataGridView1.Item(3, row).Value.ToString objbook.ManufacturingDate = DataGridView1.Item(4, row).Value.ToString objbook.ExpiryDate = DataGridView1.Item(5, row).Value.ToString objbook.Quantity = DataGridView1.Item(6, row).Value.ToString If whoiscalling = 1 Then Dim objBookView As New DeleteBook(objbook, Me) objBookView.MdiParent = Me.MdiParent objBookView.Show() End If If whoiscalling = 2 Then obj.TextBox1.Text = objbook.BookID obj.TextBox2.Text = objbook.BookName obj.TextBox3.Text = objbook.Quantity Me.Close() End If End Sub

Public Sub action(ByVal flag As Boolean) Dim objcon As SqlConnection = Nothing

Page 82: Book store Black Book - Dinesh48

82

Book Store Management

Dim query As String = "select p.bookID,bookName,BatchNo,Price,convert(varchar(20),manudate,103) as ManufacturingDate,convert(varchar(20),expirydate,103) as ExpiryDate ,quantity from bookmaster p left join inventorymaster i on p.bookid=i.bookid" Try objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table As New DataTable objda.Fill(table) DataGridView1.DataSource = table Catch ex As Exception MsgBox(ex.Message) End Try End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick getCurrentItemFromTable() End Sub

Public Sub New()

InitializeComponent()

End Sub Public Sub New(ByVal whoiscalling As Integer)

InitializeComponent() Me.whoiscalling = whoiscalling End Sub Public Sub New(ByRef obj As UpdateInventoryForm, ByVal whoiscalling As Integer) InitializeComponent() Me.obj = obj Me.whoiscalling = whoiscalling

End Class

Page 83: Book store Black Book - Dinesh48

83

Book Store Management

Coding for update inventory:

Imports System.Data.SqlClientImports System.Configuration

Public Class UpdateInventoryForm Dim constr As String Public quantity As Integer Public Sub New()

InitializeComponent()

End Sub

Public Sub New(ByRef obj As BookClass)

InitializeComponent() TextBox1.Text = obj.BookID TextBox2.Text = obj.BookName

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox3.Enabled = False Dim obj As SearchBookDialog = New SearchBookDialog(Me, 2)

Page 84: Book store Black Book - Dinesh48

84

Book Store Management

obj.MdiParent = Me.MdiParent obj.StartPosition = FormStartPosition.CenterScreen obj.Show() End Sub

Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateButton.Click If IsNumeric(TextBox3.Text.Trim) Then Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing quantity = quantity + Val(TextBox3.Text.Trim) Try myConnection = New SqlConnection(constr) myConnection.Open() If CheckBookExist() Then command = New SqlCommand("update inventorymaster set quantity=" & quantity & " where bookid=" & Val(TextBox1.Text.Trim), myConnection) Else command = New SqlCommand("insert into inventorymaster(bookid,quantity)values(" & Val(TextBox1.Text.Trim) & ",'" & Val(TextBox3.Text.Trim) & "')", myConnection) End If Dim i As Integer = command.ExecuteNonQuery If i > 0 Then MsgBox("Book Updated Successfully!") clearFields() Else MsgBox("Failed to update book!") End If

command.Dispose() myConnection.Close() Catch ex As Exception MsgBox(ex.Message) End Try Else MsgBox("Quantity must be numeric!") End If End Sub Private Sub clearFields() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" Button1.Focus() End Sub Private Function CheckBookExist() As Boolean Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Try myConnection = New SqlConnection(constr) myConnection.Open() command = New SqlCommand("select count(*) from inventorymaster where bookid=" & Val(TextBox1.Text.Trim), myConnection) Dim i As Integer = CType(command.ExecuteScalar, Integer) If i > 0 Then command.Dispose() myConnection.Close() Return True Else command.Dispose()

Page 85: Book store Black Book - Dinesh48

85

Book Store Management

myConnection.Close() Return False End If Catch ex As Exception Try command.Dispose()

Catch exc As Exception

End Try Try myConnection.Close() Catch exc As Exception

End Try MsgBox(ex.Message) Return False End Try End Function

Private Sub EditButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditButton.Click TextBox3.Enabled = True End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub

Private Sub UpdateInventoryForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString If IsNumeric(TextBox3.Text.Trim) Then quantity = Val(TextBox3.Text.Trim) End If End Sub Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If End SubEnd Class

Page 86: Book store Black Book - Dinesh48

86

Book Store Management

Coding for show all inventory:

Imports System.Data.SqlClientImports System.ConfigurationPublic Class Inventory Dim constr As String Private Sub Inventory_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim objcon As SqlConnection = Nothing Dim query As String = "select p.bookID,bookName,BatchNo,Price,convert(varchar(20),manudate,103) as ManufacturingDate,convert(varchar(20),expirydate,101) as ExpiryDate ,quantity from bookmaster p join inventorymaster i on p.bookid=i.bookid" Try objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table As New DataTable objda.Fill(table) DataGridView1.DataSource = table Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub DataGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting

If e.RowIndex >= 0 And e.ColumnIndex >= 0 Then

Page 87: Book store Black Book - Dinesh48

87

Book Store Management

Dim theRow As DataGridViewRow = DataGridView1.Rows(e.RowIndex) If CType(theRow.Cells(6).Value, Integer) < 25 Then theRow.DefaultCellStyle.BackColor = Color.Red End If Dim date1 As String = CType(theRow.Cells(5).Value, String) Dim d As Date = Date.Parse(date1) Dim i As TimeSpan = d.Subtract(Date.Now)

If i.Days <= 0 Then theRow.DefaultCellStyle.BackColor = Color.Red End If End If End SubEnd Class

Coding for add employee:

Imports System.Data.SqlClientImports System.ConfigurationImports System.Globalization

Public Class AddEmployeeForm

Private Sub NewButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewButton.Click EIDTextBox.Text = MiscUtilityClass.getID("Employee", "EmployeeID").ToString() End Sub Private Sub ClearFields() EIDTextBox.Text = "" ENameTextBox.Text = "" DesignationComboBox.SelectedIndex = 0 SalaryTextBox.Text = "" DOBTextBox.Text = "" AddressTextBox.Text = "" ENameTextBox.Focus() End Sub Private Sub FillCombo() Me.DesignationComboBox.Items.Clear() Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Try

Page 88: Book store Black Book - Dinesh48

88

Book Store Management

myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) 'myConnection = New SqlConnection("Data Source=COM4\SQLEXPRESS;Initial Catalog=MyData;Integrated Security=True;Pooling=False")

myConnection.Open() command = New SqlCommand("select * from employeedesignation", myConnection) Dim dbreader As SqlDataReader = command.ExecuteReader() While dbreader.Read() ' MsgBox("Hello" & dbreader.Item(1).ToString) Dim objlist As New DesignationClass() objlist.DesignationID = dbreader.GetValue(0) objlist.Designation = dbreader.GetString(1) DesignationComboBox.Items.Add(objlist) End While command.Dispose() myConnection.Close() DesignationComboBox.SelectedIndex = 0 Catch ex As Exception command.Dispose() myConnection.Close() MsgBox(ex.Message) End Try End Sub Private Function validateFields() As Boolean If ENameTextBox.Text.Trim.Length = 0 Then MsgBox("Employee Name is Required!") Return False End If If String.IsNullOrEmpty(SalaryTextBox.Text.Trim) Or Not IsNumeric(SalaryTextBox.Text.Trim) Then MsgBox("Valid salary is Required!") Return False End If If AddressTextBox.Text.Trim.Length = 0 Then MsgBox("Address is Required!") Return False End If Return True If Not IsNumeric(SalaryTextBox.Text.Trim) Then MsgBox("Price must be a number") Return False End If Return True

End Function Private Sub upadteEmployee() If validateFields() Then Dim d As Date = DateTimePicker1.Value Try Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open() Dim command As SqlCommand = New SqlCommand("update Employee set EmployeeName='" & ENameTextBox.Text.Trim() & "',DesignationID=" & CType(DesignationComboBox.SelectedItem, DesignationClass).DesignationID & ",Salary=" & Val(SalaryTextBox.Text) & "DateOfBirth='" & d & "',Address='" & AddressTextBox.Text.Trim() & "' where EmployeeID=" & Val(EIDTextBox.Text), myConnection) Dim i As Integer = command.ExecuteNonQuery If i > 0 Then

Page 89: Book store Black Book - Dinesh48

89

Book Store Management

If MsgBox("Book has been Updated!Do you want to continue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then ClearFields() Else command.Dispose() myConnection.Close() Me.Dispose() End If End If Catch ex As Exception MsgBox(ex.Message) End Try End If

End Sub Private Sub saveEmployee() 'MsgBox(PNameTextBox.Text.Trim() & "," & PBatchNoTextBox.Text.Trim() & "," & MDateTextBox.Text & "," & DescriptionTextBox.Text.Trim() & "," & Val(RateTextBox.Text.Trim()) & "," & Val(QuantityTextBox.Text.Trim()) & "," & Val(TotalTextBox.Text.Trim())) If validateFields() Then Dim d As Date = DateTimePicker1.Value Try Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open()

Dim command As SqlCommand = New SqlCommand("InsertEmployee", myConnection) command.CommandType = CommandType.StoredProcedure

Dim param1 As New SqlParameter() param1.ParameterName = "@EmployeeName" param1.DbType = DbType.String param1.Value = ENameTextBox.Text.Trim() command.Parameters.Add(param1)

Dim param2 As New SqlParameter() param2.ParameterName = "@DesignationID" param2.DbType = DbType.Int32 param2.Value = CType(DesignationComboBox.SelectedItem, DesignationClass).DesignationID command.Parameters.Add(param2)

Dim param3 As New SqlParameter() param3.ParameterName = "@salary" param3.DbType = DbType.Double param3.Value = SalaryTextBox.Text.Trim() command.Parameters.Add(param3)

Dim param4 As New SqlParameter() param4.ParameterName = "@dateofbirth" param4.DbType = DbType.Date param4.Value = d command.Parameters.Add(param4)

Dim param5 As New SqlParameter() param5.ParameterName = "@address" param5.DbType = DbType.String param5.Value = AddressTextBox.Text.Trim()

Page 90: Book store Black Book - Dinesh48

90

Book Store Management

command.Parameters.Add(param5)

Dim i As Integer = command.ExecuteNonQuery If i > 0 Then If MsgBox("Employee added to Database!Do you want to continue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then ClearFields() Else command.Dispose() myConnection.Close() Me.Dispose() End If End If Catch ex As Exception MsgBox(ex.Message) End Try End If

End Sub Public Sub New() InitializeComponent()

End Sub Public Sub New(ByRef obj As EmployeeClass) InitializeComponent() End Sub Private Sub fillStatus() 'StatusComboBox.Items.Clear() 'StatusComboBox.Items.Add("Active") 'StatusComboBox.Items.Add("InActive") 'StatusComboBox.SelectedIndex = 0 End Sub

Private Sub AddEmployeeForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" FillCombo() fillStatus() EIDTextBox.Text = MiscUtilityClass.getID("Employee", "EmployeeID").ToString() Me.DateTimePicker1.MaxDate = Date.Now End Sub

Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint

End Sub

Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click saveEmployee() End Sub

Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) upadteEmployee() End Sub

Page 91: Book store Black Book - Dinesh48

91

Book Store Management

Private Sub BookCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookCancelButton.Click Me.Close() End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged DOBTextBox.Text = DateTimePicker1.Value.ToString("dd/MM/yyyy") End Sub Private Sub SalaryTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles SalaryTextBox.KeyPress If Asc(e.KeyChar) = 13 Then saveEmployee() End If If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If End Sub

Private Sub ENameTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ENameTextBox.KeyPress If Char.IsLetter(e.KeyChar) Or Asc(e.KeyChar) = 127 Or Asc(e.KeyChar) = 8 Or Asc(e.KeyChar) = 11 Or Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 32 Then e.Handled = False Else e.Handled = True End If If Asc(e.KeyChar) = 13 Then saveEmployee() End If End Sub

Private Sub EIDTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles EIDTextBox.KeyPress If Asc(e.KeyChar) = 13 Then saveEmployee() End If End Sub

Private Sub DesignationComboBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DesignationComboBox.KeyPress If Asc(e.KeyChar) = 13 Then saveEmployee() End If End Sub End Class

Page 92: Book store Black Book - Dinesh48

92

Book Store Management

Coding for Search employee:

Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration

Public Class SearchEmployeeDialog Dim flag As Integer Private Sub SearchEmployeeDialog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CriteriaKey.Items.Clear() CriteriaKey.Items.Add("EmployeeID") CriteriaKey.Items.Add("EmployeeName") Action(True) End Sub

Page 93: Book store Black Book - Dinesh48

93

Book Store Management

Private Sub CriteriaValue_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CriteriaValue.TextChanged End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Action() End Sub

Private Sub CriteriaKey_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CriteriaKey.SelectedIndexChanged CriteriaValue.Text = "" End Sub Private Sub Action() Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim query As String = "" Try objcon = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) query = query & "select EmployeeID,EmployeeName,type,salary,convert(varchar(20),Dateofbirth,103) as DateOfBirth,Address,status from employee e,employeedesignation d where e.designationid=d.designationid and " If IsNumeric(CriteriaValue) Then query = query & " convert(varchar(100)," & CriteriaKey.SelectedItem.ToString & ")like '" & CriteriaValue.Text.Trim & "%'" Else query = query & "" & CriteriaKey.SelectedItem.ToString & " like '" + CriteriaValue.Text.Trim + "%'" End If

Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table As New DataTable objda.Fill(table) DataGridView1.DataSource = table

Catch ex As Exception Try objcmd.Dispose() Catch exc1 As Exception

End Try Try objcon.Close() Catch exc As Exception

End Try MsgBox(ex.Message) MsgBox(Err.Source) End Try End Sub Public Sub Action(ByVal check As Boolean) Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim query As String = "" Try objcon = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString)

Page 94: Book store Black Book - Dinesh48

94

Book Store Management

query = query & "select EmployeeID,EmployeeName,type,salary,convert(varchar(20),Dateofbirth,103) as DateOfBirth,Address,status from employee e,employeedesignation d where e.designationid=d.designationid" Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table As New DataTable objda.Fill(table) DataGridView1.DataSource = table

Catch ex As Exception Try objcmd.Dispose() Catch exc1 As Exception

End Try Try objcon.Close() Catch exc As Exception

End Try MsgBox(ex.Message) End Try End Sub

Private Sub CriteriaValue_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles CriteriaValue.KeyPress If Asc(e.KeyChar) = 13 Then Action() End If End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim row As Integer = DataGridView1.CurrentRow.Index Dim objemployee As EmployeeClass = New EmployeeClass objemployee.EmployeeID = Val(DataGridView1.Item(0, row).Value.ToString) objemployee.EmployeeName = DataGridView1.Item(1, row).Value.ToString objemployee.DesignationType = DataGridView1.Item(2, row).Value.ToString objemployee.Salary = CType(DataGridView1.Item(3, row).Value.ToString, Double) objemployee.DateofBirth = DataGridView1.Item(4, row).Value.ToString objemployee.Address = DataGridView1.Item(5, row).Value.ToString objemployee.Status = DataGridView1.Item(6, row).Value.ToString If flag = 1 Then Dim objemployeeView As New UpdateEmployeeForm(objemployee, Me) objemployeeView.MdiParent = Me.MdiParent objemployeeView.StartPosition = FormStartPosition.CenterScreen objemployeeView.Show() End If If flag = 2 Then Dim objemployeedel As New DeleteEmployeeForm(objemployee, Me) objemployeedel.MdiParent = Me.MdiParent objemployeedel.StartPosition = FormStartPosition.CenterScreen objemployeedel.Show() End If End Sub

Public Sub New() InitializeComponent() End Sub Public Sub New(ByVal flag As Integer)

Page 95: Book store Black Book - Dinesh48

95

Book Store Management

InitializeComponent() Me.flag = flag End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End SubEnd Class

Coding for Update employee:

Imports System.GlobalizationImports System.Data.SqlClientImports System.Configuration

Public Class UpdateEmployeeForm Dim objsearch As SearchEmployeeDialog Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub Private Sub fillStatus()

Page 96: Book store Black Book - Dinesh48

96

Book Store Management

StatusComboBox.Items.Clear() StatusComboBox.Items.Add("Active") StatusComboBox.Items.Add("InActive") StatusComboBox.SelectedIndex = 0 End Sub Private Sub setEmployeeValues(ByRef obj As EmployeeClass) FillCombo() fillStatus() Me.EIDTextBox.Text = obj.EmployeeID Me.ENameTextBox.Text = obj.EmployeeName Dim i As Integer For i = 0 To DesignationComboBox.Items.Count - 1 If DesignationComboBox.Items.Item(i).ToString = obj.DesignationType Then Me.DesignationComboBox.SelectedItem = DesignationComboBox.Items.Item(i) End If Next If Me.StatusComboBox.Items.Contains(obj.Status) Then Me.StatusComboBox.SelectedItem = obj.Status End If Me.DOBTextBox.Text = obj.DateofBirth Dim dateobj As DateTimeFormatInfo = New DateTimeFormatInfo() dateobj.ShortDatePattern = "dd/MM/yyyy" Dim date1 As Date = Date.Parse(obj.DateofBirth, dateobj) Me.DateTimePicker1.Value = date1 Me.SalaryTextBox.Text = obj.Salary Me.AddressTextBox.Text = obj.Address End Sub Private Sub FillCombo() Me.DesignationComboBox.Items.Clear() Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing Try myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) 'myConnection = New SqlConnection("Data Source=COM4\SQLEXPRESS;Initial Catalog=MyData;Integrated Security=True;Pooling=False")

myConnection.Open() command = New SqlCommand("select * from employeedesignation", myConnection) Dim dbreader As SqlDataReader = command.ExecuteReader() While dbreader.Read() ' MsgBox("Hello" & dbreader.Item(1).ToString) Dim objlist As New DesignationClass() objlist.DesignationID = dbreader.GetValue(0) objlist.Designation = dbreader.GetString(1) DesignationComboBox.Items.Add(objlist) End While command.Dispose() myConnection.Close() DesignationComboBox.SelectedIndex = 0 Catch ex As Exception command.Dispose() myConnection.Close() MsgBox(ex.Message) End Try End Sub Private Function validateFields() As Boolean If ENameTextBox.Text.Trim.Length = 0 Then MsgBox("Employee Name is Required!")

Page 97: Book store Black Book - Dinesh48

97

Book Store Management

Return False End If If String.IsNullOrEmpty(SalaryTextBox.Text.Trim) Or Not IsNumeric(SalaryTextBox.Text.Trim) Then MsgBox("Valid salary is Required!") Return False End If If AddressTextBox.Text.Trim.Length = 0 Then MsgBox("Address is Required!") Return False End If Return True If Not IsNumeric(SalaryTextBox.Text.Trim) Then MsgBox("Price must be a number") Return False End If Return True

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If validateFields() Then Dim d As Date = DateTimePicker1.Value Try Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) myConnection.Open() Dim query As String query = "update Employee set EmployeeName='" & ENameTextBox.Text.Trim() & "',DesignationID=" & CType(DesignationComboBox.SelectedItem, DesignationClass).DesignationID & ",Salary=" & Val(SalaryTextBox.Text) & ",DateOfBirth='" & d & "',Address='" & AddressTextBox.Text.Trim() & "',status='" & StatusComboBox.SelectedItem.ToString & "' where EmployeeID=" & Val(EIDTextBox.Text) ' MsgBox(query) Dim command As SqlCommand = New SqlCommand(query, myConnection) Dim i As Integer = command.ExecuteNonQuery If i > 0 Then If MsgBox("Employees has been Updated!Do you want to continue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then ClearFields() objsearch.Action(True) Me.Close() Else command.Dispose() myConnection.Close() Me.Dispose() End If End If Catch ex As Exception MsgBox(ex.Message) End Try End If

End Sub

Private Sub ClearFields() EIDTextBox.Text = "" ENameTextBox.Text = ""

Page 98: Book store Black Book - Dinesh48

98

Book Store Management

DesignationComboBox.SelectedIndex = 0 SalaryTextBox.Text = "" DOBTextBox.Text = "" AddressTextBox.Text = "" ENameTextBox.Focus() End Sub

Public Sub New()

' This call is required by the Windows Form Designer. InitializeComponent()

' Add any initialization after the InitializeComponent() call. End Sub Public Sub New(ByRef obj As EmployeeClass, ByRef objsearch As SearchEmployeeDialog)

' This call is required by the Windows Form Designer. InitializeComponent() Me.objsearch = objsearch ' Add any initialization after the InitializeComponent() call. setEmployeeValues(obj) End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged DOBTextBox.Text = DateTimePicker1.Value.ToString("dd/MM/yyyy") End Sub

Private Sub UpdateEmployeeForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" End Sub

Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint

End Sub

Private Sub ENameTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ENameTextBox.KeyPress If Char.IsLetter(e.KeyChar) Or Asc(e.KeyChar) = 127 Or Asc(e.KeyChar) = 8 Or Asc(e.KeyChar) = 11 Or Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 32 Then e.Handled = False Else e.Handled = True End If End Sub

Page 99: Book store Black Book - Dinesh48

99

Book Store Management

Private Sub SalaryTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles SalaryTextBox.KeyPress If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If End SubEnd Class

Coding for Delete employee:

Imports System.Data.SqlClientImports System.ConfigurationImports System.Globalization

Public Class DeleteEmployeeForm

Page 100: Book store Black Book - Dinesh48

100

Book Store Management

Dim objsearch As SearchEmployeeDialog Private Sub fillStatus() StatusComboBox.Items.Clear() StatusComboBox.Items.Add("Active") StatusComboBox.Items.Add("InActive") StatusComboBox.SelectedIndex = 0 End Sub Private Sub setEmployeeValues(ByRef obj As EmployeeClass) FillCombo() fillStatus() Me.EIDTextBox.Text = obj.EmployeeID Me.ENameTextBox.Text = obj.EmployeeName Dim i As Integer For i = 0 To DesignationComboBox.Items.Count - 1 If DesignationComboBox.Items.Item(i).ToString = obj.DesignationType Then Me.DesignationComboBox.SelectedItem = DesignationComboBox.Items.Item(i) End If Next If Me.StatusComboBox.Items.Contains(obj.Status) Then Me.StatusComboBox.SelectedItem = obj.Status End If Me.DOBTextBox.Text = obj.DateofBirth Dim dateobj As DateTimeFormatInfo = New DateTimeFormatInfo() dateobj.ShortDatePattern = "dd/MM/yyyy" Dim date1 As Date = Date.Parse(obj.DateofBirth, dateobj) Me.DateTimePicker1.Value = date1 Me.SalaryTextBox.Text = obj.Salary Me.AddressTextBox.Text = obj.Address End Sub Private Sub FillCombo() Me.DesignationComboBox.Items.Clear() Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try objcon = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) objcon.Open() objcmd = New SqlCommand("select * from employeedesignation", objcon) Dim objrdr As SqlDataReader = objcmd.ExecuteReader() While objrdr.Read() Dim objlist As New DesignationClass() objlist.DesignationID = objrdr.GetValue(0) objlist.Designation = objrdr.GetString(1) DesignationComboBox.Items.Add(objlist) End While objcmd.Dispose() objcon.Close() DesignationComboBox.SelectedIndex = 0 Catch ex As Exception objcmd.Dispose() objcon.Close() MsgBox(ex.Message) End Try End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub

Page 101: Book store Black Book - Dinesh48

101

Book Store Management

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim objcon As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Book ").ConnectionString) objcon.Open() Dim query As String query = "delete from Employee where EmployeeID=" & Val(EIDTextBox.Text) Dim objcmd As SqlCommand = New SqlCommand(query, objcon) Dim i As Integer = objcmd.ExecuteNonQuery If i > 0 Then If MsgBox("Employees has been Deleted!Do you want to continue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then ClearFields() objsearch.Action(True) Me.Close() Else objcmd.Dispose() objcon.Close() Me.Dispose() End If End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub ClearFields() EIDTextBox.Text = "" ENameTextBox.Text = "" DesignationComboBox.SelectedIndex = 0 SalaryTextBox.Text = "" DOBTextBox.Text = "" AddressTextBox.Text = "" ENameTextBox.Focus() End Sub

Public Sub New() InitializeComponent()

End Sub Public Sub New(ByRef obj As EmployeeClass, ByRef objsearch As SearchEmployeeDialog) InitializeComponent() Me.objsearch = objsearch setEmployeeValues(obj) End SubEnd Class

Coding for generate bill:

Imports System.Data.SqlClientImports System.Configuration

Public Class GenerateBill Dim constr As String

Page 102: Book store Black Book - Dinesh48

102

Book Store Management

Dim totalAmt As Double Private Sub GenerateBill_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load getBook() End Sub Private Sub getBook() ComboBox1.Items.Clear() Dim myConnection As SqlConnection = Nothing Dim command As SqlCommand = Nothing ComboBox1.Items.Add("Select") Try constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString myConnection = New SqlConnection(constr) myConnection.Open() command = New SqlCommand("select i.bookID,BookName,Price,quantity from inventorymaster i left join bookmaster p on i.bookid=p.bookid", myConnection) Dim dbreader As SqlDataReader = command.ExecuteReader While dbreader.Read Dim obj As BookClass = New BookClass obj.BookID = dbreader(0) obj.BookName = dbreader(1) obj.Price = dbreader(2) obj.Quantity = dbreader(3) ComboBox1.Items.Add(obj) End While

dbreader.Close() command.Dispose() myConnection.Close() ListView1.Items.Clear() ComboBox1.SelectedIndex = 0 Dim id As Integer = MiscUtilityClass.getID("BillMaster", "BillID") TextBox1.Text = id totalAmt = 0 AddColumn() ListView1.Columns(5).Width = 0 Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub StartUp() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" ListView1.Items.Clear() ComboBox1.SelectedIndex = 0 Dim id As Integer = MiscUtilityClass.getID("BillMaster", "BillID") TextBox1.Text = id totalAmt = 0 AddColumn() getBook() End Sub Private Sub AddColumn() ListView1.Columns.Clear() ListView1.Columns.Add("Book ID") ListView1.Columns.Add("Book Name") ListView1.Columns.Add("Quantity") ListView1.Columns.Add("Price") ListView1.Columns.Add("Amount")

Page 103: Book store Black Book - Dinesh48

103

Book Store Management

ListView1.Columns.Add("QStock") ListView1.Columns(5).Width = 0 ListView1.View = View.Details End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If ComboBox1.SelectedIndex > 0 Then Dim str1 As String = CType(ComboBox1.SelectedItem, BookClass).BookID.ToString Dim str2 As String = CType(ComboBox1.SelectedItem, BookClass).BookName Dim str3 As String = CType(ComboBox1.SelectedItem, BookClass).Price.ToString Dim q As String = CType(ComboBox1.SelectedItem, BookClass).Quantity.ToString Dim listobj As ListViewItem = New ListViewItem(str1) listobj.SubItems.Add(str2) listobj.SubItems.Add(TextBox2.Text.Trim) listobj.SubItems.Add(str3) totalAmt = totalAmt + CType(ComboBox1.SelectedItem, BookClass).Price * Val(TextBox2.Text.Trim) listobj.SubItems.Add((CType(ComboBox1.SelectedItem, BookClass).Price * Val(TextBox2.Text.Trim)).ToString) listobj.SubItems.Add(q) ListView1.Items.Add(listobj) TextBox4.Text = totalAmt End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim myConnection As SqlConnection = Nothing Dim myConnection2 As SqlConnection = Nothing Dim command As SqlCommand = Nothing Dim command2 As SqlCommand = Nothing Dim command3 As SqlCommand = Nothing Dim command4 As SqlCommand = Nothing Dim trans As SqlTransaction = Nothing

Try myConnection = New SqlConnection(constr) myConnection.Open() 'trans = myConnection.BeginTransaction

command = New SqlCommand("insert into BillMaster(BillOwner,BillDate,Total)values('" & TextBox3.Text.Trim & "','" & Date.Now.ToString("MM/dd/yyyy") & "'," & Val(TextBox4.Text.Trim) & ")", myConnection) ', trans) command.ExecuteNonQuery() TextBox1.Text = MiscUtilityClass.getID("BillMaster", "BillID") - 1 myConnection2 = New SqlConnection(constr) myConnection2.Open() For i = 0 To ListView1.Items.Count - 1 Dim id As String = ListView1.Items(i).Text Dim quantity As String = ListView1.Items(i).SubItems(2).Text Dim price As String = ListView1.Items(i).SubItems(3).Text Dim stockQ As String = ListView1.Items(i).SubItems(3).Text command2 = New SqlCommand("insert into PurchasedItem(BillId,BookID,Quantity,Price)values(" & TextBox1.Text.Trim & "," & Val(id) & "," & Val(quantity) & "," & Val(price) & ")", myConnection) ', trans) command2.ExecuteNonQuery() 'MsgBox(stockQ) stockQ = Val(stockQ) - Val(quantity)

Page 104: Book store Black Book - Dinesh48

104

Book Store Management

'MsgBox(stockQ) command3 = New SqlCommand("Update inventorymaster set quantity=" & stockQ & " where bookid=" & Val(id), myConnection) ', trans) command3.ExecuteNonQuery() Next 'trans.Commit() command.Dispose() command2.Dispose() command3.Dispose() myConnection2.Close() myConnection.Close()

MsgBox("Bill Saved!")

Catch ex As Exception Try ' trans.Rollback() Catch exc As Exception

End Try MsgBox(ex.Message) End Try End Sub

Private Sub NewBillButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewBillButton.Click StartUp() End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As BillGenerationForm = New BillGenerationForm(Val(TextBox1.Text.Trim)) obj.MdiParent = Me.MdiParent obj.Show() End Sub

Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

Page 105: Book store Black Book - Dinesh48

105

Book Store Management

If Char.IsLetter(e.KeyChar) Or Asc(e.KeyChar) = 127 Or Asc(e.KeyChar) = 8 Or Asc(e.KeyChar) = 11 Or Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 32 Then e.Handled = False Else e.Handled = True End If End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

End SubEnd Class

Page 106: Book store Black Book - Dinesh48

106

Book Store Management

Coding for Employee Salary:

Imports System.ConfigurationImports System.Data.SqlClientImports System.TextImports System.Security.CryptographyImports System.Globalization

Public Class EmployeeSalary

Private Sub EmployeeSalary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load OpenDB()

Dim cmd1 As New SqlCommand("Select * from Employee", con)

getCustomer() cboEmpId.SelectedIndex = 0

End Sub Private Sub getCustomer() cboEmpId.Items.Add("Select Employee") Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim objrdr As SqlDataReader = Nothing Dim query As String = "select * from Employee" Try objcon = New SqlConnection(ConfigurationManager.ConnectionStrings("Grocery").ConnectionString) objcon.Open() objcmd = New SqlCommand(query, objcon) objrdr = objcmd.ExecuteReader() While objrdr.Read Dim obj As CustomerClass = New CustomerClass ' obj.EmployeeName = objrdr(0) obj.EmployeeName = objrdr(1) 'obj.address = objrdr(2) 'obj.status = objrdr(3) cboEmpId.Items.Add(obj) End While objcmd.Dispose() objcon.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Sub

Private Sub cboEmpId_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboEmpId.SelectedIndexChanged End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close()

End Sub

Page 107: Book store Black Book - Dinesh48

107

Book Store Management

Private Sub DBasic_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim f As Boolean = False ' f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub DDailywages_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDDailywages.KeyPress Dim f As Boolean = False ' f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub DDays_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDDays.KeyPress Dim f As Boolean = False 'f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub MBasic_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim f As Boolean = False 'f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub MDaily_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMDaily.KeyPress Dim f As Boolean = False 'f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub MDays_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMDays.KeyPress Dim f As Boolean = False 'f = Number_Validation(e.KeyChar) If f = True Then e.Handled = True End If End Sub

Private Sub DDays_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDDays.TextChanged txtDSalary.Text = Val(Val(txtDDailywages.Text) * Val(txtDDays.Text)) End Sub

Page 108: Book store Black Book - Dinesh48

108

Book Store Management

Private Sub txtMDays_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMDays.TextChanged txtMSalary.Text = Val(txtMDays.Text) * Val(txtMDaily.Text) End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 'sallary.Show()

Dim obj As Monthlysalary = New Monthlysalary obj.StartPosition = FormStartPosition.CenterScreen ''obj.MdiParent = Me obj.Show()

End Sub Private Sub ClearFields() txtDDailywages.Text = "" txtDDays.Text = "" txtDSalary.Text = "" txtMBasic.Text = "" txtMDaily.Text = "" txtMDays.Text = "" txtMSalary.Text = "" End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click ' Dim d As Date = DateTimePicker1.Value Dim transaction As SqlTransaction = Nothing Dim objcon As SqlConnection = Nothing Try objcon = New SqlConnection(ConfigurationManager.ConnectionStrings("Grocery").ConnectionString) objcon.Open() Dim objcmd As SqlCommand = New SqlCommand("insert into Empsalary(dsalary,ddays,ddaily,emp_name,msalary,mdaily,mbasic,mdays)values('" & txtDSalary.Text.Trim() & "','" & txtDDays.Text.Trim() & "','" & txtDDailywages.Text.Trim() & "','" & cboEmpId.Text.Trim & "','" & txtMSalary.Text.Trim() & "','" & txtMDaily.Text.Trim() & "','" & txtMBasic.Text.Trim() & "','" & txtMDays.Text.Trim() & "')", objcon, transaction) ' Dim objcmd As SqlCommand = New SqlCommand("Insert into Empsalary Values(" & Val(txtDDailywages.Text) & "," & Val(txtDDays.Text) & "," & Val(txtDSalary.Text) & "," & Val(txtMBasic.Text) & "," & Val(txtMDaily.Text) & "," & Val(txtMDays.Text) & "," & Val(txtMSalary.Text) & ")", objcon, transaction) Dim i As Integer = objcmd.ExecuteNonQuery

'Dim objcmd2 As SqlCommand = New SqlCommand("insert into inventorymaster(productID,Quantity)values(" & Val(PIDTextBox.Text) & "," & Val(QuantityTextBox.Text.Trim()) & ")", objcon, transaction) 'Dim j As Integer = objcmd2.ExecuteNonQuery

'If i > 0 And j > 0 Then If MsgBox("Product added to Database!Do you want to continue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then ClearFields() Else

Page 109: Book store Black Book - Dinesh48

109

Book Store Management

objcmd.Dispose() objcon.Close() Me.Dispose() End If ' End If Catch ex As Exception MsgBox(ex.Message) End Try 'End If End Sub

Private Sub txtMDaily_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMDaily.TextChanged

End Sub

Private Sub txtMBasic_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMBasic.TextChanged txtMDaily.Text = Val(txtMBasic.Text) / 30 End Sub

Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub txtDDailywages_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDDailywages.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As Dailysalary = New Dailysalary obj.StartPosition = FormStartPosition.CenterScreen 'obj.MdiParent = Me obj.Show()

End SubEnd Class

Page 110: Book store Black Book - Dinesh48

110

Book Store Management

Coding for Print bill:

Imports System.ConfigurationImports System.Data.SqlClientImports System.Globalization

Public Class PrintBill Dim constr As String Private Sub PrintBill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load constr = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim myConnection As SqlConnection = Nothing Dim query As String = "select BillID,BillOwner,convert(varchar(20),BillDate,103) as BillDate,Total from billmaster" Try myConnection = New SqlConnection(constr) Dim databaseadapter As SqlDataAdapter = New SqlDataAdapter(query, myConnection) Dim table As New DataTable databaseadapter.Fill(table) DataGridView1.DataSource = table Catch ex As Exception MsgBox(ex.Message) End Try CriteriaKey.Items.Add("Select Bill") CriteriaKey.Items.Add("BillDate") CriteriaKey.Items.Add("BillID") CriteriaKey.SelectedIndex = 0 End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click If CriteriaKey.SelectedIndex > 0 Then Dim myConnection As SqlConnection = Nothing Dim query As String = "select BillID,BillOwner,convert(varchar(20),BillDate,103) as BillDate,Total from billmaster" Try Try

If CriteriaKey.SelectedIndex = 1 Then Dim df As DateTimeFormatInfo = New DateTimeFormatInfo df.ShortDatePattern = "dd/MM/yyyy" Dim d As Date = Date.Parse(CriteriaValue.Text.Trim, df) query = query & " where BillDate='" & d.ToString("MM/dd/yyyy") & "'" End If If CriteriaKey.SelectedIndex = 2 Then query = query & " where convert(varchar(20),BillID) like '" & CriteriaValue.Text.Trim & "%'" End If ' MsgBox(query) myConnection = New SqlConnection(constr) Dim databaseadapter As SqlDataAdapter = New SqlDataAdapter(query, myConnection) Dim table As New DataTable databaseadapter.Fill(table) DataGridView1.DataSource = table Catch ex As Exception

Page 111: Book store Black Book - Dinesh48

111

Book Store Management

MsgBox("Invalid Date") End Try Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.Close() End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim row As Integer = DataGridView1.CurrentRow.Index Dim id As Integer = Val(DataGridView1.Item(0, row).Value.ToString)

Dim obj As BillGenerationForm = New BillGenerationForm(id) obj.MdiParent = Me.MdiParent obj.Show() End SubEnd Class

Page 112: Book store Black Book - Dinesh48

112

Book Store Management

Coding for all book Report Screen:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class AllBookReportForm1

Private Sub AllBookReportForm1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport1() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand() Dim myDA As New SqlDataAdapter() Dim myDS As New Book DataSet() 'The DataSet you created.

Try

myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = "select * from bookmaster" MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "datatable1") rpt.SetDataSource(myDS) CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End SubEnd Class

Page 113: Book store Black Book - Dinesh48

113

Book Store Management

Coding for Inventory Report Screen:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class InventoryReportForm1

Private Sub InventoryReportForm1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport2() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand() Dim myDA As New SqlDataAdapter() Dim myDS As New Book DataSet() 'The DataSet you created.

Try

myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = "SELECT BookMaster.BookName, InventoryMaster.Quantity, BookMaster.price FROM InventoryMaster INNER JOIN BookMaster ON InventoryMaster.BookId = BookMaster.BookID" MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "datatable2") rpt.SetDataSource(myDS) CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End SubEnd Class

Page 114: Book store Black Book - Dinesh48

114

Book Store Management

Coding for Employee Report Screen:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class EmployeeReportForm

Private Sub EmployeeReportForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport4() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand() Dim myDA As New SqlDataAdapter() Dim myDS As New Book DataSet() 'The DataSet you created.

Try

myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = "SELECT Employee.EmployeeID, Employee.EmployeeName, EmployeeDesignation.Type, Employee.salary, Employee.dateofbirth, Employee.address FROM Employee INNER JOIN EmployeeDesignation ON Employee.DesignationID = EmployeeDesignation.DesignationID" MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "datatable5") rpt.SetDataSource(myDS) CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub

End Class

Page 115: Book store Black Book - Dinesh48

115

Book Store Management

Coding for DAILY SALES REPORT SCREEN:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class DailySalesReportForm

Private Sub DailySalesReportForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport6() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand()

Dim myDA As New SqlDataAdapter() Dim myDS As New DataSet1() 'The DataSet you created.

Try

myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = "SELECT PurchasedItem.SrNo, BookMaster.BookName, PurchasedItem.Quantity, PurchasedItem.Price, BillMaster.BillDate, BillMaster.Total FROM BookMaster INNER JOIN PurchasedItem ON BookMaster.BookID = PurchasedItem.BookID INNER JOIN BillMaster ON PurchasedItem.BillID = BillMaster.BillID where BillMaster.BillDate='" & Date.Now.ToString("MM/dd/yyyy") & "'" MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand myDA.Fill(myDS, "DataTable1") rpt.SetDataSource(myDS)

CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub

End Class

Page 116: Book store Black Book - Dinesh48

116

Book Store Management

Coding for Monthly sales report SCREEN:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class MonthlySalesReportForm

Private Sub MonthlySalesReportForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport6() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand()

Dim myDA As New SqlDataAdapter() Dim myDS As New DataSet1() 'The DataSet you created.

Dim d1 As Date = New Date(Date.Now.Year, Date.Now.Month, 1) Dim lstdate As Integer = Date.DaysInMonth(Date.Now.Year, Date.Now.Month)

Dim d2 As Date = New Date(Date.Now.Year, Date.Now.Month, lstdate)

Try Dim query As String = "SELECT PurchasedItem.SrNo, BookMaster.BookName, PurchasedItem.Quantity, PurchasedItem.Price, BillMaster.BillDate, BillMaster.Total FROM BookMaster INNER JOIN PurchasedItem ON BookMaster.BookID = PurchasedItem.BookID INNER JOIN BillMaster ON PurchasedItem.BillID = BillMaster.BillID where BillMaster.BillDate between '" & d1.ToString("MM/dd/yyyy") & "' and '" & d2.ToString("MM/dd/yyyy") & "'" 'MsgBox(query) myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = query MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand myDA.Fill(myDS, "DataTable1") rpt.SetDataSource(myDS)

CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub

End Class

Page 117: Book store Black Book - Dinesh48

117

Book Store Management

Coding for Bill Print SCREEN:

Imports System.ConfigurationImports System.Data.SqlClient

Public Class Bill Dim id As Integer

Private Sub Bill_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString = ConfigurationManager.ConnectionStrings("Book ").ConnectionString Dim rpt As New CrystalReport3() Dim myConnection As SqlConnection Dim MyCommand As New SqlCommand() Dim myDA As New SqlDataAdapter() Dim myDS As New Book DataSet().

Try

myConnection = New SqlConnection(connectionString) MyCommand.Connection = myConnection MyCommand.CommandText = "SELECT BillMaster.BillID, BillMaster.BillOwner, BillMaster.BillDate, BookMaster.BookName, PurchasedItem.Quantity, PurchasedItem.Price, BillMaster.Total FROM BillMaster INNER JOIN PurchasedItem ON BillMaster.BillID = PurchasedItem.BillID CROSS JOIN BookMaster where BillMaster.billID=" & id MyCommand.CommandType = CommandType.Text myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "DataTable3") rpt.SetDataSource(myDS) CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub

Public Sub New() InitializeComponent() End Sub Public Sub New(ByVal id As Integer) InitializeComponent()

Me.id = id End SubEnd Class

Page 118: Book store Black Book - Dinesh48

118

Book Store Management

Coding for project profile:

Public NotInheritable Class AboutBox

Private Sub AboutBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ApplicationTitle As String If My.Application.Info.Title <> "" Then ApplicationTitle = My.Application.Info.Title Else ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If Me.LabelBookName.Text = My.Application.Info.BookName Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) Me.LabelCopyright.Text = My.Application.Info.Copyright Me.LabelCompanyName.Text = My.Application.Info.CompanyName Me.TextBoxDescription.Text = My.Application.Info.Description End Sub

Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click Me.Close() End Sub

Private Sub LabelBookName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabelBookName.Click

End SubEnd Class

Page 119: Book store Black Book - Dinesh48

119

Book Store Management

7.

CONCLUSION

Page 120: Book store Black Book - Dinesh48

120

Book Store Management

CONCLUSION

An attempt is made in all its earnest towards the successful completion of the project. This system was verified with valid as well as with invalid data.

This system is user friendly since it has been developed in visual studio 8 a successful GUI environment. Since the connection can be extended to any database. The control will be more powerful.

Connecting it to any type of database extends the development control. Any suggestions for future development of the system are welcome

Upgrading the system if may can be done without affecting the proper functioning of system.

Page 121: Book store Black Book - Dinesh48

121

Book Store Management

5.

System implementation

Page 122: Book store Black Book - Dinesh48

122

Book Store Management

System implementation

To run this application, firstly we need to install VisualStudio2008

Secondly, we need to install MYSQL2005

Thirdly, we need to Copy project files on to machine

Execute project.

Page 123: Book store Black Book - Dinesh48

123

Book Store Management

6.

FUTURE ENHANCEMENTS

Page 124: Book store Black Book - Dinesh48

124

Book Store Management

FUTURE ENHANCEMENTS

Due to time constraints on the part of the developer, supplier details form could not be prepared.

Hence this project would be updated in the near future to include supplier details form and other similar reports.

Details of book transaction between the owner and the supplier also has to be added

Any suggestions are accepted. Any sort of problem would be solved.

Any changes made in the system in future, will Affect the other functioning of the

System .

Page 125: Book store Black Book - Dinesh48

125

Book Store Management

7.

References and Bibliography

Page 126: Book store Black Book - Dinesh48

126

Book Store Management

BIBLIOGRAPHY

REFERENCES BOOKS:

Software Engineering - Written by: Pankaj Jalote

Project Management - Written by: K.R.Sharma

The complete Reference for -Written by: Anne Bohem, Murach

Websites:

www.wrox.com

www.webmonkey.com

www.w3schools.com

www.google.com

Thank you.