below is my code to get the quarter and it works well
Private Function GetQuarter() As String
initializeCon()
Dim dt As DateTime
Return ((dt.Month - 1) / 3) + 1
End Function
below is my code to get the year and it works well
Private Function AutoYear() As String
initializeCon()
Dim d As Date = Now
Return d.ToString("yy")
End Function
below is my code for auto increment number. Here's my problem, first attempt it saves to the database but in the second time the code below gets error and it says Conversion from String 191001 to type Double is not valid, and the error refers to the code Return ProdID. Can somebody help me about this?
Private Function GetAutoNumber() As String
initializeCon()
Try
cmd = New SqlCommand("SELECT LotNo FROM ProductionOrder ORDER BY ID", con)
cmd.ExecuteNonQuery()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
If (dr.Read) = True Then
Dim id As Integer
id = dr(0) + 1
ProdID = id.ToString("000")
ElseIf IsDBNull(dr) Then
ProdID = "001"
Else
ProdID = "001"
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
con.Close()
End Try
Return ProdID
End Function
To get the 191001, I just called their function names. 19 is for the year, 1 is for the quarter, and 001 is for control number.