153 lines
5.5 KiB
C#
153 lines
5.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using ProjetTheAlone.Classes;
|
|||
|
using ProjetTheAlone.Gestion;
|
|||
|
using System.Collections.ObjectModel;
|
|||
|
using System.IO;
|
|||
|
using ProjetTheAlone.Config;
|
|||
|
|
|||
|
namespace ProjetTheAlone.ViewModel
|
|||
|
{
|
|||
|
public class VM_TypeEvent : BasePropriete
|
|||
|
{
|
|||
|
#region Données Écran
|
|||
|
|
|||
|
private string chConnexion = Settings2.Default.schCon /*@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\Hugues\Haute Ecole de la ville de Liège\Adrien VAN DAMME - ProjetTheAlone\ProjetTheAlone\ProjetThe.mdf';Integrated Security = True"*/;
|
|||
|
private int nAjout;
|
|||
|
private bool _ActiverUneFiche;
|
|||
|
public bool ActiverUneFiche
|
|||
|
{
|
|||
|
get { return _ActiverUneFiche; }
|
|||
|
set
|
|||
|
{
|
|||
|
AssignerChamp<bool>(ref _ActiverUneFiche, value, System.Reflection.MethodBase.GetCurrentMethod().Name);
|
|||
|
ActiverBcpFiche = !ActiverUneFiche;
|
|||
|
}
|
|||
|
}
|
|||
|
private bool _ActiverBcpFiche;
|
|||
|
public bool ActiverBcpFiche
|
|||
|
{
|
|||
|
get { return _ActiverBcpFiche; }
|
|||
|
set { AssignerChamp<bool>(ref _ActiverBcpFiche, value, System.Reflection.MethodBase.GetCurrentMethod().Name); }
|
|||
|
}
|
|||
|
private C_T_typeEvenement _TypeEventSelectionnee;
|
|||
|
public C_T_typeEvenement TypeEventSelectionnee
|
|||
|
{
|
|||
|
get { return _TypeEventSelectionnee; }
|
|||
|
set { AssignerChamp<C_T_typeEvenement>(ref _TypeEventSelectionnee, value, System.Reflection.MethodBase.GetCurrentMethod().Name); }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Données extérieures
|
|||
|
private VM_UnTypeEvent _UnTypeEvent;
|
|||
|
public VM_UnTypeEvent UnTypeEvent
|
|||
|
{
|
|||
|
get { return _UnTypeEvent; }
|
|||
|
set { AssignerChamp<VM_UnTypeEvent>(ref _UnTypeEvent, value, System.Reflection.MethodBase.GetCurrentMethod().Name); }
|
|||
|
}
|
|||
|
private ObservableCollection<C_T_typeEvenement> _BcpTypeEvents = new ObservableCollection<C_T_typeEvenement>();
|
|||
|
public ObservableCollection<C_T_typeEvenement> BcpTypeEvents
|
|||
|
{
|
|||
|
get { return _BcpTypeEvents; }
|
|||
|
set { _BcpTypeEvents = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
public VM_TypeEvent()
|
|||
|
{
|
|||
|
UnTypeEvent = new VM_UnTypeEvent();
|
|||
|
UnTypeEvent.ID = 0;
|
|||
|
UnTypeEvent.Nom = "Nom du type d'événement";
|
|||
|
BcpTypeEvents = ChargerPersonnes(chConnexion);
|
|||
|
ActiverUneFiche = false;
|
|||
|
cConfirmer = new BaseCommande(Confirmer);
|
|||
|
cAnnuler = new BaseCommande(Annuler);
|
|||
|
cAjouter = new BaseCommande(Ajouter);
|
|||
|
cModifier = new BaseCommande(Modifier);
|
|||
|
cSupprimer = new BaseCommande(Supprimer);
|
|||
|
}
|
|||
|
|
|||
|
#region Commandes
|
|||
|
public BaseCommande cConfirmer { get; set; }
|
|||
|
public BaseCommande cAnnuler { get; set; }
|
|||
|
public BaseCommande cAjouter { get; set; }
|
|||
|
public BaseCommande cModifier { get; set; }
|
|||
|
public BaseCommande cSupprimer { get; set; }
|
|||
|
#endregion
|
|||
|
|
|||
|
public ObservableCollection<C_T_typeEvenement> ChargerPersonnes(string chConn)
|
|||
|
{
|
|||
|
ObservableCollection<C_T_typeEvenement> rep = new ObservableCollection<C_T_typeEvenement>();
|
|||
|
List<C_T_typeEvenement> lTmp = new G_T_typeEvenement(chConn).Lire("TE_nom");
|
|||
|
foreach (C_T_typeEvenement Tmp in lTmp)
|
|||
|
rep.Add(Tmp);
|
|||
|
return rep;
|
|||
|
}
|
|||
|
|
|||
|
public void Confirmer()
|
|||
|
{
|
|||
|
if (nAjout == -1)
|
|||
|
{
|
|||
|
UnTypeEvent.ID = new G_T_typeEvenement(chConnexion).Ajouter(UnTypeEvent.Nom);
|
|||
|
BcpTypeEvents.Add(new C_T_typeEvenement(UnTypeEvent.ID, UnTypeEvent.Nom));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
new G_T_typeEvenement(chConnexion).Modifier(UnTypeEvent.ID, UnTypeEvent.Nom);
|
|||
|
BcpTypeEvents[nAjout] = new C_T_typeEvenement(UnTypeEvent.ID, UnTypeEvent.Nom);
|
|||
|
}
|
|||
|
ActiverUneFiche = false;
|
|||
|
}
|
|||
|
public void Annuler()
|
|||
|
{ ActiverUneFiche = false; }
|
|||
|
public void Ajouter()
|
|||
|
{
|
|||
|
UnTypeEvent = new VM_UnTypeEvent();
|
|||
|
nAjout = -1;
|
|||
|
ActiverUneFiche = true;
|
|||
|
}
|
|||
|
public void Modifier()
|
|||
|
{
|
|||
|
if (TypeEventSelectionnee != null)
|
|||
|
{
|
|||
|
C_T_typeEvenement Tmp = new G_T_typeEvenement(chConnexion).Lire_ID(TypeEventSelectionnee.ID_typeEvenement);
|
|||
|
|
|||
|
UnTypeEvent = new VM_UnTypeEvent();
|
|||
|
UnTypeEvent.ID = Tmp.ID_typeEvenement;
|
|||
|
UnTypeEvent.Nom = Tmp.TE_nom;
|
|||
|
|
|||
|
nAjout = BcpTypeEvents.IndexOf(TypeEventSelectionnee);
|
|||
|
ActiverUneFiche = true;
|
|||
|
}
|
|||
|
}
|
|||
|
public void Supprimer()
|
|||
|
{
|
|||
|
if (TypeEventSelectionnee != null)
|
|||
|
{
|
|||
|
new G_T_typeEvenement(chConnexion).Supprimer(TypeEventSelectionnee.ID_typeEvenement);
|
|||
|
BcpTypeEvents.Remove(TypeEventSelectionnee);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public class VM_UnTypeEvent : BasePropriete
|
|||
|
{
|
|||
|
private int _ID;
|
|||
|
private string _Nom;
|
|||
|
|
|||
|
|
|||
|
public int ID
|
|||
|
{
|
|||
|
get { return _ID; }
|
|||
|
set { AssignerChamp<int>(ref _ID, value, System.Reflection.MethodBase.GetCurrentMethod().Name); }
|
|||
|
}
|
|||
|
|
|||
|
public string Nom
|
|||
|
{
|
|||
|
get { return _Nom; }
|
|||
|
set { AssignerChamp<string>(ref _Nom, value, System.Reflection.MethodBase.GetCurrentMethod().Name); }
|
|||
|
}
|
|||
|
}
|
|||
|
}
|