Hi, I have a program that is used to hire out tools. If the customer hires out a tool and then returns it late there will be a fee. To calculate the fee you multiple the price of the late fee by how many days overdue the tool is. I wrote some code however I am getting incorrect values.
Here is the code:
Here is the code:
Code:
If DbConnect() Then
Dim SQLCmd As New OleDbCommand
With SQLCmd
.Connection = cn
.CommandText = " Select * " &
"From Tools, Hire, Customer " &
"Where @search1 = Customer.CustomerName"
.Parameters.AddWithValue("@search1", TxtCustName.Text)
Dim rs As OleDbDataReader = .ExecuteReader()
While rs.Read
Dim Today As Date = Date.Now
Dim EndDate As Date = rs("HireEndDate")
Dim DaysOverDue = Today - EndDate
Dim days As Integer = DaysOverDue.TotalDays
Dim StartDate As Date = rs("HireStartDate")
Dim DaysOnHire = EndDate - StartDate
Dim days1 As Integer = DaysOnHire.TotalDays
TxtOrderToolPrice.Text = rs("ToolPrice") * days1
TxtLateFee.Text = rs("ToolLateFee") * days
TxtOverallPrice.Text = CInt(TxtLateFee.Text) + CInt(TxtOrderToolPrice.Text)
End While
End With
End If
End Sub