อันนี้เป็น Code ที่ผมใช้ตรวจเชค เมื่อคลิกปุ่มขาย ก่อนตัดสต๊อก
Private Sub chkQty()
Dim comSave As New SqlCommand
Dim comUpdate As New SqlCommand
Dim NumRows, i As Integer
NumRows = grdOrder.Rows.Count - 1
For i = 0 To NumRows
strSQL = "select * from Product WHERE(P_ID = '" & CStr((grdOrder.Rows(i).Cells(0).Value.ToString)) & "'
and stock < '" & CInt(grdOrder.Rows(i).Cells(3).Value) & "')"
da = New SqlDataAdapter(strSQL, Conn)
If IsFindchk = True Then
ds.Tables("cQty").Clear()
IsFindchk = False
bQty = False
End If
da.Fill(ds, "cQty")
If ds.Tables("cQty").Rows.Count <> 0 Then
IsFindchk = True
bQty = True
End If
Next
End Sub
ขายสินค้าเกิน Stock แล้วติดลบ ต้องการตรวจเชค ดู Code ให้ทีครับ
Private Sub chkQty()
Dim comSave As New SqlCommand
Dim comUpdate As New SqlCommand
Dim NumRows, i As Integer
NumRows = grdOrder.Rows.Count - 1
For i = 0 To NumRows
strSQL = "select * from Product WHERE(P_ID = '" & CStr((grdOrder.Rows(i).Cells(0).Value.ToString)) & "'
and stock < '" & CInt(grdOrder.Rows(i).Cells(3).Value) & "')"
da = New SqlDataAdapter(strSQL, Conn)
If IsFindchk = True Then
ds.Tables("cQty").Clear()
IsFindchk = False
bQty = False
End If
da.Fill(ds, "cQty")
If ds.Tables("cQty").Rows.Count <> 0 Then
IsFindchk = True
bQty = True
End If
Next
End Sub