LOGIN CODES
Dim username As String = txtUsername.Text
Dim password As String = txtPassword.Text
Dim found As Boolean = False
If txtUsername.Text = "" And txtPassword.Text <> "" Then
MsgBox("Enter Username Pliz!", MsgBoxStyle.Information, "Opps!")
ElseIf txtUsername.Text <> "" And txtPassword.Text = "" Then
MsgBox("Enter Password Pliz!", MsgBoxStyle.Information, "Opps!")
ElseIf txtUsername.Text = "" Or txtPassword.Text = "" Then
MsgBox("Pliz fill in all the information!", MsgBoxStyle.Information,
"Opps!")
txtUsername.Focus()
Else
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
Dim full_name As String = txtFull_name.Text
Dim surname As String = txtSurname.Text
Dim Customer_ID As Integer = Val(txtCustomer_ID.Text)
Dim phone_number As Integer = Val(txtPhone_number.Text)
Dim Address As String = txtAddress.Text
Dim book_number As Integer = Val(txtBook_number.Text)
Dim book_title As String = txtBook_title.Text
Dim Amount_paid As Decimal = Val(txtAmount_paid.Text)
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)
If IsNumeric(txtFull_name.Text) = False Then
full_name = IsNumeric(txtFull_name.Text)
Else
MsgBox("Format invalid for fullname entry")
txtFull_name.Clear()
txtFull_name.Focus()
End If
If IsNumeric(txtSurname.Text) = False Then
surname = IsNumeric(txtSurname.Text)
Else
MsgBox("Format invalid for surname entry")
txtSurname.Clear()
txtSurname.Focus()
End If
If IsNumeric(txtCustomer_ID.Text) Then
Customer_ID = IsNumeric(txtCustomer_ID.Text)
Else
MsgBox("Format for CustomerID entry")
txtCustomer_ID.Clear()
txtCustomer_ID.Focus()
End If
If IsNumeric(txtPhone_number.Text) Then
phone_number = IsNumeric(txtPhone_number.Text)
Else
MsgBox("Format invalid for phone number entry")
txtPhone_number.Clear()
txtPhone_number.Focus()
End If
If IsNumeric(txtBook_number.Text) Then
book_number = IsNumeric(txtBook_number.Text)
Else
MsgBox("Format invalid for book number entry")
txtBook_number.Clear()
txtBook_number.Focus()
End If
If IsNumeric(txtAmount_paid.Text) Then
Amount_paid = IsNumeric(txtAmount_paid.Text)
Else
MsgBox("Format invalid for amount paid entry")
txtAmount_paid.Clear()
txtAmount_paid.Focus()
End If
DbCmd.Parameters.Add(New OleDbParameter("Fullname",
CType(txtFull_name.Text, String)))
DbCmd.Parameters.Add(New OleDbParameter("Surname", CType(txtSurname.Text,
String)))
DbCmd.Parameters.Add(New OleDbParameter("CustomerID",
CType(txtCustomer_ID.Text, String)))
DbCmd.Parameters.Add(New OleDbParameter("Phonenumber",
CType(txtPhone_number.Text, String)))
DbCmd.Parameters.Add(New OleDbParameter("Address", CType(txtAddress.Text,
String)))
DbCmd.Parameters.Add(New OleDbParameter("Booknumber",
CType(txtBook_number.Text, String)))
DbCmd.Parameters.Add(New OleDbParameter("Booktitle",
CType(txtBook_title.Text, String)))
DbCmd.Parameters.Add(New OleDbParameter("Date", CType(txtDate.Text,
String)))
DbCmd.Parameters.Add(New OleDbParameter("Amountpaid",
CType(txtAmount_paid.Text, String)))
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