Exemplo n.º 1
0
        public void View(IList selectedClients, DateTime expireDate, SessionTariff tariff, Double payment)
        {
            this.currentExpireDate = expireDate;
            this.CurrentPayment    = payment;
            this.ClientsList       = selectedClients;
            this.SelectedTariff    = tariff;

            this.ShowDialog();
        }
Exemplo n.º 2
0
        public void View(IList selectedClients, SessionTariff tariff, Boolean isInternet)
        {
            ClientsList = selectedClients;
            if (!PriceList.Contains(tariff))
            {
                PriceList.Add(tariff);
            }
            SelectedTariff    = tariff;
            IsInternetSession = isInternet;

            this.InitDataContext();
            this.ShowDialog();
        }
Exemplo n.º 3
0
 public void ToExtend_Session(SessionTariff tariff, Boolean isInternetSession, Double totalPayment, DateTime sessionExpire, Boolean toKillProcesses = false)
 {
     if (IsSessionStarted)
     {
         TotalPayment = totalPayment;
         Tariff       = tariff;
         RefreshSessionExpire(sessionExpire);
         NotifyPropertyChanged("RemainingTime");
         SendUpdateMessageToClient(toKillProcesses);
     }
     else
     {
         var timeNow = DateTime.Now;
         ToCreate_Session(new SessionMessage(timeNow, sessionExpire, tariff, isInternetSession, totalPayment), toKillProcesses);
     }
 }
Exemplo n.º 4
0
        public void View(IList selectedClients)
        {
            this.isDifferentSession = true;
            sliderHGrid.IsEnabled   = false;
            sliderMGrid.IsEnabled   = false;
            ClientsList             = selectedClients;

            var newTarrif = new SessionTariff()
            {
                Name = "== Текущий ==", LimitedTimeMode = true, CostPerHourGame = 13, CostPerHourInternet = 13
            };

            PriceList.Add(newTarrif);
            SelectedTariff = newTarrif;

            this.InitDataContext();
            this.ShowDialog();
        }
Exemplo n.º 5
0
 private void button_addTimeToSession_Click(object sender, RoutedEventArgs e)
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback) delegate(object o)
     {
         if (listView_clients.SelectedItems.Count > 0)
         {
             bool isNotValidToEdit = false;
             SessionTariff tarrif  = new SessionTariff();
             foreach (Client client in listView_clients.SelectedItems)
             {
                 if (!(client.EndSession.HasValue && client.Tariff.LimitedTimeMode))
                 {
                     isNotValidToEdit = true;
                     break;
                 }
             }
             if (isNotValidToEdit)
             {
                 if (MessageBox.Show("Будет создан новый сеанс. Продолжить?", "", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                 {
                     var wnd = new SessionCreationView {
                         Owner = this
                     };
                     wnd.View(listView_clients.SelectedItems);
                 }
             }
             else
             {
                 var wnd = new TimeEditionView {
                     Owner = this
                 };
                 wnd.View(listView_clients.SelectedItems);
             }
         }
         else
         {
             MessageBox.Show("Не выбран ни один клиент", "", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         var scope = FocusManager.GetFocusScope(sender as Button); // elem is the UIElement to unfocus
         FocusManager.SetFocusedElement(scope, null);              // remove logical focus
         Keyboard.ClearFocus();                                    // remove keyboard focus
         return(null);
     }, null);
 }
Exemplo n.º 6
0
 private void button_changeSession_Click(object sender, RoutedEventArgs e)
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback) delegate(object o)
     {
         if (listView_clients.SelectedItems.Count > 0)
         {
             bool isDifferent       = false;
             bool isNotValidToEdit  = false;
             bool isFirst           = true;
             bool isInternetSession = false;
             DateTime expireDate    = DateTime.Now;
             SessionTariff tarrif   = new SessionTariff();
             Double payment         = 0;
             foreach (Client client in listView_clients.SelectedItems)
             {
                 if (client.EndSession.HasValue && client.Tariff.LimitedTimeMode)
                 {
                     if (isFirst)
                     {
                         payment           = client.TotalPayment;
                         expireDate        = client.EndSession.Value;
                         tarrif            = client.Tariff;
                         isInternetSession = client.IsInternetSession;
                         isFirst           = false;
                     }
                     else
                     {
                         if (!isDifferent)
                         {
                             if (!(
                                     expireDate < client.EndSession.Value.AddSeconds(5) &&
                                     expireDate > client.EndSession.Value.AddSeconds(-5) &&
                                     tarrif.Equals(client.Tariff) &&
                                     isInternetSession.Equals(client.IsInternetSession)
                                     ))
                             {
                                 isDifferent = true;
                             }
                         }
                     }
                 }
                 else
                 {
                     isNotValidToEdit = true;
                     break;
                 }
             }
             if (isNotValidToEdit)
             {
                 if (MessageBox.Show("Будет создан новый сеанс. Продолжить?", "", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                 {
                     var wnd = new SessionCreationView {
                         Owner = this
                     };
                     wnd.View(listView_clients.SelectedItems);
                 }
             }
             else
             {
                 if (!isDifferent) //сеансы одинаковые
                 {
                     var wnd = new SessionExtensionView {
                         Owner = this
                     };
                     wnd.View(listView_clients.SelectedItems, expireDate, tarrif, payment);
                 }
                 else
                 {
                     MessageBox.Show("Сеансы различны и не могут быть изменены!\nПопробуйте добавить платеж или время.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
                 }
             }
         }
         else
         {
             MessageBox.Show("Не выбран ни один клиент", "", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         var scope = FocusManager.GetFocusScope(sender as Button); // elem is the UIElement to unfocus
         FocusManager.SetFocusedElement(scope, null);              // remove logical focus
         Keyboard.ClearFocus();                                    // remove keyboard focus
         return(null);
     }, null);
 }