Service
parent
d64a300cef
commit
55c4fbc850
|
|
@ -13,6 +13,7 @@
|
||||||
<entry key="Policlinica/Views/RegistrationView.axaml" value="Policlinica/Policlinica.csproj" />
|
<entry key="Policlinica/Views/RegistrationView.axaml" value="Policlinica/Policlinica.csproj" />
|
||||||
<entry key="Policlinica/Views/RegistrationWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
<entry key="Policlinica/Views/RegistrationWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
||||||
<entry key="Policlinica/Views/Rexord.axaml" value="Policlinica/Policlinica.csproj" />
|
<entry key="Policlinica/Views/Rexord.axaml" value="Policlinica/Policlinica.csproj" />
|
||||||
|
<entry key="Policlinica/Views/ServiecWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
||||||
<entry key="Policlinica/Views/StartView.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/StartWindow.axaml" value="Policlinica/Policlinica.csproj" />
|
||||||
</map>
|
</map>
|
||||||
|
|
|
||||||
|
|
@ -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> dataBaseConnection) : base(dataBaseConnection)
|
||||||
|
{
|
||||||
|
OpenConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Service> GetServicesByDoctor(Doctor doctor)
|
||||||
|
{
|
||||||
|
List<Service> result = new List<Service>();
|
||||||
|
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<Service> GetServicesByDoctors( Doctor selectedDoctor)
|
||||||
|
{
|
||||||
|
List<Service> s = new List<Service>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -34,22 +34,28 @@ sealed class Program
|
||||||
s.AddTransient<AdminWindowView>();
|
s.AddTransient<AdminWindowView>();
|
||||||
s.AddTransient<AdminWindowViewModel>();
|
s.AddTransient<AdminWindowViewModel>();
|
||||||
|
|
||||||
//Репозитории
|
|
||||||
s.AddTransient<DoctorRepository>();
|
|
||||||
s.AddTransient<UserRepository>();
|
|
||||||
|
|
||||||
s.AddTransient<RegistrationViewModel>();
|
s.AddTransient<RegistrationViewModel>();
|
||||||
s.AddTransient<RegistrationView>();
|
s.AddTransient<RegistrationView>();
|
||||||
|
|
||||||
s.AddTransient<StartViewModel>();
|
s.AddTransient<StartViewModel>();
|
||||||
s.AddTransient<Startview>();
|
s.AddTransient<Startview>();
|
||||||
|
|
||||||
|
s.AddTransient<Records>();
|
||||||
|
s.AddTransient<RecordViewModel>();
|
||||||
|
|
||||||
|
s.AddTransient<ServiceWindow>();
|
||||||
|
s.AddTransient<ServiceViewModel>();
|
||||||
|
|
||||||
|
//Репозитории
|
||||||
|
s.AddTransient<DoctorRepository>();
|
||||||
|
|
||||||
|
s.AddTransient<UserRepository>();
|
||||||
|
|
||||||
|
s.AddTransient<ServiceRepository>();
|
||||||
|
|
||||||
s.AddTransient<RecordRep>();
|
s.AddTransient<RecordRep>();
|
||||||
|
|
||||||
s.AddSingleton<Navigation>();
|
s.AddSingleton<Navigation>();
|
||||||
|
|
||||||
s.AddTransient<Records>();
|
|
||||||
s.AddTransient<RecordViewModel>();
|
|
||||||
}).
|
}).
|
||||||
Build();
|
Build();
|
||||||
BuildAvaloniaApp(host.Services)
|
BuildAvaloniaApp(host.Services)
|
||||||
|
|
|
||||||
|
|
@ -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<ServiceSelected> _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<Service> works = new List<Service>();
|
||||||
|
|
||||||
|
foreach (ServiceSelected s in Services)
|
||||||
|
{
|
||||||
|
if (s.IsSelected == true)
|
||||||
|
{
|
||||||
|
works.Add(s.Service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var vm = ActivatorUtilities.CreateInstance<ServiceViewModel>(
|
||||||
|
_provider,
|
||||||
|
SelectedDoctor,
|
||||||
|
Login,
|
||||||
|
Services);
|
||||||
|
var win = _provider.GetRequiredService<ServiceWindow>();
|
||||||
|
// vm.SetClose(win.Close);
|
||||||
|
win.DataContext = vm;
|
||||||
|
win.Show();
|
||||||
|
// close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<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"
|
||||||
|
x:Class="Policlinica.Views.ServiceWindow"
|
||||||
|
x:DataType="viewModels:ServiceViewModel">
|
||||||
|
|
||||||
|
|
||||||
|
</UserControl>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Policlinica.Views;
|
||||||
|
|
||||||
|
public partial class ServiceWindow : Window
|
||||||
|
{
|
||||||
|
public ServiceWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
42f46587e074d14fa4a0984c7c2e3fc4c254cb27449b5871bd3d13cc463ff9c1
|
de8dc7cc97951ec819dec96828ce49bed7e933be0937bae697edf58a0f63f41c
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Policlinica")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Policlinica")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("Policlinica")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Policlinica")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Policlinica")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
696a3eb6be9c620cb975cedba6cdc15660992fe7db0c7103404aa03ebcf91b12
|
5e3bba0f7f5d80949896325e9e597738604ad16fcf35efe01f2abfeded9a1785
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,8 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||||
[C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/RegistrationView.axaml]
|
[C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/RegistrationView.axaml]
|
||||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
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]
|
[C:/Users/artem/RiderProjects/Policlinica1/Policlinica/Views/StartView.axaml]
|
||||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
5fb5a258e691fcc4f39ccb83ad69d9066bef4d4adfd7b02e613ab2da216611b4
|
25d16a451e2488f66a2f25e63145cdf4956fae6fccc195a53e811a3f6cf31393
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
{"documents":{"C:\\Users\\artem\\RiderProjects\\Policlinica1\\*":"https://raw.githubusercontent.com/Dezkriminant/Policlinica/85939c0b5c573767a3338c4ce92fddef096efbb7/*"}}
|
{"documents":{"C:\\Users\\artem\\RiderProjects\\Policlinica1\\*":"https://raw.githubusercontent.com/Dezkriminant/Policlinica/d64a300cefd1bb59b17872fb6f0e4afcd2e4b1d4/*"}}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
17782401726378805
|
17782401731740376
|
||||||
Loading…
Reference in New Issue