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

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغات البرمجة الاخرى (http://vb4arb.com/vb/forumdisplay.php?fid=4)
+--- قسم : تقنية البرمجة Dev Express (http://vb4arb.com/vb/forumdisplay.php?fid=201)
+---- قسم : اسئلة تقنية البرمجة Dev Express (http://vb4arb.com/vb/forumdisplay.php?fid=203)
+---- الموضوع : تحويل كود من GRIDVIEW الى GRIDCONTROL (/showthread.php?tid=39475)



تحويل كود من GRIDVIEW الى GRIDCONTROL - tfarejdz - 08-09-21

السلام عليكم

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

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

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



RE: تحويل كود من GRIDVIEW الى GRIDCONTROL - tfarejdz - 11-09-21

(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