it's f****n' working
This commit is contained in:
parent
83f78b7334
commit
fa66a3def9
@ -4,21 +4,23 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopBusinessLogic.BusinessLogics
|
namespace BookShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class AuthorLogic : IAuthorLogic
|
public class AuthorLogic : IAuthorLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IAuthorStorage _authorStorage;
|
private readonly IAuthorStorage _authorStorage;
|
||||||
|
|
||||||
public AuthorLogic(ILogger<AuthorLogic> logger, IAuthorStorage authorStorage)
|
public AuthorLogic(ILogger<AuthorLogic> logger, IAuthorStorage authorStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_authorStorage = authorStorage;
|
_authorStorage = authorStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(AuthorBindingModel model)
|
public bool Create(AuthorBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
@ -4,21 +4,23 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopBusinessLogic.BusinessLogics
|
namespace BookShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class BookLogic : IBookLogic
|
public class BookLogic : IBookLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IBookStorage _bookStorage;
|
private readonly IBookStorage _bookStorage;
|
||||||
|
|
||||||
public BookLogic(ILogger<BookLogic> logger, IBookStorage bookStorage)
|
public BookLogic(ILogger<BookLogic> logger, IBookStorage bookStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_bookStorage = bookStorage;
|
_bookStorage = bookStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(BookBindingModel model)
|
public bool Create(BookBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
@ -81,7 +83,6 @@ namespace BookShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return _bookStorage.TestReadList(num);
|
return _bookStorage.TestReadList(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(BookBindingModel model)
|
public bool Update(BookBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
@ -4,21 +4,23 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopBusinessLogic.BusinessLogics
|
namespace BookShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ClientLogic : IClientLogic
|
public class ClientLogic : IClientLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IClientStorage _clientStorage;
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_clientStorage = clientStorage;
|
_clientStorage = clientStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(ClientBindingModel model)
|
public bool Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
@ -5,20 +5,23 @@ using BookShopContracts.StoragesContracts;
|
|||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopBusinessLogic.BusinessLogics
|
namespace BookShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class GenreLogic : IGenreLogic
|
public class GenreLogic : IGenreLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IGenreStorage _genreStorage;
|
private readonly IGenreStorage _genreStorage;
|
||||||
public GenreLogic(ILogger<GenreLogic> logger, IGenreStorage genreStorage)
|
public GenreLogic(ILogger<GenreLogic> logger, IGenreStorage genreStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_genreStorage = genreStorage;
|
_genreStorage = genreStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(GenreBindingModel model)
|
public bool Create(GenreBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
@ -4,13 +4,17 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopBusinessLogic.BusinessLogics
|
namespace BookShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class OrderLogic : IOrderLogic
|
public class OrderLogic : IOrderLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||||
@ -75,7 +79,6 @@ namespace BookShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. Id: { BookId}", model.Id, model.Sum, model.BookId);
|
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. Id: { BookId}", model.Id, model.Sum, model.BookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BindingModels
|
namespace BookShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class AuthorBindingModel : IAuthorModel
|
public class AuthorBindingModel : IAuthorModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string AuthorSurname { get; set; } = string.Empty;
|
public string AuthorSurname { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string AuthorName { get; set; } = string.Empty;
|
public string AuthorName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string AuthorPatronymic { get; set; } = string.Empty;
|
public string AuthorPatronymic { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BindingModels
|
namespace BookShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
@ -7,18 +12,13 @@ namespace BookShopContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
|
|
||||||
public string BookName { get; set; } = string.Empty;
|
public string BookName { get; set; } = string.Empty;
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Стоимость")]
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Жанр")]
|
[DisplayName("Жанр")]
|
||||||
|
|
||||||
public int GenreId { get; set; }
|
public int GenreId { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, IAuthorModel> BookAuthors
|
public Dictionary<int, IAuthorModel> BookAuthors
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BindingModels
|
namespace BookShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class ClientBindingModel : IClientModel
|
public class ClientBindingModel : IClientModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string ClientSurname { get; set; } = string.Empty;
|
public string ClientSurname { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string ClientName { get; set; } = string.Empty;
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string ClientPatronymic { get; set; } = string.Empty;
|
public string ClientPatronymic { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BindingModels
|
namespace BookShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class GenreBindingModel : IGenreModel
|
public class GenreBindingModel : IGenreModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string GenreName { get; set; } = string.Empty;
|
public string GenreName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,21 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BindingModels
|
namespace BookShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class OrderBindingModel : IOrderModel
|
public class OrderBindingModel : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int BookId { get; set; }
|
public int BookId { get; set; }
|
||||||
|
|
||||||
public string BookName { get; set; } = string.Empty;
|
public string BookName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
public string ClientName { get; set; } = string.Empty;
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BusinessLogicsContracts
|
namespace BookShopContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IAuthorLogic
|
public interface IAuthorLogic
|
||||||
{
|
{
|
||||||
List<AuthorViewModel>? ReadList(AuthorSearchModel? model);
|
List<AuthorViewModel>? ReadList(AuthorSearchModel? model);
|
||||||
|
|
||||||
AuthorViewModel? ReadElement(AuthorSearchModel model);
|
AuthorViewModel? ReadElement(AuthorSearchModel model);
|
||||||
|
|
||||||
bool Create(AuthorBindingModel model);
|
bool Create(AuthorBindingModel model);
|
||||||
|
|
||||||
bool Update(AuthorBindingModel model);
|
bool Update(AuthorBindingModel model);
|
||||||
|
|
||||||
bool Delete(AuthorBindingModel model);
|
bool Delete(AuthorBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BusinessLogicsContracts
|
namespace BookShopContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IBookLogic
|
public interface IBookLogic
|
||||||
{
|
{
|
||||||
List<BookViewModel>? ReadList(BookSearchModel? model);
|
List<BookViewModel>? ReadList(BookSearchModel? model);
|
||||||
|
|
||||||
BookViewModel? ReadElement(BookSearchModel model);
|
BookViewModel? ReadElement(BookSearchModel model);
|
||||||
|
|
||||||
bool Create(BookBindingModel model);
|
bool Create(BookBindingModel model);
|
||||||
|
|
||||||
bool Update(BookBindingModel model);
|
bool Update(BookBindingModel model);
|
||||||
|
|
||||||
bool Delete(BookBindingModel model);
|
bool Delete(BookBindingModel model);
|
||||||
|
|
||||||
string TestInsertList(int num);
|
string TestInsertList(int num);
|
||||||
|
|
||||||
string TestReadList(int num);
|
string TestReadList(int num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BusinessLogicsContracts
|
namespace BookShopContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IClientLogic
|
public interface IClientLogic
|
||||||
{
|
{
|
||||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||||
|
|
||||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||||
|
|
||||||
bool Create(ClientBindingModel model);
|
bool Create(ClientBindingModel model);
|
||||||
|
|
||||||
bool Update(ClientBindingModel model);
|
bool Update(ClientBindingModel model);
|
||||||
|
|
||||||
bool Delete(ClientBindingModel model);
|
bool Delete(ClientBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BusinessLogicsContracts
|
namespace BookShopContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IGenreLogic
|
public interface IGenreLogic
|
||||||
{
|
{
|
||||||
List<GenreViewModel>? ReadList(GenreSearchModel? model);
|
List<GenreViewModel>? ReadList(GenreSearchModel? model);
|
||||||
|
|
||||||
GenreViewModel? ReadElement(GenreSearchModel model);
|
GenreViewModel? ReadElement(GenreSearchModel model);
|
||||||
|
|
||||||
bool Create(GenreBindingModel model);
|
bool Create(GenreBindingModel model);
|
||||||
|
|
||||||
bool Update(GenreBindingModel model);
|
bool Update(GenreBindingModel model);
|
||||||
|
|
||||||
bool Delete(GenreBindingModel model);
|
bool Delete(GenreBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.BusinessLogicsContracts
|
namespace BookShopContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IOrderLogic
|
public interface IOrderLogic
|
||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
|
|
||||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||||
|
|
||||||
bool Create(OrderBindingModel model);
|
bool Create(OrderBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
namespace BookShopContracts.SearchModels
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class AuthorSearchModel
|
public class AuthorSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? AuthorSurname { get; set; }
|
public string? AuthorSurname { get; set; }
|
||||||
|
|
||||||
public string? AuthorName { get; set; }
|
public string? AuthorName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
namespace BookShopContracts.SearchModels
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class BookSearchModel
|
public class BookSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? BookName { get; set; }
|
public string? BookName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
namespace BookShopContracts.SearchModels
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class ClientSearchModel
|
public class ClientSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? ClientSurname { get; set; }
|
public string? ClientSurname { get; set; }
|
||||||
|
|
||||||
public string? ClientName { get; set; }
|
public string? ClientName { get; set; }
|
||||||
|
|
||||||
public string? ClientPatronymic { get; set; }
|
public string? ClientPatronymic { get; set; }
|
||||||
|
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
namespace BookShopContracts.SearchModels
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class GenreSearchModel
|
public class GenreSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? GenreName { get; set; }
|
public string? GenreName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
namespace BookShopContracts.SearchModels
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class OrderSearchModel
|
public class OrderSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
public DateTime? DateCreate { get; set; }
|
public DateTime? DateCreate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.StoragesContracts
|
namespace BookShopContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IAuthorStorage
|
public interface IAuthorStorage
|
||||||
{
|
{
|
||||||
List<AuthorViewModel> GetFullList();
|
List<AuthorViewModel> GetFullList();
|
||||||
|
|
||||||
List<AuthorViewModel> GetFilteredList(AuthorSearchModel model);
|
List<AuthorViewModel> GetFilteredList(AuthorSearchModel model);
|
||||||
|
|
||||||
AuthorViewModel? GetElement(AuthorSearchModel model);
|
AuthorViewModel? GetElement(AuthorSearchModel model);
|
||||||
|
|
||||||
AuthorViewModel? Insert(AuthorBindingModel model);
|
AuthorViewModel? Insert(AuthorBindingModel model);
|
||||||
|
|
||||||
AuthorViewModel? Update(AuthorBindingModel model);
|
AuthorViewModel? Update(AuthorBindingModel model);
|
||||||
|
|
||||||
AuthorViewModel? Delete(AuthorBindingModel model);
|
AuthorViewModel? Delete(AuthorBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.StoragesContracts
|
namespace BookShopContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IBookStorage
|
public interface IBookStorage
|
||||||
{
|
{
|
||||||
List<BookViewModel> GetFullList();
|
List<BookViewModel> GetFullList();
|
||||||
|
|
||||||
List<BookViewModel> GetFilteredList(BookSearchModel model);
|
List<BookViewModel> GetFilteredList(BookSearchModel model);
|
||||||
|
|
||||||
BookViewModel? GetElement(BookSearchModel model);
|
BookViewModel? GetElement(BookSearchModel model);
|
||||||
|
|
||||||
BookViewModel? Insert(BookBindingModel model);
|
BookViewModel? Insert(BookBindingModel model);
|
||||||
|
|
||||||
BookViewModel? Update(BookBindingModel model);
|
BookViewModel? Update(BookBindingModel model);
|
||||||
|
|
||||||
BookViewModel? Delete(BookBindingModel model);
|
BookViewModel? Delete(BookBindingModel model);
|
||||||
|
|
||||||
string TestInsertList(int num);
|
string TestInsertList(int num);
|
||||||
|
|
||||||
string TestReadList(int num);
|
string TestReadList(int num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.StoragesContracts
|
namespace BookShopContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IClientStorage
|
public interface IClientStorage
|
||||||
{
|
{
|
||||||
List<ClientViewModel> GetFullList();
|
List<ClientViewModel> GetFullList();
|
||||||
|
|
||||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||||
|
|
||||||
ClientViewModel? GetElement(ClientSearchModel model);
|
ClientViewModel? GetElement(ClientSearchModel model);
|
||||||
|
|
||||||
ClientViewModel? Insert(ClientBindingModel model);
|
ClientViewModel? Insert(ClientBindingModel model);
|
||||||
|
|
||||||
ClientViewModel? Update(ClientBindingModel model);
|
ClientViewModel? Update(ClientBindingModel model);
|
||||||
|
|
||||||
ClientViewModel? Delete(ClientBindingModel model);
|
ClientViewModel? Delete(ClientBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.StoragesContracts
|
namespace BookShopContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IGenreStorage
|
public interface IGenreStorage
|
||||||
{
|
{
|
||||||
List<GenreViewModel> GetFullList();
|
List<GenreViewModel> GetFullList();
|
||||||
|
|
||||||
List<GenreViewModel> GetFilteredList(GenreSearchModel model);
|
List<GenreViewModel> GetFilteredList(GenreSearchModel model);
|
||||||
|
|
||||||
GenreViewModel? GetElement(GenreSearchModel model);
|
GenreViewModel? GetElement(GenreSearchModel model);
|
||||||
|
|
||||||
GenreViewModel? Insert(GenreBindingModel model);
|
GenreViewModel? Insert(GenreBindingModel model);
|
||||||
|
|
||||||
GenreViewModel? Update(GenreBindingModel model);
|
GenreViewModel? Update(GenreBindingModel model);
|
||||||
|
|
||||||
GenreViewModel? Delete(GenreBindingModel model);
|
GenreViewModel? Delete(GenreBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.SearchModels;
|
using BookShopContracts.SearchModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.StoragesContracts
|
namespace BookShopContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IOrderStorage
|
public interface IOrderStorage
|
||||||
{
|
{
|
||||||
List<OrderViewModel> GetFullList();
|
List<OrderViewModel> GetFullList();
|
||||||
|
|
||||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||||
|
|
||||||
OrderViewModel? GetElement(OrderSearchModel model);
|
OrderViewModel? GetElement(OrderSearchModel model);
|
||||||
|
|
||||||
OrderViewModel? Insert(OrderBindingModel model);
|
OrderViewModel? Insert(OrderBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.ViewModels
|
namespace BookShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
@ -7,13 +12,10 @@ namespace BookShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Фамилия автора")]
|
[DisplayName("Фамилия автора")]
|
||||||
|
|
||||||
public string AuthorSurname { get; set; } = string.Empty;
|
public string AuthorSurname { get; set; } = string.Empty;
|
||||||
[DisplayName("Имя автора")]
|
[DisplayName("Имя автора")]
|
||||||
|
|
||||||
public string AuthorName { get; set; } = string.Empty;
|
public string AuthorName { get; set; } = string.Empty;
|
||||||
[DisplayName("Отчество автора")]
|
[DisplayName("Отчество автора")]
|
||||||
|
|
||||||
public string AuthorPatronymic { get; set; } = string.Empty;
|
public string AuthorPatronymic { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.ViewModels
|
namespace BookShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
@ -7,18 +12,12 @@ namespace BookShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
|
|
||||||
public string BookName { get; set; } = string.Empty;
|
public string BookName { get; set; } = string.Empty;
|
||||||
[DisplayName("Стоимость")]
|
[DisplayName("Стоимость")]
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public int GenreId { get; set; }
|
public int GenreId { get; set; }
|
||||||
|
|
||||||
public string GenreName { get; set; } = string.Empty;
|
public string GenreName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Dictionary<int, IAuthorModel> BookAuthors { get; set; } = new();
|
public Dictionary<int, IAuthorModel> BookAuthors { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
using BookShopContracts.BusinessLogicsContracts;
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.ViewModels
|
namespace BookShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
@ -8,16 +13,12 @@ namespace BookShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Фамилия клиента")]
|
[DisplayName("Фамилия клиента")]
|
||||||
|
|
||||||
public string ClientSurname { get; set; } = string.Empty;
|
public string ClientSurname { get; set; } = string.Empty;
|
||||||
[DisplayName("Имя клиента")]
|
[DisplayName("Имя клиента")]
|
||||||
|
|
||||||
public string ClientName { get; set; } = string.Empty;
|
public string ClientName { get; set; } = string.Empty;
|
||||||
[DisplayName("Отчество клиента")]
|
[DisplayName("Отчество клиента")]
|
||||||
|
|
||||||
public string ClientPatronymic { get; set; } = string.Empty;
|
public string ClientPatronymic { get; set; } = string.Empty;
|
||||||
[DisplayName("Электронная почта клиента")]
|
[DisplayName("Почта клиента")]
|
||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.ViewModels
|
namespace BookShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
@ -7,7 +12,6 @@ namespace BookShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Жанр")]
|
[DisplayName("Жанр")]
|
||||||
|
|
||||||
public string GenreName { get; set; } = string.Empty;
|
public string GenreName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,27 @@
|
|||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopContracts.ViewModels
|
namespace BookShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel: IOrderModel
|
public class OrderViewModel: IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int BookId { get; set; }
|
public int BookId { get; set; }
|
||||||
[DisplayName("Название книги")]
|
[DisplayName("Название книги")]
|
||||||
|
|
||||||
public string BookName { get; set; } = string.Empty;
|
public string BookName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[DisplayName("Фамилия клиента")]
|
[DisplayName("Фамилия клиента")]
|
||||||
|
|
||||||
public string ClientSurname {get; set; } = string.Empty;
|
public string ClientSurname {get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
|
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Дата заказа")]
|
[DisplayName("Дата заказа")]
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
@ -19,4 +20,10 @@
|
|||||||
<ProjectReference Include="..\BookShopContracts\BookShopContracts.csproj" />
|
<ProjectReference Include="..\BookShopContracts\BookShopContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="BookShopDatabase.cs">
|
||||||
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -9,7 +9,7 @@ namespace BookShopDataBaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseNpgsql(@"Host=192.168.56.101;Port=5432;Database=SUBD_Lab2;Username=postgres;Password=postgres");
|
optionsBuilder.UseNpgsql(@"Host=192.168.56.101;Port=5432;Database=BookShopOnline;Username=postgres;Password=1092010");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,11 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataBaseImplement.Models;
|
using BookShopDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Implements
|
namespace BookShopDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,12 @@ using BookShopContracts.StoragesContracts;
|
|||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataBaseImplement.Models;
|
using BookShopDataBaseImplement.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Implements
|
namespace BookShopDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,11 @@ using BookShopContracts.SearchModels;
|
|||||||
using BookShopContracts.StoragesContracts;
|
using BookShopContracts.StoragesContracts;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataBaseImplement.Models;
|
using BookShopDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Implements
|
namespace BookShopDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,12 @@ using BookShopContracts.StoragesContracts;
|
|||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataBaseImplement.Models;
|
using BookShopDataBaseImplement.Models;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Implements
|
namespace BookShopDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace BookShopDataBaseImplement.Migrations
|
namespace BookShopDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(BookShopDatabase))]
|
[DbContext(typeof(BookShopDatabase))]
|
||||||
[Migration("20230512083316_Initial")]
|
[Migration("20230513100358_Sec")]
|
||||||
partial class Initial
|
partial class Sec
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace BookShopDataBaseImplement.Migrations
|
namespace BookShopDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Initial : Migration
|
public partial class Sec : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
@ -1,8 +1,13 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
using BookShopContracts.BindingModels;
|
using BookShopContracts.BindingModels;
|
||||||
using BookShopContracts.ViewModels;
|
using BookShopContracts.ViewModels;
|
||||||
using BookShopDataModels.Models;
|
using BookShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookShopDataBaseImplement.Models
|
namespace BookShopDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
@ -67,8 +72,8 @@ namespace BookShopDataBaseImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ClientSurname = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientSurname ?? string.Empty,
|
ClientSurname = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientSurname ?? string.Empty,
|
||||||
BookName = context.Books.FirstOrDefault(x => x.Id == BookId)?.BookName ?? string.Empty,
|
|
||||||
BookId = BookId,
|
BookId = BookId,
|
||||||
|
BookName = context.Books.FirstOrDefault(x => x.Id == BookId)?.BookName ?? string.Empty,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
DateCreate = DateCreate
|
DateCreate = DateCreate
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
namespace BookShopDataModels.Models
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IAuthorModel: IId
|
public interface IAuthorModel: IId
|
||||||
{
|
{
|
||||||
string AuthorSurname { get; }
|
string AuthorSurname { get; }
|
||||||
|
|
||||||
string AuthorName { get; }
|
string AuthorName { get; }
|
||||||
|
|
||||||
string AuthorPatronymic { get; }
|
string AuthorPatronymic { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
namespace BookShopDataModels.Models
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IBookModel: IId
|
public interface IBookModel: IId
|
||||||
{
|
{
|
||||||
string BookName { get; }
|
string BookName { get; }
|
||||||
|
|
||||||
double Cost { get; }
|
double Cost { get; }
|
||||||
|
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
int GenreId { get; }
|
int GenreId { get; }
|
||||||
|
|
||||||
Dictionary<int, IAuthorModel> BookAuthors { get; }
|
Dictionary<int, IAuthorModel> BookAuthors { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
namespace BookShopDataModels.Models
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IClientModel: IId
|
public interface IClientModel: IId
|
||||||
{
|
{
|
||||||
string ClientSurname { get; }
|
string ClientSurname { get; }
|
||||||
|
|
||||||
string ClientName { get; }
|
string ClientName { get; }
|
||||||
|
|
||||||
string ClientPatronymic { get; }
|
string ClientPatronymic { get; }
|
||||||
|
|
||||||
string Email { get; }
|
string Email { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
namespace BookShopDataModels.Models
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IGenreModel : IId
|
public interface IGenreModel : IId
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
namespace BookShopDataModels.Models
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BookShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IOrderModel: IId
|
public interface IOrderModel: IId
|
||||||
{
|
{
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
int BookId { get; }
|
int BookId { get; }
|
||||||
|
|
||||||
int ClientId { get; }
|
int ClientId { get; }
|
||||||
|
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
|
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
39
BookShop/BookShopView/Form1.Designer.cs
generated
39
BookShop/BookShopView/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace BookShopView
|
|
||||||
{
|
|
||||||
partial class Form1
|
|
||||||
{
|
|
||||||
/// <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.components = new System.ComponentModel.Container();
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Text = "Form1";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace BookShopView
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
147
BookShop/BookShopView/FormAuthor.Designer.cs
generated
Normal file
147
BookShop/BookShopView/FormAuthor.Designer.cs
generated
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormAuthor
|
||||||
|
{
|
||||||
|
/// <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.FTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.ITextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.LabelF = new System.Windows.Forms.Label();
|
||||||
|
this.LabelI = new System.Windows.Forms.Label();
|
||||||
|
this.LabelP = new System.Windows.Forms.Label();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonSave = new System.Windows.Forms.Button();
|
||||||
|
this.OTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// FTextBox
|
||||||
|
//
|
||||||
|
this.FTextBox.Location = new System.Drawing.Point(128, 16);
|
||||||
|
this.FTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.FTextBox.Name = "FTextBox";
|
||||||
|
this.FTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.FTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ITextBox
|
||||||
|
//
|
||||||
|
this.ITextBox.Location = new System.Drawing.Point(128, 65);
|
||||||
|
this.ITextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ITextBox.Name = "ITextBox";
|
||||||
|
this.ITextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.ITextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// LabelF
|
||||||
|
//
|
||||||
|
this.LabelF.AutoSize = true;
|
||||||
|
this.LabelF.Location = new System.Drawing.Point(14, 20);
|
||||||
|
this.LabelF.Name = "LabelF";
|
||||||
|
this.LabelF.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.LabelF.TabIndex = 2;
|
||||||
|
this.LabelF.Text = "Фамилия: ";
|
||||||
|
//
|
||||||
|
// LabelI
|
||||||
|
//
|
||||||
|
this.LabelI.AutoSize = true;
|
||||||
|
this.LabelI.Location = new System.Drawing.Point(14, 69);
|
||||||
|
this.LabelI.Name = "LabelI";
|
||||||
|
this.LabelI.Size = new System.Drawing.Size(42, 20);
|
||||||
|
this.LabelI.TabIndex = 3;
|
||||||
|
this.LabelI.Text = "Имя:";
|
||||||
|
//
|
||||||
|
// LabelP
|
||||||
|
//
|
||||||
|
this.LabelP.AutoSize = true;
|
||||||
|
this.LabelP.Location = new System.Drawing.Point(14, 123);
|
||||||
|
this.LabelP.Name = "LabelP";
|
||||||
|
this.LabelP.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.LabelP.TabIndex = 6;
|
||||||
|
this.LabelP.Text = "Отчество:";
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(214, 172);
|
||||||
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonCancel.TabIndex = 8;
|
||||||
|
this.ButtonCancel.Text = "Отмена";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// ButtonSave
|
||||||
|
//
|
||||||
|
this.ButtonSave.Location = new System.Drawing.Point(97, 172);
|
||||||
|
this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonSave.Name = "ButtonSave";
|
||||||
|
this.ButtonSave.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonSave.TabIndex = 9;
|
||||||
|
this.ButtonSave.Text = "Сохранить";
|
||||||
|
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// OTextBox
|
||||||
|
//
|
||||||
|
this.OTextBox.Location = new System.Drawing.Point(128, 116);
|
||||||
|
this.OTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.OTextBox.Name = "OTextBox";
|
||||||
|
this.OTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.OTextBox.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// FormAuthor
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(350, 222);
|
||||||
|
this.Controls.Add(this.OTextBox);
|
||||||
|
this.Controls.Add(this.ButtonSave);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.LabelP);
|
||||||
|
this.Controls.Add(this.LabelI);
|
||||||
|
this.Controls.Add(this.LabelF);
|
||||||
|
this.Controls.Add(this.ITextBox);
|
||||||
|
this.Controls.Add(this.FTextBox);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormAuthor";
|
||||||
|
this.Text = "Автор";
|
||||||
|
this.Load += new System.EventHandler(this.FormAuthor_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox FTextBox;
|
||||||
|
private TextBox ITextBox;
|
||||||
|
private Label LabelF;
|
||||||
|
private Label LabelI;
|
||||||
|
private Label LabelP;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Button ButtonSave;
|
||||||
|
private TextBox OTextBox;
|
||||||
|
}
|
||||||
|
}
|
104
BookShop/BookShopView/FormAuthor.cs
Normal file
104
BookShop/BookShopView/FormAuthor.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormAuthor : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IAuthorLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormAuthor(ILogger<FormAuthor> logger, IAuthorLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(FTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните фамилию", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(ITextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните имя", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение автора");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new AuthorBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
AuthorName = ITextBox.Text,
|
||||||
|
AuthorSurname = FTextBox.Text,
|
||||||
|
AuthorPatronymic = OTextBox.Text
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения автора");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAuthor_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение автора");
|
||||||
|
var view = _logic.ReadElement(new AuthorSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
FTextBox.Text = view.AuthorSurname;
|
||||||
|
ITextBox.Text = view.AuthorName;
|
||||||
|
OTextBox.Text = view.AuthorPatronymic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения автора");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormAuthor.resx
Normal file
60
BookShop/BookShopView/FormAuthor.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>
|
116
BookShop/BookShopView/FormAuthors.Designer.cs
generated
Normal file
116
BookShop/BookShopView/FormAuthors.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormAuthors
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ButtonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(461, 345);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonDelete
|
||||||
|
//
|
||||||
|
this.ButtonDelete.Location = new System.Drawing.Point(493, 181);
|
||||||
|
this.ButtonDelete.Name = "ButtonDelete";
|
||||||
|
this.ButtonDelete.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.ButtonDelete.TabIndex = 1;
|
||||||
|
this.ButtonDelete.Text = "Удалить";
|
||||||
|
this.ButtonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
||||||
|
//
|
||||||
|
// ButtonUpdate
|
||||||
|
//
|
||||||
|
this.ButtonUpdate.Location = new System.Drawing.Point(493, 266);
|
||||||
|
this.ButtonUpdate.Name = "ButtonUpdate";
|
||||||
|
this.ButtonUpdate.Size = new System.Drawing.Size(115, 58);
|
||||||
|
this.ButtonUpdate.TabIndex = 2;
|
||||||
|
this.ButtonUpdate.Text = "Обновить";
|
||||||
|
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(493, 30);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonAdd.TabIndex = 3;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(493, 103);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.buttonUpd.TabIndex = 4;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
||||||
|
//
|
||||||
|
// FormAuthors
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(620, 372);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.ButtonUpdate);
|
||||||
|
this.Controls.Add(this.ButtonDelete);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormAuthors";
|
||||||
|
this.Text = "Авторы";
|
||||||
|
this.Load += new System.EventHandler(this.FormAuthors_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button ButtonDelete;
|
||||||
|
private Button ButtonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
}
|
||||||
|
}
|
113
BookShop/BookShopView/FormAuthors.cs
Normal file
113
BookShop/BookShopView/FormAuthors.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormAuthors : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IAuthorLogic _logic;
|
||||||
|
public FormAuthors(ILogger<FormAuthors> logger, IAuthorLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_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);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new AuthorBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Удаление автора");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления автора");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormAuthor));
|
||||||
|
if (service is FormAuthor form)
|
||||||
|
{
|
||||||
|
form.Id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAuthors_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["AuthorSurname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["AuthorName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["AuthorPatronymic"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка авторов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки авторов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormAuthor));
|
||||||
|
if (service is FormAuthor form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormAuthors.resx
Normal file
60
BookShop/BookShopView/FormAuthors.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>
|
268
BookShop/BookShopView/FormBook.Designer.cs
generated
Normal file
268
BookShop/BookShopView/FormBook.Designer.cs
generated
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormBook
|
||||||
|
{
|
||||||
|
/// <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.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.labelCost = new System.Windows.Forms.Label();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.labelGenre = new System.Windows.Forms.Label();
|
||||||
|
this.TextBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
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();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxGenre = new System.Windows.Forms.ComboBox();
|
||||||
|
this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnAuthorSurname = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.groupBox.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(26, 22);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// labelCost
|
||||||
|
//
|
||||||
|
this.labelCost.AutoSize = true;
|
||||||
|
this.labelCost.Location = new System.Drawing.Point(26, 61);
|
||||||
|
this.labelCost.Name = "labelCost";
|
||||||
|
this.labelCost.Size = new System.Drawing.Size(86, 20);
|
||||||
|
this.labelCost.TabIndex = 1;
|
||||||
|
this.labelCost.Text = "Стоимость:";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(26, 107);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
||||||
|
this.labelCount.TabIndex = 2;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// labelGenre
|
||||||
|
//
|
||||||
|
this.labelGenre.AutoSize = true;
|
||||||
|
this.labelGenre.Location = new System.Drawing.Point(26, 153);
|
||||||
|
this.labelGenre.Name = "labelGenre";
|
||||||
|
this.labelGenre.Size = new System.Drawing.Size(51, 20);
|
||||||
|
this.labelGenre.TabIndex = 3;
|
||||||
|
this.labelGenre.Text = "Жанр:";
|
||||||
|
//
|
||||||
|
// TextBoxName
|
||||||
|
//
|
||||||
|
this.TextBoxName.Location = new System.Drawing.Point(162, 22);
|
||||||
|
this.TextBoxName.Name = "TextBoxName";
|
||||||
|
this.TextBoxName.Size = new System.Drawing.Size(259, 27);
|
||||||
|
this.TextBoxName.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// textBoxCost
|
||||||
|
//
|
||||||
|
this.textBoxCost.Location = new System.Drawing.Point(162, 61);
|
||||||
|
this.textBoxCost.Name = "textBoxCost";
|
||||||
|
this.textBoxCost.Size = new System.Drawing.Size(259, 27);
|
||||||
|
this.textBoxCost.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(162, 104);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(259, 27);
|
||||||
|
this.textBoxCount.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// groupBox
|
||||||
|
//
|
||||||
|
this.groupBox.Controls.Add(this.buttonRef);
|
||||||
|
this.groupBox.Controls.Add(this.buttonDel);
|
||||||
|
this.groupBox.Controls.Add(this.buttonUpd);
|
||||||
|
this.groupBox.Controls.Add(this.buttonAdd);
|
||||||
|
this.groupBox.Controls.Add(this.dataGridView);
|
||||||
|
this.groupBox.Location = new System.Drawing.Point(26, 192);
|
||||||
|
this.groupBox.Name = "groupBox";
|
||||||
|
this.groupBox.Size = new System.Drawing.Size(530, 247);
|
||||||
|
this.groupBox.TabIndex = 7;
|
||||||
|
this.groupBox.TabStop = false;
|
||||||
|
this.groupBox.Text = "Авторы";
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(418, 199);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonRef.TabIndex = 4;
|
||||||
|
this.buttonRef.Text = "Обновить";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(418, 143);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(418, 84);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonUpd.TabIndex = 2;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(418, 35);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.ColumnID,
|
||||||
|
this.ColumnAuthorSurname});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(6, 26);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(389, 215);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(310, 454);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 8;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(444, 454);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 9;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// comboBoxGenre
|
||||||
|
//
|
||||||
|
this.comboBoxGenre.FormattingEnabled = true;
|
||||||
|
this.comboBoxGenre.Location = new System.Drawing.Point(160, 153);
|
||||||
|
this.comboBoxGenre.Name = "comboBoxGenre";
|
||||||
|
this.comboBoxGenre.Size = new System.Drawing.Size(261, 28);
|
||||||
|
this.comboBoxGenre.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// ColumnID
|
||||||
|
//
|
||||||
|
this.ColumnID.HeaderText = "ID";
|
||||||
|
this.ColumnID.MinimumWidth = 6;
|
||||||
|
this.ColumnID.Name = "ColumnID";
|
||||||
|
this.ColumnID.Visible = false;
|
||||||
|
this.ColumnID.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnAuthorSurname
|
||||||
|
//
|
||||||
|
this.ColumnAuthorSurname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.ColumnAuthorSurname.HeaderText = "Автор";
|
||||||
|
this.ColumnAuthorSurname.MinimumWidth = 6;
|
||||||
|
this.ColumnAuthorSurname.Name = "ColumnAuthorSurname";
|
||||||
|
//
|
||||||
|
// FormBook
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(571, 495);
|
||||||
|
this.Controls.Add(this.comboBoxGenre);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.groupBox);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.textBoxCost);
|
||||||
|
this.Controls.Add(this.TextBoxName);
|
||||||
|
this.Controls.Add(this.labelGenre);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.labelCost);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormBook";
|
||||||
|
this.Text = "Книга";
|
||||||
|
this.Load += new System.EventHandler(this.FormBook_Load);
|
||||||
|
this.groupBox.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelCost;
|
||||||
|
private Label labelCount;
|
||||||
|
private Label labelGenre;
|
||||||
|
private TextBox TextBoxName;
|
||||||
|
private TextBox textBoxCost;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private GroupBox groupBox;
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxGenre;
|
||||||
|
private DataGridViewTextBoxColumn ColumnID;
|
||||||
|
private DataGridViewTextBoxColumn ColumnAuthorSurname;
|
||||||
|
}
|
||||||
|
}
|
242
BookShop/BookShopView/FormBook.cs
Normal file
242
BookShop/BookShopView/FormBook.cs
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.SearchModels;
|
||||||
|
using BookShopContracts.ViewModels;
|
||||||
|
using BookShopDataModels.Models;
|
||||||
|
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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormBook : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IBookLogic _logic;
|
||||||
|
private readonly IGenreLogic _logicG;
|
||||||
|
private int? _id;
|
||||||
|
private Dictionary<int, IAuthorModel> _bookAuthors;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormBook(ILogger<FormBook> logger, IBookLogic logic, IGenreLogic logicG)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_bookAuthors = new Dictionary<int, IAuthorModel>();
|
||||||
|
_logicG = logicG;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormBook_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка жанров");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicG.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxGenre.DisplayMember = "Genre";
|
||||||
|
comboBoxGenre.ValueMember = "ID";
|
||||||
|
comboBoxGenre.DataSource = list.Select(c => c.GenreName).ToList();
|
||||||
|
comboBoxGenre.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка жанров");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка книги");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new BookSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
TextBoxName.Text = view.BookName;
|
||||||
|
textBoxCost.Text = view.Cost.ToString();
|
||||||
|
textBoxCount.Text = view.Count.ToString();
|
||||||
|
comboBoxGenre.SelectedIndex = view.GenreId;
|
||||||
|
_bookAuthors = view.BookAuthors ?? new Dictionary<int, IAuthorModel>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки книги");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка автора книги");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_bookAuthors != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var pc in _bookAuthors)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.AuthorSurname });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки автора книги");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormBookAuthor));
|
||||||
|
if (service is FormBookAuthor form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.AuthorModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_bookAuthors.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_bookAuthors[form.Id] = (form.AuthorModel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_bookAuthors.Add(form.Id, (form.AuthorModel));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Добавление автора:{ AuthorSurname}", form.AuthorModel.AuthorSurname);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormBookAuthor));
|
||||||
|
if (service is FormBookAuthor form)
|
||||||
|
{
|
||||||
|
int id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.AuthorModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Изменение компонента:{ ComponentName} - { Count}", form.AuthorModel.AuthorSurname);
|
||||||
|
_bookAuthors[form.Id] = (form.AuthorModel);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление компонента: { AuthorSurname}", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||||
|
_bookAuthors?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(TextBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxCost.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните количество", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxGenre.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите жанр", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_bookAuthors == null || _bookAuthors.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните авторов", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение изделия");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new BookBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
BookName = TextBoxName.Text,
|
||||||
|
Cost = Convert.ToDouble(textBoxCost.Text),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
|
GenreId = comboBoxGenre.SelectedIndex + 1,
|
||||||
|
BookAuthors = _bookAuthors
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
BookShop/BookShopView/FormBook.resx
Normal file
66
BookShop/BookShopView/FormBook.resx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<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>
|
||||||
|
<metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnAuthorSurname.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
98
BookShop/BookShopView/FormBookAuthor.Designer.cs
generated
Normal file
98
BookShop/BookShopView/FormBookAuthor.Designer.cs
generated
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormBookAuthor
|
||||||
|
{
|
||||||
|
/// <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.labelComponent = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxAuthor = new System.Windows.Forms.ComboBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelComponent
|
||||||
|
//
|
||||||
|
this.labelComponent.AutoSize = true;
|
||||||
|
this.labelComponent.Location = new System.Drawing.Point(34, 43);
|
||||||
|
this.labelComponent.Name = "labelComponent";
|
||||||
|
this.labelComponent.Size = new System.Drawing.Size(51, 20);
|
||||||
|
this.labelComponent.TabIndex = 0;
|
||||||
|
this.labelComponent.Text = "Автор";
|
||||||
|
//
|
||||||
|
// comboBoxAuthor
|
||||||
|
//
|
||||||
|
this.comboBoxAuthor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxAuthor.FormattingEnabled = true;
|
||||||
|
this.comboBoxAuthor.Location = new System.Drawing.Point(128, 40);
|
||||||
|
this.comboBoxAuthor.Name = "comboBoxAuthor";
|
||||||
|
this.comboBoxAuthor.Size = new System.Drawing.Size(265, 28);
|
||||||
|
this.comboBoxAuthor.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(34, 117);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(114, 48);
|
||||||
|
this.buttonSave.TabIndex = 4;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(301, 117);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(114, 48);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormBookAuthor
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(461, 190);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.comboBoxAuthor);
|
||||||
|
this.Controls.Add(this.labelComponent);
|
||||||
|
this.Name = "FormBookAuthor";
|
||||||
|
this.Text = "Автор книги";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelComponent;
|
||||||
|
private ComboBox comboBoxAuthor;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
77
BookShop/BookShopView/FormBookAuthor.cs
Normal file
77
BookShop/BookShopView/FormBookAuthor.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.ViewModels;
|
||||||
|
using BookShopDataModels.Models;
|
||||||
|
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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormBookAuthor : Form
|
||||||
|
{
|
||||||
|
private readonly List<AuthorViewModel>? _list;
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxAuthor.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxAuthor.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IAuthorModel? AuthorModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _list)
|
||||||
|
{
|
||||||
|
if (elem.Id == Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FormBookAuthor(IAuthorLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_list = logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxAuthor.DisplayMember = "AuthorSurname";
|
||||||
|
comboBoxAuthor.ValueMember = "Id";
|
||||||
|
comboBoxAuthor.DataSource = _list;
|
||||||
|
comboBoxAuthor.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxAuthor.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите автора", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormBookAuthor.resx
Normal file
60
BookShop/BookShopView/FormBookAuthor.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>
|
116
BookShop/BookShopView/FormBooks.Designer.cs
generated
Normal file
116
BookShop/BookShopView/FormBooks.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormBooks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ButtonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(461, 345);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonDelete
|
||||||
|
//
|
||||||
|
this.ButtonDelete.Location = new System.Drawing.Point(493, 183);
|
||||||
|
this.ButtonDelete.Name = "ButtonDelete";
|
||||||
|
this.ButtonDelete.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.ButtonDelete.TabIndex = 1;
|
||||||
|
this.ButtonDelete.Text = "Удалить";
|
||||||
|
this.ButtonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// ButtonUpdate
|
||||||
|
//
|
||||||
|
this.ButtonUpdate.Location = new System.Drawing.Point(493, 266);
|
||||||
|
this.ButtonUpdate.Name = "ButtonUpdate";
|
||||||
|
this.ButtonUpdate.Size = new System.Drawing.Size(115, 58);
|
||||||
|
this.ButtonUpdate.TabIndex = 2;
|
||||||
|
this.ButtonUpdate.Text = "Обновить";
|
||||||
|
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(493, 33);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonAdd.TabIndex = 3;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(493, 105);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonUpd.TabIndex = 4;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// FormBooks
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(620, 372);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.ButtonUpdate);
|
||||||
|
this.Controls.Add(this.ButtonDelete);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormBooks";
|
||||||
|
this.Text = "Книги";
|
||||||
|
this.Load += new System.EventHandler(this.FormBooks_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button ButtonDelete;
|
||||||
|
private Button ButtonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
}
|
||||||
|
}
|
120
BookShop/BookShopView/FormBooks.cs
Normal file
120
BookShop/BookShopView/FormBooks.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormBooks : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IBookLogic _logic;
|
||||||
|
public FormBooks(ILogger<FormBooks> logger, IBookLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormBooks_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["BookName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Cost"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Count"].Visible = false;
|
||||||
|
dataGridView.Columns["GenreId"].Visible = false;
|
||||||
|
dataGridView.Columns["GenreName"].Visible = false;
|
||||||
|
dataGridView.Columns["BookAuthors"].Visible = false;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка книг");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки книг");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormBook));
|
||||||
|
if (service is FormBook form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Удаление изделия");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new BookBindingModel
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormBook));
|
||||||
|
if (service is FormBook form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormBooks.resx
Normal file
60
BookShop/BookShopView/FormBooks.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>
|
170
BookShop/BookShopView/FormClient.Designer.cs
generated
Normal file
170
BookShop/BookShopView/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormClient
|
||||||
|
{
|
||||||
|
/// <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.FTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.ITextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.LabelF = new System.Windows.Forms.Label();
|
||||||
|
this.LabelI = new System.Windows.Forms.Label();
|
||||||
|
this.LabelP = new System.Windows.Forms.Label();
|
||||||
|
this.LabelQualification = new System.Windows.Forms.Label();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonSave = new System.Windows.Forms.Button();
|
||||||
|
this.OTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.EmailTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// FTextBox
|
||||||
|
//
|
||||||
|
this.FTextBox.Location = new System.Drawing.Point(128, 16);
|
||||||
|
this.FTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.FTextBox.Name = "FTextBox";
|
||||||
|
this.FTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.FTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ITextBox
|
||||||
|
//
|
||||||
|
this.ITextBox.Location = new System.Drawing.Point(128, 65);
|
||||||
|
this.ITextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ITextBox.Name = "ITextBox";
|
||||||
|
this.ITextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.ITextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// LabelF
|
||||||
|
//
|
||||||
|
this.LabelF.AutoSize = true;
|
||||||
|
this.LabelF.Location = new System.Drawing.Point(14, 20);
|
||||||
|
this.LabelF.Name = "LabelF";
|
||||||
|
this.LabelF.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.LabelF.TabIndex = 2;
|
||||||
|
this.LabelF.Text = "Фамилия: ";
|
||||||
|
//
|
||||||
|
// LabelI
|
||||||
|
//
|
||||||
|
this.LabelI.AutoSize = true;
|
||||||
|
this.LabelI.Location = new System.Drawing.Point(14, 69);
|
||||||
|
this.LabelI.Name = "LabelI";
|
||||||
|
this.LabelI.Size = new System.Drawing.Size(42, 20);
|
||||||
|
this.LabelI.TabIndex = 3;
|
||||||
|
this.LabelI.Text = "Имя:";
|
||||||
|
//
|
||||||
|
// LabelP
|
||||||
|
//
|
||||||
|
this.LabelP.AutoSize = true;
|
||||||
|
this.LabelP.Location = new System.Drawing.Point(14, 123);
|
||||||
|
this.LabelP.Name = "LabelP";
|
||||||
|
this.LabelP.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.LabelP.TabIndex = 6;
|
||||||
|
this.LabelP.Text = "Отчество:";
|
||||||
|
//
|
||||||
|
// LabelQualification
|
||||||
|
//
|
||||||
|
this.LabelQualification.AutoSize = true;
|
||||||
|
this.LabelQualification.Location = new System.Drawing.Point(14, 177);
|
||||||
|
this.LabelQualification.Name = "LabelQualification";
|
||||||
|
this.LabelQualification.Size = new System.Drawing.Size(49, 20);
|
||||||
|
this.LabelQualification.TabIndex = 7;
|
||||||
|
this.LabelQualification.Text = "Email:";
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(211, 225);
|
||||||
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonCancel.TabIndex = 8;
|
||||||
|
this.ButtonCancel.Text = "Отмена";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// ButtonSave
|
||||||
|
//
|
||||||
|
this.ButtonSave.Location = new System.Drawing.Point(94, 225);
|
||||||
|
this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonSave.Name = "ButtonSave";
|
||||||
|
this.ButtonSave.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonSave.TabIndex = 9;
|
||||||
|
this.ButtonSave.Text = "Сохранить";
|
||||||
|
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// OTextBox
|
||||||
|
//
|
||||||
|
this.OTextBox.Location = new System.Drawing.Point(128, 116);
|
||||||
|
this.OTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.OTextBox.Name = "OTextBox";
|
||||||
|
this.OTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.OTextBox.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// EmailTextBox
|
||||||
|
//
|
||||||
|
this.EmailTextBox.Location = new System.Drawing.Point(128, 170);
|
||||||
|
this.EmailTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.EmailTextBox.Name = "EmailTextBox";
|
||||||
|
this.EmailTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.EmailTextBox.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// FormClient
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(350, 285);
|
||||||
|
this.Controls.Add(this.EmailTextBox);
|
||||||
|
this.Controls.Add(this.OTextBox);
|
||||||
|
this.Controls.Add(this.ButtonSave);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.LabelQualification);
|
||||||
|
this.Controls.Add(this.LabelP);
|
||||||
|
this.Controls.Add(this.LabelI);
|
||||||
|
this.Controls.Add(this.LabelF);
|
||||||
|
this.Controls.Add(this.ITextBox);
|
||||||
|
this.Controls.Add(this.FTextBox);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormClient";
|
||||||
|
this.Text = "Клиент";
|
||||||
|
this.Click += new System.EventHandler(this.FormClient_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox FTextBox;
|
||||||
|
private TextBox ITextBox;
|
||||||
|
private Label LabelF;
|
||||||
|
private Label LabelI;
|
||||||
|
private Label LabelP;
|
||||||
|
private Label LabelQualification;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Button ButtonSave;
|
||||||
|
private TextBox OTextBox;
|
||||||
|
private TextBox EmailTextBox;
|
||||||
|
}
|
||||||
|
}
|
113
BookShop/BookShopView/FormClient.cs
Normal file
113
BookShop/BookShopView/FormClient.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormClient : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormClient(ILogger<FormClient> logger, IClientLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(FTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните фамилию", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(ITextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните имя", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(EmailTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните почту", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение клиента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ClientBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ClientName = ITextBox.Text,
|
||||||
|
ClientSurname = FTextBox.Text,
|
||||||
|
ClientPatronymic = OTextBox.Text,
|
||||||
|
Email = EmailTextBox.Text
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения клиента");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormClient_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение клиента");
|
||||||
|
var view = _logic.ReadElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
FTextBox.Text = view.ClientSurname;
|
||||||
|
ITextBox.Text = view.ClientName;
|
||||||
|
OTextBox.Text = view.ClientPatronymic;
|
||||||
|
EmailTextBox.Text = view.Email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения клиента");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormClient.resx
Normal file
60
BookShop/BookShopView/FormClient.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>
|
116
BookShop/BookShopView/FormClients.Designer.cs
generated
Normal file
116
BookShop/BookShopView/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormClients
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ButtonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(461, 345);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonDelete
|
||||||
|
//
|
||||||
|
this.ButtonDelete.Location = new System.Drawing.Point(493, 183);
|
||||||
|
this.ButtonDelete.Name = "ButtonDelete";
|
||||||
|
this.ButtonDelete.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.ButtonDelete.TabIndex = 1;
|
||||||
|
this.ButtonDelete.Text = "Удалить";
|
||||||
|
this.ButtonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
||||||
|
//
|
||||||
|
// ButtonUpdate
|
||||||
|
//
|
||||||
|
this.ButtonUpdate.Location = new System.Drawing.Point(493, 266);
|
||||||
|
this.ButtonUpdate.Name = "ButtonUpdate";
|
||||||
|
this.ButtonUpdate.Size = new System.Drawing.Size(115, 58);
|
||||||
|
this.ButtonUpdate.TabIndex = 2;
|
||||||
|
this.ButtonUpdate.Text = "Обновить";
|
||||||
|
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(493, 30);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonAdd.TabIndex = 3;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(493, 103);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.buttonUpd.TabIndex = 4;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
||||||
|
//
|
||||||
|
// FormClients
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(620, 372);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.ButtonUpdate);
|
||||||
|
this.Controls.Add(this.ButtonDelete);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormClients";
|
||||||
|
this.Text = "Клиенты";
|
||||||
|
this.Load += new System.EventHandler(this.FormClients_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button ButtonDelete;
|
||||||
|
private Button ButtonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
}
|
||||||
|
}
|
113
BookShop/BookShopView/FormClients.cs
Normal file
113
BookShop/BookShopView/FormClients.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormClients : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IClientLogic _logic;
|
||||||
|
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_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);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Удаление клиента");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления клиента");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||||
|
if (service is FormClient form)
|
||||||
|
{
|
||||||
|
form.Id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormClients_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientSurname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ClientName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||||
|
if (service is FormClient form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormClients.resx
Normal file
60
BookShop/BookShopView/FormClients.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>
|
101
BookShop/BookShopView/FormGenre.Designer.cs
generated
Normal file
101
BookShop/BookShopView/FormGenre.Designer.cs
generated
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormGenre
|
||||||
|
{
|
||||||
|
/// <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.NameTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.LabelName = new System.Windows.Forms.Label();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonSave = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// NameTextBox
|
||||||
|
//
|
||||||
|
this.NameTextBox.Location = new System.Drawing.Point(128, 16);
|
||||||
|
this.NameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.NameTextBox.Name = "NameTextBox";
|
||||||
|
this.NameTextBox.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.NameTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// LabelName
|
||||||
|
//
|
||||||
|
this.LabelName.AutoSize = true;
|
||||||
|
this.LabelName.Location = new System.Drawing.Point(14, 20);
|
||||||
|
this.LabelName.Name = "LabelName";
|
||||||
|
this.LabelName.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.LabelName.TabIndex = 2;
|
||||||
|
this.LabelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(211, 63);
|
||||||
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonCancel.TabIndex = 8;
|
||||||
|
this.ButtonCancel.Text = "Отмена";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// ButtonSave
|
||||||
|
//
|
||||||
|
this.ButtonSave.Location = new System.Drawing.Point(79, 63);
|
||||||
|
this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonSave.Name = "ButtonSave";
|
||||||
|
this.ButtonSave.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.ButtonSave.TabIndex = 9;
|
||||||
|
this.ButtonSave.Text = "Сохранить";
|
||||||
|
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// FormGenre
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(350, 119);
|
||||||
|
this.Controls.Add(this.ButtonSave);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.LabelName);
|
||||||
|
this.Controls.Add(this.NameTextBox);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormGenre";
|
||||||
|
this.Text = "Жанр";
|
||||||
|
this.Load += new System.EventHandler(this.FormGenre_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox NameTextBox;
|
||||||
|
private Label LabelName;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Button ButtonSave;
|
||||||
|
}
|
||||||
|
}
|
94
BookShop/BookShopView/FormGenre.cs
Normal file
94
BookShop/BookShopView/FormGenre.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormGenre : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IGenreLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormGenre(ILogger<FormGenre> logger, IGenreLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение жанра");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new GenreBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
GenreName = NameTextBox.Text
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения жанра");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormGenre_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение жанра");
|
||||||
|
var view = _logic.ReadElement(new GenreSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
NameTextBox.Text = view.GenreName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения жанра");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormGenre.resx
Normal file
60
BookShop/BookShopView/FormGenre.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>
|
116
BookShop/BookShopView/FormGenres.Designer.cs
generated
Normal file
116
BookShop/BookShopView/FormGenres.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormGenres
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ButtonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowHeadersWidth = 51;
|
||||||
|
this.DataGridView.RowTemplate.Height = 29;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(461, 345);
|
||||||
|
this.DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonDelete
|
||||||
|
//
|
||||||
|
this.ButtonDelete.Location = new System.Drawing.Point(493, 183);
|
||||||
|
this.ButtonDelete.Name = "ButtonDelete";
|
||||||
|
this.ButtonDelete.Size = new System.Drawing.Size(115, 54);
|
||||||
|
this.ButtonDelete.TabIndex = 1;
|
||||||
|
this.ButtonDelete.Text = "Удалить";
|
||||||
|
this.ButtonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonDelete.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
|
//
|
||||||
|
// ButtonUpdate
|
||||||
|
//
|
||||||
|
this.ButtonUpdate.Location = new System.Drawing.Point(493, 266);
|
||||||
|
this.ButtonUpdate.Name = "ButtonUpdate";
|
||||||
|
this.ButtonUpdate.Size = new System.Drawing.Size(115, 58);
|
||||||
|
this.ButtonUpdate.TabIndex = 2;
|
||||||
|
this.ButtonUpdate.Text = "Обновить";
|
||||||
|
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonUpdate.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(493, 29);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonAdd.TabIndex = 3;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(493, 105);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(115, 52);
|
||||||
|
this.buttonUpd.TabIndex = 4;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
|
//
|
||||||
|
// FormGenres
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(620, 372);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.ButtonUpdate);
|
||||||
|
this.Controls.Add(this.ButtonDelete);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Name = "FormGenres";
|
||||||
|
this.Text = "Жанры";
|
||||||
|
this.Load += new System.EventHandler(this.FormGenres_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button ButtonDelete;
|
||||||
|
private Button ButtonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
}
|
||||||
|
}
|
119
BookShop/BookShopView/FormGenres.cs
Normal file
119
BookShop/BookShopView/FormGenres.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormGenres : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IGenreLogic _logic;
|
||||||
|
public FormGenres(ILogger<FormGenres> logger, IGenreLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGenre));
|
||||||
|
if (service is FormGenre form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_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 GenreBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления жанра");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormGenres_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
DataGridView.DataSource = list;
|
||||||
|
DataGridView.Columns["Id"].Visible = false;
|
||||||
|
DataGridView.Columns["GenreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Загрузка жанров");
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки жанров");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGenre));
|
||||||
|
if (service is FormGenre form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormGenres.resx
Normal file
60
BookShop/BookShopView/FormGenres.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>
|
191
BookShop/BookShopView/FormMain.Designer.cs
generated
Normal file
191
BookShop/BookShopView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <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.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.AuthorsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.BooksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ClientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.GenresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ComponentGiftsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
|
this.testsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.справочникиToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(1367, 28);
|
||||||
|
this.menuStrip1.TabIndex = 0;
|
||||||
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// справочникиToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.AuthorsToolStripMenuItem,
|
||||||
|
this.BooksToolStripMenuItem,
|
||||||
|
this.ClientsToolStripMenuItem,
|
||||||
|
this.GenresToolStripMenuItem,
|
||||||
|
this.testsToolStripMenuItem});
|
||||||
|
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
|
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
||||||
|
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
|
//
|
||||||
|
// AuthorsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.AuthorsToolStripMenuItem.Name = "AuthorsToolStripMenuItem";
|
||||||
|
this.AuthorsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.AuthorsToolStripMenuItem.Text = "Авторы";
|
||||||
|
this.AuthorsToolStripMenuItem.Click += new System.EventHandler(this.AuthorsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// BooksToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.BooksToolStripMenuItem.Name = "BooksToolStripMenuItem";
|
||||||
|
this.BooksToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.BooksToolStripMenuItem.Text = "Книги";
|
||||||
|
this.BooksToolStripMenuItem.Click += new System.EventHandler(this.BooksToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// ClientsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||||
|
this.ClientsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.ClientsToolStripMenuItem.Text = "Клиенты";
|
||||||
|
this.ClientsToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// GenresToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.GenresToolStripMenuItem.Name = "GenresToolStripMenuItem";
|
||||||
|
this.GenresToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.GenresToolStripMenuItem.Text = "Жанры";
|
||||||
|
this.GenresToolStripMenuItem.Click += new System.EventHandler(this.GenresToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// ComponentsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||||
|
this.ComponentsToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
|
||||||
|
this.ComponentsToolStripMenuItem.Text = "Список компонентов";
|
||||||
|
//
|
||||||
|
// ComponentGiftsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ComponentGiftsToolStripMenuItem.Name = "ComponentGiftsToolStripMenuItem";
|
||||||
|
this.ComponentGiftsToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
|
||||||
|
this.ComponentGiftsToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||||
|
//
|
||||||
|
// OrdersToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
||||||
|
this.OrdersToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
|
||||||
|
this.OrdersToolStripMenuItem.Text = "Список заказов";
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 41);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(1123, 423);
|
||||||
|
this.dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonCreateOrder
|
||||||
|
//
|
||||||
|
this.buttonCreateOrder.Location = new System.Drawing.Point(1155, 167);
|
||||||
|
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
|
this.buttonCreateOrder.Size = new System.Drawing.Size(189, 78);
|
||||||
|
this.buttonCreateOrder.TabIndex = 2;
|
||||||
|
this.buttonCreateOrder.Text = "Создать заказ";
|
||||||
|
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(1155, 304);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(189, 78);
|
||||||
|
this.buttonRef.TabIndex = 6;
|
||||||
|
this.buttonRef.Text = "Обновить список";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// testsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.testsToolStripMenuItem.Name = "testsToolStripMenuItem";
|
||||||
|
this.testsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.testsToolStripMenuItem.Text = "Тесты";
|
||||||
|
this.testsToolStripMenuItem.Click += new System.EventHandler(this.testsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1367, 471);
|
||||||
|
this.Controls.Add(this.buttonRef);
|
||||||
|
this.Controls.Add(this.buttonCreateOrder);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.menuStrip1);
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "Книжный магазин";
|
||||||
|
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AuthorsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem BooksToolStripMenuItem;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCreateOrder;
|
||||||
|
private Button buttonRef;
|
||||||
|
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ComponentGiftsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem OrdersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ClientsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem GenresToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem testsToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
111
BookShop/BookShopView/FormMain.cs
Normal file
111
BookShop/BookShopView/FormMain.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using BookShopContracts.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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderLogic _orderLogic;
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
}
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка заказов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _orderLogic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["BookId"].Visible = false;
|
||||||
|
dataGridView.Columns["BookName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientSurname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Count"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["DateCreate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка заказов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AuthorsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAuthors));
|
||||||
|
if (service is FormAuthors form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void GenresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGenres));
|
||||||
|
|
||||||
|
if (service is FormGenres form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void BooksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormBooks));
|
||||||
|
|
||||||
|
if (service is FormBooks form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||||
|
|
||||||
|
if (service is FormClients form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormСreateOrder));
|
||||||
|
if (service is FormСreateOrder form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTests));
|
||||||
|
|
||||||
|
if (service is FormTests form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
BookShop/BookShopView/FormMain.resx
Normal file
66
BookShop/BookShopView/FormMain.resx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<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>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>36</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
238
BookShop/BookShopView/FormTests.Designer.cs
generated
Normal file
238
BookShop/BookShopView/FormTests.Designer.cs
generated
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormTests
|
||||||
|
{
|
||||||
|
/// <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.buttonInsertTest = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxInsertTime = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonReadTest = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxReadTime = new System.Windows.Forms.TextBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDownInsert = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.numericUpDownRead = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.buttonJoinQuery = new System.Windows.Forms.Button();
|
||||||
|
this.numericUpDownJoin = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.textBoxJoin = new System.Windows.Forms.TextBox();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonInsertTest
|
||||||
|
//
|
||||||
|
this.buttonInsertTest.Location = new System.Drawing.Point(14, 16);
|
||||||
|
this.buttonInsertTest.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonInsertTest.Name = "buttonInsertTest";
|
||||||
|
this.buttonInsertTest.Size = new System.Drawing.Size(98, 81);
|
||||||
|
this.buttonInsertTest.TabIndex = 0;
|
||||||
|
this.buttonInsertTest.Text = "Тест вставки сообщений";
|
||||||
|
this.buttonInsertTest.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonInsertTest.Click += new System.EventHandler(this.buttonInsertTest_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(119, 16);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(197, 20);
|
||||||
|
this.label1.TabIndex = 1;
|
||||||
|
this.label1.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(119, 71);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(187, 20);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// textBoxInsertTime
|
||||||
|
//
|
||||||
|
this.textBoxInsertTime.Location = new System.Drawing.Point(334, 68);
|
||||||
|
this.textBoxInsertTime.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.textBoxInsertTime.Name = "textBoxInsertTime";
|
||||||
|
this.textBoxInsertTime.ReadOnly = true;
|
||||||
|
this.textBoxInsertTime.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.textBoxInsertTime.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonReadTest
|
||||||
|
//
|
||||||
|
this.buttonReadTest.Location = new System.Drawing.Point(14, 141);
|
||||||
|
this.buttonReadTest.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonReadTest.Name = "buttonReadTest";
|
||||||
|
this.buttonReadTest.Size = new System.Drawing.Size(98, 75);
|
||||||
|
this.buttonReadTest.TabIndex = 5;
|
||||||
|
this.buttonReadTest.Text = "Тест чтения сообщений";
|
||||||
|
this.buttonReadTest.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonReadTest.Click += new System.EventHandler(this.buttonReadTest_Click);
|
||||||
|
//
|
||||||
|
// textBoxReadTime
|
||||||
|
//
|
||||||
|
this.textBoxReadTime.Location = new System.Drawing.Point(334, 193);
|
||||||
|
this.textBoxReadTime.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.textBoxReadTime.Name = "textBoxReadTime";
|
||||||
|
this.textBoxReadTime.ReadOnly = true;
|
||||||
|
this.textBoxReadTime.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.textBoxReadTime.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(119, 196);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(187, 20);
|
||||||
|
this.label3.TabIndex = 8;
|
||||||
|
this.label3.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(119, 141);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(197, 20);
|
||||||
|
this.label4.TabIndex = 6;
|
||||||
|
this.label4.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// numericUpDownInsert
|
||||||
|
//
|
||||||
|
this.numericUpDownInsert.Location = new System.Drawing.Point(334, 16);
|
||||||
|
this.numericUpDownInsert.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.numericUpDownInsert.Name = "numericUpDownInsert";
|
||||||
|
this.numericUpDownInsert.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.numericUpDownInsert.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// numericUpDownRead
|
||||||
|
//
|
||||||
|
this.numericUpDownRead.Location = new System.Drawing.Point(334, 139);
|
||||||
|
this.numericUpDownRead.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.numericUpDownRead.Name = "numericUpDownRead";
|
||||||
|
this.numericUpDownRead.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.numericUpDownRead.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// buttonJoinQuery
|
||||||
|
//
|
||||||
|
this.buttonJoinQuery.Location = new System.Drawing.Point(14, 263);
|
||||||
|
this.buttonJoinQuery.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonJoinQuery.Name = "buttonJoinQuery";
|
||||||
|
this.buttonJoinQuery.Size = new System.Drawing.Size(98, 99);
|
||||||
|
this.buttonJoinQuery.TabIndex = 12;
|
||||||
|
this.buttonJoinQuery.Text = "Тест сложного чтения (Join)";
|
||||||
|
this.buttonJoinQuery.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonJoinQuery.Click += new System.EventHandler(this.buttonJoinQuery_Click);
|
||||||
|
//
|
||||||
|
// numericUpDownJoin
|
||||||
|
//
|
||||||
|
this.numericUpDownJoin.Location = new System.Drawing.Point(334, 256);
|
||||||
|
this.numericUpDownJoin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.numericUpDownJoin.Name = "numericUpDownJoin";
|
||||||
|
this.numericUpDownJoin.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.numericUpDownJoin.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// textBoxJoin
|
||||||
|
//
|
||||||
|
this.textBoxJoin.Location = new System.Drawing.Point(334, 314);
|
||||||
|
this.textBoxJoin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.textBoxJoin.Name = "textBoxJoin";
|
||||||
|
this.textBoxJoin.ReadOnly = true;
|
||||||
|
this.textBoxJoin.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.textBoxJoin.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(119, 317);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(187, 20);
|
||||||
|
this.label5.TabIndex = 14;
|
||||||
|
this.label5.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(119, 263);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(197, 20);
|
||||||
|
this.label6.TabIndex = 13;
|
||||||
|
this.label6.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// FormTests
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(553, 381);
|
||||||
|
this.Controls.Add(this.numericUpDownJoin);
|
||||||
|
this.Controls.Add(this.textBoxJoin);
|
||||||
|
this.Controls.Add(this.label5);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.buttonJoinQuery);
|
||||||
|
this.Controls.Add(this.numericUpDownRead);
|
||||||
|
this.Controls.Add(this.numericUpDownInsert);
|
||||||
|
this.Controls.Add(this.textBoxReadTime);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.buttonReadTest);
|
||||||
|
this.Controls.Add(this.textBoxInsertTime);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonInsertTest);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormTests";
|
||||||
|
this.Text = "Тесты запросов к бд";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonInsertTest;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxInsertTime;
|
||||||
|
private Button buttonReadTest;
|
||||||
|
private TextBox textBoxReadTime;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private NumericUpDown numericUpDownInsert;
|
||||||
|
private NumericUpDown numericUpDownRead;
|
||||||
|
private Button buttonJoinQuery;
|
||||||
|
private NumericUpDown numericUpDownJoin;
|
||||||
|
private TextBox textBoxJoin;
|
||||||
|
private Label label5;
|
||||||
|
private Label label6;
|
||||||
|
}
|
||||||
|
}
|
75
BookShop/BookShopView/FormTests.cs
Normal file
75
BookShop/BookShopView/FormTests.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
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 BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormTests : Form
|
||||||
|
{
|
||||||
|
private readonly IBookLogic _bookLogic;
|
||||||
|
//private readonly IUserLogic _userLogic;
|
||||||
|
//private readonly ITopicLogic _topicLogic;
|
||||||
|
public FormTests(IBookLogic routeLogic)//IUserLogic userLogic, ITopicLogic topicLogic, IMessageLogic messageLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
//_userLogic = userLogic;
|
||||||
|
//_topicLogic = topicLogic;
|
||||||
|
_bookLogic = routeLogic;
|
||||||
|
numericUpDownInsert.Minimum = 0;
|
||||||
|
numericUpDownInsert.Maximum = 1000000;
|
||||||
|
numericUpDownRead.Minimum = 0;
|
||||||
|
numericUpDownRead.Maximum = 1000000;
|
||||||
|
numericUpDownJoin.Minimum = 0;
|
||||||
|
numericUpDownJoin.Maximum = 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonInsertTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// var result = _messageLogic.TestInsertList(Convert.ToInt32(numericUpDownInsert.Value),
|
||||||
|
// _userLogic.ReadList(null) ?? new(),
|
||||||
|
// _topicLogic.ReadList(null) ?? new());
|
||||||
|
|
||||||
|
// textBoxInsertTime.Text = result;
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonReadTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = _bookLogic.TestReadList(Convert.ToInt32(numericUpDownRead.Value));
|
||||||
|
textBoxReadTime.Text = result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonJoinQuery_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// var result = _messageLogic.TestJoinReadList(Convert.ToInt32(numericUpDownJoin.Value));
|
||||||
|
// textBoxJoin.Text = result;
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormTests.resx
Normal file
60
BookShop/BookShopView/FormTests.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>
|
170
BookShop/BookShopView/FormСreateOrder.Designer.cs
generated
Normal file
170
BookShop/BookShopView/FormСreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
partial class FormСreateOrder
|
||||||
|
{
|
||||||
|
/// <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.labelBook = new System.Windows.Forms.Label();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.labelSum = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxBook = new System.Windows.Forms.ComboBox();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxClient = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelClient = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelBook
|
||||||
|
//
|
||||||
|
this.labelBook.AutoSize = true;
|
||||||
|
this.labelBook.Location = new System.Drawing.Point(31, 44);
|
||||||
|
this.labelBook.Name = "labelBook";
|
||||||
|
this.labelBook.Size = new System.Drawing.Size(50, 20);
|
||||||
|
this.labelBook.TabIndex = 0;
|
||||||
|
this.labelBook.Text = "Книга";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(31, 128);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(90, 20);
|
||||||
|
this.labelCount.TabIndex = 1;
|
||||||
|
this.labelCount.Text = "Количество";
|
||||||
|
//
|
||||||
|
// labelSum
|
||||||
|
//
|
||||||
|
this.labelSum.AutoSize = true;
|
||||||
|
this.labelSum.Location = new System.Drawing.Point(34, 178);
|
||||||
|
this.labelSum.Name = "labelSum";
|
||||||
|
this.labelSum.Size = new System.Drawing.Size(55, 20);
|
||||||
|
this.labelSum.TabIndex = 2;
|
||||||
|
this.labelSum.Text = "Сумма";
|
||||||
|
//
|
||||||
|
// comboBoxBook
|
||||||
|
//
|
||||||
|
this.comboBoxBook.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxBook.FormattingEnabled = true;
|
||||||
|
this.comboBoxBook.Location = new System.Drawing.Point(141, 41);
|
||||||
|
this.comboBoxBook.Name = "comboBoxBook";
|
||||||
|
this.comboBoxBook.Size = new System.Drawing.Size(369, 28);
|
||||||
|
this.comboBoxBook.TabIndex = 3;
|
||||||
|
this.comboBoxBook.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBook_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(141, 125);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(369, 27);
|
||||||
|
this.textBoxCount.TabIndex = 4;
|
||||||
|
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||||
|
//
|
||||||
|
// textBoxSum
|
||||||
|
//
|
||||||
|
this.textBoxSum.Location = new System.Drawing.Point(141, 171);
|
||||||
|
this.textBoxSum.Name = "textBoxSum";
|
||||||
|
this.textBoxSum.ReadOnly = true;
|
||||||
|
this.textBoxSum.Size = new System.Drawing.Size(369, 27);
|
||||||
|
this.textBoxSum.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(82, 232);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(110, 58);
|
||||||
|
this.buttonSave.TabIndex = 6;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(366, 232);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(110, 58);
|
||||||
|
this.buttonCancel.TabIndex = 7;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
this.comboBoxClient.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxClient.FormattingEnabled = true;
|
||||||
|
this.comboBoxClient.Location = new System.Drawing.Point(141, 85);
|
||||||
|
this.comboBoxClient.Name = "comboBoxClient";
|
||||||
|
this.comboBoxClient.Size = new System.Drawing.Size(369, 28);
|
||||||
|
this.comboBoxClient.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// labelClient
|
||||||
|
//
|
||||||
|
this.labelClient.AutoSize = true;
|
||||||
|
this.labelClient.Location = new System.Drawing.Point(31, 88);
|
||||||
|
this.labelClient.Name = "labelClient";
|
||||||
|
this.labelClient.Size = new System.Drawing.Size(58, 20);
|
||||||
|
this.labelClient.TabIndex = 8;
|
||||||
|
this.labelClient.Text = "Клиент";
|
||||||
|
//
|
||||||
|
// FormСreateOrder
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(539, 308);
|
||||||
|
this.Controls.Add(this.comboBoxClient);
|
||||||
|
this.Controls.Add(this.labelClient);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxSum);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.comboBoxBook);
|
||||||
|
this.Controls.Add(this.labelSum);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.labelBook);
|
||||||
|
this.Name = "FormСreateOrder";
|
||||||
|
this.Text = "Заказ";
|
||||||
|
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelBook;
|
||||||
|
private Label labelCount;
|
||||||
|
private Label labelSum;
|
||||||
|
private ComboBox comboBoxBook;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private TextBox textBoxSum;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
|
private Label labelClient;
|
||||||
|
}
|
||||||
|
}
|
153
BookShop/BookShopView/FormСreateOrder.cs
Normal file
153
BookShop/BookShopView/FormСreateOrder.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
using BookShopContracts.BindingModels;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BookShopView
|
||||||
|
{
|
||||||
|
public partial class FormСreateOrder : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IBookLogic _logicB;
|
||||||
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _logicC;
|
||||||
|
public FormСreateOrder(ILogger<FormСreateOrder> logger, IBookLogic logicB, IOrderLogic logicO, IClientLogic logicC)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicB = logicB;
|
||||||
|
_logicO = logicO;
|
||||||
|
_logicC = logicC;
|
||||||
|
}
|
||||||
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка книг для заказа");
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка книг для заказа");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicB.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxBook.DisplayMember = "BookName";
|
||||||
|
comboBoxBook.ValueMember = "ID";
|
||||||
|
comboBoxBook.DataSource = list;
|
||||||
|
comboBoxBook.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка книг");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка клиентов для заказа");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicC.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "Клиент";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = list.Select(c => c.ClientSurname).ToList();
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CalcSum()
|
||||||
|
{
|
||||||
|
if (comboBoxBook.SelectedValue != null &&
|
||||||
|
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(comboBoxBook.SelectedValue);
|
||||||
|
var product = _logicB.ReadElement(new BookSearchModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
});
|
||||||
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
|
textBoxSum.Text = Math.Round(count * (product?.Cost ?? 0),
|
||||||
|
2).ToString();
|
||||||
|
_logger.LogInformation("Расчет суммы заказа");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CalcSum();
|
||||||
|
}
|
||||||
|
private void ComboBoxBook_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CalcSum();
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxBook.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите книгу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание заказа");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicO.Create(new OrderBindingModel
|
||||||
|
{
|
||||||
|
BookId = Convert.ToInt32(comboBoxBook.SelectedValue),
|
||||||
|
BookName = comboBoxBook.Text,
|
||||||
|
ClientId = comboBoxClient.SelectedIndex + 1,
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
|
|
||||||
|
});
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BookShop/BookShopView/FormСreateOrder.resx
Normal file
60
BookShop/BookShopView/FormСreateOrder.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,7 +1,18 @@
|
|||||||
|
using BookShopBusinessLogic.BusinessLogics;
|
||||||
|
using BookShopContracts.BusinessLogicsContracts;
|
||||||
|
using BookShopContracts.StoragesContracts;
|
||||||
|
using BookShopDataBaseImplement.Implements;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace BookShopView
|
namespace BookShopView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -11,7 +22,43 @@ namespace BookShopView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddLogging(option =>
|
||||||
|
{
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddNLog("nlog.config");
|
||||||
|
});
|
||||||
|
services.AddTransient<IAuthorStorage, AuthorStorage>();
|
||||||
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
|
services.AddTransient<IBookStorage, BookStorage>();
|
||||||
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
services.AddTransient<IGenreStorage, GenreStorage>();
|
||||||
|
|
||||||
|
services.AddTransient<IAuthorLogic, AuthorLogic>();
|
||||||
|
services.AddTransient<IBookLogic, BookLogic>();
|
||||||
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
services.AddTransient<IGenreLogic, GenreLogic>();
|
||||||
|
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormAuthor>();
|
||||||
|
services.AddTransient<FormAuthors>();
|
||||||
|
services.AddTransient<FormÑreateOrder>();
|
||||||
|
services.AddTransient<FormBook>();
|
||||||
|
services.AddTransient<FormBooks>();
|
||||||
|
services.AddTransient<FormBookAuthor>();
|
||||||
|
services.AddTransient<FormGenre>();
|
||||||
|
services.AddTransient<FormGenres>();
|
||||||
|
services.AddTransient<FormClients>();
|
||||||
|
services.AddTransient<FormClient>();
|
||||||
|
services.AddTransient<FormTests>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user