コード例 #1
0
 public void Search()
 {
     if (IsIdentifiant)
     {
         int id;
         if (!int.TryParse(MainSearchString, out id))
         {
             return;
         }
         var client = Main.ClientsRepository.Get(id);
         if (client != null)
         {
             ClientsSearchResult = new ObservableCollection <Client> {
                 client
             };
         }
     }
     else
     {
         ClientsSearchResult = new ObservableCollection <Client>();
         var searchresult = MainInteraction.SearchForClients(MainSearchString);
         foreach (var client in searchresult)
         {
             ClientsSearchResult.Add(client);
         }
     }
     if (ClientsSearchResult.Count == 1)
     {
         SelectedClient = ClientsSearchResult.FirstOrDefault();
     }
 }
コード例 #2
0
        public bool CanAddSubcribtion()
        {
            if (SelectedClient == null || SelectedClient.Id <= 0)
            {
                return(false);
            }
            var result       = !MainInteraction.ThisClientIsSubcribed(SelectedClient);
            var subcribtions = Main.SubcriptionsRepository.Get(n => n.Client.Id == SelectedClient.Id);

            result = result && subcribtions.Where(n => n.StartDate >= DateTime.Now).ToList().Count <= 0;
            return(result);
        }
コード例 #3
0
        private void UpdateUiDataOfForTheCurrentClient()
        {
            CanSeeDetails = false;
            var validClient = SelectedClient != null && SelectedClient.Id > 0;

            CanAddSubcribtionForCurrentClient = validClient;
            CanSeeDetails = validClient && !SelectedClient.Name.ToUpper().Contains("INCONNU") && !SelectedClient.LastName.ToUpper().Contains("INCONNU");
            Histories     = new ObservableCollection <History>();
            LoadAllHistory();
            SubcribtionState = SubcriState.None;
            if (validClient)
            {
                Histories =
                    new ObservableCollection <History>(Main.HistoriesRepository.Get(n => n.Client.Id == SelectedClient.Id));
                var sessionsLeft = MainInteraction.SessionsLeftOnThisMonthForThisClient(SelectedClient);
                SessionsLeftForSelectedClient = sessionsLeft;
                if (MainInteraction.ThisClientIsSubcribed(SelectedClient))
                {
                    var subcribtions = Main.SubcriptionsRepository.Get();
                    var subcribtionOfSelectedClient = subcribtions.FirstOrDefault(n => n.Client.Id == SelectedClient.Id);

                    if (sessionsLeft == 1)
                    {
                        SubcribtionState = SubcriState.LastSession;
                    }
                    else
                    {
                        SubcribtionState = SubcriState.Payed;
                    }
                    if (subcribtionOfSelectedClient != null)
                    {
                        SelectedStartDate =
                            subcribtionOfSelectedClient.StartDate;
                        SelectedEndDate                   = subcribtionOfSelectedClient.EndDate;
                        SelectedSubcriptionType           = subcribtionOfSelectedClient.SubcriptionType;
                        CanAddSubcribtionForCurrentClient = false;
                    }
                }
                else
                {
                    SubcribtionState = SubcriState.Unpayed;
                }
            }
            else
            {
                CanSeeDetails = false;
            }
        }
コード例 #4
0
 public void AddSubcribtion()
 {
     if (SelectedClient != null && SelectedClient.Id > 0 && !MainInteraction.ThisClientIsSubcribed(SelectedClient) && SelectedSubcriptionType != null)
     {
         var newSubcription = new Subcription {
             Client = SelectedClient, SubcriptionType = SelectedSubcriptionType, StartDate = SelectedStartDate, EndDate = SelectedEndDate
         };
         Main.SubcriptionsRepository.Add(newSubcription);
         //var history = new History {Client = SelectedClient, Record = DateTime.Now};
         //var pay=new Payement{Amount = Amount,Subription = newSubcription,History =history,Moment = DateTime.Now};
         var pay = new Payement {
             Amount = SelectedSubcriptionType.Price, Subription = newSubcription, Moment = DateTime.Now
         };
         Main.PayementsRepository.Add(pay);
         UpdateUiDataOfForTheCurrentClient();
     }
 }
コード例 #5
0
        public void Pointing()
        {
            string           sMessageBoxText;
            string           sCaption;
            MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
            MessageBoxImage  icnMessageBox = MessageBoxImage.Stop;


            if (SelectedClient != null && SelectedClient.Id > 0)
            {
                if (MainInteraction.ThisClientIsSubcribed(SelectedClient))
                {
                    MainInteraction.AddSessionForThisClient(SelectedClient);
                }
                else
                {
                    sCaption        = "Abonnemet expiré. Client: " + SelectedClient.Id;
                    sMessageBoxText = "L'abonnement de " + SelectedClient.Name + " " + SelectedClient.LastName + " est expiré, voulez vous continuer en pointant une séance ordinaire pour " + Amount + " DA ?";
                    MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
                    switch (rsltMessageBox)
                    {
                    case MessageBoxResult.Yes:
                        var history = new History {
                            Client = SelectedClient, Record = DateTime.Now
                        };
                        Main.HistoriesRepository.Add(history);
                        var payement = new Payement {
                            History = history, Amount = Amount, Moment = DateTime.Now
                        };
                        Main.PayementsRepository.Add(payement);
                        break;

                    case MessageBoxResult.No:
                        /* ... */
                        break;
                    }
                }
            }
            else
            {
                sCaption        = "Aucun client sélectionné";
                sMessageBoxText = "Voulez vous vraiment pointer une séance pour un client inconnu pour " + Amount + " DA ?";
                icnMessageBox   = MessageBoxImage.Question;
                var rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
                switch (rsltMessageBox)
                {
                case MessageBoxResult.Yes:
                    var client  = MainInteraction.SearchForClients("INCONNU").FirstOrDefault();
                    var history = new History {
                        Client = client, Record = DateTime.Now
                    };
                    Main.HistoriesRepository.Add(history);
                    var payement = new Payement {
                        History = history, Amount = Amount, Moment = DateTime.Now
                    };
                    Main.PayementsRepository.Add(payement);
                    break;

                case MessageBoxResult.No:
                    /* ... */
                    break;
                }
            }
            UpdateUiDataOfForTheCurrentClient();
        }