30-04-25, 12:49 AM
هذا الكود شيبني؛ لا أدري هل أنا لم ألحظ الخطأ الذي وقعت فيه
أم أن الكود يحتاج إلى إعادة صياغة
المشكلة تكمن في تكرار رسالة التنبيـه في حالة عدم وجـود مواد دور ثان
الكود التالي نجح في عدم تكرار الرسالة؛ لكن ليس منطقياً أن تظهر الرسالة مرة واحدة فقط
أنا أريده أن تظهر كلما اخترت مادة الكومبوكس في حالـة ولا يوجد طلبـة لهم دور ثان
الكود يحتاج إلى تعديل
أم أن الكود يحتاج إلى إعادة صياغة
المشكلة تكمن في تكرار رسالة التنبيـه في حالة عدم وجـود مواد دور ثان
الكود التالي نجح في عدم تكرار الرسالة؛ لكن ليس منطقياً أن تظهر الرسالة مرة واحدة فقط
أنا أريده أن تظهر كلما اخترت مادة الكومبوكس في حالـة ولا يوجد طلبـة لهم دور ثان
الكود يحتاج إلى تعديل
كود :
' استدعاء درجـات مواد الدور التكميلي
Dim messageShown As Boolean = False
Private Sub Student_Courses()
DataGridView1.DataSource = Nothing
DataGridView1.Rows.Clear()
DataGridView1.Refresh()
' استدع الدرجـات حسب الفصل والقسم الدراسي التابع له وحسب رقم الامتحـان
Try
Dim arrListQuery As New ArrayList
For i As Integer = 0 To Form_main.ListBoxClas.Items.Count - 1
If Form_main.ListBoxClas.GetSelected(i) Then
arrListQuery.Add( _
"SELECT TBL_Students.StudentID, TBL_Students.StudentName, TBL_Students.ClassID,TBL_Students.ClassroomID " & _
", TBL_Final1.SemesterID as [رقم الامتحــان]" & _
", TBL_Final1.on" & CombCourses.SelectedIndex + 1 & " as [أعمـال] " & _
", TBL_Final1.to" & CombCourses.SelectedIndex + 1 & " as [امتحـان] " & _
", TBL_Final1.tr" & CombCourses.SelectedIndex + 1 & " as [دور ثان] " & _
"FROM TBL_Final1 RIGHT JOIN TBL_Students ON TBL_Final1.StudentID=TBL_Students.StudentID " & _
"Where TBL_Final1.ClassID=" & CInt(i + 1).ToString() & " and TBL_Final1.ClassroomID=" & Combroom.SelectedIndex + 1 & " and TBL_Final1.SemesterID=2" & " and TBL_Final1.tr" & CombCourses.SelectedIndex + 1 & " < 50" & " and TBL_Final1.result LIKE 'دور ثان" & "' ")
End If
Next
Dim da As OleDb.OleDbDataAdapter = New OleDbDataAdapter(Nothing, Con)
Dim ds As New DataSet
For i As Integer = 0 To arrListQuery.Count - 1
If Not IsNothing(arrListQuery(i)) Then
da.SelectCommand.CommandText = arrListQuery(i).ToString
da.Fill(ds, "Student")
End If
Next
If ds.Tables("Student").Rows.Count > 0 Then
DataGridView1.DataSource = ds.Tables("Student")
FillDataGrid()
' بعد تحميل البيانات، نمر على الصفوف لتحديث الأعمدة5 و 6 و7 و8
For Each row As DataGridViewRow In DataGridView1.Rows
If Not row.IsNewRow Then
' العمود 5
If row.Cells(5).Value Is Nothing OrElse IsNullOrWhiteSpace(row.Cells(5).Value.ToString()) OrElse row.Cells(5).Value.ToString() = "0" Then
row.Cells(5).Value = 0
End If
' العمود 6
If row.Cells(6).Value Is Nothing OrElse IsNullOrWhiteSpace(row.Cells(6).Value.ToString()) OrElse row.Cells(6).Value.ToString() = "0" Then
row.Cells(6).Value = 0
End If
' العمود 7
If row.Cells(7).Value Is Nothing OrElse IsNullOrWhiteSpace(row.Cells(7).Value.ToString()) OrElse row.Cells(7).Value.ToString() = "0" Then
row.Cells(7).Value = 0
End If
End If
Next
Me.Texttotal.Text = " درجات مـادة" & " " & Me.CombCourses.Text & " - لـ " & Form_main.ListBoxClas.Text & " " & ""
messageShown = False
Else
'If Not messageShown Then
MessageBox.Show("عفـــواً ... لا يوجــد طلبــة لهم دور ثان ", "تنبيــه", MessageBoxButtons.OK, MessageBoxIcon.Information)
messageShown = True
End If
End If
Catch ex As Exception
' MessageBox.Show("حدث خطأ أثناء تحميل البيانات: " & ex.Message, "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
إذا طُعِنتَ من الخلفِ فاعلمْ أنك في المقدمةِ

