ProjetThe/ProjetTheAlone/ViewModel/EncodeRepas.cs

111 lines
4.3 KiB
C#
Raw Normal View History

2019-01-24 22:24:05 +01:00
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;
using System.Windows.Controls;
namespace ProjetTheAlone.ViewModel
{
public class VM_Repa : 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"*/;
#endregion
#region Données extérieures
private DateTime dateSelection;
public DateTime DateSelection { get => dateSelection; set { AssignerChamp<DateTime>(ref dateSelection, value, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
private ObservableCollection<C_T_plat> _BcpPlats = new ObservableCollection<C_T_plat>();
private ObservableCollection<C_T_plat> _BcpPLatJourSelectionne = new ObservableCollection<C_T_plat>();
public ObservableCollection<C_T_plat> BcpPlats
{
get { return _BcpPlats; }
set { _BcpPlats = value; }
}
public ObservableCollection<C_T_plat> BcpPLatJourSelectionne { get => _BcpPLatJourSelectionne; set => AssignerChamp< ObservableCollection<C_T_plat>>(ref _BcpPLatJourSelectionne, value, System.Reflection.MethodBase.GetCurrentMethod().Name) ; }
#endregion
public VM_Repa()
{
cConfirmer = new BaseCommande(Confirmer);
cSupprimer = new BaseCommande(Supprimer);
cSupprimer = new BaseCommande(calendar_SelectedDatesChanged);
2019-01-25 14:20:43 +01:00
DateSelection = DateTime.Now;
2019-01-24 22:24:05 +01:00
BcpPlats = ChargerRepa(chConnexion);
BcpPLatJourSelectionne = ChargerRepa(chConnexion, DateSelection);
base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(onPropertyChanged);
}
#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; }
public BaseCommande cCalendar_SelectedDatesChanged { get; set; }
#endregion
private ObservableCollection<C_T_plat> ChargerRepa(string chConn)
{
ObservableCollection<C_T_plat> rep = new ObservableCollection<C_T_plat>();
List<C_T_plat> lTmp = new G_T_plat(chConn).Lire("");
foreach (C_T_plat Tmp in lTmp)
rep.Add(Tmp);
return rep;
}
public ObservableCollection<C_T_plat> ChargerRepa(string chConn,DateTime dateV)
{
ObservableCollection<C_T_plat> rep = new ObservableCollection<C_T_plat>();
List<C_T_plat> lTmp = new Gestion.G_T_repa(Config.Settings1.Default.schCon).Lire(dateV) as List<C_T_plat>;
foreach (C_T_plat Tmp in lTmp)
rep.Add(Tmp);
return rep;
}
public void Confirmer()
{
//if (nAjout == -1)
//{
// UnPlat.ID = new G_T_plat(chConnexion).Ajouter(UnPlat.Nom, UnPlat.Img, (int)UnPlat.TypePlat);
// BcpPlats.Add(new C_T_plat(UnPlat.ID, UnPlat.Nom, UnPlat.Img, (int)UnPlat.TypePlat));
//}
//else
//{
// new G_T_plat(chConnexion).Modifier(UnPlat.ID, UnPlat.Nom, UnPlat.Img, (int)UnPlat.TypePlat);
// BcpPlats[nAjout] = new C_T_plat(UnPlat.ID, UnPlat.Nom, UnPlat.Img, (int)UnPlat.TypePlat);
//}
//ActiverUneFiche = false;
}
public void Supprimer()
{
}
public void calendar_SelectedDatesChanged()
{
Console.WriteLine($"SELECTED DATE TTTTT {DateSelection}");
}
private void onPropertyChanged(object o, System.ComponentModel.PropertyChangedEventArgs arg )
{
switch(arg.PropertyName)
{
case "DateSelection":
BcpPLatJourSelectionne = ChargerRepa(chConnexion, DateSelection);
break;
}
}
}
}