improved the interface

This commit is contained in:
NikitaOnianov 2025-03-07 12:51:20 +03:00
parent 74d24f3946
commit 5ffe40bf92
5 changed files with 114 additions and 34 deletions

View File

@ -4,9 +4,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="700"
x:Class="demo_blagodat.AddClient"
xmlns:vm="using:demo_blagodat.Models"
Title="Добавление клиентов">
<StackPanel Orientation="Vertical">
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel Spacing="10" HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<TextBlock Text="Введите ФИО"/>
@ -51,5 +52,39 @@
<TextBlock x:Name="MesAddError" Text="" Foreground="Red"/>
<TextBlock x:Name="MesAdd" Text="" Foreground="Green"/>
</StackPanel>
<Border Background="Red"
CornerRadius="10"
Padding="20"
Margin="20"
Width="1000"
Height="200">
<ScrollViewer>
<ListBox Name="ListClient">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:Client">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ClientCode}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientName}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientPassport}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientPassword}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ClientEmail}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientBirthday}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientAddress}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Border>
</StackPanel>
</Window>

View File

@ -6,16 +6,27 @@ using demo_blagodat.Models;
using System.Runtime.ExceptionServices;
using System;
using System.Linq;
using System.Collections.ObjectModel;
namespace demo_blagodat;
public partial class AddClient : Window
{
static User11Context db = new User11Context();
ObservableCollection<Client> itemSource = new ObservableCollection<Client>(db.Clients);
public Employee User; // Äàííûå ïîëüçîâàòåëÿ (â ýòîì îêíå áåñïîëåçíû)
public AddClient()
{
}
public AddClient(Employee user)
{
InitializeComponent();
User = user; // Ïåðåäà¸ì äàííûå ïîëüçîâàòåëÿ â ïóáëè÷íóþ ïåðåìåííóþ
ListClient.ItemsSource = itemSource;
}
private void addclient(object sender, RoutedEventArgs e)
@ -49,6 +60,7 @@ public partial class AddClient : Window
// Äîáàâëÿåì ïîëüçîâàòåëÿ â ÁÄ
db.Clients.Add(client);
itemSource.Add(client);
db.SaveChanges(); // Ñîõðàíÿåì èçìåíåíèÿ
// Ñòåðàåì âñå äàííûå

View File

@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="demo_blagodat.DeleteClient"
x:CompileBindings="False"
xmlns:vm="using:demo_blagodat.Models"
Title="Удалить клиента">
<StackPanel>
@ -20,13 +20,30 @@
CornerRadius="10"
Padding="20"
Margin="20"
Width="400"
Height="500">
Width="1000"
Height="300">
<ScrollViewer>
<ListBox Name="Items" SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ClientName}"/>
<DataTemplate x:DataType="vm:Client">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ClientCode}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientName}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientPassport}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientPassword}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ClientEmail}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientBirthday}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding ClientAddress}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

View File

@ -4,10 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo_blagodat.Heir"
xmlns:vm="using:demo_blagodat.Models"
Title="Наследник">
<StackPanel Spacing="15" Orientation="Vertical">
<TextBlock Text="Введите Логин сотрудника, которому хотите передать полномочия"/>
<TextBox x:Name="Login"/>
<TextBlock Text="Выберите нового Администратора"/>
<ComboBox Name="ListEmp" SelectionChanged="ComboBox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="vm:Employee">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding EmployeesName}"/>
<TextBlock Text=" : "/>
<TextBlock Text="{Binding EmployeesPosition}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock x:Name="Position" Text="Выберите себе новую должность: "/>
<StackPanel Orientation="Horizontal">

View File

@ -4,6 +4,7 @@ using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using demo_blagodat.Models;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Tmds.DBus.Protocol;
@ -11,12 +12,24 @@ namespace demo_blagodat;
public partial class Heir : Window
{
static User11Context db = new User11Context();
ObservableCollection<Employee> itemSource = new ObservableCollection<Employee>(db.Employees);
public Employee User;
public string position = "";
public Heir(Employee user)
{
InitializeComponent();
User = user;
ListEmp.ItemsSource = itemSource;
}
private void ComboBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
{
if (sender != null)
{
}
}
private void NewPositionSeller(object sender, RoutedEventArgs e)
@ -35,40 +48,30 @@ public partial class Heir : Window
{
try
{
if (Login.Text != "")
if (position != "")
{
using (User11Context db = new User11Context())
Employee emp = db.Employees.Where(i => i == ListEmp.SelectedItem).FirstOrDefault();
if (emp != null)
{
Employee employee = db.Employees.Where(it => it.EmployeesLogin == Login.Text).FirstOrDefault();
if (employee != null)
{
if(position != "")
{
employee.EmployeesPosition = "Àäìèíèñòðàòîð";
db.SaveChanges();
emp.EmployeesPosition = "Àäìèíèñòðàòîð";
db.SaveChanges();
Employee I = db.Employees.Where(it => it.EmployeesLogin == User.EmployeesLogin).FirstOrDefault();
I.EmployeesPosition = position;
I.EmployeesEntrance = false;
db.SaveChanges();
Employee I = db.Employees.Where(it => it.EmployeesLogin == User.EmployeesLogin).FirstOrDefault();
I.EmployeesPosition = position;
I.EmployeesEntrance = false;
db.SaveChanges();
new Authorization().Show();
Close();
}
else
{
MessError.Text = "Âûáåðèòå ñåáå íîâóþ äîëæíîñòü";
}
}
else
{
MessError.Text = "Òàêîãî ñîòðóäíèêà íå ñóùåñòâóåò.";
}
new Authorization().Show();
Close();
}
else
{
MessError.Text = "Òàêîãî ñîòðóäíèêà íåò";
}
}
else
{
MessError.Text = âåäèòå èìÿ íîâîãî àäìèíà";
MessError.Text = "Âûáåðèòå ñåáå íîâóþ äîëæíîñòü";
}
}
catch(Exception ex)