PIbd-42_Kashin_M.I_CPO_Cour.../ViewModel/DataManageViewModel.cs

90 lines
2.5 KiB
C#
Raw Normal View History

using EmployeeManager.Model;
using EmployeeManager.View.PhysicalPerson;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace EmployeeManager.ViewModel
{
public class DataManageViewModel : INotifyPropertyChanged
{
private List<PhysicalPerson> allPhysicalPeoples = DataWorker.GetAllPhysicalPerson();
public List<PhysicalPerson> AllPhysicalPeoples
{
get { return allPhysicalPeoples; }
set
{
allPhysicalPeoples = value;
NotifyPropertyChanged("AllPhysicalPeoples");
}
}
private RelayCommand openPhysicalPersoManagementWindow;
public RelayCommand OpenPhysicalPersoManagementWindow
{
get
{
return openPhysicalPersoManagementWindow ?? new RelayCommand(obj =>
{
OpenPhysicalPersoManagementWindowMethod();
}
);
}
}
private RelayCommand openAddPhysicalPersonWindow;
public RelayCommand OpenAddPhysicalPersonWindow
{
get
{
return openAddPhysicalPersonWindow ?? new RelayCommand(obj =>
{
OpenAddPhysicalPersonWindowMethod();
}
);
}
}
private void OpenPhysicalPersoManagementWindowMethod()
{
PhysicalPersoManagementWindow newPhysicalPersoManagementWindow = new PhysicalPersoManagementWindow();
SetCenterPositionAndOpen(newPhysicalPersoManagementWindow);
}
private void OpenAddPhysicalPersonWindowMethod()
{
AddPhysicalPersonWindow newAddPhysicalPersonWindow = new AddPhysicalPersonWindow();
SetCenterPositionAndOpen(newAddPhysicalPersonWindow);
}
private void SetCenterPositionAndOpen(Window window)
{
window.Owner = Application.Current.MainWindow;
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
window.ShowDialog();
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}