Imports System.Xml
Imports Application_Windows_Thesaurus.TreeView_MT_GEN_SPE_ASSOCIES
Public Class candidat_descripteur
Inherits System.Windows.Forms.Form
Private m_objConn As SqlConnection
Private objDS6 As DataSet
Private objDA6 As SqlDataAdapter
Public WriteOnly Property Connection() As SqlConnection
Set(ByVal Value As SqlConnection)
m_objConn = Value
End Set
End Property
[blue] Private Sub Enreg_cd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enreg_cd.Click[/blue]
Dim strInsert_cd As String, objInsertNew_cd As SqlCommand, strSQLTERMES_Cd As String, drTerme As DataRow
Dim termecd_existe As Boolean
[green] strSQLTERMES_Cd = "SELECT Lib_CD from CANDIDAT_DESCRIPTEUR"
strInsert_cd = "INSERT into CANDIDAT_DESCRIPTEUR(Lib_CD) values ('"
strInsert_cd &= Replace(txtbox_cd.Text, "'", "''") & "')"[/green)
'we verify the term does not already exist in the candidat_descripteur table
objDS6 = New DataSet
objDA6 = New SqlDataAdapter(strSQLTERMES_Cd, m_objConn)
objDA6.Fill(objDS6, "TERMES_CD")
For Each drTerme In objDS6.Tables("TERMES_CD").Rows
Dim strLibelle5, strLibelle6 As String
strLibelle5 = Replace(txtbox_cd.Text, " ", "")
strLibelle6 = Replace(strLibelle5, "-", "")
Dim libterme5, libterme6 As String
libterme5 = Replace((CType(drTerme.Item("Lib_CD"), String).ToUpper), " ", "")
libterme6 = Replace(libterme5, "-", "")
If SansAccent(strLibelle6.ToUpper) = SansAccent(libterme6) Then
[blue] termecd_existe = True[/blue]
MessageBox.Show("ce terme candidat descripteur existe déjà dans la table des candidats descripteurs, vous ne pouvez pas le réinsérer", "insertion d'un terme candidat descripteur", MessageBoxButtons.OK)
txtbox_cd.Text = ""
Exit For
Exit Sub
End If
Next
If termecd_existe = False Then
m_objConn.Open()
objInsertNew_cd = New SqlCommand(strInsert_cd, m_objConn)
objInsertNew_cd.ExecuteNonQuery()
m_objConn.Close()
MessageBox.Show("le terme candidat descripteur '" & txtbox_cd.Text.TrimEnd & "' a bien été ajouté à la table des termes candidats descripteurs", "ajout d'un terme candidat descripteur", MessageBoxButtons.OK)
txtbox_cd.Text = ""
End If
End Sub