Private Sub AddBook()
' ADD PARAMETERS
Access.AddParam("@BNo", BookNo.Text)
Access.AddParam("@Book_Category", Category.Text)
Access.AddParam("@Book_Title", Title.Text)
Access.AddParam("@Book_Stored_Date", DateTimePicker1.Value)
Access.AddParam("@Copyright_Date", Copyright_Date.Text)
Access.AddParam("@Remarks", Remarks.Text)
Access.AddParam("@Quantity", Quantity.Text)
' EXECUTE INSERT COMMAND
Access.ExecQuery("INSERT INTO db_book (Book_No,Book_Category,Book_Title,Book_Stored_Date,Copyright_Date,Remarks,Quantity) " & _
"VALUES (@BNo,@Book_Category,@Book_Title,@Book_Stored_Date,@Copyright_Date,@Remarks,@Quantity); ")
If Not IsNumeric(Me.BookNo.Text) Then
ErrorProvider1.SetError(BookNo, "PLEASE INPUT A NUMBER ONLY.")
Return
Else
Me.ErrorProvider1.SetError(Me.BookNo, "")
End If
If Not IsNumeric(Me.Quantity.Text) Then
ErrorProvider1.SetError(Quantity, "PLEASE INPUT A NUMBER ONLY.")
Return
Else
Me.ErrorProvider1.SetError(Me.Quantity, "")
End If
' REPORT & ABORT ON ERRORS
If Not String.IsNullOrEmpty(Access.Exception) Then MsgBox(Access.Exception) : Exit Sub
' SUCCESS!!
MsgBox("The book was added successfully")
books.RefreshGrid()
Me.Close()
End Sub