Shop_No Block ARA001 ARA ARA002 ARA ARA003 ARA ARA004 ARA BRA001 BRA BRA002 BRA BRA003 BRA BRA004 BRA CRA001 CRA CRA002 CRA CRA003 CRA CRA004 CRA CRA005 CRA
Dim IncrID As Integer CustAutoSqlstr = "Select *From tblRevenueRegister WHERE Block='" & cbBlock.Text & "'" CustAutodr = CustAutocmd.ExecuteReader() If IncrID < CustAutodr.Item(0) Then IncrID = CustAutodr("Shop_No").ToString End If txtShopNo.Text = IncrID + 1
Dim maxValue As Object Dim block As String = cbBlock.Text Using con As New SqlConnection("...") Using cmd As New SqlCommand("SELECT Max(Shop_No) FROM tblRevenueRegister WHERE Block = @Block") cmd.Parameters.AddWithValue("@Block", block) con.Open() maxValue = cmd.ExecuteScalar() End Using End Using If maxValue Is Nothing OrElse Convert.IsDBNull(maxValue) Then txtShopNo.Text = "1" Else Dim numberPart As String = Convert.ToString(maxValue).Substring(block.Length) Dim shopNumber As Integer = Convert.ToInt32(numberPart) txtShopNo.Text = (shopNumber + 1).ToString() End If
Using cmdAsPaid As New OleDbCommand("SELECT Count(Shop_No) FROM tblRevenueRegister WHERE Block = ?") cmdAsPaid.Parameters.AddWithValue("@p0", txtBlockNo.Text) Dim Totals As Decimal = CDec(cmdAsPaid.ExecuteScalar()) Dim CountAsPaid As Double = String.Format(Totals) txtShopNo.Text = txtBlockNo.Text & Microsoft.VisualBasic.Format(CountAsPaid, "000") + IncrID End Using
Shop_no
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)