improved the interface

This commit is contained in:
Никита Онянов 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" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="700" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="700"
x:Class="demo_blagodat.AddClient" x:Class="demo_blagodat.AddClient"
xmlns:vm="using:demo_blagodat.Models"
Title="Добавление клиентов"> Title="Добавление клиентов">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal"> <StackPanel Spacing="10" HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<TextBlock Text="Введите ФИО"/> <TextBlock Text="Введите ФИО"/>
@ -51,5 +52,39 @@
<TextBlock x:Name="MesAddError" Text="" Foreground="Red"/> <TextBlock x:Name="MesAddError" Text="" Foreground="Red"/>
<TextBlock x:Name="MesAdd" Text="" Foreground="Green"/> <TextBlock x:Name="MesAdd" Text="" Foreground="Green"/>
</StackPanel> </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> </StackPanel>
</Window> </Window>

View File

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

View File

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

View File

@ -4,10 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo_blagodat.Heir" x:Class="demo_blagodat.Heir"
xmlns:vm="using:demo_blagodat.Models"
Title="Наследник"> Title="Наследник">
<StackPanel Spacing="15" Orientation="Vertical"> <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="Выберите себе новую должность: "/> <TextBlock x:Name="Position" Text="Выберите себе новую должность: "/>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">

View File

@ -4,6 +4,7 @@ using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using demo_blagodat.Models; using demo_blagodat.Models;
using System; using System;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Tmds.DBus.Protocol; using Tmds.DBus.Protocol;
@ -11,12 +12,24 @@ namespace demo_blagodat;
public partial class Heir : Window public partial class Heir : Window
{ {
static User11Context db = new User11Context();
ObservableCollection<Employee> itemSource = new ObservableCollection<Employee>(db.Employees);
public Employee User; public Employee User;
public string position = ""; public string position = "";
public Heir(Employee user) public Heir(Employee user)
{ {
InitializeComponent(); InitializeComponent();
User = user; 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) private void NewPositionSeller(object sender, RoutedEventArgs e)
@ -34,17 +47,13 @@ public partial class Heir : Window
private void heir(object sender, RoutedEventArgs e) private void heir(object sender, RoutedEventArgs e)
{ {
try try
{
if (Login.Text != "")
{
using (User11Context db = new User11Context())
{
Employee employee = db.Employees.Where(it => it.EmployeesLogin == Login.Text).FirstOrDefault();
if (employee != null)
{ {
if (position != "") if (position != "")
{ {
employee.EmployeesPosition = "Àäìèíèñòðàòîð"; Employee emp = db.Employees.Where(i => i == ListEmp.SelectedItem).FirstOrDefault();
if (emp != null)
{
emp.EmployeesPosition = "Àäìèíèñòðàòîð";
db.SaveChanges(); db.SaveChanges();
Employee I = db.Employees.Where(it => it.EmployeesLogin == User.EmployeesLogin).FirstOrDefault(); Employee I = db.Employees.Where(it => it.EmployeesLogin == User.EmployeesLogin).FirstOrDefault();
@ -56,21 +65,15 @@ public partial class Heir : Window
Close(); Close();
} }
else else
{
MessError.Text = "Òàêîãî ñîòðóäíèêà íåò";
}
}
else
{ {
MessError.Text = "Âûáåðèòå ñåáå íîâóþ äîëæíîñòü"; MessError.Text = "Âûáåðèòå ñåáå íîâóþ äîëæíîñòü";
} }
} }
else
{
MessError.Text = "Òàêîãî ñîòðóäíèêà íå ñóùåñòâóåò.";
}
}
}
else
{
MessError.Text = "Ââåäèòå èìÿ íîâîãî àäìèíà";
}
}
catch(Exception ex) catch(Exception ex)
{ {
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);