Добавл. бинес логики и форм. Еще не подкл. сервисПров

This commit is contained in:
Екатерина Рогашова 2023-04-05 00:33:37 +04:00
parent 1cfa8dc507
commit bcaa4adae8
54 changed files with 2282 additions and 174 deletions

View File

@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalContracts", "..\HospitalContracts\HospitalContracts.csproj", "{852D330A-F5B2-4ADE-A27B-A58F9CAAE379}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalContracts", "..\HospitalContracts\HospitalContracts.csproj", "{852D330A-F5B2-4ADE-A27B-A58F9CAAE379}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalDataModels", "..\HospitalDataModels\HospitalDataModels.csproj", "{D5C93D6A-22C6-4B67-B76C-6FC183D46513}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDataModels", "..\HospitalDataModels\HospitalDataModels.csproj", "{D5C93D6A-22C6-4B67-B76C-6FC183D46513}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalDataBaseImplements", "..\HospitalDataBaseImplements\HospitalDataBaseImplements.csproj", "{2B6A087F-E3CA-439E-9FC8-954575466B8B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDataBaseImplements", "..\HospitalDataBaseImplements\HospitalDataBaseImplements.csproj", "{2B6A087F-E3CA-439E-9FC8-954575466B8B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalView", "..\HospitalView\HospitalView.csproj", "{7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalView", "..\HospitalView\HospitalView.csproj", "{7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalBusinessLogic", "HospitalBusinessLogic\HospitalBusinessLogic.csproj", "{9E73B25E-6D05-4580-8082-472A1D993A34}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -33,6 +35,10 @@ Global
{7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Debug|Any CPU.Build.0 = Debug|Any CPU {7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Release|Any CPU.ActiveCfg = Release|Any CPU {7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Release|Any CPU.Build.0 = Release|Any CPU {7CBB7FFE-03C3-4F80-9A30-C1825E2C7340}.Release|Any CPU.Build.0 = Release|Any CPU
{9E73B25E-6D05-4580-8082-472A1D993A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E73B25E-6D05-4580-8082-472A1D993A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E73B25E-6D05-4580-8082-472A1D993A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E73B25E-6D05-4580-8082-472A1D993A34}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,113 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class IllnessLogic : IIllnessLogic
{
private readonly ILogger _logger;
private readonly IIllnessStorage _illnessStorage;
public IllnessLogic(ILogger<IllnessLogic> logger, IIllnessStorage illnessStorage)
{
_logger = logger;
_illnessStorage = illnessStorage;
}
public List<IllnessViewModel>? ReadList(IllnessSearchModel? model)
{
_logger.LogInformation("ReadList. IllnessName:{IllnessName}.Id:{ Id}", model?.IllnessName, model?.Id);
var list = model == null ? _illnessStorage.GetFullList() : _illnessStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public IllnessViewModel? ReadElement(IllnessSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. IllnessName:{IllnessName}.Id:{ Id}", model.IllnessName, model.Id);
var element = _illnessStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(IllnessBindingModel model)
{
CheckModel(model);
if (_illnessStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(IllnessBindingModel model)
{
CheckModel(model);
if (_illnessStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(IllnessBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_illnessStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(IllnessBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.IllnessName))
{
throw new ArgumentNullException("Нет названия болезни",
nameof(model.IllnessName));
}
if (string.IsNullOrEmpty(model.Form))
{
throw new ArgumentNullException("Нет формы болезни", nameof(model.Form));
}
_logger.LogInformation("Illness. IllnessName:{IllnessName}.Form:{ Form}. Id: { Id}", model.IllnessName, model.Form, model.Id);
var element = _illnessStorage.GetElement(new IllnessSearchModel
{
IllnessName = model.IllnessName });
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Болезнь с таким названием уже есть");
}
}
}
}
}

View File

@ -0,0 +1,111 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class KurseLogic : IKurseLogic {
private readonly ILogger _logger;
private readonly IKurseStorage _kurseStorage;
public KurseLogic(ILogger<KurseLogic> logger, IKurseStorage kurseStorage)
{
_logger = logger;
_kurseStorage = kurseStorage;
}
public bool Create(KurseBindingModel model)
{
CheckModel(model);
if (_kurseStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(KurseBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_kurseStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public KurseViewModel? ReadElement(KurseSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _kurseStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<KurseViewModel>? ReadList(KurseSearchModel? model)
{
_logger.LogInformation("ReadElement. Id:{ Id}", model?.Id);
var list = model == null ? _kurseStorage.GetFullList() : _kurseStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(KurseBindingModel model)
{
CheckModel(model);
if (_kurseStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(KurseBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.MedicinesId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор лекарства", nameof(model.MedicinesId));
}
if (model.CountInDay <= 0)
{
throw new ArgumentNullException("Количество приемов в день должно быть больше 0", nameof(model.CountInDay));
}
_logger.LogInformation("Kurse. KurseId:{Id}.CountInDay:{ CountInDay}. MedicinesId: { MedicinesId}", model.Id, model.CountInDay, model.MedicinesId);
}
}
}

View File

@ -0,0 +1,117 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class MedicinesLogic : IMedicinesLogic
{
private readonly ILogger _logger;
private readonly IMedicinesStorage _medicinesStorage;
public MedicinesLogic(ILogger<MedicinesLogic> logger, IMedicinesStorage medicinesStorage)
{
_logger = logger;
_medicinesStorage = medicinesStorage;
}
public bool Create(MedicinesBindingModel model)
{
CheckModel(model);
if (_medicinesStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(MedicinesBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_medicinesStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public MedicinesViewModel? ReadElement(MedicinesSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. MedicinesName:{MedicinesName}. Id:{ Id}", model.MedicinesName, model.Id);
var element = _medicinesStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<MedicinesViewModel>? ReadList(MedicinesSearchModel? model)
{
_logger.LogInformation("ReadList. MedicinesName:{MedicinesName}. Id:{ Id}", model?.MedicinesName, model?.Id);
var list = model == null ? _medicinesStorage.GetFullList() : _medicinesStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(MedicinesBindingModel model)
{
CheckModel(model);
if (_medicinesStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(MedicinesBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.MedicinesName))
{
throw new ArgumentNullException("Нет названия лекарства", nameof(model.MedicinesName));
}
if (string.IsNullOrEmpty(model.Group))
{
throw new ArgumentNullException("Нет группы лекарства", nameof(model.Group));
}
_logger.LogInformation("Medicines. MedicinesName:{MedicinesName}. Group:{ Group}. Id: { Id} ", model.MedicinesName, model.Group, model.Id);
var element = _medicinesStorage.GetElement(new MedicinesSearchModel
{
MedicinesName = model.MedicinesName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Лекарство с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,117 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class ProceduresLogic : IProceduresLogic
{
private readonly ILogger _logger;
private readonly IProceduresStorage _proceduresStorage;
public ProceduresLogic(ILogger<ProceduresLogic> logger, IProceduresStorage proceduresStorage)
{
_logger = logger;
_proceduresStorage = proceduresStorage;
}
public bool Create(ProceduresBindingModel model)
{
CheckModel(model);
if (_proceduresStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ProceduresBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_proceduresStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public ProceduresViewModel? ReadElement(ProceduresSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ProceduresName:{ProceduresName}. Id:{ Id}", model.ProceduresName, model.Id);
var element = _proceduresStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ProceduresViewModel>? ReadList(ProceduresSearchModel? model)
{
_logger.LogInformation("ReadList. ProceduresName:{ProceduresName}. Id:{ Id}", model?.ProceduresName, model?.Id);
var list = model == null ? _proceduresStorage.GetFullList() : _proceduresStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(ProceduresBindingModel model)
{
CheckModel(model);
if (_proceduresStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(ProceduresBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ProceduresName))
{
throw new ArgumentNullException("Нет названия процедуры", nameof(model.ProceduresName));
}
if (string.IsNullOrEmpty(model.Type))
{
throw new ArgumentNullException("Нет типа процедуры", nameof(model.Type));
}
_logger.LogInformation("Procedures. ProceduresName:{ProceduresName}. Type:{ Type}. Id: { Id} ", model.ProceduresName, model.Type, model.Id);
var element = _proceduresStorage.GetElement(new ProceduresSearchModel
{
ProceduresName = model.ProceduresName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Процедура с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,109 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class RecipesLogic : IRecipesLogic
{
private readonly ILogger _logger;
private readonly IRecipesStorage _recipesStorage;
public RecipesLogic(ILogger<RecipesLogic> logger, IRecipesStorage recipesStorage)
{
_logger = logger;
_recipesStorage = recipesStorage;
}
public bool Create(RecipesBindingModel model)
{
CheckModel(model);
if (_recipesStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(RecipesBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_recipesStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public RecipesViewModel? ReadElement(RecipesSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _recipesStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<RecipesViewModel>? ReadList(RecipesSearchModel? model)
{
_logger.LogInformation("ReadElement. Id:{ Id}", model?.Id);
var list = model == null ? _recipesStorage.GetFullList() : _recipesStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(RecipesBindingModel model)
{
CheckModel(model);
if (_recipesStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(RecipesBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Dose))
{
throw new ArgumentNullException("В рецепте нет дозировки", nameof(model.Dose));
}
if (string.IsNullOrEmpty(model.ModeOfApplication))
{
throw new ArgumentNullException("Нет способа приема", nameof(model.ModeOfApplication));
}
_logger.LogInformation("Recipes. RecipesId:{Id}.Dose:{ Dose}. ModeOfApplication:{ ModeOfApplication}. SymptomsId: { SymptomsId}", model.Id, model.Dose, model.ModeOfApplication);
}
}
}

View File

@ -0,0 +1,113 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using HospitalContracts.StoragesContracts;
using HospitalContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalBusinessLogic.BusinessLogics
{
public class SymptomsLogic : ISymptomsLogic
{
private readonly ILogger _logger;
private readonly ISymptomsStorage _symptomsStorage;
public SymptomsLogic(ILogger<SymptomsLogic> logger, ISymptomsStorage symptomsStorage)
{
_logger = logger;
_symptomsStorage = symptomsStorage;
}
public bool Create(SymptomsBindingModel model)
{
CheckModel(model);
if (_symptomsStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(SymptomsBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_symptomsStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public SymptomsViewModel? ReadElement(SymptomsSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. SymptomsName:{SymptomsName}. Id:{ Id}", model.SymptomName, model.Id);
var element = _symptomsStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<SymptomsViewModel>? ReadList(SymptomsSearchModel? model)
{
_logger.LogInformation("ReadList. SymptomsName:{SymptomsName}. Id:{ Id}", model?.SymptomName, model?.Id);
var list = model == null ? _symptomsStorage.GetFullList() : _symptomsStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(SymptomsBindingModel model)
{
CheckModel(model);
if (_symptomsStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(SymptomsBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SymptomName))
{
throw new ArgumentNullException("Нет названия симптоматики", nameof(model.SymptomName));
}
_logger.LogInformation("Symptoms. SymptomName:{SymptomName}. Id: { Id} ", model.SymptomName, model.Id);
var element = _symptomsStorage.GetElement(new SymptomsSearchModel
{
SymptomName = model.SymptomName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Симптоматика с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\HospitalContracts\HospitalContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class IllnessBindingModel public class IllnessBindingModel: IIllnessModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string IllnessName { get; set; } = string.Empty; public string IllnessName { get; set; } = string.Empty;
@ -17,6 +17,10 @@ namespace HospitalContracts.BindingModels
get; get;
set; set;
} = new(); } = new();
public Dictionary<int, (IKurseModel, int)> IllnessKurse
{
get;
set;
} = new();
} }
} }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class KurseBindingModel public class KurseBindingModel: IKurseModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string Duration { get; set; } = string.Empty; public string Duration { get; set; } = string.Empty;

View File

@ -1,4 +1,5 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -6,10 +7,10 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class MedicinesBindingModel public class MedicinesBindingModel: IMedicinesModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string MedicineName { get; set; } = string.Empty; public string MedicinesName { get; set; } = string.Empty;
public string Group { get; set; } = string.Empty; public string Group { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -6,10 +7,10 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class ProceduresBindingModel public class ProceduresBindingModel: IProceduresModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string ProcedureName { get; set; } = string.Empty; public string ProceduresName { get; set; } = string.Empty;
public string Type { get; set; } = string.Empty; public string Type { get; set; } = string.Empty;
} }
} }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class RecipesBindingModel public class RecipesBindingModel: IRecipesModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string Dose { get; set; } = string.Empty; public string Dose { get; set; } = string.Empty;

View File

@ -1,4 +1,5 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -6,7 +7,7 @@ using System.Threading.Tasks;
namespace HospitalContracts.BindingModels namespace HospitalContracts.BindingModels
{ {
public class SymptomsBindingModel public class SymptomsBindingModel: ISymptomsModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string SymptomName { get; set; } = string.Empty; public string SymptomName { get; set; } = string.Empty;

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IIllnessLogic
{
List<IllnessViewModel>? ReadList(IllnessSearchModel? model);
IllnessViewModel? ReadElement(IllnessSearchModel model);
bool Create(IllnessBindingModel model);
bool Update(IllnessBindingModel model);
bool Delete(IllnessBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IKurseLogic
{
List<KurseViewModel>? ReadList(KurseSearchModel? model);
KurseViewModel? ReadElement(KurseSearchModel model);
bool Create(KurseBindingModel model);
bool Update(KurseBindingModel model);
bool Delete(KurseBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IMedicinesLogic
{
List<MedicinesViewModel>? ReadList(MedicinesSearchModel? model);
MedicinesViewModel? ReadElement(MedicinesSearchModel model);
bool Create(MedicinesBindingModel model);
bool Update(MedicinesBindingModel model);
bool Delete(MedicinesBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IProceduresLogic
{
List<ProceduresViewModel>? ReadList(ProceduresSearchModel? model);
ProceduresViewModel? ReadElement(ProceduresSearchModel model);
bool Create(ProceduresBindingModel model);
bool Update(ProceduresBindingModel model);
bool Delete(ProceduresBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface IRecipesLogic
{
List<RecipesViewModel>? ReadList(RecipesSearchModel? model);
RecipesViewModel? ReadElement(RecipesSearchModel model);
bool Create(RecipesBindingModel model);
bool Update(RecipesBindingModel model);
bool Delete(RecipesBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.BusinessLogicsContracts
{
public interface ISymptomsLogic
{
List<SymptomsViewModel>? ReadList(SymptomsSearchModel? model);
SymptomsViewModel? ReadElement(SymptomsSearchModel model);
bool Create(SymptomsBindingModel model);
bool Update(SymptomsBindingModel model);
bool Delete(SymptomsBindingModel model);
}
}

View File

@ -6,11 +6,6 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="BusinessLogicsContracts\" />
<Folder Include="StoragesContracts\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" /> <ProjectReference Include="..\HospitalDataModels\HospitalDataModels.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -9,6 +9,6 @@ namespace HospitalContracts.SearchModels
public class SymptomsSearchModel public class SymptomsSearchModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string? SymptomsName { get; set; } public string? SymptomName { get; set; }
} }
} }

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IIllnessStorage
{
List<IllnessViewModel> GetFullList();
List<IllnessViewModel> GetFilteredList(IllnessSearchModel model);
IllnessViewModel? GetElement(IllnessSearchModel model);
IllnessViewModel? Insert(IllnessBindingModel model);
IllnessViewModel? Update(IllnessBindingModel model);
IllnessViewModel? Delete(IllnessBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IKurseStorage
{
List<KurseViewModel> GetFullList();
List<KurseViewModel> GetFilteredList(KurseSearchModel model);
KurseViewModel? GetElement(KurseSearchModel model);
KurseViewModel? Insert(KurseBindingModel model);
KurseViewModel? Update(KurseBindingModel model);
KurseViewModel? Delete(KurseBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IMedicinesStorage
{
List<MedicinesViewModel> GetFullList();
List<MedicinesViewModel> GetFilteredList(MedicinesSearchModel model);
MedicinesViewModel? GetElement(MedicinesSearchModel model);
MedicinesViewModel? Insert(MedicinesBindingModel model);
MedicinesViewModel? Update(MedicinesBindingModel model);
MedicinesViewModel? Delete(MedicinesBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IProceduresStorage
{
List<ProceduresViewModel> GetFullList();
List<ProceduresViewModel> GetFilteredList(ProceduresSearchModel model);
ProceduresViewModel? GetElement(ProceduresSearchModel model);
ProceduresViewModel? Insert(ProceduresBindingModel model);
ProceduresViewModel? Update(ProceduresBindingModel model);
ProceduresViewModel? Delete(ProceduresBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface IRecipesStorage
{
List<RecipesViewModel> GetFullList();
List<RecipesViewModel> GetFilteredList(RecipesSearchModel model);
RecipesViewModel? GetElement(RecipesSearchModel model);
RecipesViewModel? Insert(RecipesBindingModel model);
RecipesViewModel? Update(RecipesBindingModel model);
RecipesViewModel? Delete(RecipesBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using HospitalContracts.BindingModels;
using HospitalContracts.SearchModels;
using HospitalContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalContracts.StoragesContracts
{
public interface ISymptomsStorage
{
List<SymptomsViewModel> GetFullList();
List<SymptomsViewModel> GetFilteredList(SymptomsSearchModel model);
SymptomsViewModel? GetElement(SymptomsSearchModel model);
SymptomsViewModel? Insert(SymptomsBindingModel model);
SymptomsViewModel? Update(SymptomsBindingModel model);
SymptomsViewModel? Delete(SymptomsBindingModel model);
}
}

View File

@ -1,12 +1,29 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class IllnessViewModel public class IllnessViewModel: IIllnessModel
{ {
public int Id { get; set; }
[DisplayName("Название болезни")]
public string IllnessName { get; set; }
[DisplayName("Форма болезни")]
public string Form { get; set; }
public Dictionary<int, (ISymptomsModel, int)> IllnessSymptoms
{
get;
set;
} = new();
public Dictionary<int, (IKurseModel, int)> IllnessKurse
{
get;
set;
} = new();
} }
} }

View File

@ -1,12 +1,21 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class KurseViewModel public class KurseViewModel: IKurseModel
{ {
public int Id { get; set; }
[DisplayName("Продолжительность курса")]
public string Duration { get; set; }
[DisplayName("Срок приема")]
public int CountInDay { get; set; }
[DisplayName("Название лекарства")]
public int MedicinesId { get; }
} }
} }

View File

@ -1,12 +1,19 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class MedicinesViewModel public class MedicinesViewModel: IMedicinesModel
{ {
public int Id { get; set; }
[DisplayName("Название лекарства")]
public string MedicinesName { get; set; }
[DisplayName("Группа")]
public string Group { get; set; }
} }
} }

View File

@ -1,12 +1,19 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class ProceduresViewModel public class ProceduresViewModel: IProceduresModel
{ {
public int Id { get; set; }
[DisplayName("Название процедуры")]
public string ProceduresName { get; set; }
[DisplayName("Тип процедуры")]
public string Type { get; set; }
} }
} }

View File

@ -1,12 +1,31 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class RecipesViewModel public class RecipesViewModel: IRecipesModel
{ {
public int Id { get; set; }
[DisplayName("Доза")]
public string Dose { get; set; }
[DisplayName("Дата выписки")]
public DateTime Date { get; set; }
[DisplayName("Способ приготовления")]
public string ModeOfApplication { get; set; }
public Dictionary<int, (IMedicinesModel, int)> MedicinesRecipe
{
get;
set;
} = new();
public Dictionary<int, (IProceduresModel, int)> ProceduresRecipe
{
get;
set;
} = new();
} }
} }

View File

@ -1,12 +1,19 @@
using System; using HospitalDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HospitalContracts.ViewModels namespace HospitalContracts.ViewModels
{ {
internal class SymptomsViewModel public class SymptomsViewModel: ISymptomsModel
{ {
public int Id { get; set; }
[DisplayName("Симптом")]
public string SymptomName { get; set; }
[DisplayName("Описание")]
public string Description { get; set; }
} }
} }

View File

@ -8,7 +8,7 @@ namespace HospitalDataModels.Models
{ {
public interface IMedicinesModel: IId public interface IMedicinesModel: IId
{ {
string MedicineName { get; } string MedicinesName { get; }
string Group { get; } string Group { get; }
} }
} }

View File

@ -8,7 +8,7 @@ namespace HospitalDataModels.Models
{ {
public interface IProceduresModel: IId public interface IProceduresModel: IId
{ {
string ProcedureName { get; } string ProceduresName { get; }
string Type { get; } string Type { get; }
} }
} }

View File

@ -1,10 +0,0 @@
namespace HospitalView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,14 +1,14 @@
namespace HospitalView namespace HospitalView
{ {
partial class Form1 partial class FormMain
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@ -23,15 +23,22 @@
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.SuspendLayout();
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(1047, 369);
this.Text = "Form1"; this.Name = "FormMain";
this.Text = "Поликлиника \"Будьте больны\"";
this.ResumeLayout(false);
} }
#endregion #endregion

20
HospitalView/FormMain.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalView
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

119
HospitalView/FormMedicine.Designer.cs generated Normal file
View File

@ -0,0 +1,119 @@
namespace HospitalView
{
partial class FormMedicine
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelNameMedicines = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.textBoxNameMedicine = new System.Windows.Forms.TextBox();
this.textBoxGroup = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelNameMedicines
//
this.labelNameMedicines.AutoSize = true;
this.labelNameMedicines.Location = new System.Drawing.Point(32, 40);
this.labelNameMedicines.Name = "labelNameMedicines";
this.labelNameMedicines.Size = new System.Drawing.Size(153, 20);
this.labelNameMedicines.TabIndex = 0;
this.labelNameMedicines.Text = "Название лекарства:";
//
// label
//
this.label.AutoSize = true;
this.label.Location = new System.Drawing.Point(32, 96);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(61, 20);
this.label.TabIndex = 1;
this.label.Text = "Группа:";
//
// textBoxNameMedicine
//
this.textBoxNameMedicine.Location = new System.Drawing.Point(206, 37);
this.textBoxNameMedicine.Name = "textBoxNameMedicine";
this.textBoxNameMedicine.Size = new System.Drawing.Size(211, 27);
this.textBoxNameMedicine.TabIndex = 2;
//
// textBoxGroup
//
this.textBoxGroup.Location = new System.Drawing.Point(206, 93);
this.textBoxGroup.Name = "textBoxGroup";
this.textBoxGroup.Size = new System.Drawing.Size(211, 27);
this.textBoxGroup.TabIndex = 3;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(181, 138);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(94, 29);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(323, 138);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormMedicines
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(448, 190);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxGroup);
this.Controls.Add(this.textBoxNameMedicine);
this.Controls.Add(this.label);
this.Controls.Add(this.labelNameMedicines);
this.Name = "FormMedicines";
this.Text = "Лекарства";
this.Load += new System.EventHandler(this.FormMedicines_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelNameMedicines;
private Label label;
private TextBox textBoxNameMedicine;
private TextBox textBoxGroup;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,95 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.SearchModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalView
{
public partial class FormMedicine : Form
{
private readonly ILogger _logger;
private readonly IMedicinesLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormMedicine(ILogger<FormMedicine> logger, IMedicinesLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormMedicines_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение лекарства");
var view = _logic.ReadElement(new MedicinesSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxNameMedicine.Text = view.MedicinesName;
textBoxGroup.Text = view.Group;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения лекарства");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxNameMedicine.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение лекарства");
try
{
var model = new MedicinesBindingModel
{
Id = _id ?? 0,
MedicinesName = textBoxNameMedicine.Text,
Group = textBoxGroup.Text
};
var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения лекарства");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

117
HospitalView/FormMedicines.Designer.cs generated Normal file
View File

@ -0,0 +1,117 @@
namespace HospitalView
{
partial class FormMedicines
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.GridColor = System.Drawing.SystemColors.Control;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(393, 346);
this.dataGridView.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(430, 36);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(140, 29);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(430, 124);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(140, 29);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(430, 210);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(140, 29);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(430, 302);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(140, 29);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormMedicines
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(582, 373);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormMedicines";
this.Text = "Лекарства";
this.Click += new System.EventHandler(this.FormMedicines_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,111 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalView
{
public partial class FormMedicines : Form
{
private readonly ILogger _logger;
private readonly IMedicinesLogic _logic;
public FormMedicines(ILogger<FormMedicines> logger, IMedicinesLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormMedicines_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["MedicinesName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка лекарств");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки лекарств");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMedicine));
if (service is FormMedicines form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMedicine));
if (service is FormMedicine form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление лекарства");
try
{
if (!_logic.Delete(new MedicinesBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления лекарства");
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

119
HospitalView/FormProcedure.Designer.cs generated Normal file
View File

@ -0,0 +1,119 @@
namespace HospitalView
{
partial class FormProcedure
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelNameProcedure = new System.Windows.Forms.Label();
this.labelTypeProcedure = new System.Windows.Forms.Label();
this.textBoxNameProcedure = new System.Windows.Forms.TextBox();
this.textBoxTypeProcedure = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelNameProcedure
//
this.labelNameProcedure.AutoSize = true;
this.labelNameProcedure.Location = new System.Drawing.Point(39, 28);
this.labelNameProcedure.Name = "labelNameProcedure";
this.labelNameProcedure.Size = new System.Drawing.Size(163, 20);
this.labelNameProcedure.TabIndex = 0;
this.labelNameProcedure.Text = "Название процедуры:";
//
// labelTypeProcedure
//
this.labelTypeProcedure.AutoSize = true;
this.labelTypeProcedure.Location = new System.Drawing.Point(39, 88);
this.labelTypeProcedure.Name = "labelTypeProcedure";
this.labelTypeProcedure.Size = new System.Drawing.Size(121, 20);
this.labelTypeProcedure.TabIndex = 1;
this.labelTypeProcedure.Text = "Тип процедуры:";
//
// textBoxNameProcedure
//
this.textBoxNameProcedure.Location = new System.Drawing.Point(229, 28);
this.textBoxNameProcedure.Name = "textBoxNameProcedure";
this.textBoxNameProcedure.Size = new System.Drawing.Size(241, 27);
this.textBoxNameProcedure.TabIndex = 2;
//
// textBoxTypeProcedure
//
this.textBoxTypeProcedure.Location = new System.Drawing.Point(229, 88);
this.textBoxTypeProcedure.Name = "textBoxTypeProcedure";
this.textBoxTypeProcedure.Size = new System.Drawing.Size(241, 27);
this.textBoxTypeProcedure.TabIndex = 3;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(248, 129);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(94, 29);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(376, 129);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormProcedure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(495, 171);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxTypeProcedure);
this.Controls.Add(this.textBoxNameProcedure);
this.Controls.Add(this.labelTypeProcedure);
this.Controls.Add(this.labelNameProcedure);
this.Name = "FormProcedure";
this.Text = "Процедура";
this.Load += new System.EventHandler(this.FormProcedures_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelNameProcedure;
private Label labelTypeProcedure;
private TextBox textBoxNameProcedure;
private TextBox textBoxTypeProcedure;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,94 @@
using HospitalContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HospitalContracts.SearchModels;
using HospitalContracts.BindingModels;
namespace HospitalView
{
public partial class FormProcedure : Form
{
private readonly ILogger _logger;
private readonly IProceduresLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormProcedure(ILogger<FormProcedure> logger, IProceduresLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormProcedures_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение процедуры");
var view = _logic.ReadElement(new ProceduresSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxNameProcedure.Text = view.ProceduresName;
textBoxTypeProcedure.Text = view.Type;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxNameProcedure.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение процедуры");
try
{
var model = new ProceduresBindingModel
{
Id = _id ?? 0,
ProceduresName = textBoxNameProcedure.Text,
Type = textBoxTypeProcedure.Text
};
var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения процедуры");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

116
HospitalView/FormProcedures.Designer.cs generated Normal file
View File

@ -0,0 +1,116 @@
namespace HospitalView
{
partial class FormProcedures
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(393, 346);
this.dataGridView.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(430, 36);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(140, 29);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(430, 124);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(140, 29);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(430, 210);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(140, 29);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(430, 302);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(140, 29);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormProcedures
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(582, 373);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormProcedures";
this.Text = "Процедуры";
this.Load += new System.EventHandler(this.FormProcedures_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,114 @@
using HospitalContracts.BindingModels;
using HospitalContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalView
{
public partial class FormProcedures : Form
{
private readonly ILogger _logger;
private readonly IProceduresLogic _logic;
public FormProcedures(ILogger<FormProcedures> logger, IProceduresLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormProcedures_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ProcedureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка процедур");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки процедур");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormProcedure));
if (service is FormProcedure form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormProcedure));
if (service is FormProcedure form)
{
form.Id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление процедуры");
try
{
if (!_logic.Delete(new ProceduresBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления процедуры");
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -8,4 +8,13 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalContracts\HospitalContracts.csproj" />
<ProjectReference Include="..\Hospital\HospitalBusinessLogic\HospitalBusinessLogic.csproj" />
</ItemGroup>
</Project> </Project>