2016-08-01 32 views
-2

下午好。 我正在創建一個具有以下模塊的程序,它們是:000000001等等唯一ID

採購申請,採購訂單,收貨項目和庫存申請,它們分別具有PR,PO,RI和SR的首字母縮寫。現在我爲什麼這麼說?因爲這個。

每個模塊,我剛纔說了有自己的事務,並且每個交易都有自己的參考數字或將被用來作爲唯一ID的數據。

現在我的問題在於下面的圖片

enter image description here

我怎樣才能做到這一點?(在文本框中顯示最好是)我想這種唯一ID的每個模塊我有。

認真我沒怎麼做,因爲這是我第一次做這個。

如果有一個親的和反對的對於這一點,它的好,我會設置該參數。

我希望有人可以幫助我。

+0

我試過它先生,但它很難讓我做它,因爲我是一個新手。 –

回答

0

這就是我的回答對我自己的問題,但不管怎麼說TYSM對於誰沒有回答我的問題,而不是給我一個否定的那些代碼評論員。

對不起你們我真的很需要的代碼,併爲那些誰想要這樣的代碼這裏是。

Dim con As MySqlConnection = New MySqlConnection("Your MySQL Connection") 
     Dim cmd As MySqlCommand = New MySqlCommand("select Max(Column_Of_Unique_ID) as UniqueValue from TableName", con) 
     Dim reader As MySqlDataReader 
     con.Open() 
     reader = cmd.ExecuteReader 
     Try 
      While reader.Read 

       'If its Purchase Order then PO 
       'If its Purchase Requisition then PR 
       'If its Receiving Items then RI 
       'If its Stock Requisition then SR 

       TextBox1.Text = reader.GetString("UniqueValue") 
       TextBox1.Text = TextBox1.Text.Replace("PO", "").Trim() 
       TextBox1.Text = TextBox1.Text + 1 
       If TextBox1.Text.Length = 1 Then 
        TextBox1.Text = "PO" & "0000000" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 2 Then 
        TextBox1.Text = "PO" & "000000" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 3 Then 
        TextBox1.Text = "PO" & "00000" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 4 Then 
        TextBox1.Text = "PO" & "0000" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 5 Then 
        TextBox1.Text = "PO" & "000" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 6 Then 
        TextBox1.Text = "PO" & "00" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 7 Then 
        TextBox1.Text = "PO" & "0" & TextBox1.Text 
       ElseIf TextBox1.Text.Length = 8 Then 
        TextBox1.Text = "PO" & TextBox1.Text 
       End If 
      End While 
     Catch 
      TextBox1.Text = "PO00000001" 
     End Try 
+0

不好意思說這不是一個好的解決方案。做一些你不應該做的事情並且減慢你的系統的工作是一件非常辛苦的工作。 – e4c5

+0

注意到那位先生,謝謝你提醒我.. –