begin process at 2012 02 13 00:19:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

VB.NET

 > CARNET TÉLÉPHONE AVEC ACCESS, LISTVIEW, OLEDB, COMMANDE SQL (AJOUT, MODIF ET SUPPRIMÉ), TRIE

CARNET TÉLÉPHONE AVEC ACCESS, LISTVIEW, OLEDB, COMMANDE SQL (AJOUT, MODIF ET SUPPRIMÉ), TRIE


 Information sur la source

Note :
7,5 / 10 - par 4 personnes
7,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :VB.NET Source .NET ( DotNet ) Niveau :Débutant Date de création :31/10/2004 Vu / téléchargé :11 302 / 1 708

Auteur : Creat

Ecrire un message privé
Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Un petit carnet d'adresse.  Je sais qu'il en existe plusieur, mais celui la fait appel à des commandes SQL pour faire l'ajout, modification et suppression de ligne dans la BD Access.

Si vous avez des commantaires ou des optimisation que vous pensez qu'il pourrait être fait.  Faites moi signe

Source

  • Private Sub cmdSupprime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSupprime.Click
  • Dim SQLString As String
  • Dim sNom As String, sPrenom As String, sTelephone As String
  • If iListViewPosition <> AucuneSelection Then
  • sNom = lvTelephone.Items(iListViewPosition).Text
  • sPrenom = lvTelephone.Items(iListViewPosition).SubItems(1).Text
  • sTelephone = lvTelephone.Items(iListViewPosition).SubItems(2).Text
  • SQLString = "DELETE DELETE FROM T_Iden " _
  • & "WHERE Nom = " & "'" & sNom & "'" _
  • & "AND Prenom = " & "'" & sPrenom & "'" _
  • & "AND Numero = " & "'" & sTelephone & "'"
  • ' On est pas obligé de définir c'est 3 variables on pourrait les mettre directement
  • ' dans SQLString comme ceci, mais c'est moins lisible:
  • 'SQLString = "DELETE DELETE FROM T_Iden " _
  • ' & "WHERE Nom = " & "'" & lvTelephone.Items(iListViewPosition).Text & "'" _
  • ' & "AND Prenom = " & "'" & lvTelephone.Items(iListViewPosition).SubItems(1).Text & "'" _
  • ' & "AND Numero = " & "'" & lvTelephone.Items(iListViewPosition).SubItems(2).Text & "'"
  • If AjouteModifLigne(SQLString) Then
  • lvTelephone.Items.RemoveAt(iListViewPosition)
  • End If
  • End If
  • End Sub
  • Private Sub cmdModif_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModif.Click
  • Dim SQLString As String = "UPDATE T_Iden SET Numero = '" _
  • & txtTelephone.Text.Trim & "' " & "WHERE Prenom = '" _
  • & txtPrenom.Text.Trim & "'"
  • If AjouteModifLigne(SQLString) Then
  • If AChangerValeur Then
  • ' Dans ce cas ci on met juste à jours la ligne Telephone
  • 'lvTelephone.Items(iListViewPosition).Text = txtNom.Text
  • 'lvTelephone.Items(iListViewPosition).SubItems(1).Text = txtPrenom.Text
  • lvTelephone.Items(iListViewPosition).SubItems(2).Text = txtTelephone.Text
  • End If
  • AChangerValeur = False ' La valeur ne peut plus être changé
  • End If
  • End Sub
  • Private Sub cmdAjout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAjout.Click
  • Dim LviItem As ListViewItem
  • Dim LsiSubItem As ListViewItem.ListViewSubItem
  • Dim SQLString As String
  • SQLString = "INSERT into T_Iden (Nom, Prenom, Numero) Values" _
  • & " ('" & txtNom.Text & "','" & txtPrenom.Text & "','" & txtTelephone.Text & "')"
  • If (txtNom.Text <> "") And (txtPrenom.Text <> "") Then
  • If AjouteModifLigne(SQLString) Then
  • LviItem = lvTelephone.Items.Add(txtNom.Text)
  • LsiSubItem = LviItem.SubItems.Add(txtPrenom.Text)
  • LsiSubItem = LviItem.SubItems.Add(txtTelephone.Text)
  • End If
  • End If
  • End Sub
  • Private Function AjouteModifLigne(ByVal SQLString As String) As Boolean
  • Dim objConnection As New OleDb.OleDbConnection(ConnString)
  • Try
  • objConnection.Open()
  • Dim objCommand As New OleDbCommand(SQLString, objConnection)
  • objCommand.ExecuteNonQuery()
  • objConnection.Close()
  • AjouteModifLigne = True
  • Catch ex As Exception
  • MsgBox(ex.ToString)
  • AjouteModifLigne = False
  • End Try
  • End Function
   Private Sub cmdSupprime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSupprime.Click
        Dim SQLString As String
        Dim sNom As String, sPrenom As String, sTelephone As String

        If iListViewPosition <> AucuneSelection Then
            sNom = lvTelephone.Items(iListViewPosition).Text
            sPrenom = lvTelephone.Items(iListViewPosition).SubItems(1).Text
            sTelephone = lvTelephone.Items(iListViewPosition).SubItems(2).Text

            SQLString = "DELETE DELETE FROM T_Iden " _
                    & "WHERE Nom = " & "'" & sNom & "'" _
                    & "AND Prenom = " & "'" & sPrenom & "'" _
                    & "AND Numero = " & "'" & sTelephone & "'"

            ' On est pas obligé de définir c'est 3 variables on pourrait les mettre directement
            ' dans SQLString comme ceci, mais c'est moins lisible:
            'SQLString = "DELETE DELETE FROM T_Iden " _
            '        & "WHERE Nom = " & "'" & lvTelephone.Items(iListViewPosition).Text & "'" _
            '        & "AND Prenom = " & "'" & lvTelephone.Items(iListViewPosition).SubItems(1).Text & "'" _
            '        & "AND Numero = " & "'" & lvTelephone.Items(iListViewPosition).SubItems(2).Text & "'"

            If AjouteModifLigne(SQLString) Then
                lvTelephone.Items.RemoveAt(iListViewPosition)
            End If
        End If
    End Sub

   Private Sub cmdModif_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModif.Click

        Dim SQLString As String = "UPDATE T_Iden SET Numero = '" _
                                & txtTelephone.Text.Trim & "' " & "WHERE Prenom = '" _
                                & txtPrenom.Text.Trim & "'"

        If AjouteModifLigne(SQLString) Then
            If AChangerValeur Then
                ' Dans ce cas ci on met juste à jours la ligne Telephone
                'lvTelephone.Items(iListViewPosition).Text = txtNom.Text
                'lvTelephone.Items(iListViewPosition).SubItems(1).Text = txtPrenom.Text
                lvTelephone.Items(iListViewPosition).SubItems(2).Text = txtTelephone.Text
            End If
            AChangerValeur = False ' La valeur ne peut plus être changé
        End If
    End Sub

    Private Sub cmdAjout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAjout.Click
        Dim LviItem As ListViewItem
        Dim LsiSubItem As ListViewItem.ListViewSubItem
        Dim SQLString As String

        SQLString = "INSERT into T_Iden (Nom, Prenom, Numero) Values" _
        & " ('" & txtNom.Text & "','" & txtPrenom.Text & "','" & txtTelephone.Text & "')"

        If (txtNom.Text <> "") And (txtPrenom.Text <> "") Then
            If AjouteModifLigne(SQLString) Then
                LviItem = lvTelephone.Items.Add(txtNom.Text)
                LsiSubItem = LviItem.SubItems.Add(txtPrenom.Text)
                LsiSubItem = LviItem.SubItems.Add(txtTelephone.Text)
            End If
        End If
    End Sub

    Private Function AjouteModifLigne(ByVal SQLString As String) As Boolean
        Dim objConnection As New OleDb.OleDbConnection(ConnString)

        Try
            objConnection.Open()
            Dim objCommand As New OleDbCommand(SQLString, objConnection)
            objCommand.ExecuteNonQuery()
            objConnection.Close()
            AjouteModifLigne = True
        Catch ex As Exception
            MsgBox(ex.ToString)
            AjouteModifLigne = False
        End Try
    End Function


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture Source .NET (Dotnet) LIGNE 3D
Source avec Zip Source avec une capture Source .NET (Dotnet) GESTION DE CD AVEC MS ACCESS, (AJOUT, MODIF ET SUPPRIME AVEC...
Source avec Zip Source avec une capture Source .NET (Dotnet) CALCUL DE DATE PAR UN INTERVAL DE SEMAINE

 Sources de la même categorie

Source .NET (Dotnet) MODIFICATION DATE DE WINDOWS EN VB.NET ET VBA par us_30
Source avec Zip Source avec une capture Source .NET (Dotnet) ENVOI DE MAIL AVEC PIÈCE JOINTE par EhJoe
Source .NET (Dotnet) AMUSONS NOUS AVEC UN LABEL ^^ par Adn56
Source avec Zip Source avec une capture Source .NET (Dotnet) UN NAVIGATEUR INTERNET EN VB.NET par azrti
Source avec Zip Source .NET (Dotnet) CONVERSION DE DEVISE MONAITAIRE VIA UN SERVICE WEB par bigmonkey7

Commentaires et avis

Commentaire de dionysos6868 le 31/10/2004 13:39:16

Sans vouloir etre mechant comme tu dit il en existe plusieur donc pourquoi l'avoir fait aussi simple .

tu aurais pu faire une fichier détail pour avoir le détail d'un contact:
nom
prenom
adresse perso
adresse bureau
mail
tel prive
tel bureau
portable
site perso
site professionel
commentaire
photo
...etc

autant en faire un complet ;)

Commentaire de Creat le 31/10/2004 17:04:03

C'est fort simple le pourquoi que je l'ai comme ceci.  Ce programme s'adresse à des débutants comme moi.  Je pense qu'une fois tu as une idée de la base faire l'adaptation pour ce que l'on veux est très simple.  

Mais j'en prend bonne note.

Merci

Commentaire de lobrys le 02/11/2004 09:16:31

alors là, je pose une question :
qu'est ce qui est le plus "best practise"?

function HelloWorld() as string
  return "Hello World!"
End Function

ou

function HelloWorld() as string
  HelloWorld = "Hello World!"
End Function

Commentaire de lex1111 le 19/11/2006 12:28:47

Niquel exactement ce que je cherche.
Comme quoi meme après 2 ans les codes sources sont encore utiles !!

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,702 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales