تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[كود] ممكن شرح بعض الاكواد
#1
السلام عليكم
ممكن شرح هذه الاكود
اولا موديول
كود :
Imports System.Data
Imports System.Data.OleDb
Imports System.Management

Module btlanmdule
    'Public ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\sys322.dll;Persist Security Info=True;Jet OLEDB:Database Password=omar911"
    Public ConStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\sys744.dll;Jet OLEDB:Database Password=omar911"
    Public Conn As New OleDbConnection(ConStr)
    Public AccountDataSet1 As New DataSet 'tre
    Public AccountDataSet2 As New DataSet  'low5
    Public AccountDataSet3 As New DataSet  'low6
    Public AccountDataSet4 As New DataSet  'sharh
    Public SQLstr As String = "SELECT * FROM tre"



    Public countword As Integer = 0
    Public countprint As Integer = 0


  Public searchresults As New ArrayList
    Public position As Integer = 0
    Public Function FindInternal(ByVal key As String, ByVal searchAllChildren As Boolean, ByVal treeNodeCollectionToLookIn As TreeNodeCollection, ByVal foundTreeNodes As ArrayList) As ArrayList
        If ((treeNodeCollectionToLookIn Is Nothing) OrElse (foundTreeNodes Is Nothing)) Then
            Return Nothing
        End If
        Dim i As Integer
        For i = 0 To treeNodeCollectionToLookIn.Count - 1
            If ((Not treeNodeCollectionToLookIn.Item(i) Is Nothing) AndAlso SafeCompareStrings(treeNodeCollectionToLookIn.Item(i).Text, key, True)) Then
                foundTreeNodes.Add(treeNodeCollectionToLookIn.Item(i))
            End If
        Next i
        If searchAllChildren Then
            Dim j As Integer
            For j = 0 To treeNodeCollectionToLookIn.Count - 1
                If (((Not treeNodeCollectionToLookIn.Item(j) Is Nothing) AndAlso (Not treeNodeCollectionToLookIn.Item(j).Nodes Is Nothing)) AndAlso (treeNodeCollectionToLookIn.Item(j).Nodes.Count > 0)) Then
                    foundTreeNodes = FindInternal(key, searchAllChildren, treeNodeCollectionToLookIn.Item(j).Nodes, foundTreeNodes)
                End If
            Next j
        End If
        Return foundTreeNodes
    End Function
    Public Function SafeCompareStrings(ByVal string1 As String, ByVal string2 As String, ByVal ignoreCase As Boolean) As Boolean
        If ((string1 Is Nothing) OrElse (string2 Is Nothing)) Then
            Return False
        End If
        Return ((string1.ToLower.Contains(string2.ToLower)))
    End Function

End Module



الفورم

كود :
Imports System.Data.OleDb
Imports System.Data
Public Class btlan_tree
    Dim WithEvents oBinding As Binding
    Dim WithEvents oBinding3 As Binding
    Dim WithEvents oBinding4 As Binding
  
    Private Sub oBinding_Format(ByVal sender As Object, ByVal e As System.Windows.Forms.ConvertEventArgs) Handles oBinding.Format
        On Error Resume Next
        If Not e.Value = Nothing Then e.Value = Decrypt(e.Value, True)
    End Sub

    Private Sub treemain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            '   RichTextBox1.ForeColor = My.Settings.rtf1colorfontdefult
            ' RichTextBox1.Font = My.Settings.rtf1font
            '  RichTextBox1.BackColor = My.Settings.rtf1backcolor

            ''''''''''''''''

            ''''''''''''''''''
            '      TreeView1.ForeColor = My.Settings.treforcolor
            'TreeView1.BackColor = My.Settings.trebackcolor
            '   TreeView1.Font = My.Settings.trefont

            Dim datab1 As New OleDbDataAdapter(SQLstr, ConStr)
            AccountDataSet1.Clear()
            datab1.Fill(AccountDataSet1, "tre")
            '      Me.BindingContext(AccountDataSet1, "tre").Position = 0


            CreateTree()
            Application.DoEvents()


            searchresults.Clear()
            searchresults = FindInternal("تعريــف البطــلان", True, TreeView1.Nodes, New ArrayList)
            If position > searchresults.Count - 1 Then position = 0 : Return
            TreeView1.SelectedNode = searchresults(position)
            TreeView1.Focus()

            '    Me.BindingContext(AccountDataSet1, "tre").Position = 4
            oBinding = New Binding("Text", AccountDataSet2, "low5.text")

            RichTextBox1.DataBindings.Add(oBinding)


            RichTextBox1.Refresh()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub CreateTree()
        Try

            TreeView1.BeginUpdate()
            TreeView1.Nodes.Clear()

            Dim MainHeader As New TreeNode(Me.Text)

            MainHeader.Tag = "0_"
            MainHeader.Name = "0_"
            '  MainHeader.ForeColor = Color.Red
            TreeView1.Nodes.Add(MainHeader)

            AddSubNode(MainHeader)

            TreeView1.EndUpdate()
            Application.DoEvents()

            TreeView1.Visible = False
            TreeView1.ExpandAll()
            TreeView1.Visible = True

            TreeView1.Select()
            ''  searchresults.Clear()
            ''  searchresults = FindInternal("1", True, TreeView1.Nodes, New ArrayList)
            ''  If position > searchresults.Count - 1 Then position = 0 : Return
            ''  TreeView1.SelectedNode = searchresults(position)
            ''  TreeView1.Focus()
            RichTextBox1.Refresh()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub AddSubNode(ByVal Node As TreeNode)
        Try

            Dim dv1 As DataView = AccountDataSet1.Tables("tre").DefaultView

            dv1.RowFilter = "parentkey ='" & CType(Node.Tag, String) & "'"
            dv1.Sort = "id ASC"



            For Each drLine As DataRowView In dv1

                Dim SubNode As New TreeNode(drLine("titel"))
                '    SubNode.ForeColor = Color.Black
                SubNode.Tag = drLine("key").ToString
                SubNode.Name = drLine("key").ToString
                SubNode.ImageIndex = CType(drLine("image"), Integer)
                SubNode.SelectedImageIndex = CType(drLine("imageselect"), Integer)
                Node.Nodes.Add(SubNode)
                Application.DoEvents()
                If Not CType(Node.Tag, String) Is String.Empty Then

                    AddSubNode(SubNode)

                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Try

            If e.Node.GetNodeCount(True) Then Exit Sub

            Dim datab2 As New OleDbDataAdapter("SELECT * FROM low5 where key = '" & e.Node.Name & "'", ConStr)
            AccountDataSet2.Clear()
            datab2.Fill(AccountDataSet2, "low5")

            If SplitContainer1.Panel1Collapsed = True Then
                SplitContainer1.Panel1Collapsed = False
                ToolStripButton5.Text = "توسيع مساحة عرض الفهرس"
                '      ToolStripButton5.Image = My.Resources.previous_set_2
            End If

            If ToolStripTextBox1.Text.Trim <> "" Then
                findrtf(RichTextBox1, ToolStripTextBox1.Text)
                AccountDataSet2.RejectChanges()
            End If


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


هذا المشروع
عبارة عن عرض البيانات فى treeview باستخدام ado لاكن ممكن احد يشرحلى الاكواد او تبسيط الاكواد بحيث استغنى عن الموديول
الرد }}}
تم الشكر بواسطة:
#2
لا اعتقد انك تريد شرح كل هذا الكود حدد اكواد خاصه اذا لم تفهمها ليتم شرحها لك اخي ... لان هذه الاكواد كثيره



[صورة مرفقة: g5qidgW.jpg]

ســبحــانك الـلهم بـحمدك , الـلهم لا عــلم لـنا الى مــأ علــمتــنا , الـلهـم علــمنـا ما جــهلـنا وانــفـعنــا بــما عــلمــتنـا انــك انـتَ الـسـميع الــعلــيم الـحكـيم ~~!I!

الرد }}}
تم الشكر بواسطة:
#3
اول الموديو
========

Imports System.Data
Imports System.Data.OleDb
Imports System.Management

هذه دوال يتم استيرادها من خلال الفيجول
===============================

ublic ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\sys322.dll;Persist Security Info=True;Jet OLEDBBig Grinatabase Password=omar911"

هذا الكونكشن استرينج للاتصال بقاعدة البيانات

==========================================================

Public Conn As New OleDbConnection(ConStr)
Public AccountDataSet1 As New DataSet 'tre
Public AccountDataSet2 As New DataSet 'low5
Public AccountDataSet3 As New DataSet 'low6
Public AccountDataSet4 As New DataSet 'sharh
Public SQLstr As String = "SELECT * FROM tre"

ما فهمته من هذا الكود انه بيفتح الجداول التى فى قاعدة البيانات
اسماء الجداول ( tre,low5,low6,sharh )

AccountDataSet ما فهمته ان هذا متغير اسنده 4 مرات لل dataset

ما المقصود بdataset ???
===============================================
Public SQLstr As String = "SELECT * FROM tre"

ما المقصود بهذا الكود ؟ هل يفتح جدول tre ?? لماذا استخدم sql بارغم انه معرف فى التصريح System.Data.OleDb
=================================
Public searchresults As New ArrayList
Public position As Integer = 0

هذا الكود لم افهمه ؟؟

============================

وهذه الدالة ايضا

Public Function FindInternal(ByVal key As String, ByVal searchAllChildren As Boolean, ByVal treeNodeCollectionToLookIn As TreeNodeCollection, ByVal foundTreeNodes As ArrayList) As ArrayList
If ((treeNodeCollectionToLookIn Is Nothing) OrElse (foundTreeNodes Is Nothing)) Then
Return Nothing
End If
Dim i As Integer
For i = 0 To treeNodeCollectionToLookIn.Count - 1
If ((Not treeNodeCollectionToLookIn.Item(i) Is Nothing) AndAlso SafeCompareStrings(treeNodeCollectionToLookIn.Item(i).Text, key, True)) Then
foundTreeNodes.Add(treeNodeCollectionToLookIn.Item(i))
End If
Next i
If searchAllChildren Then
Dim j As Integer
For j = 0 To treeNodeCollectionToLookIn.Count - 1
If (((Not treeNodeCollectionToLookIn.Item(j) Is Nothing) AndAlso (Not treeNodeCollectionToLookIn.Item(j).Nodes Is Nothing)) AndAlso (treeNodeCollectionToLookIn.Item(j).Nodes.Count > 0)) Then
foundTreeNodes = FindInternal(key, searchAllChildren, treeNodeCollectionToLookIn.Item(j).Nodes, foundTreeNodes)
End If
Next j
End If
Return foundTreeNodes
End Function


===================

وهذه

Public Function SafeCompareStrings(ByVal string1 As String, ByVal string2 As String, ByVal ignoreCase As Boolean) As Boolean
If ((string1 Is Nothing) OrElse (string2 Is Nothing)) Then
Return False
End If
Return ((string1.ToLower.Contains(string2.ToLower)))
End Function

End Module

====================================
الرد }}}
تم الشكر بواسطة:
#4
ثانيا الفورم
======
ما معنى هذا الكود
Dim WithEvents oBinding As Binding
Dim WithEvents oBinding3 As Binding
Dim WithEvents oBinding4 As Binding
ما هو Binding ؟؟؟؟
=============================================
Private Sub oBinding_Format(ByVal sender As Object, ByVal e As System.Windows.Forms.ConvertEventArgs) Handles oBinding.Format
On Error Resume Next
If Not e.Value = Nothing Then e.Value = Decrypt(e.Value, True)
End Sub

ماهو oBinding.Format ؟؟

===================================================
مهم جدا

Dim datab1 As New OleDbDataAdapter(SQLstr, ConStr)
AccountDataSet1.Clear()
datab1.Fill(AccountDataSet1, "tre")
' Me.BindingContext(AccountDataSet1, "tre").Position = 0

هذه الكود متعلق بعرض الدتا بيز , لاكن لم افهمه ياريت احد يساعدنى ؟؟

========================================================

' Me.BindingContext(AccountDataSet1, "tre").Position = 4
oBinding = New Binding("Text", AccountDataSet2, "low5.text")

RichTextBox1.DataBindings.Add(oBinding)

وهذا ايضا

==================================


Dim dv1 As DataView = AccountDataSet1.Tables("tre").DefaultView

dv1.RowFilter = "parentkey ='" & CType(Node.Tag, String) & "'"
dv1.Sort = "id ASC"



For Each drLine As DataRowView In dv1

Dim SubNode As New TreeNode(drLine("titel"))
' SubNode.ForeColor = Color.Black
SubNode.Tag = drLine("key").ToString
SubNode.Name = drLine("key").ToString
SubNode.ImageIndex = CType(drLine("image"), Integer)
SubNode.SelectedImageIndex = CType(drLine("imageselect"), Integer)
Node.Nodes.Add(SubNode)
Application.DoEvents()
If Not CType(Node.Tag, String) Is String.Empty Then

AddSubNode(SubNode)

End If
Next


=================================================



Dim dv1 As DataView = AccountDataSet1.Tables("tre").DefaultView

dv1.RowFilter = "parentkey ='" & CType(Node.Tag, String) & "'"
dv1.Sort = "id ASC"



For Each drLine As DataRowView In dv1

Dim SubNode As New TreeNode(drLine("titel"))
' SubNode.ForeColor = Color.Black
SubNode.Tag = drLine("key").ToString
SubNode.Name = drLine("key").ToString
SubNode.ImageIndex = CType(drLine("image"), Integer)
SubNode.SelectedImageIndex = CType(drLine("imageselect"), Integer)
Node.Nodes.Add(SubNode)
Application.DoEvents()
If Not CType(Node.Tag, String) Is String.Empty Then

AddSubNode(SubNode)

End If
Next
=================================
هذا الكود لملأ TREEVIEW من قاعدة البيانات

ماهى DataView ؟


dv1.RowFilter = "parentkey ='" & CType(Node.Tag, String) & "'"
dv1.Sort = "id ASC"

parentkey = حقل فى جدول TREE
الرد }}}
تم الشكر بواسطة:
#5
إقتباس :ما المقصود بdataset ???

http://www.dotnetperls.com/dataset-vbnet

إقتباس :ما المقصود بهذا الكود ؟ هل يفتح جدول tre ?? لماذا استخدم sql بارغم انه معرف فى التصريح System.Data.OleDb

نعم افتح جدول tre يجب عن استخدام هذا الاستعلام لاختيار الجدول ...

إقتباس :Public searchresults As New ArrayList
Public position As Integer = 0

عرف على مصفوفه جديده في متغير searchresults
وعرف عن postion واعطاه قيمه 0





إقتباس :Public Function FindInternal(ByVal key As String, ByVal searchAllChildren As Boolean, ByVal treeNodeCollectionToLookIn As TreeNodeCollection, ByVal foundTreeNodes As ArrayList) As ArrayList
If ((treeNodeCollectionToLookIn Is Nothing) OrElse (foundTreeNodes Is Nothing)) Then
Return Nothing
End If
Dim i As Integer
For i = 0 To treeNodeCollectionToLookIn.Count - 1
If ((Not treeNodeCollectionToLookIn.Item(i) Is Nothing) AndAlso SafeCompareStrings(treeNodeCollectionToLookIn.Item(i).Text, key, True)) Then
foundTreeNodes.Add(treeNodeCollectionToLookIn.Item(i))
End If
Next i
If searchAllChildren Then
Dim j As Integer
For j = 0 To treeNodeCollectionToLookIn.Count - 1
If (((Not treeNodeCollectionToLookIn.Item(j) Is Nothing) AndAlso (Not treeNodeCollectionToLookIn.Item(j).Nodes Is Nothing)) AndAlso (treeNodeCollectionToLookIn.Item(j).Nodes.Count > 0)) Then
foundTreeNodes = FindInternal(key, searchAllChildren, treeNodeCollectionToLookIn.Item(j).Nodes, foundTreeNodes)
End If
Next j
End If
Return foundTreeNodes
End Function
اعتقد بان هذا الكود لملأ اداه tree اي الشجره لعرض IItems


إقتباس :Public Function SafeCompareStrings(ByVal string1 As String, ByVal string2 As String, ByVal ignoreCase As Boolean) As Boolean
If ((string1 Is Nothing) OrElse (string2 Is Nothing)) Then
Return False
End If
Return ((string1.ToLower.Contains(string2.ToLower)))
End Function




هذا الداله اعتقد بانها تعيد اعتقد انها لتحويل الاحرف من صغير الى كبيـر مع ارسال القيمه والله اعلم ....
انا لست محتـرف ولكن حـاولت ... ان شاء الله يجــوك الشباب يفــهموك اكثـر



[صورة مرفقة: g5qidgW.jpg]

ســبحــانك الـلهم بـحمدك , الـلهم لا عــلم لـنا الى مــأ علــمتــنا , الـلهـم علــمنـا ما جــهلـنا وانــفـعنــا بــما عــلمــتنـا انــك انـتَ الـسـميع الــعلــيم الـحكـيم ~~!I!

الرد }}}
تم الشكر بواسطة:



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


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