تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحويل كود من GRIDVIEW الى GRIDCONTROL
#1
السلام عليكم

اخواني الاعزاء :

هذا كود لإذراج المنتج عن طريق الباركود إلى قاعدة البيانات ، فهل يمكن تحويله الى تقنية الديف إكسربرس ، فإنني حاولت كثيرا ولم أستطع .

كود :
Try
           If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
               If Trim(InvoiceBarcode.Text) = "" Then Exit Sub
               For i = 0 To Dgvsearch.Rows.Count - 1
                   If Dgvsearch.Rows(i).Cells(9).Value = InvoiceBarcode.Text Then
                       Dgvsearch.Rows(i).Cells(5).Value += 1
                       Dgvsearch.Rows(i).Cells(7).Value = Val(Dgvsearch.Rows(i).Cells(5).Value) * Val(Dgvsearch.Rows(i).Cells(3).Value)
                       InvoiceBarcode.Text = Nothing
                       picBarcode.BackgroundImage = Nothing
                       CalcSalatax()
                       GoTo EOS
                   End If
               Next

               Dim Sql = ""
               Dim Barc = ""
               If GetFieldName("FirstUnitBarcode") = True Then
                   Sql = "select * from Items where FirstUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 1
               ElseIf GetFieldName("SecondUnitBarcode") = True Then
                   Sql = "select * from Items where SecondUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 2
               ElseIf GetFieldName("ThirdUnitBarcode") = True Then
                   Sql = "select * from Items where ThirdUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 3
               Else
                   GoTo EOS
               End If
               Dim x = Split(GetDef_UnitAndPriceBuy(itmcod), "|")
               If Conn.State = 1 Then Conn.Close()
               Conn.Open()
               Dim Adp As New SqlClient.SqlDataAdapter(Sql, Conn)
               Dim Ds = New DataSet
               Adp.Fill(Ds)
               Dim Dt = Ds.Tables(0)
               If Dt.Rows.Count > 0 Then
                   Dgvsearch.ClearSelection()
                   Dgvsearch.Rows.Add()
                   Dim RowIndex = Dgvsearch.Rows.Count - 1
                   Dgvsearch.Rows(RowIndex).Selected = True
                   Dgvsearch.Rows(RowIndex).Cells(0).Value = Dt.Rows(0).Item("ItemsCode")
                   Dgvsearch.Rows(RowIndex).Cells(1).Value = Dt.Rows(0).Item("ItemsName")
                   itmcod = Dgvsearch.CurrentRow.Cells(1).Value
                   Dgvsearch.Rows(RowIndex).Cells(9).Value = InvoiceBarcode.Text
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("FirstUnit")
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("SecondUnit")
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("ThirdUnit")
                   Dgvsearch.Rows(RowIndex).Cells(5).Value = 1
                   Dgvsearch.Rows(RowIndex).Cells(3).Value = Format(GetDef_FullPrice(Dt.Rows(0).Item("ItemsCode"), Barc), "0.00")
                   Dgvsearch.Rows(RowIndex).Cells(4).Value = Format(GetDef_FullPriceBuy(Dt.Rows(0).Item("ItemsCode"), Barc), "0.00")
                   Dgvsearch.Rows(RowIndex).Cells(6).Value = "0.00"
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "1"
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "1"
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "2"
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "2"
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "3"
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "3"
                   Dgvsearch.Rows(RowIndex).Cells(14).Value = Dt.Rows(0).Item("CategorizationName")

                   Dgvsearch.Rows(RowIndex).Cells(7).Value = Format(Val(Dgvsearch.Rows(RowIndex).Cells(5).Value) * Val(Dgvsearch.Rows(RowIndex).Cells(3).Value), "0.00") - Format(Val(Dgvsearch.Rows(RowIndex).Cells(6).Value), "0.00")
                   'Dgvsearch.ClearSelection()
                   InvoiceBarcode.Text = ""
               End If
               CalcSalatax()
               Conn.Close()
           End If
EOS:
       Catch ex As Exception
           Conn.Close()
           MsgBox(ex.Message, vbCritical)
       End Try
الرد }}}
تم الشكر بواسطة:
#2
(08-09-21, 05:03 PM)tfarejdz كتب : السلام عليكم

اخواني الاعزاء :

هذا كود لإذراج المنتج عن طريق الباركود إلى قاعدة البيانات ، فهل يمكن تحويله الى تقنية الديف إكسربرس ، فإنني حاولت كثيرا ولم أستطع .

كود :
Try
           If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
               If Trim(InvoiceBarcode.Text) = "" Then Exit Sub
               For i = 0 To Dgvsearch.Rows.Count - 1
                   If Dgvsearch.Rows(i).Cells(9).Value = InvoiceBarcode.Text Then
                       Dgvsearch.Rows(i).Cells(5).Value += 1
                       Dgvsearch.Rows(i).Cells(7).Value = Val(Dgvsearch.Rows(i).Cells(5).Value) * Val(Dgvsearch.Rows(i).Cells(3).Value)
                       InvoiceBarcode.Text = Nothing
                       picBarcode.BackgroundImage = Nothing
                       CalcSalatax()
                       GoTo EOS
                   End If
               Next

               Dim Sql = ""
               Dim Barc = ""
               If GetFieldName("FirstUnitBarcode") = True Then
                   Sql = "select * from Items where FirstUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 1
               ElseIf GetFieldName("SecondUnitBarcode") = True Then
                   Sql = "select * from Items where SecondUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 2
               ElseIf GetFieldName("ThirdUnitBarcode") = True Then
                   Sql = "select * from Items where ThirdUnitBarcode=N'" & InvoiceBarcode.Text.Trim & "'"
                   Barc = 3
               Else
                   GoTo EOS
               End If
               Dim x = Split(GetDef_UnitAndPriceBuy(itmcod), "|")
               If Conn.State = 1 Then Conn.Close()
               Conn.Open()
               Dim Adp As New SqlClient.SqlDataAdapter(Sql, Conn)
               Dim Ds = New DataSet
               Adp.Fill(Ds)
               Dim Dt = Ds.Tables(0)
               If Dt.Rows.Count > 0 Then
                   Dgvsearch.ClearSelection()
                   Dgvsearch.Rows.Add()
                   Dim RowIndex = Dgvsearch.Rows.Count - 1
                   Dgvsearch.Rows(RowIndex).Selected = True
                   Dgvsearch.Rows(RowIndex).Cells(0).Value = Dt.Rows(0).Item("ItemsCode")
                   Dgvsearch.Rows(RowIndex).Cells(1).Value = Dt.Rows(0).Item("ItemsName")
                   itmcod = Dgvsearch.CurrentRow.Cells(1).Value
                   Dgvsearch.Rows(RowIndex).Cells(9).Value = InvoiceBarcode.Text
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("FirstUnit")
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("SecondUnit")
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(2).Value = Dt.Rows(0).Item("ThirdUnit")
                   Dgvsearch.Rows(RowIndex).Cells(5).Value = 1
                   Dgvsearch.Rows(RowIndex).Cells(3).Value = Format(GetDef_FullPrice(Dt.Rows(0).Item("ItemsCode"), Barc), "0.00")
                   Dgvsearch.Rows(RowIndex).Cells(4).Value = Format(GetDef_FullPriceBuy(Dt.Rows(0).Item("ItemsCode"), Barc), "0.00")
                   Dgvsearch.Rows(RowIndex).Cells(6).Value = "0.00"
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "1"
                   If Barc = 1 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "1"
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "2"
                   If Barc = 2 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "2"
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(10).Value = "3"
                   If Barc = 3 Then Dgvsearch.Rows(RowIndex).Cells(11).Value = "3"
                   Dgvsearch.Rows(RowIndex).Cells(14).Value = Dt.Rows(0).Item("CategorizationName")

                   Dgvsearch.Rows(RowIndex).Cells(7).Value = Format(Val(Dgvsearch.Rows(RowIndex).Cells(5).Value) * Val(Dgvsearch.Rows(RowIndex).Cells(3).Value), "0.00") - Format(Val(Dgvsearch.Rows(RowIndex).Cells(6).Value), "0.00")
                   'Dgvsearch.ClearSelection()
                   InvoiceBarcode.Text = ""
               End If
               CalcSalatax()
               Conn.Close()
           End If
EOS:
       Catch ex As Exception
           Conn.Close()
           MsgBox(ex.Message, vbCritical)
       End Try
الرد }}}
تم الشكر بواسطة: Abody


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [سؤال] سؤال فى gridview habamix 0 1,339 21-02-21, 01:04 PM
آخر رد: habamix
Wink [سؤال] مشكله فى gridcontrol habamix 0 1,170 27-01-21, 12:24 PM
آخر رد: habamix
  تحويل كود نايف 2006 2 1,927 20-05-20, 04:30 AM
آخر رد: نايف 2006
  كيفية اضافة سطور فى Gridview ومنع التكرار ؟ gedo 0 1,673 09-11-19, 04:06 PM
آخر رد: gedo
  [سؤال] أداة GridControl واضافة اعمدة اللورد محمود 2 2,652 08-01-19, 12:20 AM
آخر رد: اللورد محمود
  تطبيق الاكواد على GridControl في DevExpress كريم جودي 2 3,072 30-11-18, 10:07 PM
آخر رد: كريم جودي
  تحويل(true/false) الى (accepted/refused) noway 0 1,754 27-01-17, 03:12 PM
آخر رد: noway

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم