private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     var dataGrid = sender as DataGrid;
     var t = dataGrid?.SelectedItem as ShowClientsClass;
     if (t != null)
     {
         var newWindow = new CreateClientWindow(t.Client.Id);
         newWindow.Show();
         newWindow.Closed += NewWindow_Closed;
     }
 }
        public ShowClientsViewModel()
        {
            Recalck();
            CreateNewClientCommand = new RelayCommand(act =>
            {
                var newWindow = new CreateClientWindow();
                newWindow.Show();
                newWindow.Closed += NewWindow_Closed;
            });

            SelectComplitedCommand=new RelayCommand(act =>
            {
                OnSelectedBedChanged();
                OnSelectedClientEndChanged();
            });
        }
        public MainWindowViewModel()
        {
            OpenTestWindowCommand = new RelayCommand(arg =>
            {
                var newWindow = new SelectRoomWindow();
                newWindow.Show();
            });

            ShowAllBedCommand = new RelayCommand(arg =>
            {
                PageSource = "ShowBedsView.xaml";
            });

            ShowAllRoomCommand = new RelayCommand(act =>
            {
                PageSource = "ShowRoomsView.xaml";
            });

            RegistrNewClientCommand = new RelayCommand(arg =>
            {
                var newWindow = new CreateClientWindow();
                newWindow.Show();
            });

            CreateNewRoomCommand = new RelayCommand(arg =>
            {
                var newWindow = new CreateNewRoomWindow();
                newWindow.Show();
            });

            CreateNewBedCommand = new RelayCommand(arg =>
            {
                var newWindow = new CreateNewBedWindow();
                newWindow.Show();
            });

            ShowClientCommand = new RelayCommand(arg =>
            {
                PageSource = "ShowClientsView.xaml";
            });

            ShowAllCheckCommand = new RelayCommand(arg =>
            {
                PageSource = "ShowChecksView.xaml";
            });

            AddNewCountryCommand = new RelayCommand(act =>
            {
                var newWindow = new CreateNewCountryWindow();
                newWindow.Show();
            });

            AddNewDocumentTypeCommand = new RelayCommand(act =>
            {
                var newWindow = new CreateNewDocumentTypeWindow();
                newWindow.Show();
            });

            CreateNewCheckCommand = new RelayCommand(act =>
            {
                var newWindow = new EditCheckWindow();
                newWindow.Show();
            });
        }
        public EditCheckViewModel()
        {
            Check = new check();
            _isNewClientVisibility = Visibility.Collapsed;
            _isRoomTableVisible = Visibility.Collapsed;
            _isBedTableVisible = Visibility.Collapsed;

            _ordersListBed = new List<CheckOrderBed>();
            _ordersListRoom = new List<CheckOrderRoom>();

            PropertyChanged += EditCheckViewModel_PropertyChanged;

            SelectClientCommand = new RelayCommand(act =>
            {
                var newWindow = new SelectClientWindow();
                newWindow.Show();
                newWindow.ViewModel.SelectedClientChanged += ViewModel_SelectedClientChanged;
            });

            ShowClientCommand = new RelayCommand(act =>
            {
                var newWindow = new CreateClientWindow(Check.ClientId);
                newWindow.Show();
            });

            AddBedCommand = new RelayCommand(act =>
            {
                var newWindow = new SelectBedWindow();
                newWindow.Show();
                newWindow.ViewModel.SelectedBedChanged += ViewModel_SelectedBedChanged;
            });

            AddRoomCommand = new RelayCommand(act =>
            {
                var newWindow = new SelectRoomWindow();
                newWindow.Show();
                newWindow.ViewModel.SelectedRoomChanged += ViewModel_SelectedRoomChanged;
            });

            SaveChangesCommand = new RelayCommand(act =>
            {
                try
                {
                    if (Check.status_check == null)
                    {
                        MessageBox.Show("Укажите статус заказа!", "Неверно заполненны поля",
                           MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    if (Check.order_bed.Count == 0 && Check.order_room.Count == 0)
                    {
                        MessageBox.Show("Добавьте комнату или кровать!", "Неверно заполненны поля",
                           MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    ProjectSettings.DbContext.checks.AddOrUpdate(Check);
                    ProjectSettings.DbContext.SaveChanges();
                    OnRegistration();
                }
                catch (Exception)
                {
                    // ignored
                }
            });
        }