diff --git a/.idea/.idea.Policlinica/.idea/avalonia.xml b/.idea/.idea.Policlinica/.idea/avalonia.xml index baa64ed..17fa493 100644 --- a/.idea/.idea.Policlinica/.idea/avalonia.xml +++ b/.idea/.idea.Policlinica/.idea/avalonia.xml @@ -13,6 +13,7 @@ + diff --git a/Policlinica/DB/ServiceRepository.cs b/Policlinica/DB/ServiceRepository.cs new file mode 100644 index 0000000..28e8a6a --- /dev/null +++ b/Policlinica/DB/ServiceRepository.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using Microsoft.Extensions.Options; +using MySqlConnector; + +namespace Policlinica.DB; + +public class ServiceRepository : BaseRep +{ + public ServiceRepository(IOptions dataBaseConnection) : base(dataBaseConnection) + { + OpenConnection(); + } + + public List GetServicesByDoctor(Doctor doctor) + { + List result = new List(); + string sql = "select * from services"; + try + { + connection.Open(); + using (var mc = new MySqlCommand(sql, connection)) + using (var dr = mc.ExecuteReader()) + { + while (dr.Read()) + { + result.Add(new Service + { + Id = dr.GetInt32("id"), + DoctorId = dr.GetInt32("doctor_id"), + ServiceName = dr.GetString("service_name"), + Price = dr.GetDecimal("price"), + }); + } + } + + connection.Close(); + } + catch (MySqlException ex) + { + Console.WriteLine(ex); + } + catch (Exception e) + { + Console.WriteLine(e); + } + + return result; + } + + public List GetServicesByDoctors( Doctor selectedDoctor) + { + List s = new List(); + string sql = "select * from services where doctor_id = " + selectedDoctor.Id; + try + { + connection.Open(); + using (var mc = new MySqlCommand(sql, connection)) + using (var dr = mc.ExecuteReader()) + { + while (dr.Read()) + { + s.Add(new Service() + { + Id = dr.GetInt32("id"), + DoctorId = dr.GetInt32("doctor_id"), + ServiceName = dr.GetString("service_name"), + Price = dr.GetDecimal("price"), + }); + } + } + + connection.Close(); + } + catch (MySqlException ex) + { + Console.WriteLine(ex); + } + catch (Exception e) + { + Console.WriteLine(e); + } + + return s; + } +} \ No newline at end of file diff --git a/Policlinica/Models/ServiceSelected.cs b/Policlinica/Models/ServiceSelected.cs new file mode 100644 index 0000000..082a57d --- /dev/null +++ b/Policlinica/Models/ServiceSelected.cs @@ -0,0 +1,15 @@ +namespace Policlinica.DB; + +public class ServiceSelected +{ + + public Service Service { get; set; } + + public bool IsSelected { get; set; } + + public ServiceSelected(Service service) + { + Service = service; + } + +} diff --git a/Policlinica/Program.cs b/Policlinica/Program.cs index 0418e94..f955da6 100644 --- a/Policlinica/Program.cs +++ b/Policlinica/Program.cs @@ -34,22 +34,28 @@ sealed class Program s.AddTransient(); s.AddTransient(); - //Репозитории - s.AddTransient(); - s.AddTransient(); - s.AddTransient(); s.AddTransient(); s.AddTransient(); s.AddTransient(); - + + s.AddTransient(); + s.AddTransient(); + + s.AddTransient(); + s.AddTransient(); + + //Репозитории + s.AddTransient(); + + s.AddTransient(); + + s.AddTransient(); + s.AddTransient(); s.AddSingleton(); - - s.AddTransient(); - s.AddTransient(); }). Build(); BuildAvaloniaApp(host.Services) diff --git a/Policlinica/ViewModels/ServiceViewModel.cs b/Policlinica/ViewModels/ServiceViewModel.cs new file mode 100644 index 0000000..bdff3a3 --- /dev/null +++ b/Policlinica/ViewModels/ServiceViewModel.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Avalonia.Animation.Easings; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using Policlinica.DB; +using Policlinica.Views; + +namespace Policlinica.ViewModels; + +public partial class ServiceViewModel : ViewModelBase +{ + private readonly IServiceProvider _provider; + private readonly Navigation _navigation; + [ObservableProperty] List _services; + ServiceRepository _serviceRepository; + [ObservableProperty] string _login; + [ObservableProperty] Doctor _selectedDoctor; + + public ServiceViewModel(IServiceProvider provider, Navigation navigation,Doctor selectedDoctor, ServiceRepository repository) + { + _provider = provider; + _navigation = navigation; + _selectedDoctor = selectedDoctor; + _serviceRepository = repository; + Services = repository.GetServicesByDoctors(selectedDoctor).Select(service => new ServiceSelected(service)).ToList(); + } + + + [RelayCommand] + + public void Dobavlenie() + { + { + List works = new List(); + + foreach (ServiceSelected s in Services) + { + if (s.IsSelected == true) + { + works.Add(s.Service); + } + } + + var vm = ActivatorUtilities.CreateInstance( + _provider, + SelectedDoctor, + Login, + Services); + var win = _provider.GetRequiredService(); + // vm.SetClose(win.Close); + win.DataContext = vm; + win.Show(); + // close(); + } + + } +} \ No newline at end of file diff --git a/Policlinica/Views/ServiceWindow.axaml b/Policlinica/Views/ServiceWindow.axaml new file mode 100644 index 0000000..6e3e980 --- /dev/null +++ b/Policlinica/Views/ServiceWindow.axaml @@ -0,0 +1,11 @@ + + + + diff --git a/Policlinica/Views/ServiceWindow.axaml.cs b/Policlinica/Views/ServiceWindow.axaml.cs new file mode 100644 index 0000000..4888c9c --- /dev/null +++ b/Policlinica/Views/ServiceWindow.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Policlinica.Views; + +public partial class ServiceWindow : Window +{ + public ServiceWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Policlinica/bin/Debug/net9.0/Policlinica.dll b/Policlinica/bin/Debug/net9.0/Policlinica.dll index dc0da3e..964db4d 100644 Binary files a/Policlinica/bin/Debug/net9.0/Policlinica.dll and b/Policlinica/bin/Debug/net9.0/Policlinica.dll differ diff --git a/Policlinica/bin/Debug/net9.0/Policlinica.exe b/Policlinica/bin/Debug/net9.0/Policlinica.exe index 9163ffb..05500e3 100644 Binary files a/Policlinica/bin/Debug/net9.0/Policlinica.exe and b/Policlinica/bin/Debug/net9.0/Policlinica.exe differ diff --git a/Policlinica/bin/Debug/net9.0/Policlinica.pdb b/Policlinica/bin/Debug/net9.0/Policlinica.pdb index afaec58..1e97eef 100644 Binary files a/Policlinica/bin/Debug/net9.0/Policlinica.pdb and b/Policlinica/bin/Debug/net9.0/Policlinica.pdb differ diff --git a/Policlinica/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache b/Policlinica/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache index ac40de0..c9a9d19 100644 --- a/Policlinica/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache +++ b/Policlinica/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache @@ -1 +1 @@ -42f46587e074d14fa4a0984c7c2e3fc4c254cb27449b5871bd3d13cc463ff9c1 +de8dc7cc97951ec819dec96828ce49bed7e933be0937bae697edf58a0f63f41c diff --git a/Policlinica/obj/Debug/net9.0/Avalonia/resources b/Policlinica/obj/Debug/net9.0/Avalonia/resources index 49ec3f5..a8fc1cf 100644 Binary files a/Policlinica/obj/Debug/net9.0/Avalonia/resources and b/Policlinica/obj/Debug/net9.0/Avalonia/resources differ diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfo.cs b/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfo.cs index 93ab320..5c22109 100644 --- a/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfo.cs +++ b/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Policlinica")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+85939c0b5c573767a3338c4ce92fddef096efbb7")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d64a300cefd1bb59b17872fb6f0e4afcd2e4b1d4")] [assembly: System.Reflection.AssemblyProductAttribute("Policlinica")] [assembly: System.Reflection.AssemblyTitleAttribute("Policlinica")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfoInputs.cache b/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfoInputs.cache index 2cae04b..6885c8d 100644 --- a/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfoInputs.cache +++ b/Policlinica/obj/Debug/net9.0/Policlinica.AssemblyInfoInputs.cache @@ -1 +1 @@ -696a3eb6be9c620cb975cedba6cdc15660992fe7db0c7103404aa03ebcf91b12 +5e3bba0f7f5d80949896325e9e597738604ad16fcf35efe01f2abfeded9a1785 diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.GeneratedMSBuildEditorConfig.editorconfig b/Policlinica/obj/Debug/net9.0/Policlinica.GeneratedMSBuildEditorConfig.editorconfig index e4ac40d..f4f89ff 100644 --- a/Policlinica/obj/Debug/net9.0/Policlinica.GeneratedMSBuildEditorConfig.editorconfig +++ b/Policlinica/obj/Debug/net9.0/Policlinica.GeneratedMSBuildEditorConfig.editorconfig @@ -43,5 +43,8 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml [C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/RegistrationView.axaml] build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml +[C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/ServiceWindow.axaml] +build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml + [C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/StartView.axaml] build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.csproj.CoreCompileInputs.cache b/Policlinica/obj/Debug/net9.0/Policlinica.csproj.CoreCompileInputs.cache index e12853d..a271f67 100644 --- a/Policlinica/obj/Debug/net9.0/Policlinica.csproj.CoreCompileInputs.cache +++ b/Policlinica/obj/Debug/net9.0/Policlinica.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -5fb5a258e691fcc4f39ccb83ad69d9066bef4d4adfd7b02e613ab2da216611b4 +25d16a451e2488f66a2f25e63145cdf4956fae6fccc195a53e811a3f6cf31393 diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.dll b/Policlinica/obj/Debug/net9.0/Policlinica.dll index dc0da3e..964db4d 100644 Binary files a/Policlinica/obj/Debug/net9.0/Policlinica.dll and b/Policlinica/obj/Debug/net9.0/Policlinica.dll differ diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.pdb b/Policlinica/obj/Debug/net9.0/Policlinica.pdb index afaec58..1e97eef 100644 Binary files a/Policlinica/obj/Debug/net9.0/Policlinica.pdb and b/Policlinica/obj/Debug/net9.0/Policlinica.pdb differ diff --git a/Policlinica/obj/Debug/net9.0/Policlinica.sourcelink.json b/Policlinica/obj/Debug/net9.0/Policlinica.sourcelink.json index 4f022a0..22566e4 100644 --- a/Policlinica/obj/Debug/net9.0/Policlinica.sourcelink.json +++ b/Policlinica/obj/Debug/net9.0/Policlinica.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\artem\\RiderProjects\\Policlinica1\\*":"https://raw.githubusercontent.com/Dezkriminant/Policlinica/85939c0b5c573767a3338c4ce92fddef096efbb7/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\artem\\RiderProjects\\Policlinica1\\*":"https://raw.githubusercontent.com/Dezkriminant/Policlinica/d64a300cefd1bb59b17872fb6f0e4afcd2e4b1d4/*"}} \ No newline at end of file diff --git a/Policlinica/obj/Debug/net9.0/apphost.exe b/Policlinica/obj/Debug/net9.0/apphost.exe index 9163ffb..05500e3 100644 Binary files a/Policlinica/obj/Debug/net9.0/apphost.exe and b/Policlinica/obj/Debug/net9.0/apphost.exe differ diff --git a/Policlinica/obj/Debug/net9.0/ref/Policlinica.dll b/Policlinica/obj/Debug/net9.0/ref/Policlinica.dll index 092f028..ef98d82 100644 Binary files a/Policlinica/obj/Debug/net9.0/ref/Policlinica.dll and b/Policlinica/obj/Debug/net9.0/ref/Policlinica.dll differ diff --git a/Policlinica/obj/Debug/net9.0/refint/Policlinica.dll b/Policlinica/obj/Debug/net9.0/refint/Policlinica.dll index 092f028..ef98d82 100644 Binary files a/Policlinica/obj/Debug/net9.0/refint/Policlinica.dll and b/Policlinica/obj/Debug/net9.0/refint/Policlinica.dll differ diff --git a/Policlinica/obj/rider.project.model.nuget.info b/Policlinica/obj/rider.project.model.nuget.info index 83eda9e..aa5c1cc 100644 --- a/Policlinica/obj/rider.project.model.nuget.info +++ b/Policlinica/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17782401726378805 \ No newline at end of file +17782401731740376 \ No newline at end of file