Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Tâches 10, 11, 12, 13 done
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-vial committed Nov 5, 2012
1 parent e7e7f75 commit 4b2afb5
Show file tree
Hide file tree
Showing 9 changed files with 630 additions and 504 deletions.
141 changes: 71 additions & 70 deletions contenu/HobbyCartes/HobbyCartes/Accueil.aspx.vb
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Accueil
Inherits System.Web.UI.Page

Private m_connection As MySqlConnection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("connected") Is Nothing Then
Session.Add("connected", False)
Session.Timeout = 30
End If
If Session("idMembre") Is Nothing Then
Session.Add("idMembre", -1)
End If
If Session("Admin") Is Nothing Then
Session.Add("Admin", False)
End If
m_connection = New MySqlConnection(My.Resources.StringConnexionBdd)
m_connection.Open()
NouveauxMembre()
End Sub

Public Sub NouveauxMembre()
Dim Membres As List(Of Entites.Membre) = Entites.Membre.ListeMembresOrdonnee(m_connection)
Dim Nombre As Integer = Membres.Count

If (Nombre > 5) Then
Nombre = 5
End If


If Membres IsNot Nothing Then
For value As Integer = 0 To Nombre - 1
Dim Membre As Entites.Membre = Membres(value)
Dim nouvDiv As New HtmlGenericControl("div")
nouvDiv.Attributes.Add("class", "membre")

'Image
Dim nouvA As New HtmlGenericControl("a")
nouvA.Attributes.Add("href", "Membreinfo.aspx?pseudo=" + Membre.getNomUtilisateurParId(Membre.id, m_connection))
Dim nouvImage As New Image()
nouvImage.ID = "img" + Membre.id.ToString
nouvImage.ImageUrl = Membre.Image
nouvImage.Attributes.Add("alt", "imgAvant" + Membre.id.ToString)
nouvA.Controls.Add(nouvImage)
nouvDiv.Controls.Add(nouvA)

'Nouveau Membre
Dim nouvMembre As New Label
nouvMembre.Attributes.Add("class", "lblMembreAcceuil")
nouvMembre.ID = "lblMembre2" + Membre.id.ToString
'Label avec un balise a, font et 2 balises br dedans pour rediriger vers la page MembreInfo
nouvMembre.Text = "<a href=" & Chr(34) & "Membreinfo.aspx?pseudo=" + Membre.getNomUtilisateurParId(Membre.id, m_connection) & Chr(34) & _
"STYLE=" & Chr(34) & "TEXT-DECORATION: NONE" & Chr(34) & "><font color=" & Chr(34) & "B8C3B8" & Chr(34) & ">" & _
Membre.getNomUtilisateurParId(Membre.id, m_connection) + " <br/> <br/></font></a>"
nouvDiv.Controls.Add(nouvMembre)

'Date d'inscription
Dim nouvDateInscription As New Label()
nouvDateInscription.Attributes.Add("class", "lblDateInscription")
nouvDateInscription.ID = "lblDateInscription" + Membre.id.ToString
nouvDateInscription.Text = "Date d'inscription: " + Membre.DateInscription.Day.ToString + "-" & _
Membre.DateInscription.Month.ToString + "-" + Membre.DateInscription.Year.ToString
nouvDiv.Controls.Add(nouvDateInscription)

phNouvMembre.Controls.Add(nouvDiv)
Next
End If
End Sub
Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Accueil
Inherits System.Web.UI.Page

Private m_connection As MySqlConnection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("connected") Is Nothing Then
Session.Add("connected", False)
Session.Timeout = 30
End If
If Session("idMembre") Is Nothing Then
Session.Add("idMembre", -1)
End If
If Session("Admin") Is Nothing Then
Session.Add("Admin", False)
End If
m_connection = New MySqlConnection(My.Resources.StringConnexionBdd)
m_connection.Open()
NouveauxMembre()
m_connection.Close()
End Sub

Public Sub NouveauxMembre()
Dim Membres As List(Of Entites.Membre) = Entites.Membre.ListeMembresOrdonnee(m_connection)
Dim Nombre As Integer = Membres.Count

If (Nombre > 5) Then
Nombre = 5
End If


If Membres IsNot Nothing Then
For value As Integer = 0 To Nombre - 1
Dim Membre As Entites.Membre = Membres(value)
Dim nouvDiv As New HtmlGenericControl("div")
nouvDiv.Attributes.Add("class", "membre")

'Image
Dim nouvA As New HtmlGenericControl("a")
nouvA.Attributes.Add("href", "Membreinfo.aspx?pseudo=" + Membre.getNomUtilisateurParId(Membre.id, m_connection))
Dim nouvImage As New Image()
nouvImage.ID = "img" + Membre.id.ToString
nouvImage.ImageUrl = Membre.Image
nouvImage.Attributes.Add("alt", "imgAvant" + Membre.id.ToString)
nouvA.Controls.Add(nouvImage)
nouvDiv.Controls.Add(nouvA)

'Nouveau Membre
Dim nouvMembre As New Label
nouvMembre.Attributes.Add("class", "lblMembreAcceuil")
nouvMembre.ID = "lblMembre2" + Membre.id.ToString
'Label avec un balise a, font et 2 balises br dedans pour rediriger vers la page MembreInfo
nouvMembre.Text = "<a href=" & Chr(34) & "Membreinfo.aspx?pseudo=" + Membre.getNomUtilisateurParId(Membre.id, m_connection) & Chr(34) & _
"STYLE=" & Chr(34) & "TEXT-DECORATION: NONE" & Chr(34) & "><font color=" & Chr(34) & "B8C3B8" & Chr(34) & ">" & _
Membre.getNomUtilisateurParId(Membre.id, m_connection) + " <br/> <br/></font></a>"
nouvDiv.Controls.Add(nouvMembre)

'Date d'inscription
Dim nouvDateInscription As New Label()
nouvDateInscription.Attributes.Add("class", "lblDateInscription")
nouvDateInscription.ID = "lblDateInscription" + Membre.id.ToString
nouvDateInscription.Text = "Date d'inscription: " + Membre.DateInscription.Day.ToString + "-" & _
Membre.DateInscription.Month.ToString + "-" + Membre.DateInscription.Year.ToString
nouvDiv.Controls.Add(nouvDateInscription)

phNouvMembre.Controls.Add(nouvDiv)
Next
End If
End Sub
End Class
73 changes: 52 additions & 21 deletions contenu/HobbyCartes/HobbyCartes/Erreur.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,79 @@ Public Class Erreur
''' </summary>
Protected Sub Page_Load() Handles Me.Load
Dim previousURL As String = Session("errorPreviousURL")
Dim exception As String = Session("errorMessage")
Dim message As String = Session("errorMessage")

If IsNothing(exception) Then
If IsNothing(message) Then
erreurDescription.InnerText = "Une erreur interne est survenue"
Else
erreurDescription.InnerHtml = exception.Replace(vbCrLf, "<br />")
erreurDescription.InnerHtml = message.Replace(vbCrLf, "<br />")
End If

If IsNothing(previousURL) Then
erreurBoutonRetour.PostBackUrl = "Default.aspx"
erreurBoutonRetour.PostBackUrl = "Accueil.aspx"
Else
erreurBoutonRetour.PostBackUrl = previousURL
End If
End Sub

''' <summary>
''' Affiche un message d'erreur par défaut
''' </summary>
Public Shared Sub afficherErreur(currentPage As Page)
afficherErreur(Nothing, currentPage, DirectCast(Nothing, Page))
End Sub

''' <summary>
''' Affiche la page d'erreur decrivant un message d'erreur
''' </summary>
Public Shared Sub afficherErreur(txtErreur As String, currentPage As Page)
afficherErreur(txtErreur, currentPage, DirectCast(Nothing, Page))
End Sub

''' <summary>
''' Affiche la page d'erreur decrivant un message d'erreur
''' </summary>
Public Shared Sub afficherErreur(txtErreur As String, currentPage As Page, previousPage As Page)
If IsNothing(previousPage) Then
afficherErreur(txtErreur, currentPage, DirectCast(Nothing, Uri))
Else
afficherErreur(txtErreur, currentPage, previousPage.Request.Url)
End If
End Sub

''' <summary>
''' Affiche la page d'erreur decrivant un message d'erreur
''' </summary>
Public Shared Sub afficherErreur(txtErreur As String, currentPage As Page, previousURL As Uri)
If IsNothing(previousURL) Then
currentPage.Session("errorPreviousURL") = Nothing
Else
currentPage.Session("errorPreviousURL") = previousURL.ToString
End If
currentPage.Session("errorMessage") = txtErreur
currentPage.Response.Redirect("Erreur.aspx")
End Sub

''' <summary>
''' Affiche la page d'erreur decrivant une exception
''' </summary>
Public Shared Sub afficherException(ex As Exception, previousPage As Page, currentPage As Page)
If Not IsNothing(previousPage) Then
afficherException(ex, previousPage.Request.Url, currentPage)
Public Shared Sub afficherException(ex As Exception, currentPage As Page, previousPage As Page)
If IsNothing(ex) Then
afficherErreur(Nothing, currentPage, previousPage)
Else
afficherException(ex, DirectCast(Nothing, Uri), currentPage)
afficherErreur(ex.ToString, currentPage, previousPage)
End If
End Sub

''' <summary>
''' Affiche la page d'erreur decrivant une exception
''' </summary>
Public Shared Sub afficherException(ex As Exception, previousURL As Uri, currentPage As Page)
currentPage.Session("errorPreviousURL") = previousURL.ToString
currentPage.Session("errorMessage") = ex.ToString
currentPage.Response.Redirect("Erreur.aspx")
'If Not IsNothing(ex) And Not IsNothing(previousPage) Then
'currentPage.Response.Redirect("Erreur.aspx?description=" & ex.Message & "&previous=" & previousPage.AbsoluteUri)
'ElseIf Not IsNothing(previousPage) Then
'currentPage.Response.Redirect("Erreur.aspx?previous=" & previousPage.AbsoluteUri)
'ElseIf Not IsNothing(ex) Then
' currentPage.Response.Redirect("Erreur.aspx?description=" & ex.Message & )
'Else
'currentPage.Response.Redirect("Erreur.aspx")
'End If
Public Shared Sub afficherException(ex As Exception, currentPage As Page, previousURL As Uri)
If IsNothing(ex) Then
afficherErreur(Nothing, currentPage, previousURL)
Else
afficherErreur(ex.ToString, currentPage, previousURL)
End If
End Sub

End Class
12 changes: 6 additions & 6 deletions contenu/HobbyCartes/HobbyCartes/Membre.master
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%@ Master MasterPageFile="~/HobbyCartes.Master" %>
<%@ Master Language="vb" MasterPageFile="~/HobbyCartes.Master" Inherits="HobbyCartes.Membre" CodeBehind="~/Membre.master.vb" %>

<asp:Content ContentPlaceHolderID="cphCorps" runat="server">
<div id="membre">
<div id="membre_onglets">
<a href="/MembreInfo.aspx" class="onglet">Informations</a>
<a class="onglet" href="/MembreListeCartes.aspx">Liste des cartes</a>
<a class="onglet" href="/MembreGererCollections.aspx">Gérer ses collections</a>
<a class="onglet" href="/MembreVisualiserMessages.aspx?idMembre=1">Visualiser ses messages</a>
<a class="onglet" href="/MembreEnvoiMessage.aspx?idDestinataire=1&idDestinateur=1">Envoyer un message</a>
<a class="onglet" href="/MembreInfo.aspx" id="ongletInformations" runat="server" >Informations</a>
<a class="onglet" href="/MembreListeCartes.aspx" id="ongletListeCartes" runat="server" >Liste des cartes</a>
<a class="onglet" href="/MembreGererCollections.aspx" id="ongletGererCollections" runat="server" >Gérer ses collections</a>
<a class="onglet" href="/MembreVisualiserMessages.aspx" id="ongletVisualiserMessages" runat="server" >Visualiser ses messages</a>
<a class="onglet" href="/MembreEnvoiMessage.aspx" id="ongletEnvoiMessage" runat="server" >Envoyer un message</a>
</div>
<div id="membre_contenu">
<asp:ContentPlaceHolder ID="cphPageMembreContenu" runat="server" />
Expand Down
45 changes: 45 additions & 0 deletions contenu/HobbyCartes/HobbyCartes/Membre.master.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion contenu/HobbyCartes/HobbyCartes/Membre.master.vb
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
Public Class Membre
Imports MySql.Data.MySqlClient

''' <summary>
''' Page maitre pour l'affichage des informations, des cartes d'un membre, et pour l'envoi de messages
''' </summary>
Public Class Membre
Inherits System.Web.UI.MasterPage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connected As Boolean = Boolean.Parse(Session("connected"))
Dim idMembre As Integer = Integer.Parse(Session("idMembre"))
Dim connection As MySqlConnection = New MySqlConnection(My.Resources.StringConnexionBdd)
connection.Open()
Dim pseudoMembre As String = Entites.Membre.getNomUtilisateurParId(idMembre, connection)
connection.Close()
Dim pseudo As String = Request.QueryString("pseudo")

If IsNothing(pseudo) And Not connected Then
Erreur.afficherErreur(Page)
ElseIf IsNothing(pseudo) And connected Then
ongletGererCollections.Visible = True
ongletVisualiserMessages.Visible = True
ongletEnvoiMessage.Visible = False
Else
ongletInformations.HRef += "?pseudo=" & pseudo
ongletListeCartes.HRef += "?pseudo=" & pseudo
ongletGererCollections.Visible = False
ongletVisualiserMessages.Visible = False
If connected Then
ongletEnvoiMessage.HRef += "?pseudo=" & pseudo
Else
ongletEnvoiMessage.Visible = False
End If
End If
End Sub

End Class
Loading

0 comments on commit 4b2afb5

Please sign in to comment.