Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46d688bd74 | ||
|
|
0589efda36 | ||
|
|
adec36fa6b | ||
|
|
400838e156 | ||
|
|
f5de165db5 | ||
|
|
de477322f8 | ||
|
|
7401da2207 | ||
|
|
a79e59759a | ||
|
|
a392caad33 | ||
|
|
796505fe3b | ||
|
|
ac60db883a | ||
|
|
3331a70fed | ||
|
|
275c1135d1 | ||
|
|
9eae1097fc | ||
|
|
368716d3ba | ||
|
|
dc981b4782 | ||
|
|
914b62c426 | ||
|
|
5cefdb8d7e | ||
|
|
ac219be3bf | ||
|
|
805b93eec9 | ||
|
|
2a4d859356 | ||
|
|
bb9275361c | ||
|
|
c77c0dfae6 | ||
|
|
f806775b7b | ||
|
|
63e641cd62 | ||
|
|
530526760f | ||
|
|
6d2dccd4df | ||
|
|
b1abff7997 | ||
|
|
6519ed1296 | ||
|
|
3dabf39829 | ||
|
|
d68d22c70b | ||
|
|
3a9459b51b | ||
|
|
d56858c6f6 | ||
|
|
582d187600 | ||
|
|
0420774522 | ||
|
|
eb82dac496 | ||
|
|
d9d36e1eec | ||
|
|
e5ea0c2960 | ||
|
|
a157403c04 | ||
|
|
509d618c30 | ||
|
|
209f1fa73b | ||
|
|
225e72e21a | ||
|
|
93d8e0596a | ||
|
|
97b76f3ba6 | ||
|
|
8044cadda1 | ||
|
|
1b06ae3d96 | ||
|
|
f1706a4e42 | ||
|
|
520ea2f1d5 | ||
|
|
5bea31e5bd | ||
|
|
c2e67646a0 | ||
|
|
257981c280 | ||
|
|
e40481a9df | ||
|
|
c933ec3304 | ||
|
|
e3682318d3 | ||
|
|
fb5507c55c | ||
|
|
6457bc4afa | ||
|
|
f96f4f909d | ||
|
|
dfd97c6416 | ||
|
|
476bd776ea | ||
|
|
a64425108f | ||
|
|
87e51354ad | ||
|
|
2789df2c72 | ||
|
|
514a82e4ef | ||
|
|
bb38b406ca | ||
|
|
d0c2d6737f | ||
|
|
1794e11784 | ||
|
|
32745392d2 | ||
|
|
5d987e670b | ||
|
|
10eb208db2 | ||
|
|
e1fc21f4cc | ||
|
|
667748c3ee | ||
|
|
6b9f987f44 | ||
|
|
c734360667 | ||
|
|
c1e1972d3a | ||
|
|
08cd7160fd | ||
|
|
62cc238099 | ||
|
|
ae1ae11879 | ||
|
|
4314a0d712 | ||
|
|
1686a0c53f | ||
|
|
e43157e3d7 | ||
|
|
1bb8c060cb | ||
|
|
9687d18450 | ||
|
|
3a4c173849 | ||
|
|
0778a6d2c7 | ||
|
|
e40f70c04c | ||
|
|
792a5e9995 | ||
|
|
3b299edcd7 | ||
|
|
04c455cd7e | ||
|
|
9337f1bc53 | ||
|
|
68ce43d50a | ||
|
|
f1359d2657 | ||
|
|
ac83f7165b | ||
|
|
3d7c2ac7ac |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -14,6 +14,9 @@
|
|||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
|
||||||
|
# dll файлы
|
||||||
|
*.dll
|
||||||
|
|
||||||
# Mono auto generated files
|
# Mono auto generated files
|
||||||
mono_crash.*
|
mono_crash.*
|
||||||
|
|
||||||
|
|||||||
103
ConfectionaryBusinessLogic/BackUpLogic.cs
Normal file
103
ConfectionaryBusinessLogic/BackUpLogic.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(BackUpSaveBinidngModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
// зачистка папки и удаление старого архива
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
// берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
128
ConfectionaryBusinessLogic/ClientLogic.cs
Normal file
128
ConfectionaryBusinessLogic/ClientLogic.cs
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using ConfectioneryBusinessLogic.BusinessLogics;
|
||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
// ReSharper disable All
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class ClientLogic : IClientLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_clientStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Email:{Email}.Id:{ Id}",
|
||||||
|
model.Email, model.Id);
|
||||||
|
var element = _clientStorage.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<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Email:{Email}.Id:{ Id} ", model?.Email, model?.Id);
|
||||||
|
var list = (model == null) ? _clientStorage.GetFullList() :
|
||||||
|
_clientStorage.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(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет фио клиента", nameof(model.ClientFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина клиента", nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (!Regex.IsMatch(model.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Некорретно введенный email", nameof(model.Email));
|
||||||
|
}
|
||||||
|
// Запасной (вероятно более правильный): ^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))+$
|
||||||
|
// Просматриваем наперед последовательность (де-факто оператор &&) цифр, небуквенных символов и букв (не цифр и не пробельных символов)
|
||||||
|
if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\W)(?=.*[^\d\s]).+$"))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Некорректно введенный пароль. Пароль должен содержать хотя бы одну букву, цифру и не буквенный символ", nameof(model.Password));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email );
|
||||||
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Email = model.Email,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,107 +7,106 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.BusinessLogics
|
namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ComponentLogic : IComponentLogic
|
public class ComponentLogic : IComponentLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IComponentStorage _componentStorage;
|
private readonly IComponentStorage _componentStorage;
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_componentStorage = componentStorage;
|
_componentStorage = componentStorage;
|
||||||
}
|
}
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ",
|
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ",
|
||||||
model?.ComponentName, model?.Id);
|
model?.ComponentName, model?.Id);
|
||||||
var list = (model == null) ? _componentStorage.GetFullList() :
|
var list = (model == null) ? _componentStorage.GetFullList() :
|
||||||
_componentStorage.GetFilteredList(model);
|
_componentStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}",
|
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}",
|
||||||
model.ComponentName, model.Id);
|
model.ComponentName, model.Id);
|
||||||
var element = _componentStorage.GetElement(model);
|
var element = _componentStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
public bool Create(ComponentBindingModel model)
|
public bool Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_componentStorage.Insert(model) == null)
|
if (_componentStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Update(ComponentBindingModel model)
|
public bool Update(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_componentStorage.Update(model) == null)
|
if (_componentStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Delete(ComponentBindingModel model)
|
public bool Delete(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_componentStorage.Delete(model) == null)
|
if (_componentStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams =
|
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
||||||
true)
|
{
|
||||||
{
|
if (model == null)
|
||||||
if (model == null)
|
{
|
||||||
{
|
throw new ArgumentNullException(nameof(model));
|
||||||
throw new ArgumentNullException(nameof(model));
|
}
|
||||||
}
|
if (!withParams)
|
||||||
if (!withParams)
|
{
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
{
|
||||||
{
|
throw new ArgumentNullException("Нет названия компонента",
|
||||||
throw new ArgumentNullException("Нет названия компонента",
|
nameof(model.ComponentName));
|
||||||
nameof(model.ComponentName));
|
}
|
||||||
}
|
if (model.Cost <= 0)
|
||||||
if (model.Cost <= 0)
|
{
|
||||||
{
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
}
|
||||||
}
|
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}",
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}",
|
model.ComponentName, model.Cost, model.Id);
|
||||||
model.ComponentName, model.Cost, model.Id);
|
var element = _componentStorage.GetElement(new ComponentSearchModel
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
{
|
||||||
{
|
ComponentName = model.ComponentName
|
||||||
ComponentName = model.ComponentName
|
});
|
||||||
});
|
if (element != null && element.Id != model.Id)
|
||||||
if (element != null && element.Id != model.Id)
|
{
|
||||||
{
|
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||||
|
<PackageReference Include="MailKit" Version="3.5.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||||
|
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
123
ConfectionaryBusinessLogic/ImplementerLogic.cs
Normal file
123
ConfectionaryBusinessLogic/ImplementerLogic.cs
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class ImplementerLogic : IImplementerLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerStorage _implementerStorage;
|
||||||
|
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_implementerStorage = implementerStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_implementerStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}",
|
||||||
|
model.ImplementerFIO, model.Id);
|
||||||
|
var element = _implementerStorage.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<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. FIO:{FIO}.Id:{ Id} ", model?.ImplementerFIO, model?.Id);
|
||||||
|
var list = (model == null) ? _implementerStorage.GetFullList() :
|
||||||
|
_implementerStorage.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(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.WorkExperience < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
|
||||||
|
}
|
||||||
|
if (model.Qualification < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет фио исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
|
||||||
|
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Исполнитель с таким фио уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
100
ConfectionaryBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
100
ConfectionaryBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public abstract class AbstractMailWorker
|
||||||
|
{
|
||||||
|
protected string _mailLogin = string.Empty;
|
||||||
|
|
||||||
|
protected string _mailPassword = string.Empty;
|
||||||
|
|
||||||
|
protected string _smtpClientHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _smtpClientPort;
|
||||||
|
|
||||||
|
protected string _popHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _popPort;
|
||||||
|
|
||||||
|
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_messageInfoLogic = messageInfoLogic;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MailConfig(MailConfigBindingModel config)
|
||||||
|
{
|
||||||
|
_mailLogin = config.MailLogin;
|
||||||
|
_mailPassword = config.MailPassword;
|
||||||
|
_smtpClientHost = config.SmtpClientHost;
|
||||||
|
_smtpClientPort = config.SmtpClientPort;
|
||||||
|
_popHost = config.PopHost;
|
||||||
|
_popPort = config.PopPort;
|
||||||
|
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||||
|
await SendMailAsync(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void MailCheck()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_messageInfoLogic == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = await ReceiveMailAsync();
|
||||||
|
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||||
|
foreach (var mail in list)
|
||||||
|
{
|
||||||
|
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
|
||||||
|
_messageInfoLogic.Create(mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||||
|
|
||||||
|
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
82
ConfectionaryBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
82
ConfectionaryBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using MailKit.Net.Pop3;
|
||||||
|
using MailKit.Security;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public class MailKitWorker : AbstractMailWorker
|
||||||
|
{
|
||||||
|
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
|
||||||
|
|
||||||
|
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
using var objMailMessage = new MailMessage();
|
||||||
|
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objMailMessage.From = new MailAddress(_mailLogin);
|
||||||
|
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||||
|
objMailMessage.Subject = info.Subject;
|
||||||
|
objMailMessage.Body = info.Text;
|
||||||
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
|
objSmtpClient.EnableSsl = true;
|
||||||
|
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||||
|
|
||||||
|
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
||||||
|
{
|
||||||
|
var list = new List<MessageInfoBindingModel>();
|
||||||
|
using var client = new Pop3Client();
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
||||||
|
client.Authenticate(_mailLogin, _mailPassword);
|
||||||
|
for (int i = 0; i < client.Count; i++)
|
||||||
|
{
|
||||||
|
var message = client.GetMessage(i);
|
||||||
|
foreach (var mail in message.From.Mailboxes)
|
||||||
|
{
|
||||||
|
list.Add(new MessageInfoBindingModel
|
||||||
|
{
|
||||||
|
DateDelivery = message.Date.DateTime,
|
||||||
|
MessageId = message.MessageId,
|
||||||
|
SenderName = mail.Address,
|
||||||
|
Subject = message.Subject,
|
||||||
|
Body = message.TextBody
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (AuthenticationException)
|
||||||
|
{ }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client.Disconnect(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
ConfectionaryBusinessLogic/MessageInfoLogic.cs
Normal file
48
ConfectionaryBusinessLogic/MessageInfoLogic.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class MessageInfoLogic : IMessageInfoLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoStorage _messageInfoStorage;
|
||||||
|
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage MessageInfoStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_messageInfoStorage = MessageInfoStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (_messageInfoStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ", model?.MessageId, model?.ClientId);
|
||||||
|
var list = (model == null) ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
112
ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
112
ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToExcel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создание отчета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
public void CreateReport(ExcelInfo info)
|
||||||
|
{
|
||||||
|
CreateExcel(info);
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = 1,
|
||||||
|
Text = info.Title,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
|
});
|
||||||
|
|
||||||
|
MergeCells(new ExcelMergeParameters
|
||||||
|
{
|
||||||
|
CellFromName = "A1",
|
||||||
|
CellToName = "C1"
|
||||||
|
});
|
||||||
|
|
||||||
|
uint rowIndex = 2;
|
||||||
|
foreach (var pc in info.PastryComponents)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = pc.PastryName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var (Pastry, Count) in pc.Components)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Pastry,
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Count.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = "Итого",
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = pc.TotalCount.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveExcel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание excel-файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void CreateExcel(ExcelInfo info);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавляем новую ячейку в лист
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cellParameters"></param>
|
||||||
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Объединение ячеек
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mergeParameters"></param>
|
||||||
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void SaveExcel(ExcelInfo info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
public void CreateDoc(PdfInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
CreateParagraph(new PdfParagraph {
|
||||||
|
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "2cm", "3cm", "6cm", "4cm", "3cm" });
|
||||||
|
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var order in info.Orders)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, Convert.ToString(order.OrderStatus), order.Sum.ToString() },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||||||
|
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание doc-файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void CreatePdf(PdfInfo info);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание параграфа с текстом
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title"></param>
|
||||||
|
/// <param name="style"></param>
|
||||||
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание таблицы
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title"></param>
|
||||||
|
/// <param name="style"></param>
|
||||||
|
protected abstract void CreateTable(List<string> columns);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание и заполнение строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rowParameters"></param>
|
||||||
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void SavePdf(PdfInfo info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToWord
|
||||||
|
{
|
||||||
|
public void CreateDoc(WordInfo info)
|
||||||
|
{
|
||||||
|
CreateWord(info);
|
||||||
|
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var pastry in info.Pastries)
|
||||||
|
{
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)>
|
||||||
|
{
|
||||||
|
(pastry.PastryName , new WordTextProperties { Size = "24", Bold = true}),
|
||||||
|
(" - цена: " + pastry.Price.ToString(), new WordTextProperties { Size = "24" })
|
||||||
|
},
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание doc-файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void CreateWord(WordInfo info);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание абзаца с текстом
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paragraph"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
protected abstract void SaveWord(WordInfo info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum ExcelStyleInfoType
|
||||||
|
{
|
||||||
|
Title,
|
||||||
|
Text,
|
||||||
|
TextWithBroder
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum PdfParagraphAlignmentType
|
||||||
|
{
|
||||||
|
Center,
|
||||||
|
Left,
|
||||||
|
Rigth
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum WordJustificationType
|
||||||
|
{
|
||||||
|
Center,
|
||||||
|
Both
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelCellParameters
|
||||||
|
{
|
||||||
|
public string ColumnName { get; set; } = string.Empty;
|
||||||
|
public uint RowIndex { get; set; }
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||||
|
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ReportPastryComponentViewModel> PastryComponents
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelMergeParameters
|
||||||
|
{
|
||||||
|
public string CellFromName { get; set; } = string.Empty;
|
||||||
|
public string CellToName { get; set; } = string.Empty;
|
||||||
|
public string Merge => $"{CellFromName}:{CellToName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime DateFrom { get; set; }
|
||||||
|
public DateTime DateTo { get; set; }
|
||||||
|
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfParagraph
|
||||||
|
{
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<PastryViewModel> Pastries { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordParagraph
|
||||||
|
{
|
||||||
|
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||||
|
public WordTextProperties? TextProperties { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordTextProperties
|
||||||
|
{
|
||||||
|
public string Size { get; set; } = string.Empty;
|
||||||
|
public bool Bold { get; set; }
|
||||||
|
public WordJustificationType JustificationType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToExcel : AbstractSaveToExcel
|
||||||
|
{
|
||||||
|
private SpreadsheetDocument? _spreadsheetDocument;
|
||||||
|
|
||||||
|
private SharedStringTablePart? _shareStringPart;
|
||||||
|
|
||||||
|
private Worksheet? _worksheet;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Настройка стилей для файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workbookpart"></param>
|
||||||
|
private static void CreateStyles(WorkbookPart workbookpart)
|
||||||
|
{
|
||||||
|
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||||
|
sp.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
|
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||||
|
|
||||||
|
var fontUsual = new Font();
|
||||||
|
fontUsual.Append(new FontSize() { Val = 12D });
|
||||||
|
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
|
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||||
|
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
|
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
|
var fontTitle = new Font();
|
||||||
|
fontTitle.Append(new Bold());
|
||||||
|
fontTitle.Append(new FontSize() { Val = 14D });
|
||||||
|
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
|
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||||
|
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
|
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
|
fonts.Append(fontUsual);
|
||||||
|
fonts.Append(fontTitle);
|
||||||
|
|
||||||
|
var fills = new Fills() { Count = 2U };
|
||||||
|
|
||||||
|
var fill1 = new Fill();
|
||||||
|
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||||
|
|
||||||
|
var fill2 = new Fill();
|
||||||
|
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||||
|
|
||||||
|
fills.Append(fill1);
|
||||||
|
fills.Append(fill2);
|
||||||
|
|
||||||
|
var borders = new Borders() { Count = 2U };
|
||||||
|
|
||||||
|
var borderNoBorder = new Border();
|
||||||
|
borderNoBorder.Append(new LeftBorder());
|
||||||
|
borderNoBorder.Append(new RightBorder());
|
||||||
|
borderNoBorder.Append(new TopBorder());
|
||||||
|
borderNoBorder.Append(new BottomBorder());
|
||||||
|
borderNoBorder.Append(new DiagonalBorder());
|
||||||
|
|
||||||
|
var borderThin = new Border();
|
||||||
|
|
||||||
|
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
borderThin.Append(leftBorder);
|
||||||
|
borderThin.Append(rightBorder);
|
||||||
|
borderThin.Append(topBorder);
|
||||||
|
borderThin.Append(bottomBorder);
|
||||||
|
borderThin.Append(new DiagonalBorder());
|
||||||
|
|
||||||
|
borders.Append(borderNoBorder);
|
||||||
|
borders.Append(borderThin);
|
||||||
|
|
||||||
|
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||||
|
var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
||||||
|
|
||||||
|
cellStyleFormats.Append(cellFormatStyle);
|
||||||
|
|
||||||
|
var cellFormats = new CellFormats() { Count = 3U };
|
||||||
|
var cellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true };
|
||||||
|
var cellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true };
|
||||||
|
var cellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true };
|
||||||
|
|
||||||
|
cellFormats.Append(cellFormatFont);
|
||||||
|
cellFormats.Append(cellFormatFontAndBorder);
|
||||||
|
cellFormats.Append(cellFormatTitle);
|
||||||
|
|
||||||
|
var cellStyles = new CellStyles() { Count = 1U };
|
||||||
|
|
||||||
|
cellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U });
|
||||||
|
|
||||||
|
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U };
|
||||||
|
|
||||||
|
var tableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };
|
||||||
|
|
||||||
|
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||||
|
|
||||||
|
var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
||||||
|
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||||
|
stylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" });
|
||||||
|
|
||||||
|
var stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
|
||||||
|
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||||
|
stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" });
|
||||||
|
|
||||||
|
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||||
|
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||||
|
|
||||||
|
sp.Stylesheet.Append(fonts);
|
||||||
|
sp.Stylesheet.Append(fills);
|
||||||
|
sp.Stylesheet.Append(borders);
|
||||||
|
sp.Stylesheet.Append(cellStyleFormats);
|
||||||
|
sp.Stylesheet.Append(cellFormats);
|
||||||
|
sp.Stylesheet.Append(cellStyles);
|
||||||
|
sp.Stylesheet.Append(differentialFormats);
|
||||||
|
sp.Stylesheet.Append(tableStyles);
|
||||||
|
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение номера стиля из типа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="styleInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||||
|
{
|
||||||
|
return styleInfo switch
|
||||||
|
{
|
||||||
|
ExcelStyleInfoType.Title => 2U,
|
||||||
|
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||||
|
ExcelStyleInfoType.Text => 0U,
|
||||||
|
_ => 0U,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateExcel(ExcelInfo info)
|
||||||
|
{
|
||||||
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
|
// Создаем книгу (в ней хранятся листы)
|
||||||
|
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
|
||||||
|
CreateStyles(workbookpart);
|
||||||
|
|
||||||
|
// Получаем/создаем хранилище текстов для книги
|
||||||
|
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||||
|
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||||
|
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||||
|
|
||||||
|
// Создаем SharedStringTable, если его нет
|
||||||
|
if (_shareStringPart.SharedStringTable == null)
|
||||||
|
{
|
||||||
|
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создаем лист в книгу
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||||
|
|
||||||
|
// Добавляем лист в книгу
|
||||||
|
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист"
|
||||||
|
};
|
||||||
|
sheets.Append(sheet);
|
||||||
|
|
||||||
|
_worksheet = worksheetPart.Worksheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||||
|
{
|
||||||
|
if (_worksheet == null || _shareStringPart == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||||
|
if (sheetData == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ищем строку, либо добавляем ее
|
||||||
|
Row row;
|
||||||
|
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||||
|
{
|
||||||
|
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||||
|
sheetData.Append(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ищем нужную ячейку
|
||||||
|
Cell cell;
|
||||||
|
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||||
|
{
|
||||||
|
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Все ячейки должны быть последовательно друг за другом расположены
|
||||||
|
// нужно определить, после какой вставлять
|
||||||
|
Cell? refCell = null;
|
||||||
|
foreach (Cell rowCell in row.Elements<Cell>())
|
||||||
|
{
|
||||||
|
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||||
|
{
|
||||||
|
refCell = rowCell;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCell = new Cell() { CellReference = excelParams.CellReference };
|
||||||
|
row.InsertBefore(newCell, refCell);
|
||||||
|
|
||||||
|
cell = newCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
// вставляем новый текст
|
||||||
|
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||||
|
_shareStringPart.SharedStringTable.Save();
|
||||||
|
|
||||||
|
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||||
|
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||||
|
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||||
|
{
|
||||||
|
if (_worksheet == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MergeCells mergeCells;
|
||||||
|
|
||||||
|
if (_worksheet.Elements<MergeCells>().Any())
|
||||||
|
{
|
||||||
|
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mergeCells = new MergeCells();
|
||||||
|
|
||||||
|
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||||
|
{
|
||||||
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mergeCell = new MergeCell()
|
||||||
|
{
|
||||||
|
Reference = new StringValue(excelParams.Merge)
|
||||||
|
};
|
||||||
|
mergeCells.Append(mergeCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SaveExcel(ExcelInfo info)
|
||||||
|
{
|
||||||
|
if (_spreadsheetDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||||
|
_spreadsheetDocument.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
114
ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
114
ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToPdf : AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
private Document? _document;
|
||||||
|
|
||||||
|
private Section? _section;
|
||||||
|
|
||||||
|
private Table? _table;
|
||||||
|
|
||||||
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||||
|
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||||
|
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||||
|
_ => ParagraphAlignment.Justify,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание стилей для документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="document"></param>
|
||||||
|
private static void DefineStyles(Document document)
|
||||||
|
{
|
||||||
|
var style = document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
|
||||||
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreatePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles(_document);
|
||||||
|
|
||||||
|
_section = _document.AddSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
|
{
|
||||||
|
if (_section == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||||
|
paragraph.Format.SpaceAfter = "1cm";
|
||||||
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
|
paragraph.Style = pdfParagraph.Style;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_table = _document.LastSection.AddTable();
|
||||||
|
|
||||||
|
foreach (var elem in columns)
|
||||||
|
{
|
||||||
|
_table.AddColumn(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_table == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var row = _table.AddRow();
|
||||||
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
|
{
|
||||||
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
|
{
|
||||||
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
|
}
|
||||||
|
|
||||||
|
Unit borderWidth = 0.5;
|
||||||
|
|
||||||
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
|
||||||
|
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SavePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToWord : AbstractSaveToWord
|
||||||
|
{
|
||||||
|
private WordprocessingDocument? _wordDocument;
|
||||||
|
|
||||||
|
private Body? _docBody;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение типа выравнивания
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
WordJustificationType.Both => JustificationValues.Both,
|
||||||
|
WordJustificationType.Center => JustificationValues.Center,
|
||||||
|
_ => JustificationValues.Left,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Настройки страницы
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static SectionProperties CreateSectionProperties()
|
||||||
|
{
|
||||||
|
var properties = new SectionProperties();
|
||||||
|
|
||||||
|
var pageSize = new PageSize
|
||||||
|
{
|
||||||
|
Orient = PageOrientationValues.Portrait
|
||||||
|
};
|
||||||
|
|
||||||
|
properties.AppendChild(pageSize);
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Задание форматирования для абзаца
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paragraphProperties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||||
|
{
|
||||||
|
if (paragraphProperties == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var properties = new ParagraphProperties();
|
||||||
|
|
||||||
|
properties.AppendChild(new Justification()
|
||||||
|
{
|
||||||
|
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||||
|
});
|
||||||
|
|
||||||
|
properties.AppendChild(new SpacingBetweenLines
|
||||||
|
{
|
||||||
|
LineRule = LineSpacingRuleValues.Auto
|
||||||
|
});
|
||||||
|
|
||||||
|
properties.AppendChild(new Indentation());
|
||||||
|
|
||||||
|
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||||
|
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||||
|
{
|
||||||
|
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||||
|
}
|
||||||
|
properties.AppendChild(paragraphMarkRunProperties);
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateWord(WordInfo info)
|
||||||
|
{
|
||||||
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
_docBody = mainPart.Document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateParagraph(WordParagraph paragraph)
|
||||||
|
{
|
||||||
|
if (_docBody == null || paragraph == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
_docBody.AppendChild(docParagraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SaveWord(WordInfo info)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _wordDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_docBody.AppendChild(CreateSectionProperties());
|
||||||
|
|
||||||
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
|
|
||||||
|
_wordDocument.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryBusinessLogic.MailWorker;
|
||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
using ConfectioneryContracts.SearchModels;
|
using ConfectioneryContracts.SearchModels;
|
||||||
using ConfectioneryContracts.StoragesContract;
|
using ConfectioneryContracts.StoragesContract;
|
||||||
@@ -12,15 +13,15 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly IPastryStorage _pastryStorage;
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
private readonly IShopLogic _shopLogic;
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IPastryStorage pastryStorage, IShopLogic shopLogic)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_shopLogic = shopLogic;
|
|
||||||
_pastryStorage = pastryStorage;
|
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_mailWorker = mailWorker;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
@@ -33,11 +34,13 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
model.DateCreate = DateTime.Now;
|
model.DateCreate = DateTime.Now;
|
||||||
if (_orderStorage.Insert(model) == null)
|
var result = _orderStorage.Insert(model);
|
||||||
|
if (result == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SendOrderStatusMail(result.ClientId, $"Новый заказ создан. Номер заказа #{result.Id}", $"Заказ #{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,34 +97,61 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
if ((int)vmodel.Status + 1 != (int)orderStatus)
|
if ((int)vmodel.Status + 1 != (int)orderStatus)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " +
|
throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " +
|
||||||
$"Текущий статус: {vmodel.Status} \n" +
|
$"Текущий статус: {vmodel.Status} \n" +
|
||||||
$"Планируемый статус: {orderStatus} \n" +
|
$"Планируемый статус: {orderStatus} \n" +
|
||||||
$"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}",
|
$"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}");
|
||||||
nameof(vmodel));
|
|
||||||
}
|
|
||||||
if (orderStatus == OrderStatus.Готов)
|
|
||||||
{
|
|
||||||
var vpastry = _pastryStorage.GetElement(new() { Id = vmodel.PastryId });
|
|
||||||
|
|
||||||
if (vpastry == null || !_shopLogic.AddPastriesInShops(vpastry, vmodel.Count))
|
|
||||||
{
|
|
||||||
throw new Exception($"Не удалось заполнить магазины изделием '{vpastry?.PastryName ?? string.Empty}' из заказа {vmodel.Id}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
model.Status = orderStatus;
|
model.Status = orderStatus;
|
||||||
model.DateCreate = vmodel.DateCreate;
|
model.DateCreate = vmodel.DateCreate;
|
||||||
if (model.DateImplement == null)
|
if (model.DateImplement == null)
|
||||||
model.DateImplement = vmodel.DateImplement;
|
model.DateImplement = vmodel.DateImplement;
|
||||||
|
if (vmodel.ImplementerId.HasValue)
|
||||||
|
model.ImplementerId = vmodel.ImplementerId;
|
||||||
model.PastryId = vmodel.PastryId;
|
model.PastryId = vmodel.PastryId;
|
||||||
model.Sum = vmodel.Sum;
|
model.Sum = vmodel.Sum;
|
||||||
model.Count= vmodel.Count;
|
model.Count= vmodel.Count;
|
||||||
if (_orderStorage.Update(model) == null)
|
var result = _orderStorage.Update(model);
|
||||||
|
if (result == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SendOrderStatusMail(result.ClientId, $"Изменен статус заказа #{result.Id}", $"Заказ #{model.Id} изменен статус на {result.Status}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||||
|
var element = _orderStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SendOrderStatusMail(int clientId, string subject, string text)
|
||||||
|
{
|
||||||
|
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_mailWorker.MailSendAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = client.Email,
|
||||||
|
Subject = subject,
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
140
ConfectionaryBusinessLogic/ReportLogic.cs
Normal file
140
ConfectionaryBusinessLogic/ReportLogic.cs
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using ConfectioneryBusinessLogic.OfficePackage;
|
||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class ReportLogic : IReportLogic
|
||||||
|
{
|
||||||
|
private readonly IComponentStorage _componentStorage;
|
||||||
|
|
||||||
|
private readonly IPastryStorage _pastryStorage;
|
||||||
|
|
||||||
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
|
||||||
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
|
|
||||||
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
|
||||||
|
public ReportLogic(IPastryStorage PastryStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||||
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
|
{
|
||||||
|
_pastryStorage = PastryStorage;
|
||||||
|
_componentStorage = componentStorage;
|
||||||
|
_orderStorage = orderStorage;
|
||||||
|
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ReportPastryComponentViewModel> GetPastryComponent()
|
||||||
|
{
|
||||||
|
var components = _componentStorage.GetFullList();
|
||||||
|
|
||||||
|
var pastries = _pastryStorage.GetFullList();
|
||||||
|
|
||||||
|
var list = new List<ReportPastryComponentViewModel>();
|
||||||
|
|
||||||
|
foreach (var pastry in pastries)
|
||||||
|
{
|
||||||
|
var record = new ReportPastryComponentViewModel
|
||||||
|
{
|
||||||
|
PastryName = pastry.PastryName,
|
||||||
|
Components = new List<Tuple<string, int>>(),
|
||||||
|
TotalCount = 0
|
||||||
|
};
|
||||||
|
foreach (var component in components)
|
||||||
|
{
|
||||||
|
if (pastry.PastryComponents.ContainsKey(component.Id))
|
||||||
|
{
|
||||||
|
record.Components.Add(new(component.ComponentName, pastry.PastryComponents[component.Id].Item2));
|
||||||
|
record.TotalCount += pastry.PastryComponents[component.Id].Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка заказов за определенный период
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
|
||||||
|
.Select(x => new ReportOrdersViewModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
DateCreate = x.DateCreate,
|
||||||
|
PastryName = x.PastryName,
|
||||||
|
OrderStatus = Convert.ToString(x.Status) ?? string.Empty,
|
||||||
|
Sum = x.Sum
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение изделий в файл-Word
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
public void SavePastriesToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateDoc(new WordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список изделий",
|
||||||
|
Pastries = _pastryStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение изделий с указаеним продуктов в файл-Excel
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
public void SavePastryComponentToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateReport(new ExcelInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список изделий",
|
||||||
|
PastryComponents = GetPastryComponent()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение заказов в файл-Pdf
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateDoc(new PdfInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов",
|
||||||
|
DateFrom = model.DateFrom!.Value,
|
||||||
|
DateTo = model.DateTo!.Value,
|
||||||
|
Orders = GetOrders(model)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
using ConfectioneryBusinessLogic.BusinessLogics;
|
|
||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
||||||
using ConfectioneryContracts.SearchModels;
|
|
||||||
using ConfectioneryContracts.StoragesContract;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic
|
|
||||||
{
|
|
||||||
public class ShopLogic : IShopLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IShopStorage _shopStorage;
|
|
||||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_shopStorage = shopStorage;
|
|
||||||
}
|
|
||||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id} ",
|
|
||||||
model?.Name, model?.Id);
|
|
||||||
var list = (model == null) ? _shopStorage.GetFullList() :
|
|
||||||
_shopStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}",
|
|
||||||
model.Name, model.Id);
|
|
||||||
var element = _shopStorage.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(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
model.Pastries = new();
|
|
||||||
if (_shopStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия магазина",
|
|
||||||
nameof(model.Name));
|
|
||||||
}
|
|
||||||
if (_shopStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_shopStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия магазина",
|
|
||||||
nameof(model.Name));
|
|
||||||
}
|
|
||||||
if (model.MaxCountPastries < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException(
|
|
||||||
"Максимальное количество изделий в магазине не должно быть отрицательным",
|
|
||||||
nameof(model.MaxCountPastries));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}",
|
|
||||||
model.Name, model.Address, model.Id);
|
|
||||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
|
||||||
{
|
|
||||||
Name = model.Name
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id && element.Name == model.Name)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddPastry(ShopSearchModel model, IPastryModel pastry, int count)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("AddPastryInShop. ShopName:{ShopName}.Id:{ Id}",
|
|
||||||
model.Name, model.Id);
|
|
||||||
var element = _shopStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("AddPastryInShop element not found");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("AddPastryInShop find. Id:{Id}", element.Id);
|
|
||||||
|
|
||||||
|
|
||||||
var prevCount = element.Pastries.GetValueOrDefault(pastry.Id, (pastry, 0)).Item2;
|
|
||||||
element.Pastries[pastry.Id] = (pastry, prevCount + count);
|
|
||||||
_logger.LogInformation(
|
|
||||||
"AddPastryInShop. Has been added {count} {pastry} in {ShopName}",
|
|
||||||
count, pastry.PastryName, element.Name);
|
|
||||||
|
|
||||||
_shopStorage.Update(new()
|
|
||||||
{
|
|
||||||
Id = element.Id,
|
|
||||||
Address = element.Address,
|
|
||||||
Name = element.Name,
|
|
||||||
DateOpening = element.DateOpening,
|
|
||||||
Pastries = element.Pastries
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int GetFreePlacesWithPastriesInShops(int countPastries)
|
|
||||||
{
|
|
||||||
// Сумма разностей между максимальный кол-вом изделий и суммой всех изделий в магазине
|
|
||||||
return _shopStorage.GetFullList()
|
|
||||||
.Select(x => x.MaxCountPastries - x.Pastries
|
|
||||||
.Select(p => p.Value.Item2).Sum())
|
|
||||||
.Sum() - countPastries;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddPastriesInShops(IPastryModel pastry, int count)
|
|
||||||
{
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("AddPastriesInShops. Количество добавляемых изделий должно быть больше 0. Количество - {count}", count);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var freePlaces = GetFreePlacesWithPastriesInShops(count);
|
|
||||||
if (freePlaces < 0)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("AddPastriesInShops. Не удалось добавить изделия в магазины, поскольку они переполнены." +
|
|
||||||
"Освободите магазины на {places} изделий", -freePlaces);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach (var shop in _shopStorage.GetFullList())
|
|
||||||
{
|
|
||||||
var cnt = Math.Min(count, shop.MaxCountPastries - shop.Pastries.Select(x => x.Value.Item2).Sum());
|
|
||||||
if (cnt <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!AddPastry(new() { Id = shop.Id }, pastry, cnt))
|
|
||||||
{
|
|
||||||
_logger.LogWarning("При добавления изделий во все магазины произошла ошибка");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
count -= cnt;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SellPastries(IPastryModel pastry, int needCount)
|
|
||||||
{
|
|
||||||
return _shopStorage.SellPastries(pastry, needCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
148
ConfectionaryBusinessLogic/WorkModeling.cs
Normal file
148
ConfectionaryBusinessLogic/WorkModeling.cs
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels.Enums;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class WorkModeling : IWorkProcess
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly Random _rnd;
|
||||||
|
|
||||||
|
private IOrderLogic? _orderLogic;
|
||||||
|
|
||||||
|
public WorkModeling(ILogger<WorkModeling> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_rnd = new Random(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
||||||
|
{
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
var implementers = implementerLogic.ReadList(null);
|
||||||
|
if (implementers == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Поскольку у нас могут быть заказы в работе мы не дожны заканчивать работы, если нет Принятых заказов
|
||||||
|
// Поэтому находим заказы в работе и продолжаем работу, если они есть
|
||||||
|
var orders = _orderLogic.ReadList(new OrderSearchModel { Statusses = new() { OrderStatus.Принят, OrderStatus.Выполняется } });
|
||||||
|
if (orders == null || orders.Count == 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
|
foreach (var implementer in implementers)
|
||||||
|
{
|
||||||
|
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Иммитация работы исполнителя
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="implementer"></param>
|
||||||
|
/// <param name="orders"></param>
|
||||||
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await RunOrderInWork(implementer, orders);
|
||||||
|
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
|
||||||
|
// пытаемся назначить заказ на исполнителя
|
||||||
|
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id,
|
||||||
|
ImplementerId = implementer.Id
|
||||||
|
});
|
||||||
|
// делаем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id
|
||||||
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// заканчиваем выполнение имитации в случае иной ошибки
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="implementer"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Выбираем из всех заказов тот, который выполняется данным исполнителем
|
||||||
|
var runOrder = await Task.Run(() => allOrders.FirstOrDefault(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Выполняется));
|
||||||
|
if (runOrder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
// доделываем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = runOrder.Id
|
||||||
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
ConfectionaryFileImplement/BackUpInfo.cs
Normal file
34
ConfectionaryFileImplement/BackUpInfo.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
// Получаем значения из singleton-объекта универсального свойства содержащее тип T
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)source.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
ConfectionaryFileImplement/Client.cs
Normal file
82
ConfectionaryFileImplement/Client.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Client? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ClientFIO = element.Element("FIO")!.Value,
|
||||||
|
Email = element.Element("Email")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Client",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("FIO", ClientFIO),
|
||||||
|
new XElement("Email", Email),
|
||||||
|
new XElement("Password", Password)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
90
ConfectionaryFileImplement/ClientStorage.cs
Normal file
90
ConfectionaryFileImplement/ClientStorage.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Clients.Remove(res);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
return _source.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
if (model.Email != null && model.Password != null)
|
||||||
|
return _source.Clients
|
||||||
|
.FirstOrDefault(x => x.Email.Equals(model.Email)
|
||||||
|
&& x.Password.Equals(model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
if (model.Email != null)
|
||||||
|
return _source.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
if (model.Email != null)
|
||||||
|
{
|
||||||
|
return _source.Clients
|
||||||
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.Clients.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.Id) + 1 : 1;
|
||||||
|
var res = Client.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Clients.Add(res);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Update(model);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,60 +1,65 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
using ConfectioneryDataModels.Models;
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
|
||||||
namespace ConfectioneryFileImplement.Models
|
namespace ConfectioneryFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Component : IComponentModel
|
[DataContract]
|
||||||
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Component()
|
return new Component()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ComponentName = model.ComponentName,
|
ComponentName = model.ComponentName,
|
||||||
Cost = model.Cost
|
Cost = model.Cost
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Component? Create(XElement element)
|
public static Component? Create(XElement element)
|
||||||
{
|
{
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Component()
|
return new Component()
|
||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
ComponentName = element.Element("ComponentName")!.Value,
|
ComponentName = element.Element("ComponentName")!.Value,
|
||||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ComponentBindingModel model)
|
public void Update(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ComponentName = model.ComponentName;
|
ComponentName = model.ComponentName;
|
||||||
Cost = model.Cost;
|
Cost = model.Cost;
|
||||||
}
|
}
|
||||||
public ComponentViewModel GetViewModel => new()
|
public ComponentViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
ComponentName = ComponentName,
|
ComponentName = ComponentName,
|
||||||
Cost = Cost
|
Cost = Cost
|
||||||
};
|
};
|
||||||
public XElement GetXElement => new("Component",
|
public XElement GetXElement => new("Component",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("ComponentName", ComponentName),
|
new XElement("ComponentName", ComponentName),
|
||||||
new XElement("Cost", Cost.ToString()));
|
new XElement("Cost", Cost.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\ConfectioneryDataModels\ConfectioneryDataModels.csproj" />
|
<ProjectReference Include="..\ConfectioneryDataModels\ConfectioneryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ namespace ConfectioneryFileImplement
|
|||||||
private readonly string ComponentFileName = "Component.xml";
|
private readonly string ComponentFileName = "Component.xml";
|
||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string PastryFileName = "Pastry.xml";
|
private readonly string PastryFileName = "Pastry.xml";
|
||||||
private readonly string ShopFileName = "Shop.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
|
private readonly string MessageInfoFileName = "MessageInfo.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Pastry> Pastries { get; private set; }
|
public List<Pastry> Pastries { get; private set; }
|
||||||
public List<Shop> Shops { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
public List<MessageInfo> Messages { get; private set; }
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
@@ -26,14 +30,18 @@ namespace ConfectioneryFileImplement
|
|||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
public void SavePastries() => SaveData(Pastries, PastryFileName, "Pastries", x => x.GetXElement);
|
public void SavePastries() => SaveData(Pastries, PastryFileName, "Pastries", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
|
||||||
|
public void SaveImplementers() => SaveData(Orders, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||||
|
public void SaveMessages() => SaveData(Orders, ImplementerFileName, "Messages", x => x.GetXElement);
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Pastries = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!;
|
Pastries = LoadData(PastryFileName, "Pastry", x => Pastry.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||||
|
Messages = LoadData(MessageInfoFileName, "MessageInfo", x => MessageInfo.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
|||||||
23
ConfectionaryFileImplement/FileImplementationExtension.cs
Normal file
23
ConfectionaryFileImplement/FileImplementationExtension.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using ConfectioneryContracts.DI;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryFileImplement.Implements;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPastryStorage, PastryStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
95
ConfectionaryFileImplement/Implementer.cs
Normal file
95
ConfectionaryFileImplement/Implementer.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
ImplementerFIO = element.Element("FIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Client",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("Password", Password),
|
||||||
|
new XElement("FIO", ImplementerFIO),
|
||||||
|
new XElement("Qualification", Qualification),
|
||||||
|
new XElement("WorkExperience", WorkExperience)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
90
ConfectionaryFileImplement/ImplementerStorage.cs
Normal file
90
ConfectionaryFileImplement/ImplementerStorage.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Implementers.Remove(res);
|
||||||
|
_source.SaveImplementers();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null && model.Password != null)
|
||||||
|
return _source.Implementers
|
||||||
|
.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO)
|
||||||
|
&& x.Password.Equals(model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null)
|
||||||
|
return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
if (model.ImplementerFIO != null) // На случай если фио не будет уникальным (по заданию оно уникально)
|
||||||
|
{
|
||||||
|
return _source.Implementers
|
||||||
|
.Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.Implementers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1;
|
||||||
|
var res = Implementer.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Implementers.Add(res);
|
||||||
|
_source.SaveImplementers();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Update(model);
|
||||||
|
_source.SaveImplementers();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
92
ConfectionaryFileImplement/MessageInfo.cs
Normal file
92
ConfectionaryFileImplement/MessageInfo.cs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement.Models
|
||||||
|
{
|
||||||
|
// Update в этой сущности не нужен, поскольку в логике мы не изменяем никакие поля после создания письма
|
||||||
|
[DataContract]
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = model.Body,
|
||||||
|
Subject = model.Subject,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageInfo? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = element.Attribute("Body")!.Value,
|
||||||
|
Subject = element.Attribute("Subject")!.Value,
|
||||||
|
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||||
|
MessageId = element.Attribute("MessageId")!.Value,
|
||||||
|
SenderName = element.Attribute("SenderName")!.Value,
|
||||||
|
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Body = Body,
|
||||||
|
Subject = Subject,
|
||||||
|
ClientId = ClientId,
|
||||||
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("MessageInfo",
|
||||||
|
new XAttribute("Body", Body),
|
||||||
|
new XAttribute("Subject", Subject),
|
||||||
|
new XAttribute("ClientId", ClientId),
|
||||||
|
new XAttribute("MessageId", MessageId),
|
||||||
|
new XAttribute("SenderName", SenderName),
|
||||||
|
new XAttribute("DateDelivery", DateDelivery)
|
||||||
|
);
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
ConfectionaryFileImplement/MessageInfoStorage.cs
Normal file
54
ConfectionaryFileImplement/MessageInfoStorage.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryFileImplement.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace ConfectioneryFileImplement
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.MessageId != null)
|
||||||
|
{
|
||||||
|
return _source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
return _source.Messages
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.Messages
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
_source.SaveMessages();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,24 +2,39 @@
|
|||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
using ConfectioneryDataModels.Enums;
|
using ConfectioneryDataModels.Enums;
|
||||||
using ConfectioneryDataModels.Models;
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace ConfectioneryFileImplement.Models
|
namespace ConfectioneryFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int PastryId { get; private set; }
|
public int PastryId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
@@ -31,12 +46,14 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
Id = model.Id,
|
ImplementerId = model.ImplementerId,
|
||||||
|
Id = model.Id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Order? Create(XElement element)
|
public static Order? Create(XElement element)
|
||||||
@@ -53,7 +70,9 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value),
|
Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value),
|
||||||
PastryId = Convert.ToInt32(element.Element("PastryId")!.Value),
|
PastryId = Convert.ToInt32(element.Element("PastryId")!.Value),
|
||||||
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
DateImplement = string.IsNullOrEmpty(dateImplement) ? null : Convert.ToDateTime(dateImplement),
|
DateImplement = string.IsNullOrEmpty(dateImplement) ? null : Convert.ToDateTime(dateImplement),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -69,28 +88,35 @@ namespace ConfectioneryFileImplement.Models
|
|||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
Id = model.Id;
|
Id = model.Id;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
|
ImplementerFIO = DataFileSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
|
||||||
PastryName = DataFileSingleton.GetInstance().Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
|
PastryName = DataFileSingleton.GetInstance().Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
|
||||||
PastryId = PastryId,
|
ClientFIO = DataFileSingleton.GetInstance().Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||||
|
PastryId = PastryId,
|
||||||
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Id = Id,
|
Id = Id,
|
||||||
};
|
};
|
||||||
public XElement GetXElement => new("Order",
|
public XElement GetXElement => new("Order",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("PastryId", PastryId),
|
new XElement("PastryId", PastryId),
|
||||||
|
new XElement("ClientId", ClientId),
|
||||||
new XElement("Count", Count),
|
new XElement("Count", Count),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", (int)Status),
|
new XElement("Status", (int)Status),
|
||||||
new XElement("DateCreate", DateCreate),
|
new XElement("DateCreate", DateCreate),
|
||||||
new XElement("DateImplement", DateImplement)
|
new XElement("DateImplement", DateImplement),
|
||||||
|
new XElement("ImplementerId", ImplementerId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,16 +28,48 @@ namespace ConfectioneryFileImplement
|
|||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (model.ImplementerId.HasValue && model.Statusses != null)
|
||||||
{
|
{
|
||||||
return null;
|
return _source.Orders
|
||||||
}
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId &&
|
||||||
return _source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
model.Statusses.Contains(x.Status))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return _source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||||
|
}
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = GetElement(model);
|
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат
|
||||||
|
{
|
||||||
|
return _source.Orders
|
||||||
|
.Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
if (!model.Id.HasValue && model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return _source.Orders
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
if (!model.Id.HasValue && model.Statusses != null)
|
||||||
|
{
|
||||||
|
return _source.Orders
|
||||||
|
.Where(x => model.Statusses.Contains(x.Status))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
var result = GetElement(model);
|
||||||
return result != null ? new() { result } : new();
|
return result != null ? new() { result } : new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
using ConfectioneryDataModels.Models;
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace ConfectioneryFileImplement.Models
|
namespace ConfectioneryFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Pastry : IPastryModel
|
public class Pastry : IPastryModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string PastryName { get; private set; } = string.Empty;
|
public string PastryName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
public Dictionary<int, int> Components { get; private set; } = new();
|
||||||
private Dictionary<int, (IComponentModel, int)>? _PastryComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _PastryComponents = null;
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace ConfectioneryFileImplement
|
|
||||||
{
|
|
||||||
public class Shop : IShopModel
|
|
||||||
{
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public int MaxCountPastries { get; private set; }
|
|
||||||
|
|
||||||
public DateTime DateOpening { get; private set; }
|
|
||||||
|
|
||||||
public Dictionary<int, int> CountPastries { get; private set; } = new();
|
|
||||||
|
|
||||||
private Dictionary<int, (IPastryModel, int)>? _cachedPastries = null;
|
|
||||||
public Dictionary<int, (IPastryModel, int)> Pastries
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_cachedPastries == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_cachedPastries = CountPastries
|
|
||||||
.ToDictionary(x => x.Key, x => (source.Pastries
|
|
||||||
.FirstOrDefault(y => y.Id == x.Key)! as IPastryModel, x.Value));
|
|
||||||
}
|
|
||||||
return _cachedPastries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public static Shop? Create(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Shop()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
Name = model.Name,
|
|
||||||
Address = model.Address,
|
|
||||||
DateOpening = model.DateOpening,
|
|
||||||
MaxCountPastries = model.MaxCountPastries,
|
|
||||||
CountPastries = new()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Shop? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
Name = element.Element("Name")!.Value,
|
|
||||||
Address = element.Element("Address")!.Value,
|
|
||||||
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
|
|
||||||
MaxCountPastries = Convert.ToInt32(element.Element("MaxCountPastries")!.Value),
|
|
||||||
CountPastries = element.Element("CountPastries")!.Elements("CountPastry")
|
|
||||||
.ToDictionary(
|
|
||||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
|
||||||
x => Convert.ToInt32(x.Element("Value")?.Value)
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Name = model.Name;
|
|
||||||
Address = model.Address;
|
|
||||||
DateOpening = model.DateOpening;
|
|
||||||
CountPastries = model.Pastries.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_cachedPastries = null;
|
|
||||||
}
|
|
||||||
public ShopViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
Name = Name,
|
|
||||||
Address = Address,
|
|
||||||
Pastries = Pastries,
|
|
||||||
DateOpening = DateOpening,
|
|
||||||
MaxCountPastries = MaxCountPastries,
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Shop",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("Name", Name),
|
|
||||||
new XElement("Address", Address),
|
|
||||||
new XElement("DateOpening", DateOpening),
|
|
||||||
new XElement("MaxCountPastries", MaxCountPastries),
|
|
||||||
new XElement("CountPastries", CountPastries
|
|
||||||
.Select(x => new XElement("CountPastry",
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
new XElement("Value", x.Value))
|
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.SearchModels;
|
|
||||||
using ConfectioneryContracts.StoragesContract;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
|
|
||||||
namespace ConfectioneryFileImplement
|
|
||||||
{
|
|
||||||
public class ShopStorage : IShopStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton _source;
|
|
||||||
public ShopStorage()
|
|
||||||
{
|
|
||||||
_source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
var element = _source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
_source.Shops.Remove(element);
|
|
||||||
_source.SaveShops();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _source.Shops.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return _source.Shops
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.Where(x => x.Name.Contains(model.Name ?? string.Empty))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return _source.Shops
|
|
||||||
.Select(shop => shop.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Insert(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = _source.Shops.Count > 0 ? _source.Shops.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newShop = Shop.Create(model);
|
|
||||||
if (newShop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Shops.Add(newShop);
|
|
||||||
_source.SaveShops();
|
|
||||||
return newShop.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
var shop = _source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (shop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
shop.Update(model);
|
|
||||||
_source.SaveShops();
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasNeedPastries(IPastryModel pastry, int needCount)
|
|
||||||
{
|
|
||||||
var resultCount = _source.Shops
|
|
||||||
.Select(shop => shop.Pastries
|
|
||||||
.FirstOrDefault(x => x.Key == pastry.Id).Value.Item2)
|
|
||||||
.Sum();
|
|
||||||
return resultCount >= needCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SellPastries(IPastryModel pastry, int needCount)
|
|
||||||
{
|
|
||||||
if (!HasNeedPastries(pastry, needCount))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach (var shop in _source.Shops.Where(shop => shop.Pastries.ContainsKey(pastry.Id)))
|
|
||||||
{
|
|
||||||
var tuple = shop.Pastries[pastry.Id];
|
|
||||||
var diff = Math.Min(tuple.Item2, needCount);
|
|
||||||
shop.Pastries[pastry.Id] = (tuple.Item1, tuple.Item2 - diff);
|
|
||||||
|
|
||||||
needCount -= diff;
|
|
||||||
if (needCount <= 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
ConfectionaryListImplement/BackUpInfo.cs
Normal file
22
ConfectionaryListImplement/BackUpInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
ConfectionaryListImplement/Client.cs
Normal file
56
ConfectionaryListImplement/Client.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
98
ConfectionaryListImplement/ClientStorage.cs
Normal file
98
ConfectionaryListImplement/ClientStorage.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Clients.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Clients[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Clients[i];
|
||||||
|
_source.Clients.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue && model.Id == client.Id)
|
||||||
|
return client.GetViewModel;
|
||||||
|
if (model.Email != null && model.Password != null &&
|
||||||
|
client.Email.Equals(model.Email) && client.Password.Equals(model.Password))
|
||||||
|
return client.GetViewModel;
|
||||||
|
if (model.Email != null && client.Email.Equals(model.Email))
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
// У нас нет каких либо специфических условий для выборки списка клиентов,
|
||||||
|
// поэтому получаем лишь один элемент по модели
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ClientViewModel>();
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
result.Add(client.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (model.Id <= client.Id)
|
||||||
|
{
|
||||||
|
model.Id = client.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var res = Client.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Clients.Add(res);
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == model.Id)
|
||||||
|
{
|
||||||
|
client.Update(model);
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\ConfectioneryDataModels\ConfectioneryDataModels.csproj" />
|
<ProjectReference Include="..\ConfectioneryDataModels\ConfectioneryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -8,13 +8,18 @@ namespace ConfectioneryListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Pastry> Pastry { get; set; }
|
public List<Pastry> Pastry { get; set; }
|
||||||
public List<Shop> Shops { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
public List<MessageInfo> Messages { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Pastry = new List<Pastry>();
|
Pastry = new List<Pastry>();
|
||||||
Shops = new List<Shop>();
|
Clients = new List<Client>();
|
||||||
|
Implementers = new List<Implementer>();
|
||||||
|
Messages = new List<MessageInfo>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
|||||||
55
ConfectionaryListImplement/Implementer.cs
Normal file
55
ConfectionaryListImplement/Implementer.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Password = model.Password,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
114
ConfectionaryListImplement/ImplementerStorage.cs
Normal file
114
ConfectionaryListImplement/ImplementerStorage.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Implementers[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Implementers[i];
|
||||||
|
_source.Implementers.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var x in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue && x.Id == model.Id)
|
||||||
|
return x.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null && model.Password != null &&
|
||||||
|
x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))
|
||||||
|
return x.GetViewModel;
|
||||||
|
if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||||
|
return x.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
// На случай если при расширении проекта фио не будет уникальным
|
||||||
|
// (по заданию оно уникально)
|
||||||
|
List<ImplementerViewModel> result = new();
|
||||||
|
if (model.ImplementerFIO != null)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (model.Id <= implementer.Id)
|
||||||
|
{
|
||||||
|
model.Id = implementer.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var res = Implementer.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Implementers.Add(res);
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.Id == model.Id)
|
||||||
|
{
|
||||||
|
implementer.Update(model);
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
ConfectionaryListImplement/ListImplementationExtension.cs
Normal file
28
ConfectionaryListImplement/ListImplementationExtension.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using ConfectioneryContracts.DI;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPastryStorage, PastryStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
57
ConfectionaryListImplement/MessageInfo.cs
Normal file
57
ConfectionaryListImplement/MessageInfo.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement.Models
|
||||||
|
{
|
||||||
|
// Update в этой сущности не нужен, поскольку в логике мы не изменяем никакие поля после создания письма
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = model.Body,
|
||||||
|
Subject = model.Subject,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Body = Body,
|
||||||
|
Subject = Subject,
|
||||||
|
ClientId = ClientId,
|
||||||
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
};
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
61
ConfectionaryListImplement/MessageInfoStorage.cs
Normal file
61
ConfectionaryListImplement/MessageInfoStorage.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContract;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryListImplement.Models;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var message in _source.Messages)
|
||||||
|
{
|
||||||
|
if (model.MessageId != null && model.MessageId.Equals(message.MessageId))
|
||||||
|
return message.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
if (item.ClientId.HasValue && item.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,10 @@ namespace ConfectioneryListImplement.Models
|
|||||||
|
|
||||||
public int PastryId { get; private set; }
|
public int PastryId { get; private set; }
|
||||||
|
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@@ -30,11 +34,13 @@ namespace ConfectioneryListImplement.Models
|
|||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -50,12 +56,16 @@ namespace ConfectioneryListImplement.Models
|
|||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
Id = model.Id;
|
Id = model.Id;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
PastryId = PastryId,
|
PastryId = PastryId,
|
||||||
Count = Count,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
|
ImplementerFIO = DataListSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
|
||||||
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using ConfectioneryContracts.SearchModels;
|
|||||||
using ConfectioneryContracts.StoragesContract;
|
using ConfectioneryContracts.StoragesContract;
|
||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
using ConfectioneryListImplement.Models;
|
using ConfectioneryListImplement.Models;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace ConfectioneryListImplement
|
namespace ConfectioneryListImplement
|
||||||
{
|
{
|
||||||
@@ -40,6 +41,15 @@ namespace ConfectioneryListImplement
|
|||||||
{
|
{
|
||||||
return GetViewModel(order);
|
return GetViewModel(order);
|
||||||
}
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && model.Statusses != null &&
|
||||||
|
order.ImplementerId == model.ImplementerId && model.Statusses.Contains(order.Status))
|
||||||
|
{
|
||||||
|
return GetViewModel(order);
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
|
||||||
|
{
|
||||||
|
return GetViewModel(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -47,18 +57,32 @@ namespace ConfectioneryListImplement
|
|||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return new() { GetViewModel(order) };
|
return new() { GetViewModel(order) };
|
||||||
}
|
}
|
||||||
|
// если не ищем по айдишнику, значит ищем по диапазону дат
|
||||||
|
else if (model.DateFrom.HasValue && model.DateTo.HasValue &&
|
||||||
|
model.DateFrom <= order.DateCreate.Date && order.DateCreate.Date <= model.DateTo)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
else if (model.ClientId.HasValue && order.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && order.ImplementerId == model.ImplementerId)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
else if (model.Statusses != null && model.Statusses.Contains(order.Status))
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
@@ -114,6 +138,14 @@ namespace ConfectioneryListImplement
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == res.ClientId)
|
||||||
|
{
|
||||||
|
res.ClientFIO = client.ClientFIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
|
|
||||||
namespace ConfectioneryListImplement
|
|
||||||
{
|
|
||||||
public class Shop : IShopModel
|
|
||||||
{
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public int MaxCountPastries { get; private set; }
|
|
||||||
|
|
||||||
public DateTime DateOpening { get; private set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IPastryModel, int)> Pastries
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new();
|
|
||||||
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public static Shop? Create(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Shop()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
Name = model.Name,
|
|
||||||
Address = model.Address,
|
|
||||||
DateOpening = model.DateOpening,
|
|
||||||
MaxCountPastries = model.MaxCountPastries,
|
|
||||||
Pastries = new()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Name = model.Name;
|
|
||||||
Address = model.Address;
|
|
||||||
DateOpening = model.DateOpening;
|
|
||||||
MaxCountPastries = model.MaxCountPastries;
|
|
||||||
Pastries = model.Pastries;
|
|
||||||
}
|
|
||||||
public ShopViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
Name = Name,
|
|
||||||
Address = Address,
|
|
||||||
Pastries = Pastries,
|
|
||||||
DateOpening = DateOpening,
|
|
||||||
MaxCountPastries = MaxCountPastries,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.SearchModels;
|
|
||||||
using ConfectioneryContracts.StoragesContract;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
|
|
||||||
namespace ConfectioneryListImplement
|
|
||||||
{
|
|
||||||
public class ShopStorage : IShopStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public ShopStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Shops[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Shops[i];
|
|
||||||
_source.Shops.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.Name) &&
|
|
||||||
shop.Name == model.Name) ||
|
|
||||||
(model.Id.HasValue && shop.Id == model.Id))
|
|
||||||
{
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ShopViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (shop.Name.Contains(model.Name ?? string.Empty))
|
|
||||||
{
|
|
||||||
result.Add(shop.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ShopViewModel>();
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
result.Add(shop.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasNeedPastries(IPastryModel pastry, int needCount)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Insert(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (model.Id <= shop.Id)
|
|
||||||
{
|
|
||||||
model.Id = shop.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newShop = Shop.Create(model);
|
|
||||||
if (newShop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Shops.Add(newShop);
|
|
||||||
return newShop.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SellPastries(IPastryModel pastry, int needCount)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (shop.Id == model.Id)
|
|
||||||
{
|
|
||||||
shop.Update(model);
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryListImplement"
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryFileImplement", "ConfectionaryFileImplement\ConfectioneryFileImplement.csproj", "{47A2EA59-4443-487E-85F4-AC49C04B7211}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryFileImplement", "ConfectionaryFileImplement\ConfectioneryFileImplement.csproj", "{47A2EA59-4443-487E-85F4-AC49C04B7211}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryDatabaseImplement", "ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj", "{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryDatabaseImplement", "ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj", "{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryRestApi", "ConfectioneryRestApi\ConfectioneryRestApi.csproj", "{044CCE68-E866-4957-88D2-4A4D97634808}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryClientApp", "ConfectioneryClientApp\ConfectioneryClientApp.csproj", "{3D0CAD8C-7002-453B-9588-7D78B4B72B7B}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -51,6 +55,14 @@ Global
|
|||||||
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{044CCE68-E866-4957-88D2-4A4D97634808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{044CCE68-E866-4957-88D2-4A4D97634808}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{044CCE68-E866-4957-88D2-4A4D97634808}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{044CCE68-E866-4957-88D2-4A4D97634808}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3D0CAD8C-7002-453B-9588-7D78B4B72B7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3D0CAD8C-7002-453B-9588-7D78B4B72B7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3D0CAD8C-7002-453B-9588-7D78B4B72B7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3D0CAD8C-7002-453B-9588-7D78B4B72B7B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
11
Confectionery/App.config
Normal file
11
Confectionery/App.config
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="SmtpClientHost" value="smtp.mail.ru" />
|
||||||
|
<add key="SmtpClientPort" value="587" />
|
||||||
|
<add key="PopHost" value="pop.mail.ru" />
|
||||||
|
<add key="PopPort" value="995" />
|
||||||
|
<add key="MailLogin" value="ordersender228@mail.ru" />
|
||||||
|
<add key="MailPassword" value="v8czsQ8zztJc5wEHxKPN" />
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||||
|
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -25,4 +26,22 @@
|
|||||||
<ProjectReference Include="..\ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj" />
|
<ProjectReference Include="..\ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="FormViewClients.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="FormViewImplementers.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="App.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="ReportOrders.rdlc">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
46
Confectionery/DataGridViewExtension.cs
Normal file
46
Confectionery/DataGridViewExtension.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using ConfectioneryContracts.Attributes;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
internal static class DataGridViewExtension
|
||||||
|
{
|
||||||
|
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||||
|
{
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grid.DataSource = data;
|
||||||
|
|
||||||
|
var type = typeof(T);
|
||||||
|
var properties = type.GetProperties();
|
||||||
|
foreach (DataGridViewColumn column in grid.Columns)
|
||||||
|
{
|
||||||
|
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||||
|
if (property == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
|
||||||
|
}
|
||||||
|
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||||
|
if (attribute == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
||||||
|
}
|
||||||
|
// ищем нужный нам атрибут
|
||||||
|
if (attribute is ColumnAttribute columnAttr)
|
||||||
|
{
|
||||||
|
column.HeaderText = columnAttr.Title;
|
||||||
|
column.Visible = columnAttr.Visible;
|
||||||
|
if (columnAttr.IsUseAutoSize)
|
||||||
|
{
|
||||||
|
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
column.Width = columnAttr.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
151
Confectionery/FormAddPastryInShop.Designer.cs
generated
151
Confectionery/FormAddPastryInShop.Designer.cs
generated
@@ -1,151 +0,0 @@
|
|||||||
namespace ConfectioneryView
|
|
||||||
{
|
|
||||||
partial class FormAddPastryInShop
|
|
||||||
{
|
|
||||||
/// <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.comboBoxShop = new System.Windows.Forms.ComboBox();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
|
||||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// comboBoxShop
|
|
||||||
//
|
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(214, 17);
|
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(222, 23);
|
|
||||||
this.comboBoxShop.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(84, 20);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(124, 15);
|
|
||||||
this.label1.TabIndex = 2;
|
|
||||||
this.label1.Text = "Выбранный магазин:";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(12, 47);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(196, 15);
|
|
||||||
this.label2.TabIndex = 4;
|
|
||||||
this.label2.Text = "Изделие которое нужно добавить:";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
this.label3.AutoSize = true;
|
|
||||||
this.label3.Location = new System.Drawing.Point(133, 73);
|
|
||||||
this.label3.Name = "label3";
|
|
||||||
this.label3.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.label3.TabIndex = 5;
|
|
||||||
this.label3.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxPastry
|
|
||||||
//
|
|
||||||
this.comboBoxPastry.FormattingEnabled = true;
|
|
||||||
this.comboBoxPastry.Location = new System.Drawing.Point(214, 44);
|
|
||||||
this.comboBoxPastry.Name = "comboBoxPastry";
|
|
||||||
this.comboBoxPastry.Size = new System.Drawing.Size(222, 23);
|
|
||||||
this.comboBoxPastry.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// numericUpDownCount
|
|
||||||
//
|
|
||||||
this.numericUpDownCount.Location = new System.Drawing.Point(215, 71);
|
|
||||||
this.numericUpDownCount.Maximum = new decimal(new int[] {
|
|
||||||
1410065408,
|
|
||||||
2,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
|
||||||
this.numericUpDownCount.Size = new System.Drawing.Size(221, 23);
|
|
||||||
this.numericUpDownCount.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(280, 123);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonSave.TabIndex = 8;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(361, 123);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonCancel.TabIndex = 9;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormAddPastryInShop
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(448, 158);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.numericUpDownCount);
|
|
||||||
this.Controls.Add(this.comboBoxPastry);
|
|
||||||
this.Controls.Add(this.label3);
|
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.comboBoxShop);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Name = "FormAddPastryInShop";
|
|
||||||
this.Text = "FormAddPastryInShop";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox comboBoxShop;
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
|
||||||
private ComboBox comboBoxPastry;
|
|
||||||
private NumericUpDown numericUpDownCount;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
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 ConfectioneryView
|
|
||||||
{
|
|
||||||
public partial class FormAddPastryInShop : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IShopLogic _shopLogic;
|
|
||||||
private readonly IPastryLogic _pastryLogic;
|
|
||||||
private readonly List<ShopViewModel>? _listShops;
|
|
||||||
private readonly List<PastryViewModel>? _listPastries;
|
|
||||||
|
|
||||||
public FormAddPastryInShop(ILogger<FormAddPastryInShop> logger, IShopLogic shopLogic, IPastryLogic pastryLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_shopLogic = shopLogic;
|
|
||||||
_pastryLogic = pastryLogic;
|
|
||||||
_logger = logger;
|
|
||||||
_listShops = shopLogic.ReadList(null);
|
|
||||||
if (_listShops != null)
|
|
||||||
{
|
|
||||||
comboBoxShop.DisplayMember = "Name";
|
|
||||||
comboBoxShop.ValueMember = "Id";
|
|
||||||
comboBoxShop.DataSource = _listShops;
|
|
||||||
comboBoxShop.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_listPastries = pastryLogic.ReadList(null);
|
|
||||||
if (_listPastries != null)
|
|
||||||
{
|
|
||||||
comboBoxPastry.DisplayMember = "PastryName";
|
|
||||||
comboBoxPastry.ValueMember= "Id";
|
|
||||||
comboBoxPastry.DataSource = _listPastries;
|
|
||||||
comboBoxPastry.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxShop.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxPastry.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление изделия в магазин");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var pastry = _pastryLogic.ReadElement(new()
|
|
||||||
{
|
|
||||||
Id = (int)comboBoxPastry.SelectedValue
|
|
||||||
});
|
|
||||||
if (pastry == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
var resultOperation = _shopLogic.AddPastry(
|
|
||||||
model: new() { Id = (int)comboBoxShop.SelectedValue },
|
|
||||||
pastry: pastry,
|
|
||||||
count: (int)numericUpDownCount.Value
|
|
||||||
);
|
|
||||||
if (!resultOperation)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,8 +27,7 @@ namespace ConfectioneryView
|
|||||||
_logger.LogInformation("Получение компонента");
|
_logger.LogInformation("Получение компонента");
|
||||||
var view = _logic.ReadElement(new ComponentSearchModel
|
var view = _logic.ReadElement(new ComponentSearchModel
|
||||||
{
|
{
|
||||||
Id =
|
Id = _id.Value
|
||||||
_id.Value
|
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,104 +1,91 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ConfectioneryView
|
namespace ConfectioneryView
|
||||||
{
|
{
|
||||||
public partial class FormComponents : Form
|
public partial class FormComponents : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IComponentLogic _logic;
|
private readonly IComponentLogic _logic;
|
||||||
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
private void FormComponents_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
{
|
}
|
||||||
dataGridView.DataSource = list;
|
catch (Exception ex)
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
{
|
||||||
dataGridView.Columns["ComponentName"].AutoSizeMode =
|
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
}
|
MessageBoxIcon.Error);
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
MessageBoxIcon.Error);
|
{
|
||||||
}
|
LoadData();
|
||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
}
|
||||||
{
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
var service =
|
{
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
if (service is FormComponent form)
|
{
|
||||||
{
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
{
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
LoadData();
|
{
|
||||||
}
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
}
|
||||||
{
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
{
|
||||||
{
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
{
|
||||||
if (service is FormComponent form)
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
{
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
int id =
|
||||||
{
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
LoadData();
|
_logger.LogInformation("Удаление компонента");
|
||||||
}
|
try
|
||||||
}
|
{
|
||||||
}
|
if (!_logic.Delete(new ComponentBindingModel
|
||||||
}
|
{
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
Id = id
|
||||||
{
|
}))
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
{
|
||||||
{
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
}
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
LoadData();
|
||||||
{
|
}
|
||||||
int id =
|
catch (Exception ex)
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
{
|
||||||
_logger.LogInformation("Удаление компонента");
|
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||||
try
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
{
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
if (!_logic.Delete(new ComponentBindingModel
|
}
|
||||||
{
|
}
|
||||||
Id = id
|
}
|
||||||
}))
|
}
|
||||||
{
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
{
|
||||||
}
|
LoadData();
|
||||||
LoadData();
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
174
Confectionery/FormCreateOrder.Designer.cs
generated
174
Confectionery/FormCreateOrder.Designer.cs
generated
@@ -28,109 +28,129 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
label1 = new Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
label2 = new Label();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
label3 = new Label();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
buttonCancel = new Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
buttonSave = new Button();
|
||||||
this.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
comboBoxPastry = new ComboBox();
|
||||||
this.textBoxCount = new System.Windows.Forms.NumericUpDown();
|
textBoxCount = new NumericUpDown();
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
textBoxSum = new TextBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).BeginInit();
|
label4 = new Label();
|
||||||
this.SuspendLayout();
|
comboBoxClient = new ComboBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)textBoxCount).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
label1.Location = new Point(12, 9);
|
||||||
this.label1.Name = "label1";
|
label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(56, 15);
|
label1.Size = new Size(56, 15);
|
||||||
this.label1.TabIndex = 0;
|
label1.TabIndex = 0;
|
||||||
this.label1.Text = "Изделие:";
|
label1.Text = "Изделие:";
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(12, 40);
|
label2.Location = new Point(12, 40);
|
||||||
this.label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(75, 15);
|
label2.Size = new Size(75, 15);
|
||||||
this.label2.TabIndex = 1;
|
label2.TabIndex = 1;
|
||||||
this.label2.Text = "Количество:";
|
label2.Text = "Количество:";
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(12, 68);
|
label3.Location = new Point(12, 68);
|
||||||
this.label3.Name = "label3";
|
label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(48, 15);
|
label3.Size = new Size(48, 15);
|
||||||
this.label3.TabIndex = 2;
|
label3.TabIndex = 2;
|
||||||
this.label3.Text = "Сумма:";
|
label3.Text = "Сумма:";
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(221, 109);
|
buttonCancel.Location = new Point(221, 133);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(95, 23);
|
buttonCancel.Size = new Size(95, 23);
|
||||||
this.buttonCancel.TabIndex = 3;
|
buttonCancel.TabIndex = 3;
|
||||||
this.buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonSave.Location = new System.Drawing.Point(141, 109);
|
buttonSave.Location = new Point(141, 133);
|
||||||
this.buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
this.buttonSave.Size = new System.Drawing.Size(77, 23);
|
buttonSave.Size = new Size(77, 23);
|
||||||
this.buttonSave.TabIndex = 4;
|
buttonSave.TabIndex = 4;
|
||||||
this.buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
buttonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// comboBoxPastry
|
// comboBoxPastry
|
||||||
//
|
//
|
||||||
this.comboBoxPastry.FormattingEnabled = true;
|
comboBoxPastry.FormattingEnabled = true;
|
||||||
this.comboBoxPastry.Location = new System.Drawing.Point(101, 9);
|
comboBoxPastry.Location = new Point(101, 9);
|
||||||
this.comboBoxPastry.Name = "comboBoxPastry";
|
comboBoxPastry.Name = "comboBoxPastry";
|
||||||
this.comboBoxPastry.Size = new System.Drawing.Size(214, 23);
|
comboBoxPastry.Size = new Size(214, 23);
|
||||||
this.comboBoxPastry.TabIndex = 5;
|
comboBoxPastry.TabIndex = 5;
|
||||||
this.comboBoxPastry.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPastry_SelectedIndexChanged);
|
comboBoxPastry.SelectedIndexChanged += ComboBoxPastry_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(101, 38);
|
textBoxCount.Location = new Point(101, 38);
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(214, 23);
|
textBoxCount.Size = new Size(214, 23);
|
||||||
this.textBoxCount.TabIndex = 6;
|
textBoxCount.TabIndex = 6;
|
||||||
this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
textBoxCount.ValueChanged += TextBoxCount_TextChanged;
|
||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
this.textBoxSum.Location = new System.Drawing.Point(101, 65);
|
textBoxSum.Location = new Point(101, 65);
|
||||||
this.textBoxSum.Name = "textBoxSum";
|
textBoxSum.Name = "textBoxSum";
|
||||||
this.textBoxSum.Size = new System.Drawing.Size(214, 23);
|
textBoxSum.Size = new Size(214, 23);
|
||||||
this.textBoxSum.TabIndex = 7;
|
textBoxSum.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(12, 99);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(49, 15);
|
||||||
|
label4.TabIndex = 8;
|
||||||
|
label4.Text = "Клиент:";
|
||||||
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
comboBoxClient.FormattingEnabled = true;
|
||||||
|
comboBoxClient.Location = new Point(101, 96);
|
||||||
|
comboBoxClient.Name = "comboBoxClient";
|
||||||
|
comboBoxClient.Size = new Size(215, 23);
|
||||||
|
comboBoxClient.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(327, 144);
|
ClientSize = new Size(327, 168);
|
||||||
this.Controls.Add(this.textBoxSum);
|
Controls.Add(comboBoxClient);
|
||||||
this.Controls.Add(this.textBoxCount);
|
Controls.Add(label4);
|
||||||
this.Controls.Add(this.comboBoxPastry);
|
Controls.Add(textBoxSum);
|
||||||
this.Controls.Add(this.buttonSave);
|
Controls.Add(textBoxCount);
|
||||||
this.Controls.Add(this.buttonCancel);
|
Controls.Add(comboBoxPastry);
|
||||||
this.Controls.Add(this.label3);
|
Controls.Add(buttonSave);
|
||||||
this.Controls.Add(this.label2);
|
Controls.Add(buttonCancel);
|
||||||
this.Controls.Add(this.label1);
|
Controls.Add(label3);
|
||||||
this.Name = "FormCreateOrder";
|
Controls.Add(label2);
|
||||||
this.Text = "Создание заказа";
|
Controls.Add(label1);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit();
|
Name = "FormCreateOrder";
|
||||||
this.ResumeLayout(false);
|
Text = "Создание заказа";
|
||||||
this.PerformLayout();
|
((System.ComponentModel.ISupportInitialize)textBoxCount).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -143,5 +163,7 @@
|
|||||||
private ComboBox comboBoxPastry;
|
private ComboBox comboBoxPastry;
|
||||||
private NumericUpDown textBoxCount;
|
private NumericUpDown textBoxCount;
|
||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
|
private Label label4;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,14 +12,16 @@ namespace ConfectioneryView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IPastryLogic _logicP;
|
private readonly IPastryLogic _logicP;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
private readonly List<PastryViewModel>? _list;
|
private readonly List<PastryViewModel>? _list;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPastryLogic logicP, IOrderLogic logicO)
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPastryLogic logicP, IOrderLogic logicO, IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
_list = logicP.ReadList(null);
|
_list = logicP.ReadList(null);
|
||||||
if (_list != null)
|
if (_list != null)
|
||||||
{
|
{
|
||||||
@@ -28,6 +30,14 @@ namespace ConfectioneryView
|
|||||||
comboBoxPastry.DataSource = _list;
|
comboBoxPastry.DataSource = _list;
|
||||||
comboBoxPastry.SelectedItem = null;
|
comboBoxPastry.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
var clients = _clientLogic.ReadList(null);
|
||||||
|
if (clients != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "clientFIO";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = clients;
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -72,24 +82,31 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxPastry.SelectedValue == null)
|
if (comboBoxPastry.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (comboBoxClient.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите клиента", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
_logger.LogInformation("Создание заказа");
|
_logger.LogInformation("Создание заказа");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||||
PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue),
|
PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text),
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
|
|||||||
173
Confectionery/FormImplementer.Designer.cs
generated
Normal file
173
Confectionery/FormImplementer.Designer.cs
generated
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormImplementer
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
textBoxFio = new TextBox();
|
||||||
|
textBoxPassword = new TextBox();
|
||||||
|
numericUpDownWorkExperience = new NumericUpDown();
|
||||||
|
numericUpDownQualification = new NumericUpDown();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownQualification).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(79, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(37, 15);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "ФИО:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(69, 41);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(52, 15);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Пароль:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(78, 68);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(38, 15);
|
||||||
|
label3.TabIndex = 2;
|
||||||
|
label3.Text = "Стаж:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(25, 97);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(91, 15);
|
||||||
|
label4.TabIndex = 3;
|
||||||
|
label4.Text = "Квалификация:";
|
||||||
|
//
|
||||||
|
// textBoxFio
|
||||||
|
//
|
||||||
|
textBoxFio.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxFio.Location = new Point(127, 9);
|
||||||
|
textBoxFio.Name = "textBoxFio";
|
||||||
|
textBoxFio.Size = new Size(271, 23);
|
||||||
|
textBoxFio.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// textBoxPassword
|
||||||
|
//
|
||||||
|
textBoxPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxPassword.Location = new Point(127, 38);
|
||||||
|
textBoxPassword.Name = "textBoxPassword";
|
||||||
|
textBoxPassword.PasswordChar = '*';
|
||||||
|
textBoxPassword.Size = new Size(271, 23);
|
||||||
|
textBoxPassword.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// numericUpDownWorkExperience
|
||||||
|
//
|
||||||
|
numericUpDownWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
numericUpDownWorkExperience.Location = new Point(127, 66);
|
||||||
|
numericUpDownWorkExperience.Name = "numericUpDownWorkExperience";
|
||||||
|
numericUpDownWorkExperience.Size = new Size(271, 23);
|
||||||
|
numericUpDownWorkExperience.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// numericUpDownQualification
|
||||||
|
//
|
||||||
|
numericUpDownQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
numericUpDownQualification.Location = new Point(127, 95);
|
||||||
|
numericUpDownQualification.Name = "numericUpDownQualification";
|
||||||
|
numericUpDownQualification.Size = new Size(271, 23);
|
||||||
|
numericUpDownQualification.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(309, 138);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(89, 33);
|
||||||
|
buttonCancel.TabIndex = 8;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonSave.Location = new Point(214, 138);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(89, 33);
|
||||||
|
buttonSave.TabIndex = 9;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// FormImplementer
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(410, 183);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(numericUpDownQualification);
|
||||||
|
Controls.Add(numericUpDownWorkExperience);
|
||||||
|
Controls.Add(textBoxPassword);
|
||||||
|
Controls.Add(textBoxFio);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "FormImplementer";
|
||||||
|
Text = "Добавление / Редактирование исполнителя";
|
||||||
|
Load += FormImplementer_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownQualification).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBoxFio;
|
||||||
|
private TextBox textBoxPassword;
|
||||||
|
private NumericUpDown numericUpDownWorkExperience;
|
||||||
|
private NumericUpDown numericUpDownQualification;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
}
|
||||||
|
}
|
||||||
101
Confectionery/FormImplementer.cs
Normal file
101
Confectionery/FormImplementer.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormImplementer : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormImplementer_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение исполнителя");
|
||||||
|
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxFio.Text = view.ImplementerFIO;
|
||||||
|
textBoxPassword.Text = view.Password;
|
||||||
|
numericUpDownQualification.Value = view.Qualification;
|
||||||
|
numericUpDownWorkExperience.Value = view.WorkExperience;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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(textBoxPassword.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxFio.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните фио", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение исполнителя");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ImplementerFIO = textBoxFio.Text,
|
||||||
|
Password = textBoxPassword.Text,
|
||||||
|
Qualification = (int)numericUpDownQualification.Value,
|
||||||
|
WorkExperience = (int)numericUpDownWorkExperience.Value,
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
303
Confectionery/FormMain.Designer.cs
generated
303
Confectionery/FormMain.Designer.cs
generated
@@ -28,177 +28,182 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
pastryToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
componentToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.ShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
ImplementersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
reportsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
pastriesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
pastryComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.button3 = new System.Windows.Forms.Button();
|
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.button4 = new System.Windows.Forms.Button();
|
DoWorkToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonAddPastryInShop = new System.Windows.Forms.Button();
|
mailToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonSellPastry = new System.Windows.Forms.Button();
|
dataGridView = new DataGridView();
|
||||||
this.menuStrip1.SuspendLayout();
|
buttonCreateOrder = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
button4 = new Button();
|
||||||
this.SuspendLayout();
|
button3 = new Button();
|
||||||
|
createBackupToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, reportsToolStripMenuItem, DoWorkToolStripMenuItem, mailToolStripMenuItem, createBackupToolStripMenuItem });
|
||||||
this.справочникиToolStripMenuItem});
|
menuStrip1.Location = new Point(0, 0);
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
menuStrip1.Size = new Size(783, 24);
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(783, 24);
|
menuStrip1.TabIndex = 0;
|
||||||
this.menuStrip1.TabIndex = 0;
|
menuStrip1.Text = "menuStrip1";
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem, clientsToolStripMenuItem, ImplementersToolStripMenuItem });
|
||||||
this.pastryToolStripMenuItem,
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
this.componentToolStripMenuItem,
|
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||||
this.ShopsToolStripMenuItem});
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
//
|
||||||
// pastryToolStripMenuItem
|
// pastryToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
|
pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
|
||||||
this.pastryToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
pastryToolStripMenuItem.Size = new Size(149, 22);
|
||||||
this.pastryToolStripMenuItem.Text = "Изделия";
|
pastryToolStripMenuItem.Text = "Изделия";
|
||||||
this.pastryToolStripMenuItem.Click += new System.EventHandler(this.PastryToolStripMenuItem_Click);
|
pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// componentToolStripMenuItem
|
// componentToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
||||||
this.componentToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
componentToolStripMenuItem.Size = new Size(149, 22);
|
||||||
this.componentToolStripMenuItem.Text = "Компоненты";
|
componentToolStripMenuItem.Text = "Компоненты";
|
||||||
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ShopsToolStripMenuItem
|
// clientsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||||
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
clientsToolStripMenuItem.Size = new Size(149, 22);
|
||||||
this.ShopsToolStripMenuItem.Text = "Магазины";
|
clientsToolStripMenuItem.Text = "Клиенты";
|
||||||
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ImplementersToolStripMenuItem
|
||||||
|
//
|
||||||
|
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
||||||
|
ImplementersToolStripMenuItem.Size = new Size(149, 22);
|
||||||
|
ImplementersToolStripMenuItem.Text = "Исполнители";
|
||||||
|
ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// reportsToolStripMenuItem
|
||||||
|
//
|
||||||
|
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastriesToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem });
|
||||||
|
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
|
||||||
|
reportsToolStripMenuItem.Size = new Size(60, 20);
|
||||||
|
reportsToolStripMenuItem.Text = "Отчеты";
|
||||||
|
//
|
||||||
|
// pastriesToolStripMenuItem
|
||||||
|
//
|
||||||
|
pastriesToolStripMenuItem.Name = "pastriesToolStripMenuItem";
|
||||||
|
pastriesToolStripMenuItem.Size = new Size(215, 22);
|
||||||
|
pastriesToolStripMenuItem.Text = "Список изделий";
|
||||||
|
pastriesToolStripMenuItem.Click += PastriesToolStripMenuItem_Click_1;
|
||||||
|
//
|
||||||
|
// pastryComponentsToolStripMenuItem
|
||||||
|
//
|
||||||
|
pastryComponentsToolStripMenuItem.Name = "pastryComponentsToolStripMenuItem";
|
||||||
|
pastryComponentsToolStripMenuItem.Size = new Size(215, 22);
|
||||||
|
pastryComponentsToolStripMenuItem.Text = "Изделия с компонентами";
|
||||||
|
pastryComponentsToolStripMenuItem.Click += PastryComponentsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ordersToolStripMenuItem
|
||||||
|
//
|
||||||
|
ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
|
||||||
|
ordersToolStripMenuItem.Size = new Size(215, 22);
|
||||||
|
ordersToolStripMenuItem.Text = "Список заказов";
|
||||||
|
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// DoWorkToolStripMenuItem
|
||||||
|
//
|
||||||
|
DoWorkToolStripMenuItem.Name = "DoWorkToolStripMenuItem";
|
||||||
|
DoWorkToolStripMenuItem.Size = new Size(92, 20);
|
||||||
|
DoWorkToolStripMenuItem.Text = "Запуск работ";
|
||||||
|
DoWorkToolStripMenuItem.Click += DoWorkToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// mailToolStripMenuItem
|
||||||
|
//
|
||||||
|
mailToolStripMenuItem.Name = "mailToolStripMenuItem";
|
||||||
|
mailToolStripMenuItem.Size = new Size(62, 20);
|
||||||
|
mailToolStripMenuItem.Text = "Письма";
|
||||||
|
mailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
dataGridView.Location = new Point(12, 27);
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
dataGridView.RowTemplate.Height = 25;
|
||||||
this.dataGridView.Name = "dataGridView";
|
dataGridView.Size = new Size(606, 341);
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
dataGridView.TabIndex = 1;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(606, 399);
|
|
||||||
this.dataGridView.TabIndex = 1;
|
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(624, 39);
|
buttonCreateOrder.Location = new Point(624, 39);
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(147, 32);
|
buttonCreateOrder.Size = new Size(147, 32);
|
||||||
this.buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.TabIndex = 2;
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||||
//
|
|
||||||
// buttonTakeOrderInWork
|
|
||||||
//
|
|
||||||
this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(624, 98);
|
|
||||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
|
||||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 32);
|
|
||||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
|
||||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
|
||||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
|
||||||
//
|
|
||||||
// button2
|
|
||||||
//
|
|
||||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.button2.Location = new System.Drawing.Point(624, 157);
|
|
||||||
this.button2.Name = "button2";
|
|
||||||
this.button2.Size = new System.Drawing.Size(147, 32);
|
|
||||||
this.button2.TabIndex = 4;
|
|
||||||
this.button2.Text = "Заказ готов";
|
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
|
||||||
this.button2.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
|
||||||
//
|
|
||||||
// button3
|
|
||||||
//
|
|
||||||
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.button3.Location = new System.Drawing.Point(624, 215);
|
|
||||||
this.button3.Name = "button3";
|
|
||||||
this.button3.Size = new System.Drawing.Size(147, 32);
|
|
||||||
this.button3.TabIndex = 5;
|
|
||||||
this.button3.Text = "Заказ выдан";
|
|
||||||
this.button3.UseVisualStyleBackColor = true;
|
|
||||||
this.button3.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
|
||||||
//
|
//
|
||||||
// button4
|
// button4
|
||||||
//
|
//
|
||||||
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
button4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
this.button4.Location = new System.Drawing.Point(624, 274);
|
button4.Location = new Point(624, 157);
|
||||||
this.button4.Name = "button4";
|
button4.Name = "button4";
|
||||||
this.button4.Size = new System.Drawing.Size(147, 32);
|
button4.Size = new Size(147, 32);
|
||||||
this.button4.TabIndex = 6;
|
button4.TabIndex = 6;
|
||||||
this.button4.Text = "Обновить список";
|
button4.Text = "Обновить список";
|
||||||
this.button4.UseVisualStyleBackColor = true;
|
button4.UseVisualStyleBackColor = true;
|
||||||
this.button4.Click += new System.EventHandler(this.ButtonRef_Click);
|
button4.Click += ButtonRef_Click;
|
||||||
//
|
//
|
||||||
// buttonAddPastryInShop
|
// button3
|
||||||
//
|
//
|
||||||
this.buttonAddPastryInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 384);
|
button3.Location = new Point(624, 98);
|
||||||
this.buttonAddPastryInShop.Name = "buttonAddPastryInShop";
|
button3.Name = "button3";
|
||||||
this.buttonAddPastryInShop.Size = new System.Drawing.Size(147, 31);
|
button3.Size = new Size(147, 32);
|
||||||
this.buttonAddPastryInShop.TabIndex = 7;
|
button3.TabIndex = 5;
|
||||||
this.buttonAddPastryInShop.Text = "Пополнение магазина";
|
button3.Text = "Заказ выдан";
|
||||||
this.buttonAddPastryInShop.UseVisualStyleBackColor = true;
|
button3.UseVisualStyleBackColor = true;
|
||||||
this.buttonAddPastryInShop.Click += new System.EventHandler(this.ButtonAddPastryInShop_Click);
|
button3.Click += ButtonIssuedOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonSellPastry
|
// createBackupToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.buttonSellPastry.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
createBackupToolStripMenuItem.Name = "createBackupToolStripMenuItem";
|
||||||
this.buttonSellPastry.Location = new System.Drawing.Point(624, 331);
|
createBackupToolStripMenuItem.Size = new Size(97, 20);
|
||||||
this.buttonSellPastry.Name = "buttonSellPastry";
|
createBackupToolStripMenuItem.Text = "Создать бекап";
|
||||||
this.buttonSellPastry.Size = new System.Drawing.Size(147, 31);
|
createBackupToolStripMenuItem.Click += CreateBackupToolStripMenuItem_Click;
|
||||||
this.buttonSellPastry.TabIndex = 8;
|
|
||||||
this.buttonSellPastry.Text = "Продать изделие";
|
|
||||||
this.buttonSellPastry.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSellPastry.Click += new System.EventHandler(this.ButtonSellPastry_Click);
|
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(783, 438);
|
ClientSize = new Size(783, 380);
|
||||||
this.Controls.Add(this.buttonSellPastry);
|
Controls.Add(button4);
|
||||||
this.Controls.Add(this.buttonAddPastryInShop);
|
Controls.Add(button3);
|
||||||
this.Controls.Add(this.button4);
|
Controls.Add(buttonCreateOrder);
|
||||||
this.Controls.Add(this.button3);
|
Controls.Add(dataGridView);
|
||||||
this.Controls.Add(this.button2);
|
Controls.Add(menuStrip1);
|
||||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
MainMenuStrip = menuStrip1;
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
Name = "FormMain";
|
||||||
this.Controls.Add(this.dataGridView);
|
Text = "Кондитерская";
|
||||||
this.Controls.Add(this.menuStrip1);
|
Load += FormMain_Load;
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
menuStrip1.ResumeLayout(false);
|
||||||
this.Name = "FormMain";
|
menuStrip1.PerformLayout();
|
||||||
this.Text = "Кондитерская";
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
ResumeLayout(false);
|
||||||
this.menuStrip1.ResumeLayout(false);
|
PerformLayout();
|
||||||
this.menuStrip1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -207,14 +212,18 @@
|
|||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonTakeOrderInWork;
|
|
||||||
private Button button2;
|
|
||||||
private Button button3;
|
|
||||||
private Button button4;
|
private Button button4;
|
||||||
private ToolStripMenuItem pastryToolStripMenuItem;
|
private ToolStripMenuItem pastryToolStripMenuItem;
|
||||||
private ToolStripMenuItem componentToolStripMenuItem;
|
private ToolStripMenuItem componentToolStripMenuItem;
|
||||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
private ToolStripMenuItem reportsToolStripMenuItem;
|
||||||
private Button buttonAddPastryInShop;
|
private ToolStripMenuItem pastriesToolStripMenuItem;
|
||||||
private Button buttonSellPastry;
|
private ToolStripMenuItem pastryComponentsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DoWorkToolStripMenuItem;
|
||||||
|
private Button button3;
|
||||||
|
private ToolStripMenuItem mailToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem createBackupToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using ConfectioneryBusinessLogic;
|
||||||
using ConfectioneryBusinessLogic.BusinessLogics;
|
using ConfectioneryBusinessLogic.BusinessLogics;
|
||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.DI;
|
||||||
using ConfectioneryDataModels.Enums;
|
using ConfectioneryDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@@ -11,11 +13,18 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
private readonly IReportLogic _reportLogic;
|
||||||
|
private readonly IWorkProcess _workProcess;
|
||||||
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -25,15 +34,7 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].HeaderText = "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
||||||
dataGridView.Columns["PastryId"].Visible = false;
|
|
||||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -46,29 +47,21 @@ namespace ConfectioneryView
|
|||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
|
||||||
e)
|
e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
if (service is FormComponents form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void PastryToolStripMenuItem_Click(object sender, EventArgs e)
|
private void PastryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormViewPastry));
|
var form = DependencyManager.Instance.Resolve<FormViewPastry>();
|
||||||
if (service is FormViewPastry form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
form.ShowDialog();
|
||||||
{
|
LoadData();
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
@@ -79,7 +72,7 @@ namespace ConfectioneryView
|
|||||||
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id}. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'", id);
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id}. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{ Id = id });
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.");
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.");
|
||||||
@@ -104,8 +97,8 @@ namespace ConfectioneryView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Status = orderStatus
|
Status = orderStatus
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
@@ -153,30 +146,78 @@ namespace ConfectioneryView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void PastriesToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormViewShops));
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
if (service is FormViewShops form)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
_reportLogic.SavePastriesToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||||
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddPastryInShop_Click(object sender, EventArgs e)
|
private void PastryComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddPastryInShop));
|
var form = DependencyManager.Instance.Resolve<FormReportPastryComponents>();
|
||||||
if (service is FormAddPastryInShop form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSellPastry_Click(object sender, EventArgs e)
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellPastry));
|
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormSellPastry form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormViewClients>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormViewImplementers>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_workProcess.DoWork(
|
||||||
|
DependencyManager.Instance.Resolve<IImplementerLogic>(),
|
||||||
|
_orderLogic);
|
||||||
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormViewMail>();
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateBackupToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
454
Confectionery/FormPastry.Designer.cs
generated
454
Confectionery/FormPastry.Designer.cs
generated
@@ -1,236 +1,236 @@
|
|||||||
namespace ConfectioneryView
|
namespace ConfectioneryView
|
||||||
{
|
{
|
||||||
partial class FormPastry
|
partial class FormPastry
|
||||||
{
|
{
|
||||||
/// <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)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(62, 15);
|
this.label1.Size = new System.Drawing.Size(62, 15);
|
||||||
this.label1.TabIndex = 0;
|
this.label1.TabIndex = 0;
|
||||||
this.label1.Text = "Название:";
|
this.label1.Text = "Название:";
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(12, 40);
|
this.label2.Location = new System.Drawing.Point(12, 40);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(70, 15);
|
this.label2.Size = new System.Drawing.Size(70, 15);
|
||||||
this.label2.TabIndex = 1;
|
this.label2.TabIndex = 1;
|
||||||
this.label2.Text = "Стоимость:";
|
this.label2.Text = "Стоимость:";
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
this.groupBox1.Controls.Add(this.buttonRef);
|
this.groupBox1.Controls.Add(this.buttonRef);
|
||||||
this.groupBox1.Controls.Add(this.buttonDel);
|
this.groupBox1.Controls.Add(this.buttonDel);
|
||||||
this.groupBox1.Controls.Add(this.buttonUpd);
|
this.groupBox1.Controls.Add(this.buttonUpd);
|
||||||
this.groupBox1.Controls.Add(this.buttonAdd);
|
this.groupBox1.Controls.Add(this.buttonAdd);
|
||||||
this.groupBox1.Controls.Add(this.dataGridView);
|
this.groupBox1.Controls.Add(this.dataGridView);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(12, 67);
|
this.groupBox1.Location = new System.Drawing.Point(12, 67);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
this.groupBox1.Size = new System.Drawing.Size(776, 330);
|
this.groupBox1.Size = new System.Drawing.Size(776, 330);
|
||||||
this.groupBox1.TabIndex = 2;
|
this.groupBox1.TabIndex = 2;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Компоненты:";
|
this.groupBox1.Text = "Компоненты:";
|
||||||
//
|
//
|
||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRef.Location = new System.Drawing.Point(680, 207);
|
this.buttonRef.Location = new System.Drawing.Point(680, 207);
|
||||||
this.buttonRef.Name = "buttonRef";
|
this.buttonRef.Name = "buttonRef";
|
||||||
this.buttonRef.Size = new System.Drawing.Size(90, 37);
|
this.buttonRef.Size = new System.Drawing.Size(90, 37);
|
||||||
this.buttonRef.TabIndex = 4;
|
this.buttonRef.TabIndex = 4;
|
||||||
this.buttonRef.Text = "Обновить";
|
this.buttonRef.Text = "Обновить";
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
//
|
//
|
||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonDel.Location = new System.Drawing.Point(680, 158);
|
this.buttonDel.Location = new System.Drawing.Point(680, 158);
|
||||||
this.buttonDel.Name = "buttonDel";
|
this.buttonDel.Name = "buttonDel";
|
||||||
this.buttonDel.Size = new System.Drawing.Size(90, 33);
|
this.buttonDel.Size = new System.Drawing.Size(90, 33);
|
||||||
this.buttonDel.TabIndex = 3;
|
this.buttonDel.TabIndex = 3;
|
||||||
this.buttonDel.Text = "Удалить";
|
this.buttonDel.Text = "Удалить";
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// buttonUpd
|
||||||
//
|
//
|
||||||
this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(680, 108);
|
this.buttonUpd.Location = new System.Drawing.Point(680, 108);
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(90, 34);
|
this.buttonUpd.Size = new System.Drawing.Size(90, 34);
|
||||||
this.buttonUpd.TabIndex = 2;
|
this.buttonUpd.TabIndex = 2;
|
||||||
this.buttonUpd.Text = "Изменить";
|
this.buttonUpd.Text = "Изменить";
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(680, 62);
|
this.buttonAdd.Location = new System.Drawing.Point(680, 62);
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(90, 30);
|
this.buttonAdd.Size = new System.Drawing.Size(90, 30);
|
||||||
this.buttonAdd.TabIndex = 1;
|
this.buttonAdd.TabIndex = 1;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader;
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.id,
|
this.id,
|
||||||
this.Component,
|
this.Component,
|
||||||
this.Count});
|
this.Count});
|
||||||
this.dataGridView.Location = new System.Drawing.Point(7, 22);
|
this.dataGridView.Location = new System.Drawing.Point(7, 22);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(571, 302);
|
this.dataGridView.Size = new System.Drawing.Size(571, 302);
|
||||||
this.dataGridView.TabIndex = 0;
|
this.dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// id
|
// id
|
||||||
//
|
//
|
||||||
this.id.HeaderText = "id";
|
this.id.HeaderText = "id";
|
||||||
this.id.Name = "id";
|
this.id.Name = "id";
|
||||||
this.id.Visible = false;
|
this.id.Visible = false;
|
||||||
//
|
//
|
||||||
// Component
|
// Component
|
||||||
//
|
//
|
||||||
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
this.Component.FillWeight = 1000F;
|
this.Component.FillWeight = 1000F;
|
||||||
this.Component.HeaderText = "Компонент";
|
this.Component.HeaderText = "Компонент";
|
||||||
this.Component.Name = "Component";
|
this.Component.Name = "Component";
|
||||||
//
|
//
|
||||||
// Count
|
// Count
|
||||||
//
|
//
|
||||||
this.Count.HeaderText = "Количество";
|
this.Count.HeaderText = "Количество";
|
||||||
this.Count.Name = "Count";
|
this.Count.Name = "Count";
|
||||||
this.Count.Width = 97;
|
this.Count.Width = 97;
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
this.textBoxName.Location = new System.Drawing.Point(89, 9);
|
this.textBoxName.Location = new System.Drawing.Point(89, 9);
|
||||||
this.textBoxName.Name = "textBoxName";
|
this.textBoxName.Name = "textBoxName";
|
||||||
this.textBoxName.Size = new System.Drawing.Size(170, 23);
|
this.textBoxName.Size = new System.Drawing.Size(170, 23);
|
||||||
this.textBoxName.TabIndex = 3;
|
this.textBoxName.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// textBoxPrice
|
// textBoxPrice
|
||||||
//
|
//
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(89, 38);
|
this.textBoxPrice.Location = new System.Drawing.Point(89, 38);
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
this.textBoxPrice.Name = "textBoxPrice";
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(120, 23);
|
this.textBoxPrice.Size = new System.Drawing.Size(120, 23);
|
||||||
this.textBoxPrice.TabIndex = 4;
|
this.textBoxPrice.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(692, 403);
|
this.buttonCancel.Location = new System.Drawing.Point(692, 403);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(90, 35);
|
this.buttonCancel.Size = new System.Drawing.Size(90, 35);
|
||||||
this.buttonCancel.TabIndex = 5;
|
this.buttonCancel.TabIndex = 5;
|
||||||
this.buttonCancel.Text = "Отмена";
|
this.buttonCancel.Text = "Отмена";
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonSave.Location = new System.Drawing.Point(596, 403);
|
this.buttonSave.Location = new System.Drawing.Point(596, 403);
|
||||||
this.buttonSave.Name = "buttonSave";
|
this.buttonSave.Name = "buttonSave";
|
||||||
this.buttonSave.Size = new System.Drawing.Size(90, 35);
|
this.buttonSave.Size = new System.Drawing.Size(90, 35);
|
||||||
this.buttonSave.TabIndex = 6;
|
this.buttonSave.TabIndex = 6;
|
||||||
this.buttonSave.Text = "Сохранить";
|
this.buttonSave.Text = "Сохранить";
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
//
|
//
|
||||||
// FormPastry
|
// FormPastry
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
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(800, 450);
|
||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.textBoxPrice);
|
this.Controls.Add(this.textBoxPrice);
|
||||||
this.Controls.Add(this.textBoxName);
|
this.Controls.Add(this.textBoxName);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Name = "FormPastry";
|
this.Name = "FormPastry";
|
||||||
this.Text = "Кондитерское изделие";
|
this.Text = "Кондитерское изделие";
|
||||||
this.Load += new System.EventHandler(this.FormPastry_Load);
|
this.Load += new System.EventHandler(this.FormPastry_Load);
|
||||||
this.groupBox1.ResumeLayout(false);
|
this.groupBox1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private GroupBox groupBox1;
|
private GroupBox groupBox1;
|
||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private TextBox textBoxPrice;
|
private TextBox textBoxPrice;
|
||||||
private Button buttonRef;
|
private Button buttonRef;
|
||||||
private Button buttonDel;
|
private Button buttonDel;
|
||||||
private Button buttonUpd;
|
private Button buttonUpd;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn id;
|
private DataGridViewTextBoxColumn id;
|
||||||
private DataGridViewTextBoxColumn Component;
|
private DataGridViewTextBoxColumn Component;
|
||||||
private DataGridViewTextBoxColumn Count;
|
private DataGridViewTextBoxColumn Count;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,213 +1,207 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.DI;
|
||||||
using ConfectioneryContracts.SearchModels;
|
using ConfectioneryContracts.SearchModels;
|
||||||
using ConfectioneryDataModels.Models;
|
using ConfectioneryDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ConfectioneryView
|
namespace ConfectioneryView
|
||||||
{
|
{
|
||||||
public partial class FormPastry : Form
|
public partial class FormPastry : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IPastryLogic _logic;
|
private readonly IPastryLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
private Dictionary<int, (IComponentModel, int)> _pastryComponents;
|
private Dictionary<int, (IComponentModel, int)> _pastryComponents;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
public FormPastry(ILogger<FormPastry> logger, IPastryLogic logic)
|
public FormPastry(ILogger<FormPastry> logger, IPastryLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_pastryComponents = new Dictionary<int, (IComponentModel, int)>();
|
_pastryComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
}
|
}
|
||||||
private void FormPastry_Load(object sender, EventArgs e)
|
private void FormPastry_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка изделия");
|
_logger.LogInformation("Загрузка изделия");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var view = _logic.ReadElement(new PastrySearchModel
|
var view = _logic.ReadElement(new PastrySearchModel
|
||||||
{
|
{
|
||||||
Id = _id.Value
|
Id = _id.Value
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.PastryName;
|
textBoxName.Text = view.PastryName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
_pastryComponents = view.PastryComponents ?? new
|
_pastryComponents = view.PastryComponents ?? new
|
||||||
Dictionary<int, (IComponentModel, int)>();
|
Dictionary<int, (IComponentModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка компонент изделия");
|
_logger.LogInformation("Загрузка компонент изделия");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_pastryComponents != null)
|
if (_pastryComponents != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var pc in _pastryComponents)
|
foreach (var pc in _pastryComponents)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||||
}
|
}
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
textBoxPrice.Text = CalcPrice().ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormPastryComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
if (service is FormPastryComponent form)
|
{
|
||||||
{
|
if (form.ComponentModel == null)
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
{
|
||||||
{
|
return;
|
||||||
if (form.ComponentModel == null)
|
}
|
||||||
{
|
_logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}",
|
||||||
return;
|
form.ComponentModel.ComponentName, form.Count);
|
||||||
}
|
if (_pastryComponents.ContainsKey(form.Id))
|
||||||
_logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}",
|
{
|
||||||
form.ComponentModel.ComponentName, form.Count);
|
_pastryComponents[form.Id] = (form.ComponentModel,
|
||||||
if (_pastryComponents.ContainsKey(form.Id))
|
form.Count);
|
||||||
{
|
}
|
||||||
_pastryComponents[form.Id] = (form.ComponentModel,
|
else
|
||||||
form.Count);
|
{
|
||||||
}
|
_pastryComponents.Add(form.Id, (form.ComponentModel,
|
||||||
else
|
form.Count));
|
||||||
{
|
}
|
||||||
_pastryComponents.Add(form.Id, (form.ComponentModel,
|
LoadData();
|
||||||
form.Count));
|
}
|
||||||
}
|
}
|
||||||
LoadData();
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
}
|
{
|
||||||
}
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
}
|
{
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
var form = DependencyManager.Instance.Resolve<FormPastryComponent>();
|
||||||
{
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
form.Id = id;
|
||||||
{
|
form.Count = _pastryComponents[id].Item2;
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
if (service is FormPastryComponent form)
|
{
|
||||||
{
|
if (form.ComponentModel == null)
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
{
|
||||||
form.Id = id;
|
return;
|
||||||
form.Count = _pastryComponents[id].Item2;
|
}
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ",
|
||||||
{
|
form.ComponentModel.ComponentName, form.Count);
|
||||||
if (form.ComponentModel == null)
|
_pastryComponents[id] = (form.ComponentModel, form.Count);
|
||||||
{
|
LoadData();
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ",
|
}
|
||||||
form.ComponentModel.ComponentName, form.Count);
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
_pastryComponents[id] = (form.ComponentModel, form.Count);
|
{
|
||||||
LoadData();
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
}
|
{
|
||||||
}
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
}
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
}
|
{
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
try
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
_logger.LogInformation("Удаление компонента: { ComponentName}- { Count}",
|
||||||
{
|
dataGridView.SelectedRows[0].Cells[1].Value);
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
_pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
try
|
{
|
||||||
{
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
_logger.LogInformation("Удаление компонента: { ComponentName}- { Count}",
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
dataGridView.SelectedRows[0].Cells[1].Value);
|
}
|
||||||
_pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
}
|
||||||
MessageBox.Show(ex.Message, "Ошибка",
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
}
|
LoadData();
|
||||||
LoadData();
|
}
|
||||||
}
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
}
|
{
|
||||||
}
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
{
|
||||||
{
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
LoadData();
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
return;
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
}
|
||||||
{
|
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
{
|
||||||
{
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBox.Show("Заполните название", "Ошибка",
|
MessageBoxIcon.Error);
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (_pastryComponents == null || _pastryComponents.Count == 0)
|
||||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
{
|
||||||
{
|
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxIcon.Error);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
_logger.LogInformation("Сохранение изделия");
|
||||||
if (_pastryComponents == null || _pastryComponents.Count == 0)
|
try
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка",
|
var model = new PastryBindingModel
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
return;
|
Id = _id ?? 0,
|
||||||
}
|
PastryName = textBoxName.Text,
|
||||||
_logger.LogInformation("Сохранение изделия");
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
try
|
PastryComponents = _pastryComponents
|
||||||
{
|
};
|
||||||
var model = new PastryBindingModel
|
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||||
{
|
_logic.Create(model);
|
||||||
Id = _id ?? 0,
|
if (!operationResult)
|
||||||
PastryName = textBoxName.Text,
|
{
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
PastryComponents = _pastryComponents
|
}
|
||||||
};
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
_logic.Create(model);
|
DialogResult = DialogResult.OK;
|
||||||
if (!operationResult)
|
Close();
|
||||||
{
|
}
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
DialogResult = DialogResult.OK;
|
}
|
||||||
Close();
|
}
|
||||||
}
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
DialogResult = DialogResult.Cancel;
|
||||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
Close();
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
}
|
||||||
}
|
private double CalcPrice()
|
||||||
}
|
{
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
double price = 0;
|
||||||
{
|
foreach (var elem in _pastryComponents)
|
||||||
DialogResult = DialogResult.Cancel;
|
{
|
||||||
Close();
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
}
|
}
|
||||||
private double CalcPrice()
|
return Math.Round(price * 1.1, 2);
|
||||||
{
|
}
|
||||||
double price = 0;
|
}
|
||||||
foreach (var elem in _pastryComponents)
|
}
|
||||||
{
|
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
|
||||||
}
|
|
||||||
return Math.Round(price * 1.1, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,76 +4,76 @@ using ConfectioneryDataModels.Models;
|
|||||||
|
|
||||||
namespace ConfectioneryView
|
namespace ConfectioneryView
|
||||||
{
|
{
|
||||||
public partial class FormPastryComponent : Form
|
public partial class FormPastryComponent : Form
|
||||||
{
|
{
|
||||||
private readonly List<ComponentViewModel>? _list;
|
private readonly List<ComponentViewModel>? _list;
|
||||||
public int Id
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
comboBoxComponent.SelectedValue = value;
|
comboBoxComponent.SelectedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IComponentModel? ComponentModel
|
public IComponentModel? ComponentModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_list == null)
|
if (_list == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (var elem in _list)
|
foreach (var elem in _list)
|
||||||
{
|
{
|
||||||
if (elem.Id == Id)
|
if (elem.Id == Id)
|
||||||
{
|
{
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||||
set { textBoxCount.Text = value.ToString(); }
|
set { textBoxCount.Text = value.ToString(); }
|
||||||
}
|
}
|
||||||
public FormPastryComponent(IComponentLogic logic)
|
public FormPastryComponent(IComponentLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_list = logic.ReadList(null);
|
_list = logic.ReadList(null);
|
||||||
if (_list != null)
|
if (_list != null)
|
||||||
{
|
{
|
||||||
comboBoxComponent.DisplayMember = "ComponentName";
|
comboBoxComponent.DisplayMember = "ComponentName";
|
||||||
comboBoxComponent.ValueMember = "Id";
|
comboBoxComponent.ValueMember = "Id";
|
||||||
comboBoxComponent.DataSource = _list;
|
comboBoxComponent.DataSource = _list;
|
||||||
comboBoxComponent.SelectedItem = null;
|
comboBoxComponent.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxComponent.SelectedValue == null)
|
if (comboBoxComponent.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите компонент", "Ошибка",
|
MessageBox.Show("Выберите компонент", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
141
Confectionery/FormReportOrders.Designer.cs
generated
Normal file
141
Confectionery/FormReportOrders.Designer.cs
generated
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormReportOrders
|
||||||
|
{
|
||||||
|
/// <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.panel = new System.Windows.Forms.Panel();
|
||||||
|
this.buttonToPdf = new System.Windows.Forms.Button();
|
||||||
|
this.buttonMake = new System.Windows.Forms.Button();
|
||||||
|
this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.labelTo = new System.Windows.Forms.Label();
|
||||||
|
this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.labelFrom = new System.Windows.Forms.Label();
|
||||||
|
this.panel.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
this.panel.Controls.Add(this.buttonToPdf);
|
||||||
|
this.panel.Controls.Add(this.buttonMake);
|
||||||
|
this.panel.Controls.Add(this.dateTimePickerTo);
|
||||||
|
this.panel.Controls.Add(this.labelTo);
|
||||||
|
this.panel.Controls.Add(this.dateTimePickerFrom);
|
||||||
|
this.panel.Controls.Add(this.labelFrom);
|
||||||
|
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.panel.Name = "panel";
|
||||||
|
this.panel.Size = new System.Drawing.Size(1031, 40);
|
||||||
|
this.panel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonToPdf
|
||||||
|
//
|
||||||
|
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonToPdf.Location = new System.Drawing.Point(878, 8);
|
||||||
|
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.buttonToPdf.Name = "buttonToPdf";
|
||||||
|
this.buttonToPdf.Size = new System.Drawing.Size(139, 27);
|
||||||
|
this.buttonToPdf.TabIndex = 5;
|
||||||
|
this.buttonToPdf.Text = "В Pdf";
|
||||||
|
this.buttonToPdf.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
|
||||||
|
//
|
||||||
|
// buttonMake
|
||||||
|
//
|
||||||
|
this.buttonMake.Location = new System.Drawing.Point(476, 8);
|
||||||
|
this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.buttonMake.Name = "buttonMake";
|
||||||
|
this.buttonMake.Size = new System.Drawing.Size(139, 27);
|
||||||
|
this.buttonMake.TabIndex = 4;
|
||||||
|
this.buttonMake.Text = "Сформировать";
|
||||||
|
this.buttonMake.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
|
||||||
|
//
|
||||||
|
// dateTimePickerTo
|
||||||
|
//
|
||||||
|
this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7);
|
||||||
|
this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.dateTimePickerTo.Name = "dateTimePickerTo";
|
||||||
|
this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23);
|
||||||
|
this.dateTimePickerTo.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelTo
|
||||||
|
//
|
||||||
|
this.labelTo.AutoSize = true;
|
||||||
|
this.labelTo.Location = new System.Drawing.Point(208, 10);
|
||||||
|
this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelTo.Name = "labelTo";
|
||||||
|
this.labelTo.Size = new System.Drawing.Size(21, 15);
|
||||||
|
this.labelTo.TabIndex = 2;
|
||||||
|
this.labelTo.Text = "по";
|
||||||
|
//
|
||||||
|
// dateTimePickerFrom
|
||||||
|
//
|
||||||
|
this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7);
|
||||||
|
this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.dateTimePickerFrom.Name = "dateTimePickerFrom";
|
||||||
|
this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23);
|
||||||
|
this.dateTimePickerFrom.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelFrom
|
||||||
|
//
|
||||||
|
this.labelFrom.AutoSize = true;
|
||||||
|
this.labelFrom.Location = new System.Drawing.Point(14, 10);
|
||||||
|
this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelFrom.Name = "labelFrom";
|
||||||
|
this.labelFrom.Size = new System.Drawing.Size(15, 15);
|
||||||
|
this.labelFrom.TabIndex = 0;
|
||||||
|
this.labelFrom.Text = "С";
|
||||||
|
//
|
||||||
|
// FormReportOrders
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1031, 647);
|
||||||
|
this.Controls.Add(this.panel);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.Name = "FormReportOrders";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Заказы";
|
||||||
|
this.panel.ResumeLayout(false);
|
||||||
|
this.panel.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Panel panel;
|
||||||
|
private System.Windows.Forms.Button buttonToPdf;
|
||||||
|
private System.Windows.Forms.Button buttonMake;
|
||||||
|
private System.Windows.Forms.DateTimePicker dateTimePickerTo;
|
||||||
|
private System.Windows.Forms.Label labelTo;
|
||||||
|
private System.Windows.Forms.DateTimePicker dateTimePickerFrom;
|
||||||
|
private System.Windows.Forms.Label labelFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
91
Confectionery/FormReportOrders.cs
Normal file
91
Confectionery/FormReportOrders.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Reporting.WinForms;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormReportOrders : Form
|
||||||
|
{
|
||||||
|
private readonly ReportViewer reportViewer;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
reportViewer = new ReportViewer
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Fill
|
||||||
|
};
|
||||||
|
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
|
||||||
|
Controls.Clear();
|
||||||
|
Controls.Add(reportViewer);
|
||||||
|
Controls.Add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonMake_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dataSource = _logic.GetOrders(new ReportBindingModel
|
||||||
|
{
|
||||||
|
DateFrom = dateTimePickerFrom.Value,
|
||||||
|
DateTo = dateTimePickerTo.Value
|
||||||
|
});
|
||||||
|
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||||
|
reportViewer.LocalReport.DataSources.Clear();
|
||||||
|
reportViewer.LocalReport.DataSources.Add(source);
|
||||||
|
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
|
||||||
|
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
|
||||||
|
reportViewer.LocalReport.SetParameters(parameters);
|
||||||
|
|
||||||
|
reportViewer.RefreshReport();
|
||||||
|
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonToPdf_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName,
|
||||||
|
DateFrom = dateTimePickerFrom.Value,
|
||||||
|
DateTo = dateTimePickerTo.Value
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Confectionery/FormReportOrders.resx
Normal file
120
Confectionery/FormReportOrders.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?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>
|
||||||
113
Confectionery/FormReportPastryComponents.Designer.cs
generated
Normal file
113
Confectionery/FormReportPastryComponents.Designer.cs
generated
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormReportPastryComponents
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonSaveToExcel = new Button();
|
||||||
|
ColumnPastry = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnComponent = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AllowUserToOrderColumns = true;
|
||||||
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnPastry, ColumnComponent, ColumnCount });
|
||||||
|
dataGridView.Dock = DockStyle.Bottom;
|
||||||
|
dataGridView.Location = new Point(0, 47);
|
||||||
|
dataGridView.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.Size = new Size(616, 510);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSaveToExcel
|
||||||
|
//
|
||||||
|
buttonSaveToExcel.Location = new Point(14, 14);
|
||||||
|
buttonSaveToExcel.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||||
|
buttonSaveToExcel.Size = new Size(186, 27);
|
||||||
|
buttonSaveToExcel.TabIndex = 1;
|
||||||
|
buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||||
|
buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||||
|
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
|
||||||
|
//
|
||||||
|
// ColumnPastry
|
||||||
|
//
|
||||||
|
ColumnPastry.HeaderText = "Изделие";
|
||||||
|
ColumnPastry.Name = "ColumnPastry";
|
||||||
|
ColumnPastry.ReadOnly = true;
|
||||||
|
ColumnPastry.Width = 200;
|
||||||
|
//
|
||||||
|
// ColumnComponent
|
||||||
|
//
|
||||||
|
ColumnComponent.HeaderText = "Компонент";
|
||||||
|
ColumnComponent.Name = "ColumnComponent";
|
||||||
|
ColumnComponent.ReadOnly = true;
|
||||||
|
ColumnComponent.Width = 200;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// FormReportPastryComponents
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(616, 557);
|
||||||
|
Controls.Add(buttonSaveToExcel);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(4, 3, 4, 3);
|
||||||
|
Name = "FormReportPastryComponents";
|
||||||
|
Text = "Изделия с компонентами";
|
||||||
|
Load += FormReportPastryComponents_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.DataGridView dataGridView;
|
||||||
|
private System.Windows.Forms.Button buttonSaveToExcel;
|
||||||
|
private DataGridViewTextBoxColumn ColumnPastry;
|
||||||
|
private DataGridViewTextBoxColumn ColumnComponent;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
79
Confectionery/FormReportPastryComponents.cs
Normal file
79
Confectionery/FormReportPastryComponents.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.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 ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormReportPastryComponents : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportPastryComponents(ILogger<FormReportPastryComponents> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormReportPastryComponents_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dict = _logic.GetPastryComponent();
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var elem in dict)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" });
|
||||||
|
foreach (var listElem in elem.Components)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
|
}
|
||||||
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||||
|
dataGridView.Rows.Add(Array.Empty<object>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SavePastryComponentToExcelFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
133
Confectionery/FormSellPastry.Designer.cs
generated
133
Confectionery/FormSellPastry.Designer.cs
generated
@@ -1,133 +0,0 @@
|
|||||||
namespace ConfectioneryView
|
|
||||||
{
|
|
||||||
partial class FormSellPastry
|
|
||||||
{
|
|
||||||
/// <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.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.buttonSell = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// comboBoxPastry
|
|
||||||
//
|
|
||||||
this.comboBoxPastry.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.comboBoxPastry.FormattingEnabled = true;
|
|
||||||
this.comboBoxPastry.Location = new System.Drawing.Point(141, 12);
|
|
||||||
this.comboBoxPastry.Name = "comboBoxPastry";
|
|
||||||
this.comboBoxPastry.Size = new System.Drawing.Size(121, 23);
|
|
||||||
this.comboBoxPastry.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(123, 15);
|
|
||||||
this.label1.TabIndex = 1;
|
|
||||||
this.label1.Text = "Изделие на продажу:";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(60, 46);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.label2.TabIndex = 2;
|
|
||||||
this.label2.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// numericUpDownCount
|
|
||||||
//
|
|
||||||
this.numericUpDownCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.numericUpDownCount.Location = new System.Drawing.Point(142, 46);
|
|
||||||
this.numericUpDownCount.Maximum = new decimal(new int[] {
|
|
||||||
10000000,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
|
||||||
this.numericUpDownCount.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
|
||||||
this.numericUpDownCount.Size = new System.Drawing.Size(120, 23);
|
|
||||||
this.numericUpDownCount.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonSell
|
|
||||||
//
|
|
||||||
this.buttonSell.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonSell.Location = new System.Drawing.Point(12, 90);
|
|
||||||
this.buttonSell.Name = "buttonSell";
|
|
||||||
this.buttonSell.Size = new System.Drawing.Size(123, 23);
|
|
||||||
this.buttonSell.TabIndex = 4;
|
|
||||||
this.buttonSell.Text = "Продать";
|
|
||||||
this.buttonSell.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(142, 90);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(123, 23);
|
|
||||||
this.buttonCancel.TabIndex = 5;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormSellPastry
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(277, 122);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSell);
|
|
||||||
this.Controls.Add(this.numericUpDownCount);
|
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.comboBoxPastry);
|
|
||||||
this.Name = "FormSellPastry";
|
|
||||||
this.Text = "Продажа изделия";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox comboBoxPastry;
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
|
||||||
private NumericUpDown numericUpDownCount;
|
|
||||||
private Button buttonSell;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
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 ConfectioneryView
|
|
||||||
{
|
|
||||||
public partial class FormSellPastry : Form
|
|
||||||
{
|
|
||||||
private readonly IShopLogic _shopLogic;
|
|
||||||
private readonly IPastryLogic _pastryLogic;
|
|
||||||
|
|
||||||
public FormSellPastry(IPastryLogic logic, IShopLogic shopLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_pastryLogic = logic;
|
|
||||||
_shopLogic = shopLogic;
|
|
||||||
var list = logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxPastry.DisplayMember = "PastryName";
|
|
||||||
comboBoxPastry.ValueMember = "Id";
|
|
||||||
comboBoxPastry.DataSource = list;
|
|
||||||
comboBoxPastry.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSell_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxPastry.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (numericUpDownCount.Value <= 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Количество должно быть больше нуля", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var count = (int)numericUpDownCount.Value;
|
|
||||||
var pastry = _pastryLogic.ReadElement(new() { Id = (int)comboBoxPastry.SelectedValue });
|
|
||||||
if (pastry == null || !_shopLogic.SellPastries(pastry, count))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось продать изделия. Информацию смотрите в логах", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
217
Confectionery/FormShop.Designer.cs
generated
217
Confectionery/FormShop.Designer.cs
generated
@@ -1,217 +0,0 @@
|
|||||||
namespace ConfectioneryView
|
|
||||||
{
|
|
||||||
partial class FormShop
|
|
||||||
{
|
|
||||||
/// <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.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.PastryName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxDateOpening = new System.Windows.Forms.TextBox();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
|
||||||
this.numericUpDownMaxPastry = new System.Windows.Forms.NumericUpDown();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxPastry)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(116, 15);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Название магазина:";
|
|
||||||
//
|
|
||||||
// comboBoxShop
|
|
||||||
//
|
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(12, 27);
|
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(141, 23);
|
|
||||||
this.comboBoxShop.TabIndex = 1;
|
|
||||||
this.comboBoxShop.SelectedIndexChanged += new System.EventHandler(this.ComboBoxShop_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.PastryName,
|
|
||||||
this.Price,
|
|
||||||
this.Count});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 64);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(640, 213);
|
|
||||||
this.dataGridView.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// PastryName
|
|
||||||
//
|
|
||||||
this.PastryName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.PastryName.HeaderText = "Имя изделия";
|
|
||||||
this.PastryName.Name = "PastryName";
|
|
||||||
//
|
|
||||||
// Price
|
|
||||||
//
|
|
||||||
this.Price.HeaderText = "Цена";
|
|
||||||
this.Price.Name = "Price";
|
|
||||||
//
|
|
||||||
// Count
|
|
||||||
//
|
|
||||||
this.Count.HeaderText = "Количество";
|
|
||||||
this.Count.Name = "Count";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(159, 9);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(97, 15);
|
|
||||||
this.label2.TabIndex = 3;
|
|
||||||
this.label2.Text = "Адрес магазина:";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
this.label3.AutoSize = true;
|
|
||||||
this.label3.Location = new System.Drawing.Point(366, 9);
|
|
||||||
this.label3.Name = "label3";
|
|
||||||
this.label3.Size = new System.Drawing.Size(100, 15);
|
|
||||||
this.label3.TabIndex = 4;
|
|
||||||
this.label3.Text = "Время открытия:";
|
|
||||||
//
|
|
||||||
// textBoxAddress
|
|
||||||
//
|
|
||||||
this.textBoxAddress.Location = new System.Drawing.Point(159, 27);
|
|
||||||
this.textBoxAddress.Name = "textBoxAddress";
|
|
||||||
this.textBoxAddress.Size = new System.Drawing.Size(201, 23);
|
|
||||||
this.textBoxAddress.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// textBoxDateOpening
|
|
||||||
//
|
|
||||||
this.textBoxDateOpening.Location = new System.Drawing.Point(366, 27);
|
|
||||||
this.textBoxDateOpening.Name = "textBoxDateOpening";
|
|
||||||
this.textBoxDateOpening.Size = new System.Drawing.Size(160, 23);
|
|
||||||
this.textBoxDateOpening.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(549, 283);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(103, 23);
|
|
||||||
this.buttonCancel.TabIndex = 7;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(423, 284);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(120, 22);
|
|
||||||
this.buttonSave.TabIndex = 8;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
this.label4.AutoSize = true;
|
|
||||||
this.label4.Location = new System.Drawing.Point(530, 9);
|
|
||||||
this.label4.Name = "label4";
|
|
||||||
this.label4.Size = new System.Drawing.Size(118, 15);
|
|
||||||
this.label4.TabIndex = 9;
|
|
||||||
this.label4.Text = "Максимум изделий:";
|
|
||||||
//
|
|
||||||
// numericUpDownMaxPastry
|
|
||||||
//
|
|
||||||
this.numericUpDownMaxPastry.Location = new System.Drawing.Point(532, 27);
|
|
||||||
this.numericUpDownMaxPastry.Maximum = new decimal(new int[] {
|
|
||||||
10000000,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.numericUpDownMaxPastry.Name = "numericUpDownMaxPastry";
|
|
||||||
this.numericUpDownMaxPastry.Size = new System.Drawing.Size(120, 23);
|
|
||||||
this.numericUpDownMaxPastry.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// FormShop
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(664, 317);
|
|
||||||
this.Controls.Add(this.numericUpDownMaxPastry);
|
|
||||||
this.Controls.Add(this.label4);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.textBoxDateOpening);
|
|
||||||
this.Controls.Add(this.textBoxAddress);
|
|
||||||
this.Controls.Add(this.label3);
|
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.comboBoxShop);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Name = "FormShop";
|
|
||||||
this.Text = "Просмотр изделий магазина";
|
|
||||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxPastry)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxShop;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
|
||||||
private TextBox textBoxAddress;
|
|
||||||
private TextBox textBoxDateOpening;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private DataGridViewTextBoxColumn PastryName;
|
|
||||||
private DataGridViewTextBoxColumn Price;
|
|
||||||
private DataGridViewTextBoxColumn Count;
|
|
||||||
private Label label4;
|
|
||||||
private NumericUpDown numericUpDownMaxPastry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
||||||
using ConfectioneryContracts.ViewModels;
|
|
||||||
using ConfectioneryDataModels;
|
|
||||||
using ConfectioneryDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ConfectioneryView
|
|
||||||
{
|
|
||||||
public partial class FormShop : Form
|
|
||||||
{
|
|
||||||
private readonly List<ShopViewModel>? _listShops;
|
|
||||||
private readonly IShopLogic _logic;
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IShopModel? GetShop(int id)
|
|
||||||
{
|
|
||||||
if (_listShops == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _listShops)
|
|
||||||
{
|
|
||||||
if (elem.Id == id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_listShops = logic.ReadList(null);
|
|
||||||
_logic = logic;
|
|
||||||
if (_listShops != null)
|
|
||||||
{
|
|
||||||
comboBoxShop.DisplayMember = "Name";
|
|
||||||
comboBoxShop.ValueMember = "Id";
|
|
||||||
comboBoxShop.DataSource = _listShops;
|
|
||||||
comboBoxShop.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData(bool extendDate = true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = GetShop(extendDate ? Id : Convert.ToInt32(comboBoxShop.SelectedValue));
|
|
||||||
if (model != null)
|
|
||||||
{
|
|
||||||
numericUpDownMaxPastry.Value = model.MaxCountPastries;
|
|
||||||
comboBoxShop.Text = model.Name;
|
|
||||||
textBoxAddress.Text = model.Address;
|
|
||||||
textBoxDateOpening.Text = Convert.ToString(model.DateOpening);
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var el in model.Pastries.Values)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[]{el.Item1.PastryName, el.Item1.Price, el.Item2 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка магазинов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComboBoxShop_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(comboBoxShop.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime.TryParse(textBoxDateOpening.Text, out var dateTime);
|
|
||||||
ShopBindingModel model = new()
|
|
||||||
{
|
|
||||||
Name = comboBoxShop.Text,
|
|
||||||
Address = textBoxAddress.Text,
|
|
||||||
DateOpening = dateTime,
|
|
||||||
MaxCountPastries = (int)numericUpDownMaxPastry.Value,
|
|
||||||
};
|
|
||||||
var vmodel = GetShop(Id);
|
|
||||||
bool operationResult = false;
|
|
||||||
|
|
||||||
if (vmodel != null)
|
|
||||||
{
|
|
||||||
model.Id = vmodel.Id;
|
|
||||||
operationResult = _logic.Update(model);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
operationResult = _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();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormShop_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
90
Confectionery/FormViewClients.Designer.cs
generated
Normal file
90
Confectionery/FormViewClients.Designer.cs
generated
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormViewClients
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonRef = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonRef.Location = new Point(626, 67);
|
||||||
|
buttonRef.Name = "buttonRef";
|
||||||
|
buttonRef.Size = new Size(90, 37);
|
||||||
|
buttonRef.TabIndex = 9;
|
||||||
|
buttonRef.Text = "Обновить";
|
||||||
|
buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
buttonRef.Click += ButtonRef_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonDel.Location = new Point(626, 12);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(90, 33);
|
||||||
|
buttonDel.TabIndex = 8;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.Size = new Size(553, 302);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormViewClients
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(722, 319);
|
||||||
|
Controls.Add(buttonRef);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormViewClients";
|
||||||
|
Text = "Просмотри и удаление клиентов";
|
||||||
|
Load += FormViewClients_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
||||||
78
Confectionery/FormViewClients.cs
Normal file
78
Confectionery/FormViewClients.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.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 ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormViewClients : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientLogic _logic;
|
||||||
|
public FormViewClients(ILogger<FormViewClients> logger, IClientLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormViewClients_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 ClientBindingModel
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
Confectionery/FormViewImplementers.Designer.cs
generated
Normal file
118
Confectionery/FormViewImplementers.Designer.cs
generated
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormViewImplementers
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonRef = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonRef.Location = new Point(626, 202);
|
||||||
|
buttonRef.Name = "buttonRef";
|
||||||
|
buttonRef.Size = new Size(90, 37);
|
||||||
|
buttonRef.TabIndex = 9;
|
||||||
|
buttonRef.Text = "Обновить";
|
||||||
|
buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
buttonRef.Click += ButtonRef_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonDel.Location = new Point(626, 151);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(90, 33);
|
||||||
|
buttonDel.TabIndex = 8;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonUpd.Location = new Point(626, 102);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(90, 34);
|
||||||
|
buttonUpd.TabIndex = 7;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonAdd.Location = new Point(626, 57);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(90, 30);
|
||||||
|
buttonAdd.TabIndex = 6;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.Size = new Size(553, 302);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormViewImplementers
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(722, 319);
|
||||||
|
Controls.Add(buttonRef);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormViewImplementers";
|
||||||
|
Text = "Просмотр списка исполнителей";
|
||||||
|
Load += FormViewImplementers_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
||||||
100
Confectionery/FormViewImplementers.cs
Normal file
100
Confectionery/FormViewImplementers.cs
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.DI;
|
||||||
|
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 ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormViewImplementers : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public FormViewImplementers(ILogger<FormViewImplementers> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormViewImplementers_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
|
_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 form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
|
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 ImplementerBindingModel
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,22 +57,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="PastryName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="PastryName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
62
Confectionery/FormViewMail.Designer.cs
generated
Normal file
62
Confectionery/FormViewMail.Designer.cs
generated
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormViewMail
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.Size = new Size(803, 450);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// FormViewMail
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormViewMail";
|
||||||
|
Text = "Письма";
|
||||||
|
Load += FormViewMail_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
Confectionery/FormViewMail.cs
Normal file
43
Confectionery/FormViewMail.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using ConfectioneryBusinessLogic.MailWorker;
|
||||||
|
using ConfectioneryContracts.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 ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormViewMail : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
|
||||||
|
public FormViewMail(ILogger<FormViewMail> logger, IMessageInfoLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormViewMail_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
|
_logger.LogInformation("Загрузка списка писем");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки писем");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Confectionery/FormViewMail.resx
Normal file
60
Confectionery/FormViewMail.resx
Normal 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>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using ConfectioneryContracts.BindingModels;
|
using ConfectioneryContracts.BindingModels;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -31,15 +32,7 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["PastryComponents"].Visible = false;
|
|
||||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
_logger.LogInformation("Загрузка изделий");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -51,28 +44,23 @@ namespace ConfectioneryView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
|
var form = DependencyManager.Instance.Resolve<FormPastry>();
|
||||||
if (service is FormPastry form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
|
var form = DependencyManager.Instance.Resolve<FormPastry>();
|
||||||
if (service is FormPastry form)
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
LoadData();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
|||||||
121
Confectionery/FormViewShops.Designer.cs
generated
121
Confectionery/FormViewShops.Designer.cs
generated
@@ -1,121 +0,0 @@
|
|||||||
namespace ConfectioneryView
|
|
||||||
{
|
|
||||||
partial class FormViewShops
|
|
||||||
{
|
|
||||||
/// <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.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(685, 202);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(90, 37);
|
|
||||||
this.buttonRef.TabIndex = 14;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDel.Location = new System.Drawing.Point(685, 151);
|
|
||||||
this.buttonDel.Name = "buttonDel";
|
|
||||||
this.buttonDel.Size = new System.Drawing.Size(90, 33);
|
|
||||||
this.buttonDel.TabIndex = 13;
|
|
||||||
this.buttonDel.Text = "Удалить";
|
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(685, 102);
|
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(90, 34);
|
|
||||||
this.buttonUpd.TabIndex = 12;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(685, 57);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(90, 30);
|
|
||||||
this.buttonAdd.TabIndex = 11;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(540, 379);
|
|
||||||
this.dataGridView.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// FormViewShops
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(787, 403);
|
|
||||||
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 = "FormViewShops";
|
|
||||||
this.Text = "Просмотр магазинов";
|
|
||||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user