Sub ID_AUTO()
Dim sql As String = ""
Dim conn2 As New SqlConnection _
(M_ConnStr.strConn)
Dim Command_Adp2 As SqlCommand
Dim Sql_Reader As SqlDataReader
sql = "select max(substring(Pro_id,2,4)) as g_ID_AUTO from Product"
conn2.Open()
Command_Adp2 = New SqlCommand(sql, conn2)
Sql_Reader = Command_Adp2.ExecuteReader()
If Sql_Reader.Read() Then
If Sql_Reader.Item("g_ID_AUTO").ToString() <> "" Then
txtid.Text = "P" & Format((CDbl(Sql_Reader.Item("g_ID_AUTO").ToString()) + 1), "0000")
Else
txtid.Text = "P0001"
End If
Else
txtid.Text = "P0001"
End If
End Sub
Sub ID_AUTO()
Dim sql As String = ""
Dim conn2 As New SqlConnection _
(M_ConnStr.strConn)
Dim Command_Adp2 As SqlCommand
Dim Sql_Reader As SqlDataReader
sql = "select max(substring(Brand_id,2,4)) as g_ID_AUTO from Product"
conn2.Open()
Command_Adp2 = New SqlCommand(sql, conn2)
Sql_Reader = Command_Adp2.ExecuteReader()
If Sql_Reader.Read() Then
If Sql_Reader.Item("g_ID_AUTO").ToString() <> "" Then
txtid.Text = "B" & Format((CDbl(Sql_Reader.Item("g_ID_AUTO").ToString()) + 1), "0000")
Else
txtid.Text = "B0001"
End If
Else
txtid.Text = "B0001"
End If
End Sub
Sub ID_AUTO()
Dim sql As String = ""
Dim conn2 As New SqlConnection _
(M_ConnStr.strConn)
Dim Command_Adp2 As SqlCommand
Dim Sql_Reader As SqlDataReader
sql = "select max(substring(Brand_id,2,4)) as g_ID_AUTO from Product"
conn2.Open()
Command_Adp2 = New SqlCommand(sql, conn2)
Sql_Reader = Command_Adp2.ExecuteReader()
If Sql_Reader.Read() Then
If Sql_Reader.Item("g_ID_AUTO").ToString() <> "" Then
txtid.Text = "B" & Format((CDbl(Sql_Reader.Item("g_ID_AUTO").ToString()) + 1), "0000")
Else
txtid.Text = "B0001"
End If
Else
txtid.Text = "B0001"
End If
End Sub
Sub ID_AUTO()
Dim sql As String = ""
Dim conn2 As New SqlConnection _
(M_ConnStr.strConn)
Dim Command_Adp2 As SqlCommand
Dim Sql_Reader As SqlDataReader
sql = "select max(substring(Brand_name,2,4)) as g_ID_AUTO from Brand" <<Brand_name from Brand ถูกมั้ยครับ
conn2.Open()
Command_Adp2 = New SqlCommand(sql, conn2)
Sql_Reader = Command_Adp2.ExecuteReader()
If Sql_Reader.Read() Then
If Sql_Reader.Item("g_ID_AUTO").ToString() <> "" Then
txtid.Text = "P" & Format((CDbl(Sql_Reader.Item("g_ID_AUTO").ToString()) + 1), "0000") บรรทัดนี้แก้ยังไง
Else
txtid.Text = "P0001" บรรทัดนี้แก้ยังไง
End If
Else
txtid.Text = "P0001" สามบรรทัดนี้แก้ยังไง ในเมื่อไม่ได้ให้มันรันจาก id แต่รันจาก Brand_name
End If
End Sub