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(ref dateSelection, value, System.Reflection.MethodBase.GetCurrentMethod().Name); } } private ObservableCollection _BcpPlats = new ObservableCollection(); private ObservableCollection _BcpPLatJourSelectionne = new ObservableCollection(); public ObservableCollection BcpPlats { get { return _BcpPlats; } set { _BcpPlats = value; } } public ObservableCollection BcpPLatJourSelectionne { get => _BcpPLatJourSelectionne; set => AssignerChamp< ObservableCollection>(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); DateSelection = DateTime.Now; 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 ChargerRepa(string chConn) { ObservableCollection rep = new ObservableCollection(); List lTmp = new G_T_plat(chConn).Lire(""); foreach (C_T_plat Tmp in lTmp) rep.Add(Tmp); return rep; } public ObservableCollection ChargerRepa(string chConn,DateTime dateV) { ObservableCollection rep = new ObservableCollection(); List lTmp = new Gestion.G_T_repa(Config.Settings1.Default.schCon).Lire(dateV) as List; 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; } } } }