13-12-18, 11:10 PM
(آخر تعديل لهذه المشاركة : 13-12-18, 11:33 PM {2} بواسطة محمد اسماعيل.)
(13-12-18, 10:49 PM)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
بشكرك علي ردك ومتابعتك الموضوع اسمح لي دقائق
هجرب ورد عليك
(13-12-18, 10:49 PM)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
طيب انا عدلت الوظيفة كالاتي :-
علي اساس جملة الاتصال للبرنامج عامة con
كود :
Public Function code(ByVal ds As DataSet, ByVal tb As String, ByVal tbcode As String) As String
Dim StrSQL As String = "Select IIF(Max(" & tbcode & ") Is NULL,50,Max(" & tbcode & ")+1) From " & tb & ""
Dim da As New OleDbDataAdapter(StrSQL, con)
ds.Clear()
da.Fill(ds, tb)
Dim bignum As String = ds.Tables(tb).Rows(0)(0).ToString()
code = bignum
End Functionالي بيحصل كالاتي
الاكواد عندي زادت من 509 الي 510 وانا اريد تثبيت قيمة الخمسين لعملية البحث عن الفاتورة .
فاصبحت هنا حاجة مختلفة 51 بدلا من 5010
انا عايز 509 تبقي 5010 و 5011 و 5012 وهكذا
بردك عند 5099 تبقي 50100 وهكذا
ما اريدة بدون اطالة الخمسين ثابت لايتغير ويضاف 1 الي مابعدة

