Beispiel #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();
     }
 }
Beispiel #2
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();
        }