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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
   | Imports BMLWebAppl.Metier
Imports BMLWebAppl.BDAccess
Imports System.Data.SqlClient
 
Namespace BDObjet
 
    Public Class BDUser
 
        Public Function loginCheck(ByVal pseudo As String, ByVal psw As String) As Lecteur
            Dim da As New DataAccess
            Dim ds As New DataSet
            Dim comm As New SqlCommand
 
 
            Try
                comm.CommandType = CommandType.Text
 
                comm.CommandText = "SELECT ""User"".IdUser, ""User"".Type, ""User"".Pseudo, ""User"".Psw, ""User"".NoCarte, ""Us" & _
                "er"".ValAu, ""User"".Echeance, ""User"".Saisie, ""User"".Modif, ""User"".Prenom, ""User"".N" & _
                "om, ""User"".Naiss, ""User"".Sexe, ""User"".Ind, ""User"".Dpt, ""User"".GrpPret, ""User"".Gr" & _
                "pStat, ""User"".Inst, ""User"".Adresse, ""User"".No, ""User"".NPA, ""User"".Ville, ""User""." & _
                "Canton, ""User"".Pays, ""User"".TelPrive, ""User"".TelNatel, ""User"".Mail, ""User"".Titre" & _
                ", ""User"".Nationalite, ""User"".Cot, Statut.Description AS Statut FROM ""User"" INNER" & _
                " JOIN Statut ON ""User"".IdStatut = Statut.IdStatut WHERE (""User"".Pseudo = @Pseudo" & _
                ") AND (""User"".Psw = @Psw)"
 
                comm.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PSEUDO", System.Data.SqlDbType.VarChar, 30))
                comm.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PSW", System.Data.SqlDbType.VarChar, 30))
                comm.Parameters("@PSEUDO").Value = pseudo
                comm.Parameters("@PSW").Value = psw
                'Récupération d'un utilisateur
                ds = da.getDataSet(comm)
                'Création d'un lecteur ou d'un employer
                Return CreateUser(ds)
 
            Catch ex As Exception
                Throw
            Finally
                da = Nothing
                ds = Nothing
            End Try
        End Function
 
        Public Function CreateUser(ByRef ds As DataSet) As User
            Dim user = New User
            Dim bd_emp As New BDEmp
            Dim bd_Lec As New BDLecteur
            'Si le DataSet contient un utiisateur
            If ds.Tables(0).Rows.Count > 0 Then
                'Charger ses données personnelles
                user.Id = ds.Tables(0).Rows(0).Item("IDUSER")
                user.Pseudo = ds.Tables(0).Rows(0).Item("PSEUDO").ToString()
                user.Pwd = ds.Tables(0).Rows(0).Item("PSW").ToString()
                If Not ds.Tables(0).Rows(0).IsNull("NOCARTE") Then
                    user.NoCarte = ds.Tables(0).Rows(0).Item("NOCARTE")
                End If
                If Not ds.Tables(0).Rows(0).IsNull("VALAU") Then
                    user.ValAu = ds.Tables(0).Rows(0).Item("VALAU")
                End If
                If Not ds.Tables(0).Rows(0).IsNull("ECHEANCE") Then
                    user.Echeance = ds.Tables(0).Rows(0).Item("ECHEANCE")
                End If
                user.Saisie = ds.Tables(0).Rows(0).Item("SAISIE")
                If Not ds.Tables(0).Rows(0).IsNull("MODIF") Then
                    user.Modif = ds.Tables(0).Rows(0).Item("MODIF")
                End If
                user.Prenom = ds.Tables(0).Rows(0).Item("PRENOM").ToString()
                user.Nom = ds.Tables(0).Rows(0).Item("NOM").ToString()
                user.Naiss = ds.Tables(0).Rows(0).Item("NAISS")
                user.Ind = ds.Tables(0).Rows(0).Item("IND").ToString()
                user.Sexe = ds.Tables(0).Rows(0).Item("SEXE").ToString()
                user.Dpt = ds.Tables(0).Rows(0).Item("DPT").ToString()
                user.GpPret = ds.Tables(0).Rows(0).Item("GRPPRET").ToString()
                user.GpStat = ds.Tables(0).Rows(0).Item("GRPSTAT").ToString()
                user.Inst = ds.Tables(0).Rows(0).Item("INST").ToString()
                user.Adr = ds.Tables(0).Rows(0).Item("ADRESSE").ToString()
                user.No = ds.Tables(0).Rows(0).Item("NO")
                user.NPA = ds.Tables(0).Rows(0).Item("NPA")
                user.Ville = ds.Tables(0).Rows(0).Item("VILLE").ToString()
                user.Cant = ds.Tables(0).Rows(0).Item("CANTON").ToString()
                user.Pays = ds.Tables(0).Rows(0).Item("PAYS").ToString()
                user.TelPrive = ds.Tables(0).Rows(0).Item("TELPRIVE").ToString()
                user.TelNat = ds.Tables(0).Rows(0).Item("TELNATEL").ToString()
                user.Email = ds.Tables(0).Rows(0).Item("MAIL").ToString()
                user.Titre = ds.Tables(0).Rows(0).Item("TITRE").ToString()
                user.Nation = ds.Tables(0).Rows(0).Item("NATIONALITE").ToString()
                user.Cot = ds.Tables(0).Rows(0).Item("COT")
                user.Statut = ds.Tables(0).Rows(0).Item("STATUT").ToString()
                'Vérifier son type
                For Each oRow As DataRow In ds.Tables(0).Rows
                    If oRow.Item("TYPE") = 0 Then
                        user = bd_Lec.createLec(user)
                    ElseIf oRow.Item("TYPE") = 1 Then
                        user = bd_emp.createEmp(user)
                    End If
                Next
            Else
                user = Nothing
            End If
            'Retourner l'objet visiteur
            Return user
        End Function
    End Class
End Namespace | 
Partager