Добавление папк для паттерна MVVM.
Иницилиазация и элементарый вывод работника. (Без БД)
This commit is contained in:
parent
95d899f508
commit
e768af07da
3
App.xaml
3
App.xaml
@ -1,8 +1,7 @@
|
||||
<Application x:Class="EmployeeManagementApp.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:EmployeeManagementApp"
|
||||
StartupUri="MainWindow.xaml">
|
||||
xmlns:local="clr-namespace:EmployeeManagementApp">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
|
@ -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
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
MainView mainView = new MainView();
|
||||
mainView.Show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
)]
|
@ -1,12 +0,0 @@
|
||||
<Window x:Class="EmployeeManagementApp.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:EmployeeManagementApp"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
18
Models/Employee.cs
Normal file
18
Models/Employee.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
19
ViewModels/BaseViewModel.cs
Normal file
19
ViewModels/BaseViewModel.cs
Normal file
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
25
ViewModels/MainViewModel.cs
Normal file
25
ViewModels/MainViewModel.cs
Normal file
@ -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<Employee> Employees { get; set; }
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
// Инициализация данных
|
||||
Employees = new ObservableCollection<Employee>
|
||||
{
|
||||
new Employee { Id = 1, FirstName = "Иван", LastName = "Иванов", Position = "Менеджер", Salary = 50000, VacationDays = 14 },
|
||||
new Employee { Id = 2, FirstName = "Мария", LastName = "Петрова", Position = "Разработчик", Salary = 70000, VacationDays = 20 }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
22
Views/MainView.xaml
Normal file
22
Views/MainView.xaml
Normal file
@ -0,0 +1,22 @@
|
||||
<Window x:Class="EmployeeManagementApp.Views.MainView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:EmployeeManagementApp.ViewModels"
|
||||
Title="Управление Сотрудниками" Height="400" Width="600">
|
||||
<Window.DataContext>
|
||||
<vm:MainViewModel />
|
||||
</Window.DataContext>
|
||||
|
||||
<Grid>
|
||||
<DataGrid ItemsSource="{Binding Employees}" AutoGenerateColumns="False" Margin="10">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50" />
|
||||
<DataGridTextColumn Header="Имя" Binding="{Binding FirstName}" Width="150" />
|
||||
<DataGridTextColumn Header="Фамилия" Binding="{Binding LastName}" Width="150" />
|
||||
<DataGridTextColumn Header="Должность" Binding="{Binding Position}" Width="150" />
|
||||
<DataGridTextColumn Header="Зарплата" Binding="{Binding Salary}" Width="100" />
|
||||
<DataGridTextColumn Header="Дни отпуска" Binding="{Binding VacationDays}" Width="100" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// Логика взаимодействия для MainView.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainView : Window
|
||||
{
|
||||
public MainWindow()
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user