diff --git a/Labaratory/Labaratory/Images/Admin.png b/Labaratory/Labaratory/Images/Admin.png
new file mode 100644
index 0000000..c476114
Binary files /dev/null and b/Labaratory/Labaratory/Images/Admin.png differ
diff --git a/Labaratory/Labaratory/Images/Buhalter.jpeg b/Labaratory/Labaratory/Images/Buhalter.jpeg
new file mode 100644
index 0000000..2c3e9a5
Binary files /dev/null and b/Labaratory/Labaratory/Images/Buhalter.jpeg differ
diff --git a/Labaratory/Labaratory/Images/Laborant.jpeg b/Labaratory/Labaratory/Images/Laborant.jpeg
new file mode 100644
index 0000000..e0c105c
Binary files /dev/null and b/Labaratory/Labaratory/Images/Laborant.jpeg differ
diff --git a/Labaratory/Labaratory/Images/LaborantExplorer.png b/Labaratory/Labaratory/Images/LaborantExplorer.png
new file mode 100644
index 0000000..22e3d88
Binary files /dev/null and b/Labaratory/Labaratory/Images/LaborantExplorer.png differ
diff --git a/Labaratory/Labaratory/Labaratory.csproj b/Labaratory/Labaratory/Labaratory.csproj
index 8e7e902..51cf7ba 100644
--- a/Labaratory/Labaratory/Labaratory.csproj
+++ b/Labaratory/Labaratory/Labaratory.csproj
@@ -38,6 +38,9 @@
4
+
+ ..\packages\BouncyCastle.Cryptography.2.6.2\lib\net461\BouncyCastle.Cryptography.dll
+
..\packages\EasyCaptcha.Wpf.0.9.0.3\lib\net45\EasyCaptcha.Wpf.dll
@@ -47,6 +50,9 @@
..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.SqlServer.dll
+
+ ..\packages\iTextSharp.5.5.13.5\lib\net461\itextsharp.dll
+
..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll
@@ -98,7 +104,10 @@
Model1.tt
+
+
+
Model1.tt
@@ -156,6 +165,10 @@
Model1.tt
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -181,6 +194,9 @@
Code
+
+ AddPatientWindow.xaml
+
AdminWindow.xaml
@@ -233,6 +249,10 @@
+
+
+
+
TextTemplatingFileGenerator
Model1.Context.cs
diff --git a/Labaratory/Labaratory/Models/Model1.Designer.cs b/Labaratory/Labaratory/Models/Model1.Designer.cs
index 4cfa274..e29ec55 100644
--- a/Labaratory/Labaratory/Models/Model1.Designer.cs
+++ b/Labaratory/Labaratory/Models/Model1.Designer.cs
@@ -1,4 +1,4 @@
-// Создание кода T4 для модели "C:\Users\usersql\Source\Repos\UP01TASK3\Labaratory\Labaratory\Models\Model1.edmx" включено.
+// Создание кода T4 для модели "C:\Users\usersql\source\repos\UP01TASK3\Labaratory\Labaratory\Models\Model1.edmx" включено.
// Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
// на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
// открыта в конструкторе.
diff --git a/Labaratory/Labaratory/Models/Model1.edmx b/Labaratory/Labaratory/Models/Model1.edmx
index 0b22d44..58feb0d 100644
--- a/Labaratory/Labaratory/Models/Model1.edmx
+++ b/Labaratory/Labaratory/Models/Model1.edmx
@@ -46,13 +46,11 @@
-
-
+
@@ -386,6 +384,7 @@
+
@@ -397,14 +396,6 @@
-
- SELECT
- [LoggnHistory].[ID] AS [ID],
- [LoggnHistory].[Login] AS [Login],
- [LoggnHistory].[AttemptTime] AS [AttemptTime],
- [LoggnHistory].[IsSuccess] AS [IsSuccess]
- FROM [dbo].[LoggnHistory] AS [LoggnHistory]
-
diff --git a/Labaratory/Labaratory/Services/AuthService.cs b/Labaratory/Labaratory/Services/AuthService.cs
new file mode 100644
index 0000000..0ef039e
--- /dev/null
+++ b/Labaratory/Labaratory/Services/AuthService.cs
@@ -0,0 +1,26 @@
+using Labaratory.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Labaratory.Services
+{
+ public static class AuthService
+ {
+ public static void LogAttempt(string login, bool isSuccess)
+ {
+ using (var db = new Models.LaboratoryDBEntities())
+ {
+ db.LoggnHistories.Add(new Models.LoggnHistory
+ {
+ AttemptTime = DateTime.Now,
+ Login = login,
+ IsSuccess = isSuccess
+ });
+ db.SaveChanges();
+ }
+ }
+ }
+}
diff --git a/Labaratory/Labaratory/Services/StringToImageConverter.cs b/Labaratory/Labaratory/Services/StringToImageConverter.cs
new file mode 100644
index 0000000..5bbc254
--- /dev/null
+++ b/Labaratory/Labaratory/Services/StringToImageConverter.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media.Imaging;
+
+namespace Labaratory.Services
+{
+ public class StringToImageConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string imageName = value as string;
+
+ if (string.IsNullOrWhiteSpace(imageName))
+ return null;
+
+ try
+ {
+ return new BitmapImage(new Uri($"pack://application:,,,/Images/{imageName}"));
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ => throw new NotImplementedException();
+ }
+}
diff --git a/Labaratory/Labaratory/Services/Valid.cs b/Labaratory/Labaratory/Services/Valid.cs
index 7edd86a..5f70b1e 100644
--- a/Labaratory/Labaratory/Services/Valid.cs
+++ b/Labaratory/Labaratory/Services/Valid.cs
@@ -1,4 +1,7 @@
-using System;
+using Labaratory.Models;
+using Labaratory.ViewModels;
+using Labaratory.Views;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -26,5 +29,40 @@ namespace Labaratory.Services
if (string.IsNullOrEmpty(input)) return false;
return input.Trim().ToUpper() == original.ToUpper();
}
+ public static void OpenRoleWindow(User user)
+ {
+ if (user.Role.Value == 1)
+ {
+ var nextWindow = new AdminWindow();
+
+ var mainVM = new AdminModel(user);
+ nextWindow.DataContext = mainVM;
+ nextWindow.Show();
+ }
+ if (user.Role.Value == 2)
+ {
+ var nextWindow = new ByhalterWindow();
+
+ var mainVM = new ByhalterModel(user);
+ nextWindow.DataContext = mainVM;
+ nextWindow.Show();
+ }
+ if (user.Role.Value == 3)
+ {
+ var nextWindow = new Views.Laborant();
+
+ var mainVM = new ViewModels.Laborant(user);
+ nextWindow.DataContext = mainVM;
+ nextWindow.Show();
+ }
+ if (user.Role.Value == 4)
+ {
+ var nextWindow = new Views.LaborantExplorer();
+
+ var mainVM = new ViewModels.LaborantExplorer(user);
+ nextWindow.DataContext = mainVM;
+ nextWindow.Show();
+ }
+ }
}
}
diff --git a/Labaratory/Labaratory/ViewModels/AddPatientViewModel.cs b/Labaratory/Labaratory/ViewModels/AddPatientViewModel.cs
new file mode 100644
index 0000000..2332de6
--- /dev/null
+++ b/Labaratory/Labaratory/ViewModels/AddPatientViewModel.cs
@@ -0,0 +1,102 @@
+using Labaratory.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using Wpf.Ui.Input;
+
+namespace Labaratory.ViewModels
+{
+ public class AddPatientViewModel : BaseViewModel
+ {
+ private Models.LaboratoryDBEntities db = new Models.LaboratoryDBEntities();
+
+ public string Surname { get; set; }
+ public string FirstName { get; set; }
+ public string Patronymic { get; set; }
+ public DateTime BirthDate { get; set; } = DateTime.Now.AddYears(-20);
+ public string PassportSeries { get; set; }
+ public string PassportNumber { get; set; }
+ public string Phone { get; set; }
+ public string Email { get; set; }
+ public string InsuranceNumber { get; set; }
+
+ public List PolicyTypes => db.Policy_Types.ToList();
+ public List Companies => db.Insurance_Companies.ToList();
+
+ public Models.Policy_Types SelectedPolicyType { get; set; }
+ public Models.Insurance_Companies SelectedCompany { get; set; }
+
+ public Models.Patient SavedPatient { get; private set; }
+ public ICommand SaveCommand { get; }
+ public ICommand CancelCommand { get; }
+
+ public AddPatientViewModel()
+ {
+ SaveCommand = new RelayCommand(ExecuteSave);
+ CancelCommand = new RelayCommand(ExecuteCancel);
+ }
+
+ private void ExecuteSave(Window window)
+ {
+ if (Save())
+ {
+ if (window != null)
+ {
+ window.DialogResult = true;
+ window.Close();
+ }
+ }
+ }
+
+ private void ExecuteCancel(Window window)
+ {
+ if (window != null)
+ {
+ window.DialogResult = false;
+ window.Close();
+ }
+ }
+
+ public bool Save()
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(Surname) || string.IsNullOrWhiteSpace(FirstName))
+ {
+ MessageBox.Show("Заполните обязательные поля: Фамилия и Имя");
+ return false;
+ }
+
+ var newPatient = new Models.Patient
+ {
+ Surname = Surname,
+ FirstName = FirstName,
+ Patronymic = Patronymic,
+ BirthDate = BirthDate,
+ PassportSeries = PassportSeries,
+ PassportNumber = PassportNumber,
+ Phone = Phone,
+ Email = Email,
+ InsuranceNumber = InsuranceNumber,
+ PolicyType = SelectedPolicyType?.ID_PolicyType,
+ Company = SelectedCompany?.ID_Company
+ };
+
+ db.Patients.Add(newPatient);
+ db.SaveChanges();
+
+ SavedPatient = newPatient;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Ошибка при сохранении: " + ex.Message);
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Labaratory/Labaratory/ViewModels/AdminModel.cs b/Labaratory/Labaratory/ViewModels/AdminModel.cs
index 7b30107..5035eab 100644
--- a/Labaratory/Labaratory/ViewModels/AdminModel.cs
+++ b/Labaratory/Labaratory/ViewModels/AdminModel.cs
@@ -7,6 +7,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Wpf.Ui.Input;
+using Labaratory.Models;
+using System.Collections.ObjectModel;
namespace Labaratory.ViewModels
{
@@ -17,6 +19,40 @@ namespace Labaratory.ViewModels
public AdminModel(Models.User user)
{
CurrentUser = user;
+ LoadData();
+ }
+ private Models.LaboratoryDBEntities db = new Models.LaboratoryDBEntities();
+ private string _filterLogin;
+ private List _allLogs;
+
+ public string FilterLogin
+ {
+ get => _filterLogin;
+ set { _filterLogin = value; OnPropertyChanged(); ApplyFilter(); }
+ }
+
+ private ObservableCollection _history;
+ public ObservableCollection History
+ {
+ get => _history;
+ set { _history = value; OnPropertyChanged(); }
+ }
+ public void LoadData()
+ {
+ _allLogs = db.LoggnHistories.OrderByDescending(h => h.AttemptTime).ToList();
+ History = new ObservableCollection(_allLogs);
+ }
+
+ private void ApplyFilter()
+ {
+ var filtered = _allLogs.AsEnumerable();
+
+ if (!string.IsNullOrWhiteSpace(FilterLogin))
+ {
+ filtered = filtered.Where(h => h.Login.ToLower().Contains(FilterLogin.ToLower()));
+ }
+
+ History = new ObservableCollection(filtered);
}
}
}
diff --git a/Labaratory/Labaratory/ViewModels/Laborant.cs b/Labaratory/Labaratory/ViewModels/Laborant.cs
index 958e060..abf57ca 100644
--- a/Labaratory/Labaratory/ViewModels/Laborant.cs
+++ b/Labaratory/Labaratory/ViewModels/Laborant.cs
@@ -4,6 +4,14 @@ using System.Linq;
using System.Text;
using System.Windows;
using System.Threading.Tasks;
+using iTextSharp.text;
+using iTextSharp.text.pdf;
+using System.IO;
+using Labaratory.Models;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using Wpf.Ui.Input;
+using Labaratory.Views;
namespace Labaratory.ViewModels
{
@@ -15,10 +23,34 @@ namespace Labaratory.ViewModels
{
CurrentUser = user;
CalculateNextNumber();
+ ProcessOrderCommand = new RelayCommand
+
\ No newline at end of file
diff --git a/Labaratory/Labaratory/Views/LaborantWindow.xaml.cs b/Labaratory/Labaratory/Views/LaborantWindow.xaml.cs
index 428f865..029094a 100644
--- a/Labaratory/Labaratory/Views/LaborantWindow.xaml.cs
+++ b/Labaratory/Labaratory/Views/LaborantWindow.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using Labaratory.Models;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -22,7 +23,6 @@ namespace Labaratory.Views
public Laborant()
{
InitializeComponent();
- DataContext = new Laborant();
}
}
}
diff --git a/Labaratory/Labaratory/packages.config b/Labaratory/Labaratory/packages.config
index c99e7e3..fe65b39 100644
--- a/Labaratory/Labaratory/packages.config
+++ b/Labaratory/Labaratory/packages.config
@@ -1,8 +1,9 @@
+
-
+