Виктор Пиктор
parent
db9efc98b9
commit
feb4764a4f
|
|
@ -22,6 +22,7 @@
|
|||
<entry key="Policlinica/Views/ServiecWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
||||
<entry key="Policlinica/Views/StartView.axaml" value="Policlinica/Policlinica.csproj" />
|
||||
<entry key="Policlinica/Views/StartWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
||||
<entry key="Policlinica/Views/SugarCheckView.axaml" value="Policlinica/Policlinica.csproj" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public class RecordRep:BaseRep
|
|||
mc.Parameters.AddWithValue("@total_amount", record.TotalAmount);
|
||||
mc.Parameters.AddWithValue("@record_date", record.RecordDate);
|
||||
|
||||
int result = mc.ExecuteNonQuery();
|
||||
Console.WriteLine($"ExecuteNonQuery returned: {result}");
|
||||
mc.ExecuteNonQuery();
|
||||
Console.WriteLine($"ExecuteNonQuery returned");
|
||||
}
|
||||
|
||||
// Получаем ID последней вставленной записи
|
||||
|
|
@ -119,21 +119,31 @@ public class RecordRep:BaseRep
|
|||
|
||||
public bool Delete(int id)
|
||||
{
|
||||
string sql = @"delete from `records` where `id` = @id";
|
||||
try
|
||||
{
|
||||
using (var mc = new MySqlCommand(sql, connection))
|
||||
// Сначала удаляем все связанные record_items
|
||||
string deleteItemsSql = @"delete from `record_items` where `record_id` = @id";
|
||||
using (var mc = new MySqlCommand(deleteItemsSql, connection))
|
||||
{
|
||||
mc.Parameters.AddWithValue("@id", id);
|
||||
mc.ExecuteNonQuery();
|
||||
|
||||
Console.WriteLine($"Deleted record items for record {id}");
|
||||
}
|
||||
return true;
|
||||
|
||||
// Затем удаляем саму запись
|
||||
string deleteRecordSql = @"delete from `records` where `id` = @id";
|
||||
using (var mc = new MySqlCommand(deleteRecordSql, connection))
|
||||
{
|
||||
mc.Parameters.AddWithValue("@id", id);
|
||||
mc.ExecuteNonQuery();
|
||||
Console.WriteLine($"Deleted record {id}");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
Console.WriteLine($"Error deleting record: {e}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,10 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\SugarCheckView.axaml.cs">
|
||||
<DependentUpon>SugarCheckView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Policlinica.ViewModels;
|
||||
using Policlinica.Views;
|
||||
|
||||
namespace Policlinica;
|
||||
|
||||
|
|
@ -24,7 +25,15 @@ public class ViewLocator : IDataTemplate
|
|||
|
||||
if (type != null)
|
||||
{
|
||||
return (Control)Activator.CreateInstance(type)!;
|
||||
var view = (Control)Activator.CreateInstance(type)!;
|
||||
|
||||
// Специальная обработка для SugarCheckViewModel
|
||||
if (param is SugarCheckViewModel sugarVm && view is SugarCheckView sugarView)
|
||||
{
|
||||
sugarVm.SetView(sugarView);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
return new TextBlock { Text = "Not Found: " + name };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
|
@ -23,6 +23,7 @@ public partial class AdminViewModel : ViewModelBase
|
|||
[ObservableProperty] ObservableCollection<Record> _recordsList = new();
|
||||
[ObservableProperty] private Record _selectedRecord;
|
||||
[ObservableProperty] private ObservableCollection<User> userList = new ObservableCollection<User>();
|
||||
[ObservableProperty] string statusMessage = "";
|
||||
|
||||
public AdminViewModel(Navigation navigation, IServiceProvider provider, RecordRep recordRep,User user,UserRepository userRepository)
|
||||
{
|
||||
|
|
@ -40,17 +41,38 @@ public partial class AdminViewModel : ViewModelBase
|
|||
Id = obj.Id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RecordsList = new ObservableCollection<Record>(recordRep.GetRecord(Id));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void DeleteRecord()
|
||||
{
|
||||
_recordRep.Delete(SelectedRecord.Id);
|
||||
if (SelectedRecord == null)
|
||||
{
|
||||
StatusMessage = "Выберите запись для удаления";
|
||||
Console.WriteLine("No record selected for deletion");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
bool deleted = _recordRep.Delete(SelectedRecord.Id);
|
||||
if (deleted)
|
||||
{
|
||||
StatusMessage = "Запись успешно удалена";
|
||||
RecordsList = new ObservableCollection<Record>(_recordRep.GetRecord(Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusMessage = "Ошибка при удалении записи";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusMessage = $"Ошибка: {ex.Message}";
|
||||
Console.WriteLine($"Error deleting record: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void GoService()
|
||||
|
|
@ -59,4 +81,11 @@ public partial class AdminViewModel : ViewModelBase
|
|||
_navigation.Navigate(vm);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void GoSugarCheck()
|
||||
{
|
||||
var vm = ActivatorUtilities.CreateInstance<SugarCheckViewModel>(_provider);
|
||||
_navigation.Navigate(vm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +1,53 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Policlinica.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="700"
|
||||
x:Class="Policlinica.Views.AdminView"
|
||||
x:DataType="viewModels:AdminViewModel">
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto" Margin="20">
|
||||
<DataGrid ItemsSource="{Binding RecordsList }" SelectedItem="{Binding SelectedRecord }">
|
||||
<StackPanel Margin="30" Spacing="20">
|
||||
<TextBlock Text="Управление записями" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center"/>
|
||||
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Список записей:" FontWeight="Bold" FontSize="16"/>
|
||||
<DataGrid ItemsSource="{Binding RecordsList }" SelectedItem="{Binding SelectedRecord }" MinHeight="300">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn IsVisible="True"/>
|
||||
<!--><DataGridCheckBoxColumn/><!-->
|
||||
<DataGridTextColumn Binding="{Binding ClientName}" Header="Имя клиента"/>
|
||||
<DataGridTextColumn Binding="{Binding ClientSurname}" Header="Фамилия клиента"/>
|
||||
<DataGridTextColumn Binding="{Binding Title}" Header="Врач"/>
|
||||
<DataGridTextColumn Binding="{Binding Name}" Header="Логин"/>
|
||||
<DataGridTextColumn Binding="{Binding TotalAmount}" Header="Цена"/>
|
||||
<DataGridTextColumn Binding="{Binding ServiceName}" Header="Услуга"/>
|
||||
<DataGridTextColumn Binding="{Binding RecordDate}" Header="Дата"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
|
||||
|
||||
<Button Content="Удалить выбранную работу" FontSize="20" HorizontalAlignment="Center" Command="{Binding DeleteRecordCommand}"/>
|
||||
<Button Content="Добавить запись" FontSize="20" HorizontalAlignment="Center" Command="{Binding GoServiceCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="{Binding StatusMessage}" Foreground="Green" FontSize="14" TextWrapping="Wrap"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
|
||||
<Button Content="Удалить запись"
|
||||
FontSize="16"
|
||||
Padding="18,12"
|
||||
Background="Red"
|
||||
Foreground="White"
|
||||
Command="{Binding DeleteRecordCommand}"/>
|
||||
<Button Content="Добавить запись"
|
||||
FontSize="16"
|
||||
Padding="18,12"
|
||||
Background="Green"
|
||||
Foreground="White"
|
||||
Command="{Binding GoServiceCommand}"/>
|
||||
<Button Content="Проверка сахара"
|
||||
FontSize="16"
|
||||
Padding="18,12"
|
||||
Background="Orange"
|
||||
Foreground="White"
|
||||
Command="{Binding GoSugarCheckCommand}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
<!-->я устал<!-->
|
||||
<!-->я тоже<!-->
|
||||
|
|
|
|||
|
|
@ -3,26 +3,49 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:Policlinica.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
|
||||
x:Class="Policlinica.Views.DoctorView"
|
||||
x:DataType="vm:DoctorViewModel">
|
||||
|
||||
<Border BorderBrush="Aqua" CornerRadius="8" BorderThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="40" Spacing="20">
|
||||
|
||||
<TextBlock Text="Создание заказа" FontSize="20" FontWeight="Bold" HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="Создание записи" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center"/>
|
||||
|
||||
<TextBlock Text="Введите имя клиента:" />
|
||||
<TextBox Text="{Binding Name}"/>
|
||||
|
||||
<TextBlock Text="Введите фамилию клиента:" />
|
||||
<TextBox Text="{Binding Surname}"/>
|
||||
|
||||
<ComboBox ItemsSource="{Binding DoctorList}"
|
||||
SelectedItem="{Binding SelectedDoctor}"
|
||||
DisplayMemberBinding="{Binding Title}"/>
|
||||
<Button Content="Далее"
|
||||
Command="{Binding StartTestCommand}"/>
|
||||
<!-- Ввод имени клиента -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Имя клиента:" FontWeight="Bold" FontSize="14"/>
|
||||
<TextBox Text="{Binding Name}" Padding="10" FontSize="13" Watermark="Введите имя"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Ввод фамилии клиента -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Фамилия клиента:" FontWeight="Bold" FontSize="14"/>
|
||||
<TextBox Text="{Binding Surname}" Padding="10" FontSize="13" Watermark="Введите фамилию"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Выбор врача -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Выберите врача:" FontWeight="Bold" FontSize="14"/>
|
||||
<ComboBox ItemsSource="{Binding DoctorList}"
|
||||
SelectedItem="{Binding SelectedDoctor}"
|
||||
DisplayMemberBinding="{Binding Title}"
|
||||
Padding="10"
|
||||
FontSize="13"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Кнопка -->
|
||||
<Button Content="Далее"
|
||||
FontSize="16"
|
||||
Padding="20,12"
|
||||
Background="Green"
|
||||
Foreground="White"
|
||||
HorizontalAlignment="Center"
|
||||
Command="{Binding StartTestCommand}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Policlinica.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
|
||||
mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="700"
|
||||
x:Class="Policlinica.Views.RecordItemsView"
|
||||
x:DataType="viewModels:RecordItemsViewModel">
|
||||
|
||||
<StackPanel Margin="20" Spacing="15">
|
||||
<StackPanel Margin="30" Spacing="20">
|
||||
<!-- Заголовок -->
|
||||
<TextBlock Text="Подтверждение записи" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center"/>
|
||||
|
||||
<!-- Информация о клиенте -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock FontWeight="Bold" FontSize="16">Клиент:</TextBlock>
|
||||
<TextBlock Text="Клиент:" FontWeight="Bold" FontSize="16"/>
|
||||
<TextBlock Text="{Binding ClientName}" FontSize="14"/>
|
||||
<TextBlock Text="{Binding ClientSurname}" FontSize="14"/>
|
||||
</StackPanel>
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
<!-- Информация о враче -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock FontWeight="Bold" FontSize="16">Врач:</TextBlock>
|
||||
<TextBlock Text="Врач:" FontWeight="Bold" FontSize="16"/>
|
||||
<TextBlock Text="{Binding SelectedDoctor.Title}" FontSize="14"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
|
@ -31,14 +31,14 @@
|
|||
<!-- Выбранные услуги -->
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock FontWeight="Bold" FontSize="16">Выбранные услуги:</TextBlock>
|
||||
<TextBlock Text="Выбранные услуги:" FontWeight="Bold" FontSize="16"/>
|
||||
|
||||
<ListBox ItemsSource="{Binding SelectedServices}" Height="150">
|
||||
<ListBox ItemsSource="{Binding SelectedServices}" MinHeight="150">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="20">
|
||||
<TextBlock Text="{Binding ServiceName}" Width="200"/>
|
||||
<TextBlock Text="{Binding Price}" Width="100"/>
|
||||
<StackPanel Orientation="Horizontal" Spacing="20" Margin="5">
|
||||
<TextBlock Text="{Binding ServiceName}" Width="300" FontSize="13"/>
|
||||
<TextBlock Text="{Binding Price}" Width="100" FontSize="13"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
|
@ -47,10 +47,10 @@
|
|||
</Border>
|
||||
|
||||
<!-- Итоговая сумма -->
|
||||
<Border BorderBrush="LightBlue" BorderThickness="2" Padding="15" CornerRadius="5" Background="#F0F8FF">
|
||||
<Border BorderBrush="DodgerBlue" BorderThickness="2" Padding="20" CornerRadius="5" Background="WhiteSmoke">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="30">
|
||||
<TextBlock Text="Итого:" FontWeight="Bold" FontSize="16" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding TotalAmount}" FontSize="18" FontWeight="Bold" Foreground="Blue"/>
|
||||
<TextBlock Text="Итого:" FontWeight="Bold" FontSize="16"/>
|
||||
<TextBlock Text="{Binding TotalAmount}" FontSize="18" FontWeight="Bold" Foreground="DodgerBlue"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
|
|
@ -58,10 +58,18 @@
|
|||
<TextBlock Text="{Binding StatusMessage}" Foreground="Green" FontSize="14" TextWrapping="Wrap"/>
|
||||
|
||||
<!-- Кнопки -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20" Margin="0,20,0,0">
|
||||
<Button Content="Сохранить запись" FontSize="16" Padding="20,10" Background="Green" Foreground="White"
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
|
||||
<Button Content="Сохранить запись"
|
||||
FontSize="16"
|
||||
Padding="20,12"
|
||||
Background="Green"
|
||||
Foreground="White"
|
||||
Command="{Binding SaveToDatabaseCommand}"/>
|
||||
<Button Content="Вернуться" FontSize="16" Padding="20,10" Background="Gray" Foreground="White"
|
||||
<Button Content="Вернуться"
|
||||
FontSize="16"
|
||||
Padding="20,12"
|
||||
Background="Gray"
|
||||
Foreground="White"
|
||||
Command="{Binding CancelCommand}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -1,28 +1,46 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Policlinica.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="700"
|
||||
x:Class="Policlinica.Views.ServiceView"
|
||||
x:DataType="viewModels:ServiceViewModel">
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto" Margin="20">
|
||||
<StackPanel Margin="30" Spacing="20">
|
||||
|
||||
<ListBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Services}">
|
||||
<TextBlock Text="Выберите услугу" FontSize="24" FontWeight="Bold" HorizontalAlignment="Center"/>
|
||||
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Доступные услуги:" FontWeight="Bold" FontSize="14"/>
|
||||
<ListBox ItemsSource="{Binding Services}" MinHeight="250">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding IsSelected}" ></CheckBox>
|
||||
<TextBlock Text="{Binding Service.ServiceName}"></TextBlock>
|
||||
<TextBlock Text="{Binding Service.Price}"></TextBlock>
|
||||
<StackPanel Orientation="Horizontal" Spacing="20" Margin="10">
|
||||
<CheckBox IsChecked="{Binding IsSelected}"/>
|
||||
<TextBlock Text="{Binding Service.ServiceName}" Width="250" FontSize="13"/>
|
||||
<TextBlock Text="{Binding Service.Price}" Width="100" FontSize="13"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="Выберите услугу" FontSize="20" HorizontalAlignment="Center"/>
|
||||
<Button Grid.Row="2" Content="Продолжить" FontSize="20" HorizontalAlignment="Center" Command="{Binding DobavlenieCommand}"/>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
|
||||
<Button Content="Продолжить"
|
||||
FontSize="16"
|
||||
Padding="20,12"
|
||||
Background="Green"
|
||||
Foreground="White"
|
||||
Command="{Binding DobavlenieCommand}"/>
|
||||
<Button Content="Назад"
|
||||
FontSize="16"
|
||||
Padding="20,12"
|
||||
Background="Gray"
|
||||
Foreground="White"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
|
|
|
|||
Loading…
Reference in New Issue