You are on page 1of 8

FEDERAL UNIVERSITY OF LAFIA

DEPARTMENT OF COMPUTER SCIENCE

ASSIGNMENT
ON

COURSE CODE: CSC 318


COURSE TITLE: STRUCTURED PROGRAMMING

PREPARED BY

NAME: MUHAMMED USMAN


MATRIC NO.: 2031720007
Just like in any fast food chains automated cashiering, this cashiering system
also displays orders on screen that are available in the kitchen. It’s a user
friendly, fast and efficient. It execute multiple orders and it automaticalty
compute the total amount of the customer’s order. It also provide printed
reciept.

These are the following features of the system:

 Manage foods
 Manage Category of foods
 Transaction (recieve order,place order)
 Manage User
 Login and Logout

Public Class add_product

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "Picture Files (*)|*.bmp;*.gif;*.jpg"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
photos.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
End Sub

Private Sub add_product_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Try
reloadDtg("Select pro_id as 'code number' ,Item_name as 'Item
Name',Product_name as 'Product name',price as 'Price',size as 'Size' From foods_list",
dglist)

dglist.Columns(0).Visible = False

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

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles fsave.Click
'MsgBox(OpenFileDialog1.SafeFileName)
'MsgBox(imagename)
Dim picname As String = ""
If OpenFileDialog1.SafeFileName = "" Or OpenFileDialog1.SafeFileName =
"OpenFileDialog1" Then
picname = ""
Else
picname = OpenFileDialog1.SafeFileName
End If

create("insert into foods_list


(pro_id,Item_name,Product_name,category,price,size,Photos)" _
& "values('" & Idproduct.Text & "','" & Idcode.Text & "','" & foodname.Text _
& "','" & cbocateg.Text & "',,'" & price.Text & "','" & fsize.Text & "','" &
picname & "')")

My.Computer.FileSystem.CopyFile( _
OpenFileDialog1.FileName, _
Application.StartupPath & "/pic/" & picname)
'''''''''''''''''''''''''''''''''''''''''''
photos.Image = Nothing
Idproduct.Clear()
Idcode.Clear()
foodname.Clear()
price.Clear()

Try
fsize.Text = "Small"
reloadDtg("Select pro_id as 'Product ID' ,Item_name as 'Item code
name',Product_name as 'Product name' ,category as 'Category',price as 'price',size as
'size' From foods_list", dglist)
dglist.Columns(0).Visible = False

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

Private Sub Idproduct_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Idproduct.TextChanged
End Sub
Dim imagename As String = ""
Private Sub dglist_DoubleClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles dglist.DoubleClick
Try

reloadtxt("select * from foods_list where `pro_id` = '" &


dglist.CurrentRow.Cells(0).Value & "'")

If dt.Rows.Count > 0 Then


Idproduct.Text = dt.Rows(0).Item("pro_id")
Idcode.Text = dt.Rows(0).Item("Item_name")
foodname.Text = dt.Rows(0).Item("Product_name")
cbocateg.Text = dt.Rows(0).Item("category")
price.Text = dt.Rows(0).Item("price")
fsize.Text = dt.Rows(0).Item("size")
photos.Image = Image.FromFile(Application.StartupPath & "/pic/" &
dt.Rows(0).Item("Photos"))
imagename = dt.Rows(0).Item("Photos")

End If

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

Private Sub fupdate_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles fupdate.Click
Try
'MsgBox(OpenFileDialog1.SafeFileName)
Dim picname As String = ""
If OpenFileDialog1.SafeFileName = "" Or OpenFileDialog1.SafeFileName =
"OpenFileDialog1" Then
picname = imagename
Else
picname = OpenFileDialog1.SafeFileName
End If

updates("UPDATE foods_list SET Item_name='" & Idcode.Text &


"',Product_name='" & foodname.Text _
& "',category='" & cbocateg.Text & "',price='" & price.Text & "',size='" &
fsize.Text & "',Photos= '" & picname & "' WHERE pro_id='" & Idproduct.Text & "'")

Call fclear_Click(sender, e)

'My.Computer.FileSystem.CopyFile( _
' OpenFileDialog1.FileName, _
' Application.StartupPath & "/pic/" & picname)

Catch ex As Exception

End Try
End Sub

Private Sub fclear_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles fclear.Click
Try
photos.Image = Nothing
cleartext(GroupBox1)
reloadDtg("Select pro_id as 'Product ID' ,Item_name as 'Item code
name',Product_name as 'Product name' ,category as 'Category',price as 'price',size as
'size' From foods_list", dglist)
dglist.Columns(0).Visible = False

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

Private Sub fdelete_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles fdelete.Click
Try
sql = "DELETE FROM foods_list WHERE pro_id = '" & Idproduct.Text & "'"
deletes(sql)
Call fclear_Click(sender, e)
Catch ex As Exception

End Try
End Sub

Private Sub fclose_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles fclose.Click
Me.Close()
End Sub

Private Sub dglist_CellContentClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles dglist.CellContentClick

End Sub
End Class

Imports MySql.Data.MySqlClient
Public Class adduser

Private Sub adduser_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Try
cbo_type.Text = "Owner"
Call btn_New_Click(sender, e)
If lbl_id.Text = "ID" Then

btn_update.Enabled = False
btn_delete.Enabled = False
btn_saveuser.Enabled = True

Else
btn_saveuser.Enabled = True
btn_update.Enabled = True
btn_delete.Enabled = True
End If

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

Private Sub btn_saveuser_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btn_saveuser.Click

create("insert into cashier_user


(Firstname,Lastname,username,pass,User_status) " _
& "values('" & TextBox1.Text & "','" & txt_name.Text & "','" &
txt_username.Text _
& "','" & txt_pass.Text & "','" & cbo_type.Text _
& "')")
TextBox1.Clear()
txt_name.Clear()
txt_username.Clear()
txt_pass.Clear()

Try
cbo_type.Text = "Owner"
Call btn_New_Click(sender, e)
If lbl_id.Text = "ID" Then

btn_update.Enabled = False
btn_delete.Enabled = False
btn_saveuser.Enabled = True

Else
btn_saveuser.Enabled = True
btn_update.Enabled = True
btn_delete.Enabled = True
End If

Catch ex As Exception
' MsgBox(ex.Message)
End Try

End Sub
Public Sub deletes(ByVal sql As String)
Try
con.Open()
With cmd
.Connection = con
.CommandText = sql
End With
'If MessageBox.Show("Do you want to delete this rocord?", "Delete" _
' , MessageBoxButtons.YesNo,
MessageBoxIcon.Information) _
' = Windows.Forms.DialogResult.Yes Then
result = cmd.ExecuteNonQuery
If result = 0 Then
MsgBox("Delete failed.")
Else
MsgBox("The data has been deleted in the database.")
End If
'End If
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_update_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_update.Click
Try
If txt_name.Text = "" Or txt_pass.Text = "" Or txt_username.Text = "" Then

Else
updates("update cashier_user set Firstname = '" & TextBox1.Text &
"',Lastname = '" & txt_name.Text & "',username= '" & txt_username.Text _
& "',pass='" & txt_pass.Text & "',User_status= '" &
cbo_type.Text _
& "' where ID = " & lbl_id.Text)
Call btn_New_Click(sender, e)

End If

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

Private Sub dtg_listUser_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles dtg_listUser.Click
Try
sql = "SELECT * FROM `cashier_user` WHERE `ID` = '" &
dtg_listUser.CurrentRow.Cells(0).Value & "'"
reloadtxt(sql)
If dt.Rows.Count > 0 Then
With dt.Rows(0)
lbl_id.Text = .Item("ID")
TextBox1.Text = .Item("Firstname")
txt_name.Text = .Item("Lastname")
txt_username.Text = .Item("username")
txt_pass.Text = .Item("pass")
cbo_type.Text = .Item("User_status")
End With

End If
Catch ex As Exception

End Try
End Sub

Private Sub btn_New_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btn_New.Click
cleartext(grp_user)
reloadDtg("Select ID as 'ID' ,Firstname as 'FirstName',Lastname as
'Lastname',username as 'UserName', User_status as 'User type' From cashier_user",
dtg_listUser)
dtg_listUser.Columns(0).Visible = False
End Sub

Private Sub btn_delete_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btn_delete.Click
sql = "DELETE FROM cashier_user WHERE ID = '" &
dtg_listUser.CurrentRow.Cells(0).Value & "'"
deletes(sql)
Call btn_New_Click(sender, e)
End Sub

Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtsearch.TextChanged
reloadDtg("Select ID as 'ID' ,Firstname as 'FirstName',Lastname as
'Lastname',username as 'UserName', User_status as 'User type' From cashier_user WHERE
ID LIKE '%" & txtsearch.Text & "%'", dtg_listUser)
dtg_listUser.Columns(0).Visible = False
End Sub

Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnclose.Click
Me.Close()
End Sub
End Class

Public Class breakfastform

Private Sub breakfastform_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Try
reloadDtg("Select pro_id as 'code number' ,Item_name as 'Item
Name',Product_name as 'Product name',price as 'Price',size as 'Size' From foods_list
where category = 'BreakFast'", gtd_food)
gtd_food.Columns(0).Visible = False

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

Private Sub gtd_food_CellContentClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles gtd_food.CellContentClick

End Sub

Private Sub gtd_food_DoubleClick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles gtd_food.DoubleClick
casher(gtd_food)
Me.Close()
End Sub
End Class

You might also like