From e768af07da83a2968bd038af605eeba48af2073f Mon Sep 17 00:00:00 2001 From: maksim Date: Mon, 11 Nov 2024 16:11:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0=D0=BF=D0=BA=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B0=D1=82=D1=82=D0=B5=D1=80=D0=BD=D0=B0=20MVV?= =?UTF-8?q?M.=20=D0=98=D0=BD=D0=B8=D1=86=D0=B8=D0=BB=D0=B8=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B8=20=D1=8D=D0=BB=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0.=20(=D0=91=D0=B5=D0=B7=20=D0=91=D0=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.xaml | 3 +-- App.xaml.cs | 9 ++++++- AssemblyInfo.cs | 10 -------- MainWindow.xaml | 12 ---------- Models/Employee.cs | 18 ++++++++++++++ ViewModels/BaseViewModel.cs | 19 +++++++++++++++ ViewModels/MainViewModel.cs | 25 ++++++++++++++++++++ Views/MainView.xaml | 22 +++++++++++++++++ MainWindow.xaml.cs => Views/MainView.xaml.cs | 17 +++++++------ 9 files changed, 103 insertions(+), 32 deletions(-) delete mode 100644 AssemblyInfo.cs delete mode 100644 MainWindow.xaml create mode 100644 Models/Employee.cs create mode 100644 ViewModels/BaseViewModel.cs create mode 100644 ViewModels/MainViewModel.cs create mode 100644 Views/MainView.xaml rename MainWindow.xaml.cs => Views/MainView.xaml.cs (53%) diff --git a/App.xaml b/App.xaml index 5a7a43e..600ae3b 100644 --- a/App.xaml +++ b/App.xaml @@ -1,8 +1,7 @@  + xmlns:local="clr-namespace:EmployeeManagementApp"> diff --git a/App.xaml.cs b/App.xaml.cs index ae334b7..46a75d1 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,5 @@ -using System.Configuration; +using EmployeeManagementApp.Views; +using System.Configuration; using System.Data; using System.Windows; @@ -9,6 +10,12 @@ namespace EmployeeManagementApp /// public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + MainView mainView = new MainView(); + mainView.Show(); + } } } diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs deleted file mode 100644 index b0ec827..0000000 --- a/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/MainWindow.xaml b/MainWindow.xaml deleted file mode 100644 index b204bba..0000000 --- a/MainWindow.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/Models/Employee.cs b/Models/Employee.cs new file mode 100644 index 0000000..008a9c6 --- /dev/null +++ b/Models/Employee.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagementApp.Models +{ + public class Employee + { + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string Position { get; set; } + public decimal Salary { get; set; } + public int VacationDays { get; set; } + } +} diff --git a/ViewModels/BaseViewModel.cs b/ViewModels/BaseViewModel.cs new file mode 100644 index 0000000..ec59722 --- /dev/null +++ b/ViewModels/BaseViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagementApp.ViewModels +{ + public class BaseViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..957cd70 --- /dev/null +++ b/ViewModels/MainViewModel.cs @@ -0,0 +1,25 @@ +using EmployeeManagementApp.Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagementApp.ViewModels +{ + public class MainViewModel : BaseViewModel + { + public ObservableCollection Employees { get; set; } + + public MainViewModel() + { + // Инициализация данных + Employees = new ObservableCollection + { + new Employee { Id = 1, FirstName = "Иван", LastName = "Иванов", Position = "Менеджер", Salary = 50000, VacationDays = 14 }, + new Employee { Id = 2, FirstName = "Мария", LastName = "Петрова", Position = "Разработчик", Salary = 70000, VacationDays = 20 } + }; + } + } +} diff --git a/Views/MainView.xaml b/Views/MainView.xaml new file mode 100644 index 0000000..f167745 --- /dev/null +++ b/Views/MainView.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/MainWindow.xaml.cs b/Views/MainView.xaml.cs similarity index 53% rename from MainWindow.xaml.cs rename to Views/MainView.xaml.cs index b053788..b472e6b 100644 --- a/MainWindow.xaml.cs +++ b/Views/MainView.xaml.cs @@ -1,4 +1,8 @@ -using System.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -6,19 +10,18 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Navigation; using System.Windows.Shapes; -namespace EmployeeManagementApp +namespace EmployeeManagementApp.Views { /// - /// Interaction logic for MainWindow.xaml + /// Логика взаимодействия для MainView.xaml /// - public partial class MainWindow : Window + public partial class MainView : Window { - public MainWindow() + public MainView() { InitializeComponent(); } } -} \ No newline at end of file +}