(20-03-20, 07:50 PM)mohamedalqadi كتب :كود :
'=========== طريقة الادخال عن طريق الباركود ===========
Dim BAR_ As Integer
If TXT_BARCODE.Text <> Nothing Then
Dim DT As New DataTable
Dim DA As New SqlClient.SqlDataAdapter("SELECT * FROM ITEM WHERE ITEM_BAR LIKE '" & TXT_BARCODE.Text & "'", sqlconn)
DA.Fill(DT)
If DT.Rows.Count > 0 Then
'======= التحقق من رقم كود الصنف =========
For I As Integer = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(I).Cells(0).Value = DT.Rows(0).Item("ITEM_CODE") Then
DataGridView1.Rows(I).Cells(4).Value = DataGridView1.Rows(I).Cells(4).Value + 1
calc()
TXT_BARCODE.Clear()
Exit Sub
End If
Next
'======= اضافة سجل للداتا جريد ===========
Dim dr = DT.NewRow
DT.Rows.Add(dr)
DataGridView1.DataSource = DT
DataGridView1(0, BAR_).Value = DT.Rows(0).Item("ITEM_CODE")
DataGridView1(1, BAR_).Value = DT.Rows(0).Item("ITEM_NAME")
DataGridView1(2, BAR_).Value = DT.Rows(0).Item("ITEM_UNIT")
DataGridView1(3, BAR_).Value = DT.Rows(0).Item("ITEM_TKLFA")
DataGridView1(4, BAR_).Value = 1
calc()
End If
End If
TXT_BARCODE.Clear()
calc()
PHP كود :
'=========== طريقة الادخال عن طريق الباركود ==========='
DataGridView1.DataSource = Nothing
If TXT_BARCODE.Text <> Nothing Then
Dim DT As New DataTable
Dim DA As New SqlClient.SqlDataAdapter("SELECT * FROM ITEM WHERE ITEM_BAR LIKE '" & TXT_BARCODE.Text & "'", sqlconn)
If DA.Fill(DT) > 0 Then
Dim rowindex As Integer = -1
'======= التحقق من رقم كود الصنف ========='
For Each dgvr As DataGridViewRow In DataGridView1.Rows
If dgvr.Cells(0).Value = DT(0).Item("ITEM_CODE") Then
rowindex = dgvr.Index
Exit For
End If
Next
If rowindex <> -1 Then
DataGridView1(4, rowindex).Value += 1
Else
'======= اضافة سجل للداتا جريد ==========='
Dim dr As DataRow = DT.Rows(0)
DataGridView1.Rows.Add(dr.Item("ITEM_CODE"), dr.Item("ITEM_NAME"), dr.Item("ITEM_UNIT"), dr.Item("ITEM_TKLFA"), 1)
End If
TXT_BARCODE.Clear()
calc()
Else
MsgBox("Barcode not found: " & TXT_BARCODE.Text, MsgBoxStyle.Critical)
TXT_BARCODE.SelectAll()
End If
End If
TXT_BARCODE.Focus()
