public void MakeAttachmentsToEvents(PersonInfoModel pInfo) { pInfo.PropertyChanged += HabitantDetailsView_PropertyChanged; if (pInfo.Payments != null) { pInfo.Payments.CollectionChanged += Payments_CollectionChanged; } }
public PersonInfoView(PersonInfoModel oldViewModel) { InitializeComponent(); removedPayments = new List<PersonPaymentsModel>(); this.DataContext = oldViewModel; oldContextKeeper = new BinaryFormatter(); ms = new MemoryStream(); oldContextKeeper.Serialize(ms, oldViewModel); MakeAttachmentsToEvents(oldViewModel); }
private void CancelButton_Click(object sender, RoutedEventArgs e) { if (((PersonInfoModel)this.DataContext).ViewModelStatus==RecordActions.Inserted) { this.Close(); } else { ms.Position = 0; oldContext = (PersonInfoModel)oldContextKeeper.Deserialize(ms); MakeAttachmentsToEvents(oldContext); this.DataContext = oldContext; removedPayments = new List<PersonPaymentsModel>(); InitialOperations(); } }
private void LoginWin_onKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { //FullFillDBWithRooms(); //FullFillDBWithFurniture(); try { using (DataBaseConnector dbService = new DataBaseConnector(5)) { PersonInfoModel viewPerson; IRoom dbRoom; List<IRoom> tempRoomList = new List<IRoom>(); PersonInfoListView hb = new PersonInfoListView(); ObservableCollection<PersonInfoModel> viewPersons = new ObservableCollection<PersonInfoModel>(); List<IPersonInfo> dbPersons = dbService.GetAllRecords<IPersonInfo>(); List<IRoom> dbRoomList = dbService.GetAllRecords<IRoom>(); PropertyInfo[] propInfos = typeof(IPersonInfo).GetProperties(); foreach (var dbPer in dbPersons) { viewPerson = new PersonInfoModel(); foreach (var curPropt in propInfos) { curPropt.SetValue(viewPerson, curPropt.GetValue(dbPer)); } tempRoomList = dbRoomList.Where(t => t.UUID == viewPerson.RoomUUID).ToList(); if (tempRoomList.Count>0) { dbRoom = tempRoomList[0]; viewPerson.RoomNumber = dbRoom.RoomNumber; } viewPersons.Add(viewPerson); } PersonInfoListViewModel hbViewModel = new PersonInfoListViewModel(viewPersons); hb.NewButton.Click += hbViewModel.NewButton_Click; hb.ManagerButton.Click += hbViewModel.ManagerButton_Click; hb.SchemeButton.Click += hbViewModel.SchemeButton_Click; hb.Redirect_HabitantsGridRow_DoubleClick += hbViewModel.Row_DoubleClick; hb.Redirect_HabitantsGridRow_MouseLeftButtonDown += hbViewModel.Row_MouseLeftButtonDown; hb.DataContext = hbViewModel; hb.Show(); } } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }
public void NewButton_Click(object sender, RoutedEventArgs e) { PersonInfoModel outputPersonInfo = new PersonInfoModel(); outputPersonInfo.UUID = Guid.NewGuid().ToString(); outputPersonInfo.ViewModelStatus = RecordActions.Inserted; PersonInfoView hbDetailed = new PersonInfoView(outputPersonInfo); hbDetailed.ParentListView = this; hbDetailed.Show(); }
public void UpdatePersonList(PersonInfoModel person, RecordActions status) { PersonInfoModel tempPerson; switch (status) { case RecordActions.Inserted: Habitants.Add(person); break; /*case RecordActions.Updated: //PersonInfo object itselt is passed to DetailedWindow tempPerson = Habitants.Where(t => t.UUID == person.UUID).FirstOrDefault(); if (tempPerson != null) tempPerson = person; break;*/ case RecordActions.Deleted: Habitants.Remove(person); break; } }