/
SergeyReHub
/
WPF_Project_TeraTeams
Обзор
Документация
Войти
/
SergeyReHub
/
WPF_Project_TeraTeams
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ViewModel/ClientFormViewModel.cs
149 строк
4 KB
SergeyReHub
Code_commit
08 дек 2024, 11:43
08 дек 2024, 11:43
33f488f
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using CursovayaRybakov.Model; using CursovayaRybakov.View; using System.Threading.Tasks; using CursovayaRybakov.Navigation; using System.Windows; using CursovayaRybakov.Repositories; using System.Windows.Input; using Org.BouncyCastle.Crypto.Modes; namespace CursovayaRybakov.ViewModel { public class ClientFormViewModel : ViewModelBase { //Values public Client client; private readonly IWindowService _windowService; string _polis; string _bolnichny; string _years; string _name; string _recordTime; string _info; string _textButtonBolnichniy; //Properties public string TextButtonBolnichniy { get { return _textButtonBolnichniy; } set { _textButtonBolnichniy = value; OnPropertyChanged(nameof(TextButtonBolnichniy)); } } public string Polis { get { return _polis; } set { _polis = value; OnPropertyChanged(nameof(Polis)); } } public string Bolnichny { get { return _bolnichny; } set { _bolnichny = value; OnPropertyChanged(nameof(Bolnichny)); } } public string Years { get { return _years; } set { _years = value; OnPropertyChanged(nameof(Years)); } } public string Name { get { return _name; } set { _name = value; OnPropertyChanged(nameof(Name)); } } public string RecodTime { get { return _recordTime; } set { _recordTime = value; OnPropertyChanged(nameof(RecodTime)); } } public string Info { get { return _info; } set { _info = value; OnPropertyChanged(nameof(Info)); } } //Commands public ICommand SaveChangesCommand { get; } public ICommand BackCommand { get; } public ICommand ChangeBolnichniyCommand { get; } //Constructor public ClientFormViewModel(IWindowService windowService, Client client) { _windowService = windowService; this.client = client; //Taking Client from bindable element by paramtr Polis = client.Polys; if (client.Bolnichniy) { Bolnichny = "На больничном"; TextButtonBolnichniy = "Закрыть больничный"; } else {Bolnichny = "Не болеет"; TextButtonBolnichniy = "Отправить на больничный"; } Years = "Лет: " + Convert.ToString(client.Years); Name = client.Name; RecodTime = client.Record_Time_String; SaveChangesCommand = new ViewModelComand(SaveChangesCommandExecute); BackCommand = new ViewModelComand(BackCommandExecute); ChangeBolnichniyCommand = new ViewModelComand(ChangeBolnichniyCommandExecute); } void SaveChangesCommandExecute(object obj) { ElementListRepository elementList = new ElementListRepository(); if(elementList.ChangeInfo(Info, client.Id)) _windowService.ShowWindow(new ListClients()); } void BackCommandExecute(object obj) { _windowService.ShowWindow(new ListClients()); } void ChangeBolnichniyCommandExecute(object obj) { client.Bolnichniy = !client.Bolnichniy; if (client.Bolnichniy) { Bolnichny = "На больничном"; TextButtonBolnichniy = "Закрыть больничный"; } else { Bolnichny = "Не болеет"; TextButtonBolnichniy = "Отправить на больничный"; } } } }