منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : تعديل كود لو سمحتو
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
كود :
  Private Sub txtlabel_KeyDown(sender As Object, e As KeyEventArgs) Handles txtlabel.KeyDown
        Try
            If e.KeyCode = Keys.Enter Then
                'get product infos
                cmd = New OleDb.OleDbCommand("select id, PRICE from tab_pro where label = " & txtlabel.Text, con)
                con.Open()
                Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader
                dr.Read()
                If dr.HasRows Then
                    txtid.Text = dr(0)
                    txtprice.Text = dr(1)
                    txtqty.Focus()
                Else
                    MsgBox("تحقق من المنتج", MsgBoxStyle.Exclamation, "تنبيه")
                    clear()
                End If
                dr.Close()
            End If
        Catch ex As Exception
            Exit Sub
        Finally
            con.Close()
        End Try
    End Sub
ما التعديل المطلوب؟
تفضل التعديل
PHP كود :
Private Sub txtlabel_KeyDown(sender As ObjectAs KeyEventArgsHandles txtlabel.KeyDown
    
If e.KeyCode Keys.Enter Then
        
Try

            
'get product infos
            Dim da As New OleDb.OleDbDataAdapter("SELECT [id], [PRICE] FROM [tab_pro] WHERE [label] = @lab", con)
            da.SelectCommand.Parameters.AddWithValue("@lab", txtlabel.Text)

            Dim dt As New DataTable
            If da.Fill(dt) > 0 Then
                Dim r As DataRow = dt.Rows(0)
                txtid.Text = r("id")
                txtprice.Text = r("PRICE")
                txtqty.Select()

            Else
                MsgBox("تحقق من المنتج", MsgBoxStyle.Exclamation, "تنبيه")
                clear()

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End If
End Sub