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 70 71 72 73 74 75 76 77 78 79
| Imports System.Data.OleDb
Imports DataAccessLayer.clsDataAccessLayer
Imports DataTransfertObject
Public Class PersonDB
Inherits clsDALAppli
Private Const K_TITRE_RETRY As String = "Réessayer la lecture ?"
Public Function GetPersonId(ByVal PersonId As String) As PersonDTO
Const K_REQUETTE As String = "select * from personnes where PersonId = ?"
Try
DALApp.AjouteParam("PersonId", DbType.String, PersonId)
Return DALApp.GetSingleDTO(Of DTOParser_Person)(K_REQUETTE)
Catch ex As Exception
If MessageBox.Show(ex.Message, K_TITRE_RETRY, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = vbYes Then
Return DALApp.GetSingleDTO((New DTOParser_Person).GetType.AssemblyQualifiedName, K_REQUETTE)
End If
End Try
Return Nothing
End Function
Public Function GetPersonByEmail(ByVal email As String) As PersonDTO
Const K_REQUETTE As String = "select * from personnes where email = ?"
Try
DALApp.AjouteParam("email", DbType.String, email)
Return DALApp.GetSingleDTO(Of DTOParser_Person)(K_REQUETTE)
Catch ex As Exception
If MessageBox.Show(ex.Message, K_TITRE_RETRY, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = vbYes Then
Return DALApp.GetSingleDTO((New DTOParser_Person).GetType.AssemblyQualifiedName, K_REQUETTE)
End If
End Try
Return Nothing
End Function
Public Function GetAll() As List(Of DTOBase) 'TODO voir probleme type générique
Try
Return DALApp.GetListDTO(Of DTOParser_Person)("select * from personnes")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return Nothing
End Function
' avec le DTO 1 seul paramètre
Public Sub EnregPerson(ByVal UnePersonne As PersonDTO, ByVal Ins As Boolean)
Const K_REQUETTE_INSERT As String = "insert into personnes ([PersonId], [City], [Email], [ImAddress], [ImType], [LanguageId], [NamePers], [NickName], [Password], [PhoneHome], [PhoneMobile], [State], [TimeZoneId], [UtcCreated], [UtcModified], [ZipCode], [SpeakFrench]) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "
Dim req As String = "update personnes set City=?, [Email]=?, [ImAddress]=?, [ImType]=?, [LanguageId]=?, [NamePers]=?, [NickName]=?, [Password]=?, [PhoneHome]=?, [PhoneMobile]=?, [State]=?, [TimeZoneId]=?, [UtcCreated]=?, [UtcModified]=?, [ZipCode]=?,SpeakFrench=? where PersonId = ?"
Dim res As Integer
If Ins Then req = K_REQUETTE_INSERT
Try
DALApp.EffaceListParam()
If Ins Then DALApp.AjouteParam("PersonId", DbType.Int32, UnePersonne.PersonId)
DALApp.AjouteParam("City", DbType.String, UnePersonne.City)
DALApp.AjouteParam("Email", DbType.String, UnePersonne.Email)
DALApp.AjouteParam("ImAddress", DbType.String, UnePersonne.ImAddress)
DALApp.AjouteParam("ImType", DbType.Int32, UnePersonne.ImType)
DALApp.AjouteParam("LanguageId", DbType.Int32, UnePersonne.LanguageId)
DALApp.AjouteParam("NamePers", DbType.String, UnePersonne.NamePers)
DALApp.AjouteParam("NickName", DbType.String, UnePersonne.NickName)
DALApp.AjouteParam("Password", DbType.String, UnePersonne.Password)
DALApp.AjouteParam("PhoneHome", DbType.String, UnePersonne.PhoneHome)
DALApp.AjouteParam("PhoneMobile", DbType.String, UnePersonne.PhoneMobile)
DALApp.AjouteParam("State", DbType.String, UnePersonne.State)
DALApp.AjouteParam("TimeZoneId", DbType.Int32, UnePersonne.TimeZoneId)
DALApp.AjouteParam("UtcCreated", DbType.Date, "20/05/2013")
DALApp.AjouteParam("UtcModified", DbType.Date, "31/05/2013")
DALApp.AjouteParam("ZipCode", DbType.Int32, 6)
DALApp.AjouteParam("SpeakFrench", DbType.Boolean, True)
If Not Ins Then DALApp.AjouteParam("PersonId", DbType.Int32, UnePersonne.PersonId)
DALApp.ExecuterCommande(req, res)
Catch ex As Exception
End Try
End Sub
End Class |
Partager