From 32a16c9954e592606cf340f861350f9a88674716 Mon Sep 17 00:00:00 2001
From: Mikan <72257910+Mikan-DS@users.noreply.github.com>
Date: Thu, 22 May 2025 21:15:36 +0300
Subject: [PATCH] update
---
OfficeFlow/Models/Utils/User.cs | 37 +++++
OfficeFlow/OfficeFlow.csproj | 15 ++
.../Pages/EmployeePages/EmployeesPage.xaml | 14 ++
.../Pages/EmployeePages/EmployeesPage.xaml.cs | 28 ++++
.../EmployeePages/EmployeesPositionsPage.xaml | 14 ++
.../EmployeesPositionsPage.xaml.cs | 28 ++++
OfficeFlow/Pages/LoginPage.xaml.cs | 9 ++
OfficeFlow/Pages/MainPage.xaml.cs | 92 +++++++++++-
.../StartupPages/InitializeDataPage.xaml.cs | 133 ++++++++++++++++++
9 files changed, 369 insertions(+), 1 deletion(-)
create mode 100644 OfficeFlow/Models/Utils/User.cs
create mode 100644 OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml
create mode 100644 OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml.cs
create mode 100644 OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml
create mode 100644 OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml.cs
diff --git a/OfficeFlow/Models/Utils/User.cs b/OfficeFlow/Models/Utils/User.cs
new file mode 100644
index 0000000..7595f43
--- /dev/null
+++ b/OfficeFlow/Models/Utils/User.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OfficeFlow.Models
+{
+ public partial class User
+ {
+ public Role Role {
+
+ get
+ {
+ return this.User_Role.FirstOrDefault()?.Role;
+ }
+ set
+ {
+ var userRole = this.User_Role.FirstOrDefault();
+ if (userRole == null)
+ {
+ userRole = new User_Role {
+
+ User = this,
+
+
+ };
+
+ App.Entities.User_Role.Add(userRole);
+ }
+ userRole.Role = value;
+
+ }
+
+ }
+ }
+}
diff --git a/OfficeFlow/OfficeFlow.csproj b/OfficeFlow/OfficeFlow.csproj
index d129894..7720e6d 100644
--- a/OfficeFlow/OfficeFlow.csproj
+++ b/OfficeFlow/OfficeFlow.csproj
@@ -64,6 +64,13 @@
MSBuild:Compile
Designer
+
+
+ EmployeesPage.xaml
+
+
+ EmployeesPositionsPage.xaml
+
NewEmployeePage.xaml
@@ -89,6 +96,14 @@
MainWindow.xaml
Code
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml b/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml
new file mode 100644
index 0000000..c5ba3bd
--- /dev/null
+++ b/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml.cs b/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml.cs
new file mode 100644
index 0000000..5cbcfc4
--- /dev/null
+++ b/OfficeFlow/Pages/EmployeePages/EmployeesPage.xaml.cs
@@ -0,0 +1,28 @@
+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;
+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 OfficeFlow.Pages.EmployeePages
+{
+ ///
+ /// Interaction logic for EmployeesPage.xaml
+ ///
+ public partial class EmployeesPage : Page
+ {
+ public EmployeesPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml b/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml
new file mode 100644
index 0000000..b4f358d
--- /dev/null
+++ b/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml.cs b/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml.cs
new file mode 100644
index 0000000..b54e4ed
--- /dev/null
+++ b/OfficeFlow/Pages/EmployeePages/EmployeesPositionsPage.xaml.cs
@@ -0,0 +1,28 @@
+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;
+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 OfficeFlow.Pages.EmployeePages
+{
+ ///
+ /// Interaction logic for EmployeesPositionsPage.xaml
+ ///
+ public partial class EmployeesPositionsPage : Page
+ {
+ public EmployeesPositionsPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/OfficeFlow/Pages/LoginPage.xaml.cs b/OfficeFlow/Pages/LoginPage.xaml.cs
index ad86e7a..c1d00eb 100644
--- a/OfficeFlow/Pages/LoginPage.xaml.cs
+++ b/OfficeFlow/Pages/LoginPage.xaml.cs
@@ -28,7 +28,16 @@ namespace OfficeFlow.Pages
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
+ try
+ {
+ Session.Authenticate(App.Entities.Users.FirstOrDefault());
+ }
+ finally
+ {
+
+ NavigationService.Navigate(new MainPage());
+ }
string login = LoginTextBox.Text.Trim();
string password = PasswordBox.Password;
diff --git a/OfficeFlow/Pages/MainPage.xaml.cs b/OfficeFlow/Pages/MainPage.xaml.cs
index 5eb271b..cb5b10f 100644
--- a/OfficeFlow/Pages/MainPage.xaml.cs
+++ b/OfficeFlow/Pages/MainPage.xaml.cs
@@ -1,4 +1,5 @@
-using OfficeFlow.Utils;
+using OfficeFlow.Pages.EmployeePages;
+using OfficeFlow.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,6 +32,95 @@ namespace OfficeFlow.Pages
public void ReloadMenu()
{
MainMenu.Items.Clear();
+
+ string roleName = Session.CurrentUser.Role.RoleName;
+
+ if (roleName == "Администратор")
+ {
+
+ MainMenu.Items.Add(CreateAdminMenu());
+ }
+
+
+ var aboutMenuItem = new MenuItem
+ {
+ Header = "Справка",
+
+ };
+
+ aboutMenuItem.Click += MenuItemAbout_Click;
+
+ MainMenu.Items.Add(
+
+ aboutMenuItem
+
+ );
+
+ }
+
+ private MenuItem CreateAdminMenu()
+ {
+ MenuItem adminMenuItem = new MenuItem
+ {
+ Name = "MenuItemAdmin",
+ Header = "Администрирование"
+
+ };
+
+ var empl = new MenuItem
+ {
+ Header = "Сотрудники",
+
+ };
+ empl.Click += (object sender, RoutedEventArgs e) => NavigationService.Navigate(new EmployeesPage());
+ adminMenuItem.Items.Add(empl);
+
+ var emplPositions = new MenuItem
+ {
+ Header = "Должности",
+
+ };
+ emplPositions.Click += (object sender, RoutedEventArgs e) => NavigationService.Navigate(new EmployeesPositionsPage());
+ adminMenuItem.Items.Add(emplPositions);
+
+ var users = new MenuItem
+ {
+ Header = "Учётные записи",
+
+ };
+ users.Click += (object sender, RoutedEventArgs e) => throw new NotImplementedException();
+ adminMenuItem.Items.Add(users);
+ var tmp = new MenuItem
+ {
+ Header = "Кабинеты",
+
+ };
+ tmp.Click += (object sender, RoutedEventArgs e) => throw new NotImplementedException();
+ adminMenuItem.Items.Add(tmp);
+ tmp = new MenuItem
+ {
+ Header = "Услуги",
+
+ };
+ tmp.Click += (object sender, RoutedEventArgs e) => throw new NotImplementedException();
+ adminMenuItem.Items.Add(tmp);
+ tmp = new MenuItem
+ {
+ Header = "Виды условий оплат",
+
+ };
+ tmp.Click += (object sender, RoutedEventArgs e) => throw new NotImplementedException();
+ adminMenuItem.Items.Add(tmp);
+ tmp = new MenuItem
+ {
+ Header = "Единицы измерений для услуг",
+
+ };
+ tmp.Click += (object sender, RoutedEventArgs e) => throw new NotImplementedException();
+ adminMenuItem.Items.Add(tmp);
+
+
+ return adminMenuItem;
}
public void ClearHistory()
diff --git a/OfficeFlow/Pages/StartupPages/InitializeDataPage.xaml.cs b/OfficeFlow/Pages/StartupPages/InitializeDataPage.xaml.cs
index b4a483b..8e79eee 100644
--- a/OfficeFlow/Pages/StartupPages/InitializeDataPage.xaml.cs
+++ b/OfficeFlow/Pages/StartupPages/InitializeDataPage.xaml.cs
@@ -32,6 +32,12 @@ namespace OfficeFlow.Pages.StartupPages
var needAccountStatuses = App.Entities.AccountStatuses.Count() == 0;
var needEmployeeStatuses = App.Entities.EmployeeStatuses.Count() == 0;
+ var needPaymentTerms = App.Entities.PaymentTerms.Count() == 0;
+ var needPaymentStatuses = App.Entities.PaymentStatuses.Count() == 0;
+ var needTenantStatuses = App.Entities.TenantStatuses.Count() == 0;
+ var needRentalStatuses = App.Entities.RentalStatuses.Count() == 0;
+ var needRoomStatuses = App.Entities.RoomStatuses.Count() == 0;
+
using (var transaction = App.Entities.Database.BeginTransaction())
{
@@ -131,6 +137,133 @@ namespace OfficeFlow.Pages.StartupPages
});
}
+ // Заполнение условий оплаты
+ if (needPaymentTerms)
+ {
+ App.Entities.PaymentTerms.Add(new PaymentTerm()
+ {
+ TermName = "Ежемесячно",
+ TermDescription = "Оплата производится один раз в месяц."
+ });
+ App.Entities.PaymentTerms.Add(new PaymentTerm()
+ {
+ TermName = "Ежеквартально",
+ TermDescription = "Оплата производится один раз в квартал (3 месяца)."
+ });
+ App.Entities.PaymentTerms.Add(new PaymentTerm()
+ {
+ TermName = "Ежегодно",
+ TermDescription = "Оплата производится один раз в год."
+ });
+ App.Entities.PaymentTerms.Add(new PaymentTerm()
+ {
+ TermName = "По факту",
+ TermDescription = "Оплата производится после предоставления услуги."
+ });
+ }
+
+ // Заполнение статусов платежей
+ if (needPaymentStatuses)
+ {
+ App.Entities.PaymentStatuses.Add(new PaymentStatus()
+ {
+ StatusName = "Оплачен",
+ StatusDescription = "Платеж успешно проведен."
+ });
+ App.Entities.PaymentStatuses.Add(new PaymentStatus()
+ {
+ StatusName = "Не оплачен",
+ StatusDescription = "Платеж ожидает оплаты."
+ });
+ App.Entities.PaymentStatuses.Add(new PaymentStatus()
+ {
+ StatusName = "Частично оплачен",
+ StatusDescription = "Платеж частично покрыт."
+ });
+ App.Entities.PaymentStatuses.Add(new PaymentStatus()
+ {
+ StatusName = "Отменен",
+ StatusDescription = "Платеж отменен."
+ });
+ }
+
+ // Заполнение статусов арендаторов
+ if (needTenantStatuses)
+ {
+ App.Entities.TenantStatuses.Add(new TenantStatus()
+ {
+ StatusName = "Активен",
+ StatusDescription = "Арендатор активно пользуется услугами."
+ });
+ App.Entities.TenantStatuses.Add(new TenantStatus()
+ {
+ StatusName = "Неактивен",
+ StatusDescription = "Арендатор временно не использует услуги."
+ });
+ App.Entities.TenantStatuses.Add(new TenantStatus()
+ {
+ StatusName = "Заблокирован",
+ StatusDescription = "Арендатор заблокирован из-за нарушений."
+ });
+ App.Entities.TenantStatuses.Add(new TenantStatus()
+ {
+ StatusName = "Ожидает подтверждения",
+ StatusDescription = "Арендатор зарегистрирован, но его статус ожидает подтверждения."
+ });
+ }
+
+ // Заполнение статусов аренды
+ if (needRentalStatuses)
+ {
+ App.Entities.RentalStatuses.Add(new RentalStatus()
+ {
+ StatusName = "Активна",
+ StatusDescription = "Аренда действует и оплачивается."
+ });
+ App.Entities.RentalStatuses.Add(new RentalStatus()
+ {
+ StatusName = "Завершена",
+ StatusDescription = "Аренда завершена и больше не действует."
+ });
+ App.Entities.RentalStatuses.Add(new RentalStatus()
+ {
+ StatusName = "Просрочена",
+ StatusDescription = "Аренда просрочена и требует оплаты."
+ });
+ App.Entities.RentalStatuses.Add(new RentalStatus()
+ {
+ StatusName = "Резерв",
+ StatusDescription = "Помещение зарезервировано, но аренда еще не началась."
+ });
+ }
+
+ // Заполнение статусов помещений
+ if (needRoomStatuses)
+ {
+ App.Entities.RoomStatuses.Add(new RoomStatus()
+ {
+ StatusName = "Свободно",
+ StatusDescription = "Помещение свободно для аренды."
+ });
+ App.Entities.RoomStatuses.Add(new RoomStatus()
+ {
+ StatusName = "Занято",
+ StatusDescription = "Помещение занято арендатором."
+ });
+ App.Entities.RoomStatuses.Add(new RoomStatus()
+ {
+ StatusName = "В ремонте",
+ StatusDescription = "Помещение находится в ремонте и недоступно для аренды."
+ });
+ App.Entities.RoomStatuses.Add(new RoomStatus()
+ {
+ StatusName = "Резерв",
+ StatusDescription = "Помещение зарезервировано, но аренда еще не началась."
+ });
+ }
+
+
+
App.Entities.SaveChanges();
transaction.Commit();