منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
تعديل كود لو سمحتو - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم دورات VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=187)
+--- الموضوع : تعديل كود لو سمحتو (/showthread.php?tid=20009)



تعديل كود لو سمحتو - نبيل كونكت - 14-04-17

كود :
  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



RE: تعديل كود لو سمحتو - الفالوجي - 21-04-17

ما التعديل المطلوب؟


RE: تعديل كود لو سمحتو - عبـدالله - 22-04-17

تفضل التعديل
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