public CreateDocumentTypeViewModel() { SaveCommand = new RelayCommand(act => { if (!string.IsNullOrEmpty(_name)) { if (ProjectSettings.DbContext.document_type.All(c => c.Name != _name)) { ProjectSettings.DbContext.document_type.AddOrUpdate(new document_type { Name = _name, Identity = _identity }); ProjectSettings.DbContext.SaveChanges(); OnRegistration(); } else { MessageBox.Show("Такой тип документов уже зарегистрирован в системе!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Не заполнено поле \"Имя\"!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); } }); }
public SelectRoomViewModel() { Title = "Выбор комнаты"; _rooms = new List<RoomForSelect>(); var temp = ProjectSettings.DbContext.rooms.Where(b => (b.Price >= StartPrice && b.Price <= EndPrice)).ToList(); foreach ( var item in ProjectSettings.DbContext.order_room.Where( ob => (ob.StartDate >= StartDate && ob.StartDate <= EndDate) || (ob.EndDate >= StartDate && ob.EndDate <= EndDate))) { temp.Remove(item.room); } foreach (var item in temp) { _rooms.Add(new RoomForSelect(item)); } _selectedRooms = new List<room>(); PropertyChanged += SelectBedViewModel_PropertyChanged; SelectCommand = new RelayCommand(act => { SelectedRooms = Rooms.Where(item => item.IsSelect).Select(item => item.Room).ToList(); }); }
public SelectBedViewModel() { Title = "Выбор кровати"; _beds = new List<BedForSelect>(); var temp = ProjectSettings.DbContext.beds.Where(b => (b.Price >= StartPrice && b.Price <= EndPrice)).ToList(); foreach ( var item in ProjectSettings.DbContext.order_bed.Where( ob => (ob.StartDate >= StartDate && ob.StartDate <= EndDate) || (ob.EndDate >= StartDate && ob.EndDate <= EndDate))) { temp.Remove(item.bed); } foreach (var item in temp) { _beds.Add(new BedForSelect(item)); } _selectedBeds = new List<bed>(); PropertyChanged += SelectBedViewModel_PropertyChanged; SelectCommand = new RelayCommand(act => { SelectedBeds = Beds.Where(item => item.IsSelect).Select(item => item.Bed).ToList(); }); }
public ShowOneRoomViewModel() { SaveChangesCommand = new RelayCommand(act => { if (Room != null) { var tempRoom = ProjectSettings.DbContext.rooms.FirstOrDefault(r => r.Id == Room.Id); if (tempRoom != null && Room.Price > 0) { tempRoom.Price = Room.Price; if (Room.LastServiceDate != null) { tempRoom.LastServiceDate = Room.LastServiceDate; } } else if (Room.Price <= 0) { MessageBox.Show("Цена не может быть меньше или равной 0", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); return; } ProjectSettings.DbContext.SaveChanges(); OnRegistration(); } }); }
public CreateCountryViewModel() { SaveCommand = new RelayCommand(act => { if (!string.IsNullOrEmpty(_name)) { if (ProjectSettings.DbContext.countries.All(c => c.Name != _name)) { ProjectSettings.DbContext.countries.AddOrUpdate(new country { Name = _name }); ProjectSettings.DbContext.SaveChanges(); OnRegistration(); } else { MessageBox.Show("Страна с таким именем уже зарегистрирована в системе!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Не заполнено поле \"Имя\"!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); } }); }
public CreateNewDocumentViewModel() { SaveCommand = new RelayCommand(act => { if (Country == null) { MessageBox.Show("Укажите страну!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (Type == null) { MessageBox.Show("Укажите тип документа!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (Type.Identity) { DocumentI = new identity_document { CountryId = _country.Id, DocumentTypeId = _type.Id, Number = _number, Series = _series, country = _country, document_type = _type }; OnRegistrationI(); } else { if (_validDate != null && _incomeDate != null) { DocumentM = new migration_document { CountryId = _country.Id, DocumentTypeId = _type.Id, Number = _number, Series = _series, ValidDate = (DateTime) _validDate, IncomeDate = (DateTime) _incomeDate, country = _country, document_type = _type }; OnRegistrationM(); } else { MessageBox.Show("Укажите обе даты!", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); return; } } OnEndRegistrationEvent(); }); }
public CreateBedViewModel() { SaveCommand = new RelayCommand(act => { if (Save()) { OnRegistration(); } }); }
public AuthViewModel() { AuthButtonClickCommand = new RelayCommand(arg => { if (!AuthFunction()) return; var newWindow = new MainWindow(); OnAuth(); newWindow.Show(); }); }
public ShowRoomsViewModel() { Recalck(); PropertyChanged += ShowBedsViewModel_PropertyChanged; CreateNewRoomCommand = new RelayCommand(act => { var newWindow = new CreateNewRoomWindow(); 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 ShowOneBedViewModel() { SaveChangesCommand=new RelayCommand(act => { if (Bed != null) { var tempBed = ProjectSettings.DbContext.beds.FirstOrDefault(b => b.Id == Bed.Id); if (tempBed != null && Bed.Price > 0) tempBed.Price = Bed.Price; else if (Bed.Price <= 0) { MessageBox.Show("Цена не может быть меньше или равной 0", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); return; } ProjectSettings.DbContext.SaveChanges(); OnRegistration(); } }); }
public ClientViewModel() { _client = new client {BirthDate = DateTime.Today}; RegistrNewClientCommand = new RelayCommand(arg => { if ((string.IsNullOrEmpty(Client.Email) && !string.IsNullOrEmpty(Client.Password)) || (!string.IsNullOrEmpty(Client.Email) && string.IsNullOrEmpty(Client.Password))) { MessageBox.Show("Пожалуйста укажите пароль и Email", "Неверно заполненны поля", MessageBoxButton.OK, MessageBoxImage.Warning); } else { if (SaveClient()) OnRegistration(); } }); AddNewDocumentICommand = new RelayCommand(act => { var newWindow = new CreateNewDocumentWindow(true); newWindow.Show(); newWindow.ViewModel.RegistrationDocumentIEvent += ViewModel_RegistrationDocumentIEvent; newWindow.Closed += NewWindow_Closed; }); AddNewDocumentMCommand = new RelayCommand(act => { var newWindow = new CreateNewDocumentWindow(false); newWindow.Show(); newWindow.ViewModel.RegistrationDocumentMEvent += ViewModel_RegistrationDocumentMEvent; newWindow.Closed += NewWindow_Closed; }); AutoGeneratePassword = new RelayCommand(arg => { Client.Password = ProjectSettings.GenerateKey(); OnPropertyChanged("Client"); }); }
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 } }); }