Function getcus() As Integer
If con.State = ConnectionState.Closed Then
con.Open()
End If
Try
Dim Ole As String = "SELECT MAX(Cus_id)FORM Customer"
Dim com As New OleDbCommand(Ole, con)
Dim max As Integer = com.ExecuteScalar
Return max + 1
Catch ex As Exception
Return 1001
End Try
End Function
Private Sub add_Click(sender As System.Object, e As System.EventArgs) Handles addButton.Click
Cus_IDTextBox.Text = "C" & getcus()
Me.CustomerBindingSource.AddNew()
Call read()
Cus_IDTextBox.Focus()
End Sub
Public Function NextData(value As String, cri As String, format As String) As String
Dim str As String = ""
Dim _cri As String = ""
If (value = "" Or cri = "") Then
Return str
End If
str = String.Format("{0:" & format & "}", Integer.Parse(value.Substring(cri.Length, value.Length - cri.Length)) + 1)
Return str
End Function