Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to copy a term(node) in a treeview

Status
Not open for further replies.

curiousvbnet

Programmer
Apr 6, 2007
40
FR
Hi,

I have created a treeview called TreeView1.
this treeview contains terms.
I would like to permit a user to copy one term at another place in the treeview.

Until now i did not succed to.


All the terms are in a table called TERMES

All the relationships parent/child are in a table called GENERIQUES which fields are :
ID_TERME_SOURCE_G( child field), ID_TERME_GENERIQUE( parent field)

More over in this table there is the field TV_LOC( treeview location) which is the index of the term(id_terme_source_g) in the treeview.

Here is untils now the code i use to add a terme which already exists

Code:
 [blue] strSQLTERMES = "SELECT ID_TERME, Lib_TERME FROM TERMES  where ID_THES = " & intNumThes.ToString & " ORDER BY Lib_TERME;"[/blue]


objDS.Tables("TERMES").Clear()
                objDA = New SqlDataAdapter(strSQLTERMES, objConn)
                objDA.Fill(objDS, "TERMES")
Dim termeexiste as boolean
termeexiste = True
                      [green]  ' if the user says he wants to reuse this term with all its childs , then create a new relationshiop parent/child ; the new parent will be the term above in the treeview[/green]
                       
                        ident_terme_source_g = CType(drTerme.Item("ID_TERME"), Integer)

                                                    
                            
                        If MessageBox.Show("this term already exists in the thesaurus, do you want to insert it again woith all its childs?", "Add a new term", MessageBoxButtons.YesNoCancel) = DialogResult.Yes Then

                          [green]  'we add 1 to the  TV_LOC1 value[/green] 
  Dim tmpSQLCommand As String
  Dim tmpResetTV_LOC1 As SqlCommand
  tmpSQLCommand = "UPDATE GENERIQUES SET TV_LOC1 = TV_LOC1 + 1 WHERE ID_TERME_GENERIQUE = " & iParentID.ToString & " AND TV_LOC1 >= " & n.Index.ToString

 tmpResetTV_LOC1 = New SqlCommand(tmpSQLCommand, objConn)
 'on ouvre la connexion
                            objConn.Open()
  tmpResetTV_LOC1.ExecuteNonQuery()
  tmpResetTV_LOC1.Dispose()


[green]' Update the GENERIQUES table[/green]
                            strSQLInsertGeneriqueTermerepete = "INSERT INTO GENERIQUES( ID_TERME_SOURCE_G , ID_TERME_GENERIQUE, TV_LOC1 ) VALUES( " + ident_terme_source_g.ToString + " , " + iParentID.ToString + " , " & n.Index.ToString & " )"

objinsertgeneriquetermerepete = New SqlCommand(strSQLInsertGeneriqueTermerepete, objConn)
                            objinsertgeneriquetermerepete.ExecuteNonQuery()
                          [green]  'we close the connection[/green]
                            objConn.Close()


                            Exit For
                        Else [green]'if the user has clicked on the the 'cancel' button or 'no' button [/green]

                            Exit Sub
                        End If 


                    End If 'fin de If strLibelle.ToLower = CType(drTerme.Item("Lib_TERME"), String) 

                Next

If you could help me on this point it would be very kind from you because it makes such a long time i don't succed to copy correctly a term in the treeview.

Best Regards

Nathalie

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top