CODES
CODES
DbCon.Open()
dbCmd = New OleDbCommand("Select * from `LOGIN` where [Name]='" &
username & "' and [Password]='" & password & "'", DbCon)
read = dbCmd.ExecuteReader
If IsNumeric(txtUsername.Text) = False Then
username = IsNumeric(txtUsername.Text)
Else
MsgBox("Please enter a valid username format")
txtUsername.Clear()
txtUsername.Focus()
End If
While read.Read
found = True
End While
If found = True Then
MsgBox("Welcome to Wholesale and Retail Shopping Center",
MsgBoxStyle.Information, "Login Successful")
txtUsername.Clear()
txtPassword.Clear()
frmMAIN_MENU.Show()
If frmMAIN_MENU.Visible Then
Me.Hide()
DbCon.Close()
End If
Else
MsgBox("WRONG USERNAME OR PASSWORD!")
DbCon.Close()
If attempts = 4 Then
MsgBox("Number of attempts(4), program will close")
Close()
Else
MsgBox("Password incorrect, please reEnter, the number of
trials attempted are" & attempts & " of 4")
attempts = attempts + 1
txtPassword.Clear()
txtPassword.Focus()
End If
End If
End If
SAVE CODES
DbCon.Open()
Dim str As String
str = "Insert into `CUSTOMERS FORM`(Name],[Surname],[CustomerID],
[Phonenumber],[Address],[Gender],[Date of Delivery],[Date],[Amountpaid]) Values
(?,?,?,?,?,?,?,?,?)"
Dim DbCmd As OleDbCommand = New OleDbCommand(str, DbCon)
Try
DbCmd.ExecuteNonQuery()
Call CUSTOMERS()
DbCmd.Dispose()
MsgBox("Details submitted", MsgBoxStyle.Information, "CUSTOMER
REGISTERED")
txtAddress.Clear()
txtAmount_paid.Clear()
txtBook_number.Clear()
txtBook_title.Clear()
txtCustomer_ID.Clear()
txtFull_name.Clear()
txtPhone_number.Clear()
txtSurname.Clear()
Catch ex As Exception
MsgBox("Execution failed!", MsgBoxStyle.Critical, "Error while saving
data")
End Try
DbCon.Close()
SEARCH CODES
DbCon.Open()
Dim cmd As New OleDbCommand("Select * from `CUSTOMERS FORM` where
[CustomerID]=@ID", DbCon)
cmd.Parameters.AddWithValue("@ID", txtSearch.Text)
Dim found As Boolean = False
Dim adapter As New OleDbDataAdapter(cmd)
Dim dataset As New DataSet
adapter.Fill(dataset)
CUSTOMERS_FORMDataGridView.DataSource = dataset.Tables(0)
DbCon.Close()
DELETE CODES
DbCon.Open()
Dim DbCmd As New OleDbCommand("Select * from `CUSTOMERS FORM` where
[CustomerID]=@ID", DbCon)
DbCmd.Parameters.AddWithValue("@ID", txtCustomer_ID.Text)
Dim datareader As OleDbDataReader
Dim found As Boolean = False
datareader = DbCmd.ExecuteReader
While datareader.Read
found = True
End While
If found = True Then
DbCmd = New OleDbCommand("Delete from `CUSTOMERS FORM` where
[CustomerID]=@ID", DbCon)
DbCmd.Parameters.AddWithValue("@ID", txtCustomer_ID.Text)
DbCmd.ExecuteNonQuery()
Call CUSTOMERS()
MsgBox("Successfully deleted!")
Else
MsgBox("That record is not found!")
End If
DbCon.Close()
UPDATE CODES
DbCon.Open()
Dim str As String
str = "UPDATE [BOOK BORROWED FORM] set [Fullname]= '" & txtFull_name.Text &
"',[Surname]=' " & txtSurname.Text & "',[Booknumber]='" & txtBook_number.Text & "',
[Booktitle]='" & txtBook_title.Text & "',[Date of Borrowing]='" &
txtDate_of_Borrowing.Text & "',[Date of return]='" & txtDate_of_returned.Text & "',
[Amountpaid]='" & txtAmount_paid.Text & "' Where [Signature]='" & txtSignature.Text
& "'"
Dim cmd As OleDbCommand = New OleDbCommand(str, DbCon)
Dim adapter As New OleDbDataAdapter(cmd)
Dim dataset As New DataSet
adapter.Fill(dataset)
BOOK_BORROWED_FORMDataGridView.DataSource = dataset.Tables(0)
Try
cmd.ExecuteNonQuery()
Call booksborrowed()
cmd.Dispose()
MsgBox("Successfully updated")
Dbcon.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try