je possède le code de ces méthodes en vb.net je veux juste savoir comment traduire ce code en c#
je suis encore débutant au niveau de la programmation c#
merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 #Region "MAJ Base" 'Méthode Ajouter Public Function Ajouter() As Boolean 'Déclaration de la variable SqlCommand Dim Cmd As SqlCommand = New SqlCommand Try With Cmd 'Affectation des paramètres de la variable SqlCommand .CommandType = CommandType.Text .Connection = ClApplication.Cn 'Exécution de la requète Ajouter .CommandText = "INSERT INTO [dbo].[Responsable]([Numero_CIN], [Nom], [Prenom]) VALUES ('" & m_Numero_CIN & "', '" & m_Nom & "', '" & m_Prenom & "')" If .ExecuteNonQuery <> 0 Then Return True End If End With Catch ex As Exception MsgBox(Err.Description) Return False Finally End Try End Function 'Méthode Modifier Public Function Modifier() As Boolean 'Déclaration de la variable SqlCommand Dim Cmd As SqlCommand = New SqlCommand Try With Cmd 'Affectation des paramètres de la variable SqlCommand .CommandType = CommandType.Text .Connection = ClApplication.Cn .CommandText = "UPDATE [dbo].[Responsable] SET [Nom]='" & m_Nom & "', [Prenom]='" & m_Prenom & "' WHERE [Numero_CIN] = '" & m_Numero_CIN & "'" 'Exécution de la requète Modifier If .ExecuteNonQuery <> 0 Then Return True End If End With Catch ex As Exception 'Traitement de l'erreur MsgBox(Err.Description) Return False Finally End Try End Function 'Méthode Supprimer Public Function Supprimer() As Boolean 'Déclaration de la variable SqlCommand Dim Cmd As SqlCommand = New SqlCommand Try With Cmd 'Affectation des paramètres de la variable SqlCommand .CommandType = CommandType.Text .Connection = ClApplication.Cn .CommandText = "DELETE FROM [dbo].[Responsable] WHERE [Numero_CIN] = '" & m_Numero_CIN & "'" 'Exécution de la requète Supprimer If .ExecuteNonQuery <> 0 Then Return True End If End With Catch ex As Exception 'Traitement de l'erreur MsgBox(Err.Description) Return False Finally End Try End Function
Partager