Visual Basic - Net Case Study
Visual Basic - Net Case Study
Visual Basic - Net Case Study
Case Study
Food world is one of country’s leading supermarkets. You are asked to develop a prototype to keep
track of the company’s inventory and sales transactions. You are given with the table structure for the
prototype. Note that the requirement is to develop an initial prototype and not necessary the
implementation of a complete system.
Table design
The prototype consists of 3 tables including Product table, Sales table and Sales Details table. Table
structure and necessary relationships are given as follows:
Product Table
Product table consist of a primary column ProdID, which records the primary key of the table the ID of
the Product. Note that ProdID should be an auto generated number where the identity increment is 1
and the seed is 1000.
Other columns specified in the table contain information about Product description, vendor or
manufacturer of the product, unit price of a product, unit which product is measured and the current
(hand-in) stock.
Sales Table
Sales table records information of each transaction. The bill no will be the primary key again it should be
auto generated at the run time. Let the identity increment be 1 and the seed is 10000. Note that sales
table contains only summarized information of a transaction that is date of billing, total of transaction,
the amount of tax, discount if any and the net total of each transaction.
A customer should be able to purchase multiple products in one bill. Product details of each purchase
are recorded in the Sales Details table.
Sales details table is related to Product table and sales table. BillNo and ProdID fields are served as
composite primary keys where all the products purchased will be listed with the associated BillNo. Then
Product description and unit price is filtered from the product table by ProdID and the purchased
quantity is recorded in the sales details table.
Inventory form
This form is the user interface offered to warehouse manager or the stock keeper to keep track of the
product stock in the supermarket. Allow functions to add new products to the stock, edit them or delete
them from the stock. This form also provide functionalities to record navigation, display data in data grid
view, search by various parameters.
Configure the data connection; create a new dataset & data adapter and bind
data into textboxes and data grid view
Imports System.Data.SqlClient
End Sub
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Sub
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNext.Click
Try
If ptr <> RowCount - 1 Then
ptr += 1
Call RecordNavigator()
Else
MessageBox.Show("That's the last record")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Try
If ptr <> RowCount - 1 Then
ptr = RowCount - 1
Call RecordNavigator()
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Try
Dim sq As String
com.ExecuteNonQuery()
con.Close()
con.Open()
ds.Clear()
str = "Select * from Product"
da = New SqlDataAdapter(str, con)
da.Fill(ds, "Items")
Me.DataGridView1.DataSource = Nothing
Me.DataGridView1.Refresh()
DataGridView1.DataSource = ds.Tables("Items")
btnSave.Enabled = False
RowCount += 1
Catch ex As Exception
MsgBox("Invalid Input")
End Try
End Sub
Dim x As Integer
x = MessageBox.Show("Are you sure to update this record? Hit NO if
you want to cancel modifications", "Are you sure?", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If x = System.Windows.Forms.DialogResult.Yes Then
com.ExecuteNonQuery()
DataGridView1.DataSource = Nothing
DataGridView1.Refresh()
ds.Clear()
str = "Select * from Product"
da = New SqlDataAdapter(str, con)
da.Fill(ds, "Items")
DataGridView1.DataSource = ds.Tables("Items")
'con.Close()
Else
MsgBox("Tables are not updated", MsgBoxStyle.OkOnly,
"Cancellation")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Dim x As Integer
x = MessageBox.Show("Are you sure to Delete item " &
txtProdDesc.Text & " from database? Hit NO if no to cancel deletions", "Are
you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If x = System.Windows.Forms.DialogResult.Yes Then
com.ExecuteNonQuery()
RowCount -= 1
DataGridView1.DataSource = Nothing
DataGridView1.Refresh()
ds.Clear()
str = "Select * from Product"
da = New SqlDataAdapter(str, con)
da.Fill(ds, "Items")
DataGridView1.DataSource = ds.Tables("Items")
txtProdID.Text = ""
txtProdDesc.Text = ""
txtVendor.Text = ""
txtUnitPrice.Text = ""
txtUnit.Text = ""
txtStock.Text = ""
Else
MsgBox("Deletion is cancelled", MsgBoxStyle.OkOnly,
"Cancellation")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Sub