Dim check As Boolean = False
sb.Remove(0, sb.Length)
sb.Append("select TOP 1 Doc_No from cg_pos_head where OU_Code='" + DataGridView2.Rows(b).Cells(0).Value.ToString() + "' order by Doc_No desc")
Dim sqlcg_pos_head As String = sb.ToString()
com = New SqlCommand
With com
.CommandType = CommandType.Text
.CommandText = sqlcg_pos_head
.Parameters.Clear()
.Connection = con
.Transaction = tr
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
batid = dt.Rows(0)("Doc_No").ToString()
batid2 = CInt(batid) + 1
batNO = batid2.ToString("000000")
Else
batNO = batid2.ToString("000000")
End If
dr.Close()
check = True
End With
If check = True Then
Dim tatollvat As Double = CDbl(DataGridView2.Rows(b).Cells(2).Value)
sb.Remove(0, sb.Length)
sb.Append("select VAT_RATE from cg_shop where ou_code='" + DataGridView2.Rows(b).Cells(0).Value.ToString() + "'")
Dim sqlingood As String = sb.ToString()
com = New SqlCommand
With com
.CommandType = CommandType.Text
.CommandText = sqlingood
.Connection = con
.Transaction = tr
.Parameters.Clear()
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
vat = CInt(dt.Rows(0)("VAT_RATE").ToString())
End If
dr.Close()
End With
sumvat = tatollvat * vat / 107
End If