13-12-18, 10:49 PM
(آخر تعديل لهذه المشاركة : 13-12-18, 10:57 PM {2} بواسطة asemshahen5.)
كود :
Public Function serial(ByVal ds As DataSet, ByVal tb As String, ByVal tbcode As String) As String
Dim cn As New SqlConnection("Server =(local);database=ALASEM2;integrated security=True")
ClearTools()
Dim StrSQL As String = "Select IIF(Max(" & tbcode & ") Is NULL,50,Max(" & tbcode & ")+1) From " & tb & ""
Dim StrTableName As String = "CASTOMER"
Dim da As New SqlDataAdapter(StrSQL, cn)
ds.Clear()
da.Fill(ds, StrTableName)
Dim bignum As String = ds.Tables(StrTableName).Rows(0)(0).ToString()
serial = bignum
End Functionكود :
Dim StrSQL As String = "Select IIF(Max(ID) Is NULL,50,Max(ID)+1) From CASTOMER"
Dim cn As New SqlConnection("Server =(local);database=ALASEM2;integrated security=True")
Dim StrTableName As String = "CASTOMER"
Dim da As New SqlDataAdapter(StrSQL, cn)
Dim dt As New DataSet
da.Fill(dt, StrTableName)
Txt_ID.Text = dt.Tables(StrTableName).Rows(0)(0).ToString()كود :
Public Function serial1(ByVal dt As DataSet, ByVal tb As String, ByVal tbcode As String) As String
Dim bignum As String = CType(dt.Tables(tb).Compute("Max(" & tbcode & ")+1", tbcode & " >= 0"), String)
serial1 = bignum
End Function