black final grocery 3
Post on 05-Apr-2018
227 Views
Preview:
TRANSCRIPT
-
8/2/2019 Black Final Grocery 3
1/101
PREFACEThis project aims at the Introduction to computerized
Grocery Selling Updating Stuff System
This software is also developed for daily basis businessprocesses and effectively Grocery Sales managing and stuffsystem.
This software is designed keeping in mind the users
efficiency & ease of handling and maintenance, as and securedsystem over centralized data handling and providing with thefeatures to get the complete study and control over thebusiness.
The report depicts the basics logic used for softwaredevelopment long with the Activity diagrams so that logicsmay be apprehended without difficulty.
For detailed information, screen layouts, provided alongwith this report can be viewed.
Although this report is prepared with considering the resultsrequired these may be across since the project is subjected tofuture enhancements as per the need of organizations.
1 | P a g e
-
8/2/2019 Black Final Grocery 3
2/101
ACKNOWLEDGEMENTIts a great pleasure to get this opportunity and sincerely thank
all the people, who have showed me the way to create a
successful .net project and helped me a lot during the
completion of the project.
I am highly obliged to the teaching and non-teaching staff
members of the Computer Science Department who spared
efforts in making the project a successful one with theirguidance, appropriate advice and encouragement and of course
inspiration without which the project would be ineffective
difficult task.
It gives a great pleasure in presenting this project report. It
justification will never sound good if I do not express my vote of
thanks to our Bhavna Trust College and Principal
DR.MRS.ANJALI V. KARANDIKAR.I sincerely thank and express my profound gratitude and
indebtedness to our Project Guides Prof. Alok Kumar Singh
(HOD), Prof. Vrushali Gholap and Prof. Sangeeta for their
timely and prestigious guidance required for the project
completion at each phase of the project development apart
from the inspiration and motivation.
I also to owe my Friends who have been a constant source ofhelp to solve their problems that cropped up during the
development of the project and for being an encouraging and
guiding force towards the successful completion of the project.
2 | P a g e
-
8/2/2019 Black Final Grocery 3
3/101
PreliminaryInvestigation
3 | P a g e
-
8/2/2019 Black Final Grocery 3
4/101
Description of the System The current system used by shop is basically entering data
related to the customers, manually done using registers.
All product or customer related information is filled in their
respective form or receipt copy of the same is given to the
customer too.
All the records of order product form and all reports are stored
in different registers.
This system also enables the owner to calculate profit.
After completion of project and satisfactory result project issubmitted to Client Company with completion.
Limitations of theCurrentSystem:
Lack of Data security :
Tampering of data.
Physical destruction of data.
Unauthorized access of data by other person.
Overhead of data management :
Lots of paper work.
Updating is complicated :
Difficult to rectify the data.
Wastage of time for searching required details.
Proposed System:4 | P a g e
-
8/2/2019 Black Final Grocery 3
5/101
Since existing system is manual, focus is on automating the entire
system and computerizes the handling process. So that the work
should be easy and more accurate.
Proposed System
Requirement:
To make provision for user friendly interface to enter the all
required details.
Have provision to generate various required details of
customer, product, order etc. easily with the help of Name, ID,
etc.
Maintain all updated details of products, inventory and
employees.
To produce bill slip to customer.
Advantages of Proposed
System
5 | P a g e
-
8/2/2019 Black Final Grocery 3
6/101
Data security:
No tampering of data.
No physical destruction.
No unauthorized access.
Faster processing :
Searching is easy and faster, hence the access
time is reduced.
User friendly interface.
Easy updating and modifications of data.
Easy searching of data.
6 | P a g e
-
8/2/2019 Black Final Grocery 3
7/101
FEASIBILITY STUDYEvery project would be feasible, if provided with unlimited
resources and unlimited time. But unfortunately, the development
of computer-based system of product 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:
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.
7 | P a g e
-
8/2/2019 Black Final Grocery 3
8/101
Operating Environment
8 | P a g e
-
8/2/2019 Black Final Grocery 3
9/101
SOFTWARE AND
HARDWAREREQUIREMENT
Software Requirement Specification: - The system will bedeveloped using.
Operating system: - Windows XP, Windows7
Front-end Tool: - Visual studio 2008
Back-end Tool: - SQL Server
Report Generation: - Crystal Report Basic
Hardware Requirement Specification: - The system will be
developed using.
Operating system: - WINDOWS XP
Ram: - 256 MB
Hard Disk: - 40 GB
9 | P a g e
-
8/2/2019 Black Final Grocery 3
10/101
Gantt chart
10 | P a g e
-
8/2/2019 Black Final Grocery 3
11/101
Event Table11 | P a g e
-
8/2/2019 Black Final Grocery 3
12/101
12 | P a g e
No. Event Trigger Source Activity Response Destination
1.Create an
employee
Employee
DetailsEmployee
Add
employee
details
Information
savedEmployee
2.Update
Employee
Update
employeeEmployee
Update
employee
Update
InformationEmployee
3.
Add Product
Product
details
and add
in
inventory
Product
Add
Product
and in
inventory
Information
savedProduct
4.Update
Inventory
Update
productProduct
Update
quantity
Information
updated
Inventory
Master
5.
Generate billCreate
billBill
Calculate
bill amountBill generated Bill Master
6.Save Bill Save Bill Bill Save Bill
Information
savedBill Master
7.
Print BillGenerate
and printBill Print bill
Take print of
BillBill master
8.Get Inventory
report
Inventory
report
Inventory
master
Produce
inventory
report
Report
generated
Inventory
master
-
8/2/2019 Black Final Grocery 3
13/101
UML Diagrams
13 | P a g e
-
8/2/2019 Black Final Grocery 3
14/101
UML Diagrams
descriptionsThe underlying premise of UML is that no one diagram can capture
the different elements of a system in its entirety. Hence, UML is
made up of nine diagrams that can be used to model a system at
different points of time in the software life cycle of a system. The
nine UML diagrams are:
Use case diagram: The use case diagram is used to
identify the primary elements and processes that form thesystem. 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.
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. These
functionalities provided by the class are termed "methods" of
the class. Apart from this, each class may have certain
"attributes" that uniquely identify the class.
Object diagram:The object diagram is a special kind of
class diagram. An object is an instance of a class. This
essentially means that an object represents the state of a class
at a given point of time while the system is running. The object
diagram captures the state of different classes in the system
and their relationships or associations at a given point of time.
State diagram:A state diagram, as the name suggests,
represents the different states that objects in the system
undergo during their life cycle. Objects in the system change
states in response to events. In addition to this, a state
diagram also captures the transition of the object's state from
an initial state to a final state in response to events affecting
the system.
14 | P a g e
-
8/2/2019 Black Final Grocery 3
15/101
Activity diagram: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.
Sequence diagram: A sequence diagram represents theinteraction 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".
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 thesystem and how they are interrelated. A component diagram
depicts the components culled after the system has undergone
the development or construction phase.
Deployment diagram:The 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.
Now that we have an idea of the different UML diagrams, let us seeif we can somehow group together these diagrams to enable us to
further understand how to use them.
15 | P a g e
-
8/2/2019 Black Final Grocery 3
16/101
UML Diagram Classification
Static,Dynamic, and
ImplementationA software system can be said to have two distinct characteristics: a
structural, "static" part and a behavioral, "dynamic" part. In
addition to these two characteristics, an additional characteristic
that a software system possesses is related to implementation.
Before we categorize UML diagrams into each of these three
characteristics, let us take a quick look at exactly what these
characteristics are.
Static:The static characteristic of a system is essentially
the structural aspect of the system. The static characteristics
define what parts the system is made up of.
Dynamic:The behavioral features of a system; forexample, the ways a system behaves in response to certain
events or actions are the dynamic characteristics of a system.
Implementation:The implementation characteristic of a
system is an entirely new feature that describes the differentelements required for deploying a system.
The UML diagrams that fall under each of thesecategories are:
Static
Use case diagram
Class diagram2 Dynamic
Object diagram
State diagram
Activity diagram
Sequence diagram
3 Implementation Component diagram
Deployment diagram
16 | P a g e
-
8/2/2019 Black Final Grocery 3
17/101
4+1 View of UML
DiagramsConsidering that the UML diagrams can be used in different stagesin the life cycle of a system, let us take a look at the "4+1 view" of
UML diagrams. The 4+1 view offers a different perspective to
classify and apply UML diagrams. The 4+1 view is essentially how a
system can be viewed from a software life cycle perspective. Each of
these views represents how a system can be modeled. This will
enable us to understand where exactly the UML diagrams fit in and
their applicability.
These different views are:
Design View:The design viewof a system is the structural
view of the system. This gives an idea of what a given system
is made up of. Class diagrams and object diagrams form the
design view of the system.
Process View:The dynamic behavior of a system can be
seen using theprocess view. The different diagrams such as
the state diagram, activity diagram, and sequence diagram are
used in this view.
Component View:Next, you have the component view
that shows the grouped modules of a given system modeled
using the component diagram.
Deployment View:The deployment diagram of UML is
used to identify the deployment modules for a given system.
This is the deployment viewof the
Use case View:Finally, we have the use case view. Use
case diagrams of UML are used to view a system from this
perspective as a set of discrete activities or transactions.
17 | P a g e
-
8/2/2019 Black Final Grocery 3
18/101
Use Case Diagram
Customer
Admin
PurchaseProduct
Add Product
View Inventry
View Product
Print Bill
Product
Availability
Pay Bill
System
18 | P a g e
-
8/2/2019 Black Final Grocery 3
19/101
Entity Relationship
Diagram
Product Inventory
Employee
Inventory ID
QuantityProduct ID
Employee
Contact
Employee
Address
Employee
Name
Employee
ID
Product
Name
Product ID
Batch No.
update
sales
Employee
Designation
Type
Designation ID
has
Expiry DateManufacturing
Date
Price
Product
Bill ID
Bill Owner
Bill Date
Generates B ill
19 | P a g e
-
8/2/2019 Black Final Grocery 3
20/101
Activity Diagram
Manage
Employee
Create
Employee Modify
Employee
Remove
Employee
Employee
Completed
Employee Exits
Modify
Emoloyee
Remove Employee
New Employee
20 | P a g e
-
8/2/2019 Black Final Grocery 3
21/101
Class Diagram
Product
Product ID:int
Product Name:string
Batch No:int
Price:int
Manufacturing date:int
Expiry Date:int
Add( )void
Update( )void
Delete( )void
Search( )void
Employee Designation
Designation ID:int
Designation Type:string
Add( )void
Update( )void
Delete( )voidSearch( )void
Inventory
Inventory ID:int
Product ID:int
Quantity:int
Add( )void
Update( )voidDelete( )void
Search( )void
Employee
Employee ID:int
Employee Name:string
Employee Address:string
Employee DOB:string
Add( )void
Update( )void
Delete( )void
Search( )void
*1
1
*
*
1
1
*
21 | P a g e
-
8/2/2019 Black Final Grocery 3
22/101
Object Diagram
prd:Product
Product ID:int
Product Name:string
Batch No:int
Price:int
Manufacturing date:int
Expiry Date:int
empldesg:Employee
Designation
Designation ID:int
Designation Type:string
inv:Inventory
Inventory ID:int
Product ID:int
Quantity:int
emp:Employee
Employee ID:int
Employee Name:string
Employee Address:string
Employee DOB:string
* 1
1
*
*
1
1
*
Sequence Diagram22 | P a g e
-
8/2/2019 Black Final Grocery 3
23/101
23 | P a g e
-
8/2/2019 Black Final Grocery 3
24/101
SYSTEM DESIGN
Component Diagram24 | P a g e
-
8/2/2019 Black Final Grocery 3
25/101
25 | P a g e
-
8/2/2019 Black Final Grocery 3
26/101
Package Diagram
26 | P a g e
-
8/2/2019 Black Final Grocery 3
27/101
Deployment Diagram
27 | P a g e
-
8/2/2019 Black Final Grocery 3
28/101
Menu Tree
GROCERY SHOP MANAGEMENT SYSTEM
Product
ReportsBill
InventoryTools & Utilities
GROCERY SHOP MANAGEMENT SYSTEM
Add
Product
Update
Product
Delete
Product
Show all
Product
CalculatorUpdate
Inventory
Show Inventory
status
Generate
Bill
Product
Info
Inventory
Info
Search
Product
Employee
Search
Employee
Add
Employee
Update
Employee
Delete
Employee
Exit
28 | P a g e
-
8/2/2019 Black Final Grocery 3
29/101
Database Tables
Table Name: UserMaster
Key Field Name Field
Type
Field
Size
Description
* Primary username varchar 50 Users name
29 | P a g e
-
8/2/2019 Black Final Grocery 3
30/101
key
password varchar 50 User password
30 | P a g e
-
8/2/2019 Black Final Grocery 3
31/101
Table Name: Employee
31 | P a g e
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
-
8/2/2019 Black Final Grocery 3
32/101
Table Name: EmployeeDesignation
Key Field Name FieldType
FieldSize
Description
* Primary
Key
DesignationId numeric (18,0) Employee
Designation
ID
Type varchar 50 Employee
Designation
Type
Table Name: ProductMaster
32 | P a g e
-
8/2/2019 Black Final Grocery 3
33/101
Key Field Name Field
Type
Field
Size
Description
* Primary
Key
ProductID numeric (18,0) Product ID
ProductName varchar 50 Product Name
Batch No varchar 50 Product Batch
Number
price numeric (7,2) Product Price
manuDate datetime Product
Manufacturing
Date
Expiry date datetime Product Expiry
Date
Table Name: InventoryMaster
33 | P a g e
-
8/2/2019 Black Final Grocery 3
34/101
Key Field Name Field
Type
Field
Size
Description
* Primary
Key
InventoryId numeric (18,0) Inventory ID
ProductId numeric (18,0) Product Id
Quantity numeric (18,0) Inventory
Quantity
Table Name: PurchasedItem
Key Field Name Field
Type
Field
Size
Description
34 | P a g e
-
8/2/2019 Black Final Grocery 3
35/101
* Primary
Key
SrNo numeric (18,0) Bill Serial
Number
BillID numeric (18,0) Bill ID
ProductID numeric (18,0) Product ID
Quantity numeric (18,0) Total Product
Quantity
Price numeric (18,0) Product Price
Table Name: BillMaster
Key Field Name Field
Type
Field
Size
Description
* Primary BillID numeric (18,0) Bill ID
35 | P a g e
-
8/2/2019 Black Final Grocery 3
36/101
Key
BillOwner varchar 50 Bill Owner
Name
BillDate datetime Bill Date
Total numeric (18,2) Total Amount
36 | P a g e
-
8/2/2019 Black Final Grocery 3
37/101
ValidationThere 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 ofthe application using public and private APIs
Code coverage - creating tests to satisfy some criteria of codecoverage (e.g., the test designer can create tests to cause allstatements in the program to be executed at least once)
Fault injection methods - improving the coverage of a test byintroducing faults to test code paths
37 | P a g e
-
8/2/2019 Black Final Grocery 3
38/101
Mutation testing methods
Static testing - White box testing includes all static testing
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 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.
38 | P a g e
-
8/2/2019 Black Final Grocery 3
39/101
Coding for validation
For Only Alphabets
PrivateSub TextBox2_KeyPress(ByVal sender AsObject, ByVal eAs System.Windows.Forms.KeyPressEventArgs) HandlesTextBox2.KeyPress If IsNumeric(e.KeyChar) Then
MsgBox("ENTER CHARACTER")
e.KeyChar = Nothing EndIf
EndSub
For Only NumbersPrivateFunction validatFields() AsBoolean IfNot IsNumeric(TextBox4.Text.Trim) Then
MsgBox("Price must be a number")
ReturnFalse EndIf ReturnTrue EndFunction
39 | P a g e
-
8/2/2019 Black Final Grocery 3
40/101
Forms and layouts :
40 | P a g e
-
8/2/2019 Black Final Grocery 3
41/101
Splash Screen
Screen shot:
login Screen
41 | P a g e
-
8/2/2019 Black Final Grocery 3
42/101
Screen shot:
42 | P a g e
-
8/2/2019 Black Final Grocery 3
43/101
Project Main Screen
Screen shot:
43 | P a g e
-
8/2/2019 Black Final Grocery 3
44/101
project profile:
Sreen shot:
Add Product Screen
44 | P a g e
-
8/2/2019 Black Final Grocery 3
45/101
Screen shot:
update product Screen
45 | P a g e
-
8/2/2019 Black Final Grocery 3
46/101
Screen shot:
delete product ScreenScreen shot:
46 | P a g e
-
8/2/2019 Black Final Grocery 3
47/101
Search product Screen
Screen shot:
47 | P a g e
-
8/2/2019 Black Final Grocery 3
48/101
update inventory Screen
Screen shot:
48 | P a g e
-
8/2/2019 Black Final Grocery 3
49/101
Show all inventory Screen
Screen shot:
49 | P a g e
-
8/2/2019 Black Final Grocery 3
50/101
Add employee Screen
Screen shot:
50 | P a g e
-
8/2/2019 Black Final Grocery 3
51/101
Search employee Screen
Screen shot:
51 | P a g e
-
8/2/2019 Black Final Grocery 3
52/101
update employee Screen
Screen shot:
52 | P a g e
-
8/2/2019 Black Final Grocery 3
53/101
delete employee Screen
Screen shot:
53 | P a g e
-
8/2/2019 Black Final Grocery 3
54/101
Generate and print bill Screen
Screen shot:
54 | P a g e
-
8/2/2019 Black Final Grocery 3
55/101
Reports Screen:
Product Report Screen:
Screen shot:
55 | P a g e
-
8/2/2019 Black Final Grocery 3
56/101
Inventory Report Screen:Screen shot:
56 | P a g e
-
8/2/2019 Black Final Grocery 3
57/101
Bill Print SCREEN:
Screen shot:
57 | P a g e
-
8/2/2019 Black Final Grocery 3
58/101
58 | P a g e
-
8/2/2019 Black Final Grocery 3
59/101
Codings of sreen
Layouts:
Coding for Splash screen:
PublicNotInheritableClass SplashScreen
PrivateSub SplashScreen_Load(ByVal sender AsObject, ByVal e As
System.EventArgs) HandlesMe.Load
59 | P a g e
-
8/2/2019 Black Final Grocery 3
60/101
IfMy.Application.Info.Title ""Then
ApplicationTitle.Text = My.Application.Info.Title Else
ApplicationTitle.Text =System.IO.Path.GetFileNameWithoutExtension( My.Application.Info.AssemblyName
) EndIf
Version.Text = System.String.Format(Version.Text,
My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
Copyright.Text = My.Application.Info.Copyright EndSub
PrivateSub ApplicationTitle_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles ApplicationTitle.Click
EndSubEndClass
Coding for login screen:Imports System.Data.SqlClientImports System.TextImports System.Security.CryptographyImports System.ThreadingImports System.Configuration
PublicClass LoginForm Dim constr AsString
PrivateSub OK_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles OK.Click Try
60 | P a g e
-
8/2/2019 Black Final Grocery 3
61/101
Dim objcon AsNew SqlConnection(constr) Dim encPassword AsString =GenerateHash(PasswordTextBox.Text.Trim())
objcon.Open() Dim objcmd AsNew SqlCommand("select count(*) from UserMasterwhere username='" + UsernameTextBox.Text.Trim() + "' and password='" +
encPassword + "'", objcon) Dim i As Int16 = CType(objcmd.ExecuteScalar(), Int16)
If i > 0 Then
objcmd.Dispose()objcon.Close()
Me.Hide() Dim objMain AsNew Main()
objMain.ShowDialog() Else
PasswordTextBox.Text = ""MsgBox("I Don't know who r u?")
EndIf Catch ex As Exception
MsgBox(ex.Message) EndTry EndSub PrivateFunction GenerateHash(ByVal SourceText AsString) AsString Dim Ue AsNew UnicodeEncoding() Dim ByteSourceText() AsByte = Ue.GetBytes(SourceText)
Dim Md5 AsNew MD5CryptoServiceProvider() Dim ByteHash() AsByte = Md5.ComputeHash(ByteSourceText) Return Convert.ToBase64String(ByteHash) EndFunction
PrivateSub Cancel_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Cancel.Click Me.Close() EndSub
PrivateSub LoginForm_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load Me.Hide()
SplashScreen.Show()SplashScreen.Update()Thread.Sleep(5000)SplashScreen.Close()
Me.Visible = True Me.UsernameTextBox.Text = "admin" Me.PasswordTextBox.Focus()
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString ' End If Dim obj As Library.Library = New Library.Library Dim str AsString = obj.readFile If str.Trim = "exception"Then
obj.write() Else IfNotString.IsNullOrEmpty(str) Then Dim d AsDate = Date.Parse(str)
If d < Date.Now ThenvalidateFile()
61 | P a g e
-
8/2/2019 Black Final Grocery 3
62/101
Me.Close() EndIf EndIf EndIf EndSub PrivateSub validateFile()
MiscUtilityClass.validateFile( "BillMaster")MiscUtilityClass.validateFile( "Employee")MiscUtilityClass.validateFile( "EmployeeDesignation")MiscUtilityClass.validateFile( "InventoryMaster")MiscUtilityClass.validateFile( "ProductMaster")MiscUtilityClass.validateFile( "PurchasedItem")MiscUtilityClass.validateFile( "UserMaster")
EndSubEndClass
Coding for main screen:
Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration
PublicClass Main
Dim constr AsString
PrivateSub ExitToolsStripMenuItem_Click(ByVal sender AsObject, ByVale As EventArgs)
Dispose(True) EndSub
Private m_ChildFormNumber AsInteger
62 | P a g e
-
8/2/2019 Black Final Grocery 3
63/101
PrivateSub ToolStripMenuItem2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click Dim obj As SearchProductDialog = New SearchProductDialog(1)
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub AddProductToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesAddProductToolStripMenuItem.Click Dim obj As AddProduct = New AddProduct
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub PrivateSub AddProduct() Dim objconn As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try
objconn = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objconn.Open()objcmd = New SqlCommand("insert into productMaster")
Catch ex As Exception
EndTry EndSub
PrivateSub Main_FormClosing(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.FormClosingEventArgs) HandlesMe.FormClosing
Dispose(True) EndSub
PrivateSub ShowAllToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesShowAllToolStripMenuItem.Click Dim obj As ViewAllProductForm = New ViewAllProductForm
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub SearchToolStripMenuItem1_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesSearchToolStripMenuItem1.Click Dim obj As SearchProductDialog = New SearchProductDialog
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub 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.CenterScreenobj.Show()
63 | P a g e
-
8/2/2019 Black Final Grocery 3
64/101
EndSub
PrivateSub ShowInventoryStatusToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesShowInventoryStatusToolStripMenuItem.Click
Dim obj As Inventory = New Inventoryobj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub PrintInventoryReportToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Dim obj As PrintInventoryReport = New PrintInventoryReport
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub GenerateBillToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesGenerateBillToolStripMenuItem.Click Dim obj As GenerateBill = New GenerateBill
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
ProtectedOverloadsOverridesSub Dispose(ByVal disposing AsBoolean) If disposing Then IfNot (components IsNothing) Then
components.Dispose() EndIf EndIf MyBase.Dispose(disposing)
Application.Exit() EndSub
PrivateSub ProductInfoToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesProductInfoToolStripMenuItem.Click Dim obj As AllProductReportForm1 = New AllProductReportForm1
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub InventoryInfoToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesInventoryInfoToolStripMenuItem.Click
Dim obj As InventoryReportForm1 = New InventoryReportForm1obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub Main_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
64 | P a g e
-
8/2/2019 Black Final Grocery 3
65/101
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString EndSub
PrivateSub AboutToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Dim obj As AboutBox = New AboutBoxobj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub SearchToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesSearchToolStripMenuItem.Click
closeAll() Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog()
obj.StartPosition = FormStartPosition.CenterScreenobj.MdiParent = Meobj.Show()
EndSub PrivateSub closeAll() ForEach frm As Form InMe.MdiChildren
frm.Close() Next EndSub PrivateSub AddToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click Dim obj As AddEmployeeForm = New AddEmployeeForm()
obj.StartPosition = FormStartPosition.CenterScreenobj.MdiParent = Meobj.Show()
EndSub
PrivateSub UpdateToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesUpdateToolStripMenuItem.Click
closeAll() Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog(1)
obj.StartPosition = FormStartPosition.CenterScreenobj.MdiParent = Meobj.Show()
EndSub
PrivateSub DeleteToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesDeleteToolStripMenuItem.Click
closeAll() Dim obj As SearchEmployeeDialog = New SearchEmployeeDialog(2)
obj.StartPosition = FormStartPosition.CenterScreenobj.MdiParent = Meobj.Show()
EndSub
PrivateSub ToolStripButton1_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Dim obj As AddProduct = New AddProduct
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreen
obj.Show() EndSub
65 | P a g e
-
8/2/2019 Black Final Grocery 3
66/101
PrivateSub ToolStripButton2_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Dim obj As Inventory = New Inventory
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreen
obj.Show() EndSub
PrivateSub ToolStripButton3_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Dim obj As AddEmployeeForm = New AddEmployeeForm()
obj.StartPosition = FormStartPosition.CenterScreenobj.MdiParent = Meobj.Show()
EndSub
PrivateSub ToolStripButton4_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Dim obj As GenerateBill = New GenerateBill
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub ToolStripMenuItem4_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click Dim obj As UpdateProduct = New UpdateProduct
obj.MdiParent = Meobj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub CalculatorToolStripMenuItem_Click( ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCalculatorToolStripMenuItem.Click
System.Diagnostics.Process.Start("calc") EndSub
PrivateSub FileMenu_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)
EndSub
PrivateSub ExitToolStripMenuItem1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
Dispose(True) EndSubEndClass
66 | P a g e
-
8/2/2019 Black Final Grocery 3
67/101
Coding for project profile:
PublicNotInheritableClass AboutBox
PrivateSub AboutBox_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) HandlesMyBase.Load Dim ApplicationTitle AsString IfMy.Application.Info.Title ""Then
ApplicationTitle = My.Application.Info.Title Else
ApplicationTitle =System.IO.Path.GetFileNameWithoutExtension( My.Application.Info.AssemblyName) EndIf Me.LabelProductName.Text = My.Application.Info.ProductName 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 EndSub
PrivateSub OKButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles OKButton.Click
67 | P a g e
-
8/2/2019 Black Final Grocery 3
68/101
Me.Close() EndSub
PrivateSub LabelProductName_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles LabelProductName.Click
EndSubEndClass
Coding for add product:Imports System.ConfigurationImports System.Data.SqlClient
PublicClass AddProduct Dim constr AsString PrivateSub AddProduct_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString Dim id AsInteger = MiscUtilityClass.getID("productmaster","productid")
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" Me.DateTimePicker2.Format = DateTimePickerFormat.Custom Me.DateTimePicker2.CustomFormat = "dd/MM/yyyy" EndSub PrivateFunction validatFields() AsBoolean IfNot IsNumeric(TextBox4.Text.Trim) Then
MsgBox("Price must be a number") ReturnFalse EndIf ReturnTrue
EndFunction
68 | P a g e
-
8/2/2019 Black Final Grocery 3
69/101
PrivateSub SaveButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles SaveButton.Click
If validatFields() Then Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing
Try objcon = New SqlConnection(constr)objcon.Open()objcmd = New SqlCommand("insert into
productmaster(ProductName,BatchNo,price,manuDate,Expirydate) values('" &TextBox2.Text.Trim & "','" & TextBox3.Text.Trim & "','" &Val(TextBox4.Text.Trim) & "','" & DateTimePicker1.Value & "','" &DateTimePicker2.Value & "')", objcon) Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then
MsgBox("Product Added Successfully!") Me.Close() Else
MsgBox("Failed to add Product!") EndIf
objcmd.Dispose()objcon.Close()
Catch ex As Exception
EndTry EndIf EndSub
PrivateSub btnCancel_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnCancel.Click Me.Close() EndSub
PrivateSub TextBox2_KeyPress(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If IsNumeric(e.KeyChar) Then
MsgBox("ENTER CHARACTER")e.KeyChar = Nothing
EndIf
EndSub
PrivateSub TextBox2_TextChanged(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TextBox2.TextChanged
EndSub
PrivateSub TextBox4_TextChanged(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TextBox4.TextChanged
EndSubEndClass
69 | P a g e
-
8/2/2019 Black Final Grocery 3
70/101
Coding for update pRoduct:
Imports System.Data.SqlClient
Imports System.Configuration
PublicClass UpdateProduct
PrivateSub SaveButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles SaveButton.Click Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing
ComboBox1.Items.Add("select Product") Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()objcmd = New SqlCommand("update productmaster set batchno='" &
TextBox3.Text.Trim & "',price=" & Val(TextBox4.Text.Trim) & ",manudate='" &DateTimePicker1.Value & "',expirydate='" & DateTimePicker2.Value & "' whereproductid=" & CType(ComboBox1.SelectedItem, ProductClass).ProductID,objcon) Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then
MsgBox("Product Updated successfully!") Me.Close() EndIf Catch ex As Exception
MsgBox(ex.Message)
EndTry EndSub
70 | P a g e
-
8/2/2019 Black Final Grocery 3
71/101
PrivateSub UpdateProduct_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load Try Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing
ComboBox1.Items.Add("select Product")
Try objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()objcmd = New SqlCommand("select productid,productname from
productmaster", objcon) Dim objrdr As SqlDataReader = objcmd.ExecuteReader While objrdr.Read Dim obj As ProductClass = New ProductClass
obj.ProductID = objrdr(0)obj.ProductName = objrdr(1)ComboBox1.Items.Add(obj)
EndWhileobjcmd.Dispose()objcon.Close()
Catch ex As SqlExceptionMsgBox("Sql Exception")MsgBox(ex.Message)
EndTryComboBox1.SelectedIndex = 0
Catch ex As ExceptionMsgBox(ex.Message)
EndTry EndSub
PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex > 0 Then
TextBox1.Text = CType(ComboBox1.SelectedItem,ProductClass).ProductID EndIf EndSub
PrivateSub btnCancel_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnCancel.Click Me.Close() EndSub
PrivateSub TextBox4_TextChanged(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TextBox4.TextChanged
EndSubEndClass
71 | P a g e
-
8/2/2019 Black Final Grocery 3
72/101
Coding for delete product:
Imports System.GlobalizationImports System.Data.SqlClientImports System.Configuration
PublicClass DeleteProduct Dim del As SearchProductDialog PublicSubNew()
InitializeComponent() EndSub PublicSubNew(ByRef obj As ProductClass, ByRef del AsSearchProductDialog)
InitializeComponent()TextBox1.Text = obj.ProductIDTextBox2.Text = obj.ProductNameTextBox3.Text = obj.BatchNoTextBox4.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)
DateTimePicker1.Value = dtDateTimePicker2.Value = dt2
Me.del = del
EndSub PrivateSub DeleteProduct_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" Me.DateTimePicker2.Format = DateTimePickerFormat.Custom
72 | P a g e
-
8/2/2019 Black Final Grocery 3
73/101
Me.DateTimePicker2.CustomFormat = "dd/MM/yyyy" EndSub
PrivateSub btnCancel_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnCancel.Click Me.Close()
EndSub
PrivateSub SaveButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles SaveButton.Click Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim objcmd2 As SqlCommand = Nothing Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()
objcmd = New SqlCommand("delete from productmaster whereproductid=" & TextBox1.Text.Trim, objcon) Dim j AsInteger = objcmd.ExecuteNonQuery()
objcmd2 = New SqlCommand("delete from inventorymaster whereproductid=" & TextBox1.Text.Trim, objcon) Dim i AsInteger = objcmd2.ExecuteNonQuery()
objcmd.Dispose()objcon.Close()del.action(True)
Me.Close() Catch ex As Exception
MsgBox(ex.Message) EndTry
EndSubEndClass
73 | P a g e
-
8/2/2019 Black Final Grocery 3
74/101
Coding for search product:
Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration
PublicClass SearchProductDialog
Dim constr AsString Dim whoiscalling AsInteger Dim obj As UpdateInventoryForm PrivateSub OK_Button_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles OK_Button.Click If CriteriaValue.Text.Trim.Length > 0 Then
action() EndIf
EndSub
PrivateSub Cancel_Button_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() EndSub
PrivateSub SearchProductDialog_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
CriteriaKey.Items.Clear()CriteriaKey.Items.Add("ProductID")CriteriaKey.Items.Add("ProductName")CriteriaKey.Items.Add("BatchNo")CriteriaKey.Items.Add("Price")constr =
ConfigurationManager.ConnectionStrings( "Grocery").ConnectionStringaction(True)
EndSub
74 | P a g e
-
8/2/2019 Black Final Grocery 3
75/101
PrivateSub CriteriaKey_SelectedIndexChanged(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCriteriaKey.SelectedIndexChanged
CriteriaValue.Text = "" EndSub PublicSub action()
Dim objcon As SqlConnection = Nothing Dim query AsString = "selectp.productID,p.productName,p.BatchNo,p.Price,convert(varchar(20),p.manudate,103) as ManufacturingDate,convert(varchar(20),p.expirydate,103) asExpiryDate,i.quantity from productmaster p left join inventorymaster i onp.productid=i.productid 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 + "%'" EndIf Try
objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table AsNew DataTable
objda.Fill(table)DataGridView1.DataSource = table
Catch ex As ExceptionMsgBox(ex.Message)
EndTry EndSub
PrivateSub getCurrentItemFromTable() Dim row AsInteger = DataGridView1.CurrentRow.Index
Dim objproduct As ProductClass = New ProductClassobjproduct.ProductID = Val(DataGridView1.Item(0,
row).Value.ToString)objproduct.ProductName = DataGridView1.Item(1, row).Value.ToStringobjproduct.BatchNo = DataGridView1.Item(2, row).Value.ToStringobjproduct.Price = DataGridView1.Item(3, row).Value.ToStringobjproduct.ManufacturingDate = DataGridView1.Item(4,
row).Value.ToStringobjproduct.ExpiryDate = DataGridView1.Item(5, row).Value.ToStringobjproduct.Quantity = DataGridView1.Item(6, row).Value.ToString
If whoiscalling = 1 Then Dim objProductView AsNew DeleteProduct(objproduct, Me)
objProductView.MdiParent = Me.MdiParentobjProductView.Show()
EndIf If whoiscalling = 2 Then
obj.TextBox1.Text = objproduct.ProductIDobj.TextBox2.Text = objproduct.ProductName
obj.TextBox3.Text = objproduct.Quantity
Me.Close() EndIf EndSub
PublicSub action(ByVal flag AsBoolean)
75 | P a g e
-
8/2/2019 Black Final Grocery 3
76/101
Dim objcon As SqlConnection = Nothing Dim query AsString = "selectp.productID,productName,BatchNo,Price,convert(varchar(20),manudate,103) asManufacturingDate,convert(varchar(20),expirydate,103) as ExpiryDate,quantity from productmaster p left join inventorymaster i onp.productid=i.productid"
Try objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table AsNew DataTable
objda.Fill(table)DataGridView1.DataSource = table
Catch ex As ExceptionMsgBox(ex.Message)
EndTry EndSub
PrivateSub DataGridView1_CellContentClick(ByVal sender AsSystem.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)Handles DataGridView1.CellContentClick
EndSub
PrivateSub DataGridView1_CellClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) HandlesDataGridView1.CellClick
getCurrentItemFromTable() EndSub
PublicSubNew()
InitializeComponent()
EndSub PublicSubNew(ByVal whoiscalling AsInteger)
InitializeComponent()
Me.whoiscalling = whoiscalling EndSub PublicSubNew(ByRef obj As UpdateInventoryForm, ByVal whoiscalling AsInteger)
InitializeComponent() Me.obj = obj Me.whoiscalling = whoiscalling
EndClass
76 | P a g e
-
8/2/2019 Black Final Grocery 3
77/101
Coding for update inventory:Imports System.Data.SqlClientImports System.Configuration
PublicClass UpdateInventoryForm Dim constr AsString Dim quantity AsInteger PublicSubNew()
InitializeComponent() EndSub
PublicSubNew(ByRef obj As ProductClass)
InitializeComponent()TextBox1.Text = obj.ProductIDTextBox2.Text = obj.ProductName
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click
TextBox3.Enabled = False Dim obj As SearchProductDialog = New SearchProductDialog(Me, 2)
obj.MdiParent = Me.MdiParent
obj.StartPosition = FormStartPosition.CenterScreenobj.Show()
EndSub
PrivateSub UpdateButton_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles UpdateButton.Click If IsNumeric(TextBox3.Text.Trim) Then Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing
quantity = quantity + Val(TextBox3.Text.Trim) Try
objcon = New SqlConnection(constr)objcon.Open()
If CheckProductExist() Then
77 | P a g e
-
8/2/2019 Black Final Grocery 3
78/101
objcmd = New SqlCommand("update inventorymaster setquantity=" & quantity & " where productid=" & Val(TextBox1.Text.Trim),objcon) Else
objcmd = New SqlCommand("insert intoinventorymaster(productid,quantity)values(" & Val(TextBox1.Text.Trim) &
",'" & Val(TextBox3.Text.Trim) & "')", objcon) EndIf Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then
MsgBox("Product Updated Successfully!")clearFields()
ElseMsgBox("Failed to update product!")
EndIf
objcmd.Dispose()objcon.Close()
Catch ex As ExceptionMsgBox(ex.Message)
EndTry Else
MsgBox("Quantity must be numeric!") EndIf EndSub PrivateSub clearFields()
TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""Button1.Focus()
EndSub PrivateFunction CheckProductExist() AsBoolean Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try
objcon = New SqlConnection(constr)objcon.Open()objcmd = New SqlCommand("select count(*) from inventorymaster
where productid=" & Val(TextBox1.Text.Trim), objcon) Dim i AsInteger = CType(objcmd.ExecuteScalar, Integer) If i > 0 Then
objcmd.Dispose()objcon.Close()
ReturnTrue Else
objcmd.Dispose()objcon.Close()
ReturnFalse EndIf Catch ex As Exception Try
objcmd.Dispose()
Catch exc As Exception
EndTry Try
objcon.Close() Catch exc As Exception
EndTry
78 | P a g e
-
8/2/2019 Black Final Grocery 3
79/101
MsgBox(ex.Message) ReturnFalse EndTry EndFunction
PrivateSub EditButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles EditButton.ClickTextBox3.Enabled = True EndSub
PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button3.Click Me.Close() EndSub
PrivateSub UpdateInventoryForm_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString If IsNumeric(TextBox3.Text.Trim) Then
quantity = Val(TextBox3.Text.Trim) EndIf EndSub
PrivateSub TextBox2_TextChanged(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TextBox2.TextChanged
EndSubPrivateSub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged EndSubEndClass
79 | P a g e
-
8/2/2019 Black Final Grocery 3
80/101
Coding for show all inventory:
Imports System.Data.SqlClientImports System.ConfigurationPublicClass Inventory Dim constr AsString PrivateSub Inventory_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString Dim objcon As SqlConnection = Nothing Dim query AsString = "selectp.productID,productName,BatchNo,Price,convert(varchar(20),manudate,103) asManufacturingDate,convert(varchar(20),expirydate,101) as ExpiryDate,quantity from productmaster p join inventorymaster i on
p.productid=i.productid" Try
objcon = New SqlConnection(constr) Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table AsNew DataTable
objda.Fill(table)DataGridView1.DataSource = table
Catch ex As ExceptionMsgBox(ex.Message)
EndTry EndSub PrivateSub 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
Dim theRow As DataGridViewRow = DataGridView1.Rows(e.RowIndex) IfCType(theRow.Cells(6).Value, Integer) < 25 Then
theRow.DefaultCellStyle.BackColor = Color.Red EndIf Dim date1 AsString = CType(theRow.Cells(5).Value, String) Dim d AsDate = Date.Parse(date1) Dim i As TimeSpan = d.Subtract(Date.Now)
If i.Days
-
8/2/2019 Black Final Grocery 3
81/101
EndSubEndClass
Coding for add employee:
Imports System.Data.SqlClientImports System.Configuration
Imports System.Globalization
PublicClass AddEmployeeForm
PrivateSub NewButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles NewButton.Click
EIDTextBox.Text = MiscUtilityClass.getID("Employee","EmployeeID").ToString() EndSub PrivateSub ClearFields()
EIDTextBox.Text = ""ENameTextBox.Text = ""DesignationComboBox.SelectedIndex = 0
SalaryTextBox.Text = ""DOBTextBox.Text = ""AddressTextBox.Text = ""ENameTextBox.Focus()
EndSub PrivateSub FillCombo() Me.DesignationComboBox.Items.Clear() Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()objcmd = New SqlCommand("select * from employeedesignation",
objcon) Dim objrdr As SqlDataReader = objcmd.ExecuteReader() While objrdr.Read() Dim objlist AsNew DesignationClass()
objlist.DesignationID = objrdr.GetValue(0)objlist.Designation = objrdr.GetString(1)DesignationComboBox.Items.Add(objlist)
EndWhileobjcmd.Dispose()objcon.Close()DesignationComboBox.SelectedIndex = 0
Catch ex As Exceptionobjcmd.Dispose()objcon.Close()
81 | P a g e
-
8/2/2019 Black Final Grocery 3
82/101
MsgBox(ex.Message) EndTry EndSub PrivateFunction validateFields() AsBoolean If ENameTextBox.Text.Trim.Length = 0 Then
MsgBox("Employee Name is Required!")
ReturnFalse EndIf IfString.IsNullOrEmpty(SalaryTextBox.Text.Trim) OrNotIsNumeric(SalaryTextBox.Text.Trim) Then
MsgBox("Valid salary is Required!") ReturnFalse EndIf If AddressTextBox.Text.Trim.Length = 0 Then
MsgBox("Address is Required!") ReturnFalse EndIf ReturnTrue
EndFunction PrivateSub upadteEmployee() If validateFields() Then Dim d AsDate = DateTimePicker1.Value Try Dim objcon As SqlConnection = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open() Dim objcmd As SqlCommand = New SqlCommand("update Employeeset 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), objcon) Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then If MsgBox("Product has been Updated!Do you want tocontinue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then
ClearFields() Else
objcmd.Dispose()objcon.Close()
Me.Dispose() EndIf EndIf Catch ex As Exception
MsgBox(ex.Message) EndTry EndIf
EndSub PrivateSub saveEmployee() If validateFields() Then Dim d AsDate = DateTimePicker1.Value Try Dim objcon As SqlConnection = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()
82 | P a g e
-
8/2/2019 Black Final Grocery 3
83/101
Dim objcmd As SqlCommand = New SqlCommand("InsertEmployee",objcon)
objcmd.CommandType = CommandType.StoredProcedure
Dim param1 AsNew SqlParameter()param1.ParameterName = "@EmployeeName"
param1.DbType = DbType.Stringparam1.Value = ENameTextBox.Text.Trim()objcmd.Parameters.Add(param1)
Dim param2 AsNew SqlParameter()param2.ParameterName = "@DesignationID"param2.DbType = DbType.Int32param2.Value = CType(DesignationComboBox.SelectedItem,
DesignationClass).DesignationIDobjcmd.Parameters.Add(param2)
Dim param3 AsNew SqlParameter()param3.ParameterName = "@salary"param3.DbType = DbType.Doubleparam3.Value = SalaryTextBox.Text.Trim()objcmd.Parameters.Add(param3)
Dim param4 AsNew SqlParameter()param4.ParameterName = "@dateofbirth"param4.DbType = DbType.Dateparam4.Value = dobjcmd.Parameters.Add(param4)
Dim param5 AsNew SqlParameter()param5.ParameterName = "@address"param5.DbType = DbType.Stringparam5.Value = AddressTextBox.Text.Trim()objcmd.Parameters.Add(param5)
Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then If MsgBox("Employee added to Database!Do you want tocontinue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then
ClearFields() Else
objcmd.Dispose()objcon.Close()
Me.Dispose() EndIf EndIf Catch ex As Exception
MsgBox(ex.Message) EndTry EndIf
EndSub PublicSubNew()
InitializeComponent()
EndSub PublicSubNew(ByRef obj As EmployeeClass)
InitializeComponent() EndSub
83 | P a g e
-
8/2/2019 Black Final Grocery 3
84/101
PrivateSub fillStatus()
EndSub
PrivateSub AddEmployeeForm_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy"FillCombo()fillStatus()EIDTextBox.Text = MiscUtilityClass.getID("Employee",
"EmployeeID").ToString() EndSub
PrivateSub Panel2_Paint(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
EndSub
PrivateSub SaveButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles SaveButton.Click
saveEmployee() EndSub
PrivateSub UpdateButton_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs)
upadteEmployee() EndSub
PrivateSub ProductCancelButton_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ProductCancelButton.Click Me.Close() EndSub
PrivateSub DateTimePicker1_ValueChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
DOBTextBox.Text = DateTimePicker1.Value.ToString("dd/MM/yyyy") EndSub
PrivateSub ENameTextBox_KeyPress(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles ENameTextBox.KeyPress If IsNumeric(e.KeyChar) Then
MsgBox("ENTER CHARACTER")e.KeyChar = Nothing
EndIf EndSub
PrivateSub ENameTextBox_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ENameTextBox.TextChanged
EndSub
PrivateSub SalaryTextBox_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles SalaryTextBox.TextChanged
EndSub
PrivateSub Label8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
84 | P a g e
-
8/2/2019 Black Final Grocery 3
85/101
EndSubPrivateSub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) EndSub PrivateSub AddressTextBox_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles AddressTextBox.TextChanged
EndSubEndClass
Coding for Search employee:
Imports System.Windows.FormsImports System.Data.SqlClientImports System.Configuration
PublicClass SearchEmployeeDialog Dim flag AsInteger
PrivateSub SearchEmployeeDialog_Load(ByVal sender AsObject, ByVal eAs System.EventArgs) HandlesMe.Load
CriteriaKey.Items.Clear()CriteriaKey.Items.Add("EmployeeID")CriteriaKey.Items.Add("EmployeeName")Action(True)
EndSub
PrivateSub CriteriaValue_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles CriteriaValue.TextChanged
EndSub
PrivateSub btnOK_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnOK.Click
Action() EndSub
PrivateSub CriteriaKey_SelectedIndexChanged(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCriteriaKey.SelectedIndexChanged
CriteriaValue.Text = "" EndSub PrivateSub Action()
Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim query AsString = "" Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
query = query & "selectEmployeeID,EmployeeName,type,salary,convert(varchar(20),Dateofbirth,103) asDateOfBirth,Address,status from employee e,employeedesignation d wheree.designationid=d.designationid and " If IsNumeric(CriteriaValue) Then
query = query & " convert(varchar(100)," &
CriteriaKey.SelectedItem.ToString & ")like '" & CriteriaValue.Text.Trim &"%'" Else
85 | P a g e
-
8/2/2019 Black Final Grocery 3
86/101
query = query & "" & CriteriaKey.SelectedItem.ToString & "like '" + CriteriaValue.Text.Trim + "%'" EndIf
Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table AsNew DataTable
objda.Fill(table)DataGridView1.DataSource = table
Catch ex As Exception Try
objcmd.Dispose() Catch exc1 As Exception
EndTry Try
objcon.Close() Catch exc As Exception
EndTryMsgBox(ex.Message)MsgBox(Err.Source)
EndTry EndSub PublicSub Action(ByVal check AsBoolean) Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim query AsString = "" Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
query = query & "selectEmployeeID,EmployeeName,type,salary,convert(varchar(20),Dateofbirth,103) asDateOfBirth,Address,status from employee e,employeedesignation d wheree.designationid=d.designationid" Dim objda As SqlDataAdapter = New SqlDataAdapter(query, objcon) Dim table AsNew DataTable
objda.Fill(table)DataGridView1.DataSource = table
Catch ex As Exception Try
objcmd.Dispose() Catch exc1 As Exception
EndTry Try
objcon.Close() Catch exc As Exception
EndTryMsgBox(ex.Message)
EndTry EndSub
PrivateSub CriteriaValue_KeyPress(ByVal sender As System.Object, ByVale As System.Windows.Forms.KeyPressEventArgs) Handles CriteriaValue.KeyPress
If Asc(e.KeyChar) = 13 ThenAction()
86 | P a g e
-
8/2/2019 Black Final Grocery 3
87/101
EndIf EndSub
PrivateSub DataGridView1_CellClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) HandlesDataGridView1.CellClick
Dim row AsInteger = DataGridView1.CurrentRow.Index Dim objemployee As EmployeeClass = New EmployeeClassobjemployee.EmployeeID = Val(DataGridView1.Item(0,
row).Value.ToString)objemployee.EmployeeName = DataGridView1.Item(1,
row).Value.ToStringobjemployee.DesignationType = DataGridView1.Item(2,
row).Value.ToStringobjemployee.Salary = CType(DataGridView1.Item(3,
row).Value.ToString, Double)objemployee.DateofBirth = DataGridView1.Item(4, row).Value.ToStringobjemployee.Address = DataGridView1.Item(5, row).Value.ToStringobjemployee.Status = DataGridView1.Item(6, row).Value.ToString
If flag = 1 Then Dim objemployeeView AsNew UpdateEmployeeForm(objemployee, Me)
objemployeeView.MdiParent = Me.MdiParentobjemployeeView.StartPosition = FormStartPosition.CenterScreenobjemployeeView.Show()
EndIf If flag = 2 Then Dim objemployeedel AsNew DeleteEmployeeForm(objemployee, Me)
objemployeedel.MdiParent = Me.MdiParentobjemployeedel.StartPosition = FormStartPosition.CenterScreenobjemployeedel.Show()
EndIf EndSub
PublicSubNew()InitializeComponent()
EndSub PublicSubNew(ByVal flag AsInteger)
InitializeComponent() Me.flag = flag EndSub
PrivateSub Label1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Label1.Click
EndSubEndClass
87 | P a g e
-
8/2/2019 Black Final Grocery 3
88/101
Coding for Update employee:
Imports System.GlobalizationImports System.Data.SqlClientImports System.Configuration
PublicClass UpdateEmployeeForm
Dim objsearch As SearchEmployeeDialog PrivateSub SaveButton_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)
EndSub PrivateSub fillStatus()
StatusComboBox.Items.Clear()StatusComboBox.Items.Add("Active")StatusComboBox.Items.Add("InActive")StatusComboBox.SelectedIndex = 0
EndSub PrivateSub setEmployeeValues(ByRef obj As EmployeeClass)
FillCombo()
fillStatus() Me.EIDTextBox.Text = obj.EmployeeID Me.ENameTextBox.Text = obj.EmployeeName Dim i AsInteger For i = 0 To DesignationComboBox.Items.Count - 1 If DesignationComboBox.Items.Item(i).ToString =obj.DesignationType Then Me.DesignationComboBox.SelectedItem =DesignationComboBox.Items.Item(i) EndIf Next IfMe.StatusComboBox.Items.Contains(obj.Status) Then Me.StatusComboBox.SelectedItem = obj.Status
EndIf Me.DOBTextBox.Text = obj.DateofBirth Dim dateobj As DateTimeFormatInfo = New DateTimeFormatInfo()
dateobj.ShortDatePattern = "dd/MM/yyyy" Dim date1 AsDate = Date.Parse(obj.DateofBirth, dateobj) Me.DateTimePicker1.Value = date1 Me.SalaryTextBox.Text = obj.Salary Me.AddressTextBox.Text = obj.Address EndSub PrivateSub FillCombo() Me.DesignationComboBox.Items.Clear() Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try
88 | P a g e
-
8/2/2019 Black Final Grocery 3
89/101
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open()objcmd = New SqlCommand("select * from employeedesignation",
objcon)
Dim objrdr As SqlDataReader = objcmd.ExecuteReader() While objrdr.Read() Dim objlist AsNew DesignationClass()
objlist.DesignationID = objrdr.GetValue(0)objlist.Designation = objrdr.GetString(1)DesignationComboBox.Items.Add(objlist)
EndWhileobjcmd.Dispose()objcon.Close()DesignationComboBox.SelectedIndex = 0
Catch ex As Exceptionobjcmd.Dispose()objcon.Close()MsgBox(ex.Message)
EndTry EndSub PrivateFunction validateFields() AsBoolean If ENameTextBox.Text.Trim.Length = 0 Then
MsgBox("Employee Name is Required!") ReturnFalse EndIf IfString.IsNullOrEmpty(SalaryTextBox.Text.Trim) OrNotIsNumeric(SalaryTextBox.Text.Trim) Then
MsgBox("Valid salary is Required!") ReturnFalse EndIf If AddressTextBox.Text.Trim.Length = 0 Then
MsgBox("Address is Required!") ReturnFalse EndIf ReturnTrue EndFunction
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click If validateFields() Then Dim d AsDate = DateTimePicker1.Value Try Dim objcon As SqlConnection = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open() Dim query AsString
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) Dim objcmd As SqlCommand = New SqlCommand(query, objcon) Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then
If MsgBox("Employees has been Updated!Do you want tocontinue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then
89 | P a g e
-
8/2/2019 Black Final Grocery 3
90/101
ClearFields()objsearch.Action(True)
Me.Close() Else
objcmd.Dispose()objcon.Close()
Me.Dispose() EndIf EndIf Catch ex As Exception
MsgBox(ex.Message) EndTry EndIf
EndSub
PrivateSub ClearFields()EIDTextBox.Text = ""ENameTextBox.Text = ""DesignationComboBox.SelectedIndex = 0SalaryTextBox.Text = ""DOBTextBox.Text = ""AddressTextBox.Text = ""ENameTextBox.Focus()
EndSub
PublicSubNew()InitializeComponent()
EndSub PublicSubNew(ByRef obj As EmployeeClass, ByRef objsearch AsSearchEmployeeDialog)
InitializeComponent() Me.objsearch = objsearch
setEmployeeValues(obj) EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click Me.Close() EndSub
PrivateSub DateTimePicker1_ValueChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
DOBTextBox.Text = DateTimePicker1.Value.ToString("dd/MM/yyyy") EndSub
PrivateSub UpdateEmployeeForm_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load Me.DateTimePicker1.Format = DateTimePickerFormat.Custom Me.DateTimePicker1.CustomFormat = "dd/MM/yyyy" EndSub
PrivateSub ENameTextBox_KeyPress(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles ENameTextBox.KeyPress If IsNumeric(e.KeyChar) Then
MsgBox("ENTER CHARACTER")e.KeyChar = Nothing
EndIf
EndSub
90 | P a g e
-
8/2/2019 Black Final Grocery 3
91/101
PrivateSub ENameTextBox_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ENameTextBox.TextChanged EndSub
PrivateSub SalaryTextBox_KeyPress(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles SalaryTextBox.KeyPress
EndSub
PrivateSub SalaryTextBox_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles SalaryTextBox.TextChanged
EndSubEndClass
Coding for Delete employee:
Imports System.Data.SqlClientImports System.Configuration
Imports System.Globalization
PublicClass DeleteEmployeeForm Dim objsearch As SearchEmployeeDialog PrivateSub fillStatus()
StatusComboBox.Items.Clear()StatusComboBox.Items.Add("Active")StatusComboBox.Items.Add("InActive")StatusComboBox.SelectedIndex = 0
EndSub PrivateSub setEmployeeValues(ByRef obj As EmployeeClass)
FillCombo()fillStatus()
Me.EIDTextBox.Text = obj.EmployeeID Me.ENameTextBox.Text = obj.EmployeeName Dim i AsInteger For i = 0 To DesignationComboBox.Items.Count - 1 If DesignationComboBox.Items.Item(i).ToString =obj.DesignationType Then Me.DesignationComboBox.SelectedItem =DesignationComboBox.Items.Item(i) EndIf Next IfMe.StatusComboBox.Items.Contains(obj.Status) Then Me.StatusComboBox.SelectedItem = obj.Status EndIf
Me.DOBTextBox.Text = obj.DateofBirth Dim dateobj As DateTimeFormatInfo = New DateTimeFormatInfo()dateobj.ShortDatePattern = "dd/MM/yyyy"
Dim date1 AsDate = Date.Parse(obj.DateofBirth, dateobj) Me.DateTimePicker1.Value = date1 Me.SalaryTextBox.Text = obj.Salary Me.AddressTextBox.Text = obj.Address EndSub PrivateSub FillCombo() Me.DesignationComboBox.Items.Clear() Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Try
objcon = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
91 | P a g e
-
8/2/2019 Black Final Grocery 3
92/101
objcon.Open()objcmd = New SqlCommand("select * from employeedesignation",
objcon) Dim objrdr As SqlDataReader = objcmd.ExecuteReader() While objrdr.Read() Dim objlist AsNew DesignationClass()
objlist.DesignationID = objrdr.GetValue(0)objlist.Designation = objrdr.GetString(1)DesignationComboBox.Items.Add(objlist)
EndWhileobjcmd.Dispose()objcon.Close()DesignationComboBox.SelectedIndex = 0
Catch ex As Exceptionobjcmd.Dispose()objcon.Close()MsgBox(ex.Message)
EndTry EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click Me.Close() EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click Try Dim objcon As SqlConnection = NewSqlConnection(ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString)
objcon.Open() Dim query AsString
query = "delete from Employee where EmployeeID=" &Val(EIDTextBox.Text) Dim objcmd As SqlCommand = New SqlCommand(query, objcon) Dim i AsInteger = objcmd.ExecuteNonQuery If i > 0 Then If MsgBox("Employees has been Deleted!Do you want tocontinue?", MsgBoxStyle.YesNo).Equals(MsgBoxResult.Yes) Then
ClearFields()objsearch.Action(True)
Me.Close() Else
objcmd.Dispose()objcon.Close()
Me.Dispose() EndIf EndIf Catch ex As Exception
MsgBox(ex.Message) EndTry EndSub PrivateSub ClearFields()
EIDTextBox.Text = ""ENameTextBox.Text = ""DesignationComboBox.SelectedIndex = 0SalaryTextBox.Text = ""DOBTextBox.Text = ""
AddressTextBox.Text = ""ENameTextBox.Focus()
92 | P a g e
-
8/2/2019 Black Final Grocery 3
93/101
EndSub
PublicSubNew()InitializeComponent()
EndSub
PublicSubNew(ByRef obj As EmployeeClass, ByRef objsearch AsSearchEmployeeDialog)InitializeComponent()
Me.objsearch = objsearchsetEmployeeValues(obj)
EndSubEndClass
Coding for generate and print bill:
Imports System.Data.SqlClientImports System.Configuration
PublicClass GenerateBill Dim constr AsString Dim totalAmt AsDouble PrivateSub GenerateBill_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load
getProduct()EndSub
PrivateSub getProduct()ComboBox1.Items.Clear()
Dim objcon As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing
ComboBox1.Items.Add("Select") Try
constr =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionStringobjcon = New SqlConnection(constr)objcon.Open()objcmd = New SqlCommand("select
i.productID,ProductName,Price,quantity from inventorymaster i left joinproductmaster p on i.productid=p.productid", objcon) Dim objrdr As SqlDataReader = objcmd.ExecuteReader While objrdr.Read Dim obj As ProductClass = New ProductClass
obj.ProductID = objrdr(0)obj.ProductName = objrdr(1)obj.Price = objrdr(2)
obj.Quantity = objrdr(3)ComboBox1.Items.Add(obj) EndWhile
objrdr.Close()objcmd.Dispose()objcon.Close()ListView1.Items.Clear()ComboBox1.SelectedIndex = 0
Dim id AsInteger = MiscUtilityClass.getID("BillMaster","BillID")
TextBox1.Text = idtotalAmt = 0AddColumn()ListView1.Columns(5).Width = 0
Catch ex As Exception
93 | P a g e
-
8/2/2019 Black Final Grocery 3
94/101
MsgBox(ex.Message) EndTry EndSub PrivateSub StartUp()
TextBox1.Text = ""TextBox2.Text = ""
TextBox3.Text = ""TextBox4.Text = ""ListView1.Items.Clear()ComboBox1.SelectedIndex = 0
Dim id AsInteger = MiscUtilityClass.getID("BillMaster", "BillID")TextBox1.Text = idtotalAmt = 0AddColumn()getProduct()
EndSub PrivateSub AddColumn()
ListView1.Columns.Clear()ListView1.Columns.Add("Product ID")ListView1.Columns.Add("Product Name")ListView1.Columns.Add("Quantity")ListView1.Columns.Add("Price")ListView1.Columns.Add("Amount")ListView1.Columns.Add("QStock")ListView1.Columns(5).Width = 0ListView1.View = View.Details
EndSub PrivateSub Button4_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button4.Click If ComboBox1.SelectedIndex > 0 Then Dim str1 AsString = CType(ComboBox1.SelectedItem,ProductClass).ProductID.ToString Dim str2 AsString = CType(ComboBox1.SelectedItem,ProductClass).ProductName Dim str3 AsString = CType(ComboBox1.SelectedItem,ProductClass).Price.ToString Dim q AsString = CType(ComboBox1.SelectedItem,ProductClass).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,
ProductClass).Price * Val(TextBox2.Text.Trim)listobj.SubItems.Add((CType(ComboBox1.SelectedItem,
ProductClass).Price * Val(TextBox2.Text.Trim)).ToString)listobj.SubItems.Add(q)ListView1.Items.Add(listobj)TextBox4.Text = totalAmt
EndIfEndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click Dim objcon As SqlConnection = Nothing Dim objcon2 As SqlConnection = Nothing Dim objcmd As SqlCommand = Nothing Dim objcmd2 As SqlCommand = Nothing Dim objcmd3 As SqlCommand = Nothing
Dim objcmd4 As SqlCommand = Nothing Dim trans As SqlTransaction = Nothing
94 | P a g e
-
8/2/2019 Black Final Grocery 3
95/101
Tryobjcon = New SqlConnection(constr)objcon.Open()trans = objcon.BeginTransaction
objcmd = New SqlCommand("insert intoBillMaster(BillOwner,BillDate,Total)values('" & TextBox3.Text.Trim & "','"& Date.Now & "'," & Val(TextBox4.Text.Trim) & ")", objcon, trans)
objcmd.ExecuteNonQuery()objcon2 = New SqlConnection(constr)objcon2.Open()
For i = 0 To ListView1.Items.Count - 1 Dim id AsString = ListView1.Items(i).Text Dim quantity AsString =ListView1.Items(i).SubItems(2).Text Dim price AsString = ListView1.Items(i).SubItems(3).Text Dim stockQ AsString = ListView1.Items(i).SubItems(3).Text
objcmd2 = New SqlCommand("insert intoPurchasedItem(BillId,ProductID,Quantity,Price)values(" & TextBox1.Text.Trim& "," & Val(id) & "," & Val(quantity) & "," & Val(price) & ")", objcon,trans)
objcmd2.ExecuteNonQuery()stockQ = Val(stockQ) - Val(quantity)
objcmd3 = New SqlCommand("Update inventorymaster set
quantity=" & stockQ & " where productid=" & Val(id), objcon, trans)objcmd3.ExecuteNonQuery()
Nexttrans.Commit()objcmd.Dispose()objcmd2.Dispose()objcmd3.Dispose()objcon2.Close()objcon.Close()
MsgBox("Bill Saved!")
Catch ex As Exception Try
trans.Rollback() Catch exc As Exception
EndTryMsgBox(ex.Message)
EndTry EndSub
PrivateSub NewBillButton_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles NewBillButton.Click
StartUp() EndSub
PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button3.Click Me.Close() EndSub PrivateSub Button1_Click_1(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click
Dim obj As BillGenerationForm = NewBillGenerationForm(Val(TextBox1.Text.Trim))
95 | P a g e
-
8/2/2019 Black Final Grocery 3
96/101
obj.MdiParent = Me.MdiParentobj.S
Coding for all product Report Screen:Imports System.ConfigurationImports System.Data.SqlClient
PublicClass AllProductReportForm1
PrivateSub AllProductReportForm1_Load(ByVal sender AsObject, ByVal eAs System.EventArgs) HandlesMe.Load Dim connectionString =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString Dim rpt AsNew CrystalReport1() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand AsNew SqlCommand() Dim myDA AsNew SqlDataAdapter() Dim myDS AsNew GroceryDataSet() 'The DataSet you created.
Try
myConnection = New SqlConnection(connectionString)MyCommand.Connection = myConnectionMyCommand.CommandText = "select * from productmaster"MyCommand.CommandType = CommandType.TextmyDA.SelectCommand = MyCommand
myDA.Fill(myDS, "datatable1")rpt.SetDataSource(myDS)CrystalReportViewer1.ReportSource = rpt
Catch Excep As ExceptionMessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error) EndTry EndSubEndClass
96 | P a g e
-
8/2/2019 Black Final Grocery 3
97/101
Coding for Inventory Report Screen:Imports System.ConfigurationImports System.Data.SqlClient
PublicClass InventoryReportForm1
PrivateSub InventoryReportForm1_Load(ByVal sender AsObject, ByVal e
As System.EventArgs) HandlesMe.Load Dim connectionString =ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString Dim rpt AsNew CrystalReport2() 'The report you created. Dim myConnection As SqlConnection Dim MyCommand AsNew SqlCommand() Dim myDA AsNew SqlDataAdapter() Dim myDS AsNew GroceryDataSet() 'The DataSet you created.
Try
myConnection = New SqlConnection(connectionString)
MyCommand.Connection = myConnectionMyCommand.CommandText = "SELECT ProductMaster.ProductName,
InventoryMaster.Quantity, ProductMaster.price FROM InventoryMaster INNERJOIN ProductMaster ON InventoryMaster.ProductId = ProductMaster.ProductID"
MyCommand.CommandType = CommandType.TextmyDA.SelectCommand = MyCommand
myDA.Fill(myDS, "datatable2")rpt.SetDataSource(myDS)CrystalReportViewer1.ReportSource = rpt
Catch Excep As ExceptionMessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error) EndTry EndSubEndClass
97 | P a g e
-
8/2/2019 Black Final Grocery 3
98/101
Coding for Bill Print SCREEN:
Imports System.ConfigurationImports System.Data.SqlClient
PublicClass Bill Dim id AsInteger
PrivateSub Bill_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load Dim connectionString =
ConfigurationManager.ConnectionStrings( "Grocery").ConnectionString Dim rpt AsNew CrystalReport3() Dim myConnection As SqlConnection Dim MyCommand AsNew SqlCommand() Dim myDA AsNew SqlDataAdapter() Dim myDS AsNew GroceryDataSet().
Try
myConnection = New SqlConnection(connectionString)MyCommand.Connection = myConnectionMyCommand.CommandText = "SELECT BillMaster.BillID,
BillMaster.BillOwner, BillMaster.BillDate, ProductMaster.ProductName,
PurchasedItem.Quantity, PurchasedItem.Price, BillMaster.Total FROMBillMaster INNER JOIN PurchasedItem ON BillMaster.BillID =PurchasedItem.BillID CROSS JOIN ProductMaster where BillMaster.billID=" &id
MyCommand.CommandType = CommandType.TextmyDA.SelectCommand = MyCommand
myDA.Fill(myDS, "DataTable3")rpt.SetDataSource(myDS)CrystalReportViewer1.ReportSource = rpt
Catch Excep As ExceptionMessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error) EndTry EndSub
PublicSubNew()InitializeComponent()
EndSub PublicSubNew(ByVal id AsInteger)
InitializeComponent()
Me.id = id EndSubEndClass
98 | P a g e
-
8/2/2019 Black Final Grocery 3
99/101
CONCLUSIONAn 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.
99 | P a g e
-
8/2/2019 Black Final Grocery 3
100/101
bibliography
BOOKS REFERED:-
1. Programming In Visual studio 6.0 By Murach2. Mastering in visual basic
3. Software Engineering By Pankaj Jalote
Website: -
www.google.com
100 | P a g e
-
8/2/2019 Black Final Grocery 3
101/101
top related