diff --git a/demo_blagodat/Functions/AddClient.axaml b/demo_blagodat/Functions/AddClient.axaml index 216cff7..4d2d44c 100644 --- a/demo_blagodat/Functions/AddClient.axaml +++ b/demo_blagodat/Functions/AddClient.axaml @@ -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> diff --git a/demo_blagodat/Functions/AddClient.axaml.cs b/demo_blagodat/Functions/AddClient.axaml.cs index fbc296e..1fea182 100644 --- a/demo_blagodat/Functions/AddClient.axaml.cs +++ b/demo_blagodat/Functions/AddClient.axaml.cs @@ -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(); // ��������� ��������� // ������� ��� ������ diff --git a/demo_blagodat/Functions/DeleteClient.axaml b/demo_blagodat/Functions/DeleteClient.axaml index 786441b..51ce0a1 100644 --- a/demo_blagodat/Functions/DeleteClient.axaml +++ b/demo_blagodat/Functions/DeleteClient.axaml @@ -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> diff --git a/demo_blagodat/Functions/Heir.axaml b/demo_blagodat/Functions/Heir.axaml index 72cacc1..ba87ae9 100644 --- a/demo_blagodat/Functions/Heir.axaml +++ b/demo_blagodat/Functions/Heir.axaml @@ -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"> diff --git a/demo_blagodat/Functions/Heir.axaml.cs b/demo_blagodat/Functions/Heir.axaml.cs index d16775d..e2ec828 100644 --- a/demo_blagodat/Functions/Heir.axaml.cs +++ b/demo_blagodat/Functions/Heir.axaml.cs @@ -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)