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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| Imports System.ComponentModel
Public Class Groupes
Inherits List(Of Groupe)
Implements INotifyPropertyChanged
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(ByVal info As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
End Sub
Public Overloads Sub Add(ByVal groupe As Groupe)
MyBase.Add(groupe)
NotifyPropertyChanged("ListGroups")
End Sub
Public Overloads Function Find(ByVal id As Integer) As Groupe
For Each elem As Groupe In Me
If elem.Id = id Then
Return elem
End If
Next
Return Nothing
End Function
Public Function CommitUpdates() As Boolean
Dim result As Boolean = False
For Each groupe As Groupe In Me
Select Case groupe.Status
Case BLL.Groupe.e_status.Updated
If DAL.dal_Groupe.UpdateGroupe(groupe) Then
groupe.Status = BLL.Groupe.e_status.UpToDate
Else
Throw New Exception("")
End If
Case BLL.Groupe.e_status.Created
If DAL.dal_Groupe.CreateGroupe(groupe) Then
groupe.Status = BLL.Groupe.e_status.UpToDate
Else
Throw New Exception("")
End If
End Select
Next
Return result
End Function
Public Overloads Function Remove(ByVal groupToRemove As Groupe) As Boolean
If Not Groupe.DeleteGroupe(groupToRemove) Then
Throw New Exception("Impossible de supprimer ce groupe.")
Return False
Else
Return MyBase.Remove(groupToRemove)
End If
End Function
Public Shared Function GetAllgroupes() As Groupes
Return DAL.dal_Groupe.GetAllgroupes
End Function
End Class
Public Class Groupe
Public Property Id As Integer
Private _Ordre As Integer
Public Property Ordre As Integer
Get
Return _Ordre
End Get
Set(value As Integer)
_Ordre = value
Me.Status = e_status.Updated
End Set
End Property
Private _textes As Textes
Public Property Textes As Textes
Set(value As Textes)
_textes = value
Me.Status = e_status.Updated
End Set
Get
Return _textes
End Get
End Property
Private _Comptetences As List(Of Competence)
Public Property Competences As List(Of Competence)
Get
Return _Comptetences
End Get
Set(value As List(Of Competence))
_Comptetences = value
Me.Status = e_status.Updated
End Set
End Property
Public Sub New(ByVal id As Integer, ByVal textes As Textes)
Me.Id = id
Me.Textes = textes
End Sub
Public Sub New(ByVal textes As Textes)
Me.Id = 0
Me.Textes = textes
End Sub
Public Property Status As e_status
Public Enum e_status As Integer
UpToDate = 1
Created = 2
Updated = 3
End Enum
Public Shared Function NewGroupe(ByVal groupe As Groupe) As Boolean
Return DAL_Groupe.NewGroupe(groupe)
End Function
Public Shared Function DeleteGroupe(ByVal groupe As Groupe) As Boolean
Return DAL_Groupe.DeleteGroupe(groupe)
End Function
Public Shared Function UpdateGroupe(ByVal groupe As Groupe) As Boolean
Return DAL_Groupe.UpdateGroupe(groupe)
End Function
Public Shared Function GetGroupeById(ByVal id As Integer) As Groupe
Return DAL_Groupe.GetGroupeById(id)
End Function
End Class |
Partager