27-01-18, 07:39 PM
انا استعملت هذا الكود وموجود فيه اسماء الحقول الكود شغال خارج الداتا قرايد فيو لكن مع الاداة ما زبطش وصار مشكلة بطء شديد في عرض البيانات
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells(10).Value = "نعم" Then
' Me.DGV_acounts.Rows(i).Cells(6).Style.ForeColor = Color.Red
Dim cmd As New SqlClient.SqlCommand
Dim DR_units As SqlClient.SqlDataReader
Dim MySqlSreach As String
MySqlSreach = " Select sum(storedetail.q3) as x4 ,sum(storedetail.q4)as x5 ,(sum(storedetail.q3)-sum(storedetail.q4))as x6 From units LEFT JOIN storedetail ON units.itemnum = storedetail.itemnum where units.maingroup ='" & DataGridView1.CurrentRow.Cells(0).Value & "' group by units.maingroup" ''" & DataGridView1.CurrentRow.Cells(0).Value & "' group by units.maingroup " ',storedetail.active order by x6 "
' Try
If Con.State = ConnectionState.Open Then Con.Close()
Con.Open()
cmd.Connection = Con
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = MySqlSreach
DR_units = cmd.ExecuteReader
DR_units.Read()
If DR_units.HasRows Then
DataGridView1.CurrentRow.Cells(3).Value = DR_units("x6").ToString
' MessageBox.Show(DR_units("x6").ToString)
DR_units.Close()
Else
DR_units.Close()
' MsgBox(" عفواً . لا يوجد بيانات ", MsgBoxStyle.Information)
End If
' Catch ex As Exception
' MessageBox.Show(ex.Message)
' Con.Close()
' End Try
Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Yellow
End If
Next
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells(10).Value = "نعم" Then
' Me.DGV_acounts.Rows(i).Cells(6).Style.ForeColor = Color.Red
Dim cmd As New SqlClient.SqlCommand
Dim DR_units As SqlClient.SqlDataReader
Dim MySqlSreach As String
MySqlSreach = " Select sum(storedetail.q3) as x4 ,sum(storedetail.q4)as x5 ,(sum(storedetail.q3)-sum(storedetail.q4))as x6 From units LEFT JOIN storedetail ON units.itemnum = storedetail.itemnum where units.maingroup ='" & DataGridView1.CurrentRow.Cells(0).Value & "' group by units.maingroup" ''" & DataGridView1.CurrentRow.Cells(0).Value & "' group by units.maingroup " ',storedetail.active order by x6 "
' Try
If Con.State = ConnectionState.Open Then Con.Close()
Con.Open()
cmd.Connection = Con
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = MySqlSreach
DR_units = cmd.ExecuteReader
DR_units.Read()
If DR_units.HasRows Then
DataGridView1.CurrentRow.Cells(3).Value = DR_units("x6").ToString
' MessageBox.Show(DR_units("x6").ToString)
DR_units.Close()
Else
DR_units.Close()
' MsgBox(" عفواً . لا يوجد بيانات ", MsgBoxStyle.Information)
End If
' Catch ex As Exception
' MessageBox.Show(ex.Message)
' Con.Close()
' End Try
Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Yellow
End If
Next
