Compare commits

..

7 Commits
main ... lab3

Author SHA1 Message Date
8bdab27452 supermicrofix 2024-10-29 13:08:17 +04:00
1be331ffa7 update readme 2024-10-29 13:03:52 +04:00
dyakonovr
72737c3a3d microfix 2024-10-29 13:02:36 +04:00
dyakonovr
f8fc0b4584 done 2024-10-28 20:58:57 +04:00
dyakonovr
4b3da3c21e какой то фикс 2024-10-28 20:46:35 +04:00
dyakonovr
b4035d6b13 lab2 2024-09-29 21:12:45 +04:00
dyakonovr
e57bd46f1f done 2024-09-29 21:11:27 +04:00
35 changed files with 2289 additions and 1 deletions

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,65 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic
{
public class ManufacturerLogic : IManufacturerLogic
{
private readonly IManufacturerStorage _ManufacturerStorage;
public ManufacturerLogic(IManufacturerStorage ManufacturerStorage)
{
_ManufacturerStorage = ManufacturerStorage;
}
public void CreateOrUpdate(ManufacturerBindingModel model)
{
var element = _ManufacturerStorage.GetElement(
new ManufacturerBindingModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Такой статус уже существует");
}
if (model.Id.HasValue)
{
_ManufacturerStorage.Update(model);
}
else
{
_ManufacturerStorage.Insert(model);
}
}
public void Delete(ManufacturerBindingModel model)
{
var element = _ManufacturerStorage.GetElement(new ManufacturerBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Статус не найден");
}
_ManufacturerStorage.Delete(model);
}
public List<ManufacturerViewModel> Read(ManufacturerBindingModel model)
{
if (model == null)
{
return _ManufacturerStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<ManufacturerViewModel> { _ManufacturerStorage.GetElement(model) };
}
return _ManufacturerStorage.GetFilteredList(model);
}
}
}

View File

@ -0,0 +1,76 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic
{
public class ProductLogic : IProductLogic
{
private readonly IProductStorage _ProductStorage;
public ProductLogic(IProductStorage ProductStorage)
{
_ProductStorage = ProductStorage;
}
public void CreateOrUpdate(ProductBindingModel model)
{
var element = _ProductStorage.GetElement(
new ProductBindingModel
{
DeliveryDate = model.DeliveryDate,
Name = model.Name,
Manufacturers = model.Manufacturers,
Image = model.Image
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Клиент с таким именем уже существует");
}
if (model.Id.HasValue)
{
_ProductStorage.Update(model);
}
else
{
_ProductStorage.Insert(model);
}
}
public void Delete(ProductBindingModel model)
{
var element = _ProductStorage.GetElement(new ProductBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Клиент не найден");
}
_ProductStorage.Delete(model);
}
public List<ProductViewModel> Read(ProductBindingModel model)
{
if (model == null)
{
return _ProductStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<ProductViewModel> { _ProductStorage.GetElement(model) };
}
return _ProductStorage.GetFilteredList(model);
}
public List<(int, double)> GetWordInfo()
{
var data = _ProductStorage.GetProductCountByManufacturer();
return data
.Select((g, index) => (Index: index + 1, Value: (double)g.Count))
.ToList();
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class ManufacturerBindingModel
{
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class ProductBindingModel
{
public int? Id { get; set; }
public string Name { get; set; }
public byte[] Image { get; set; }
public string Manufacturers { get; set; }
public DateTime DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IManufacturerLogic
{
List<ManufacturerViewModel> Read(ManufacturerBindingModel model);
void CreateOrUpdate(ManufacturerBindingModel model);
void Delete(ManufacturerBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IProductLogic
{
List<ProductViewModel> Read(ProductBindingModel model);
List<(int, double)> GetWordInfo();
void CreateOrUpdate(ProductBindingModel model);
void Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ReportModels
{
public class ProductReportModel
{
public int? Id { get; set; }
public string Name { get; set; }
public string Image { get; set; }
public string Manufacturers { get; set; }
public string DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IManufacturerStorage
{
List<ManufacturerViewModel> GetFullList();
List<ManufacturerViewModel> GetFilteredList(ManufacturerBindingModel model);
ManufacturerViewModel GetElement(ManufacturerBindingModel model);
void Insert(ManufacturerBindingModel model);
void Update(ManufacturerBindingModel model);
void Delete(ManufacturerBindingModel model);
}
}

View File

@ -0,0 +1,23 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductBindingModel model);
ProductViewModel GetElement(ProductBindingModel model);
List<(string Manufacturer, int Count)> GetProductCountByManufacturer();
void Insert(ProductBindingModel model);
void Update(ProductBindingModel model);
void Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ManufacturerViewModel
{
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ProductViewModel
{
public int? Id { get; set; }
[DisplayName("Название")]
public string Name { get; set; }
[DisplayName("Изображение")]
public byte[] Image { get; set; }
[DisplayName("Производитель")]
public string Manufacturers { get; set; }
[DisplayName("Дата поставки")]
public DateTime DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,121 @@
using Contracts.BindingModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class ManufacturerStorage : IManufacturerStorage
{
public void Delete(ManufacturerBindingModel model)
{
var context = new ProductsDatabase();
var Manufacturer = context.Manufacturers.FirstOrDefault(rec => rec.Id == model.Id);
if (Manufacturer != null)
{
context.Manufacturers.Remove(Manufacturer);
context.SaveChanges();
}
else
{
throw new Exception("Производитель не найден");
}
}
public ManufacturerViewModel GetElement(ManufacturerBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new ProductsDatabase();
var manufacturer = context.Manufacturers
.ToList()
.FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
return manufacturer != null ? CreateModel(manufacturer) : null;
}
public List<ManufacturerViewModel> GetFilteredList(ManufacturerBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new ProductsDatabase();
return context.Manufacturers
.Where(rec => rec.Name.Contains(model.Name))
.Select(CreateModel)
.ToList();
}
public List<ManufacturerViewModel> GetFullList()
{
using var context = new ProductsDatabase();
return context.Manufacturers
.Select(CreateModel)
.ToList();
}
public void Insert(ManufacturerBindingModel model)
{
var context = new ProductsDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Manufacturers.Add(CreateModel(model, new Manufacturer()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(ManufacturerBindingModel model)
{
var context = new ProductsDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var Manufacturer = context.Manufacturers.FirstOrDefault(rec => rec.Id == model.Id);
if (Manufacturer == null)
{
throw new Exception("Производитель не найден");
}
CreateModel(model, Manufacturer);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
private static Manufacturer CreateModel(ManufacturerBindingModel model, Manufacturer Manufacturer)
{
Manufacturer.Name = model.Name;
return Manufacturer;
}
private static ManufacturerViewModel CreateModel(Manufacturer Manufacturer)
{
return new ManufacturerViewModel
{
Id = Manufacturer.Id,
Name = Manufacturer.Name
};
}
}
}

View File

@ -0,0 +1,144 @@
using Contracts.BindingModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class ProductStorage : IProductStorage
{
public void Delete(ProductBindingModel model)
{
var context = new ProductsDatabase();
var Product = context.Products.FirstOrDefault(rec => rec.Id == model.Id);
if (Product != null)
{
context.Products.Remove(Product);
context.SaveChanges();
}
else
{
throw new Exception("Продукт не найден");
}
}
public ProductViewModel GetElement(ProductBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new ProductsDatabase();
var Product = context.Products
.ToList()
.FirstOrDefault(rec => rec.Id == model.Id);
return Product != null ? CreateModel(Product) : null;
}
public List<ProductViewModel> GetFilteredList(ProductBindingModel model)
{
var context = new ProductsDatabase();
return context.Products
.ToList()
.Select(CreateModel)
.ToList();
}
public List<(string Manufacturer, int Count)> GetProductCountByManufacturer()
{
var context = new ProductsDatabase();
return context.Products
.GroupBy(p => p.Manufacturers)
.Select(g => new { Manufacturer = g.Key, Count = g.Count() })
.AsEnumerable() // Приведение к Enumerable, чтобы продолжить обработку в памяти
.Select(g => (g.Manufacturer, g.Count))
.ToList();
}
private ProductViewModel CustomCreateModel(Product product)
{
return new ProductViewModel
{
Manufacturers = product.Manufacturers,
};
}
public List<ProductViewModel> GetFullList()
{
using (var context = new ProductsDatabase())
{
return context.Products
.ToList()
.Select(CreateModel)
.ToList();
}
}
public void Insert(ProductBindingModel model)
{
var context = new ProductsDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Products.Add(CreateModel(model, new Product()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(ProductBindingModel model)
{
var context = new ProductsDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var Product = context.Products.FirstOrDefault(rec => rec.Id == model.Id);
if (Product == null)
{
throw new Exception("Продукт не найден");
}
CreateModel(model, Product);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
private static Product CreateModel(ProductBindingModel model, Product Product)
{
Product.DeliveryDate = model.DeliveryDate;
Product.Name = model.Name;
Product.Manufacturers = model.Manufacturers;
Product.Image = model.Image;
return Product;
}
private ProductViewModel CreateModel(Product Product)
{
return new ProductViewModel
{
Id = Product.Id,
Image = Product.Image,
Name = Product.Name,
Manufacturers = Product.Manufacturers,
DeliveryDate = Product.DeliveryDate
};
}
}
}

View File

@ -0,0 +1,74 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(ProductsDatabase))]
[Migration("20241012142150_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.33")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("DatabaseImplement.Models.Manufacturer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Manufacturers");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<DateTime>("DeliveryDate")
.HasColumnType("datetime2");
b.Property<byte[]>("Image")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<string>("Manufacturers")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Manufacturers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Image = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
Manufacturers = table.Column<string>(type: "nvarchar(max)", nullable: false),
DeliveryDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Manufacturers");
migrationBuilder.DropTable(
name: "Products");
}
}
}

View File

@ -0,0 +1,72 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(ProductsDatabase))]
partial class ProductsDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.33")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("DatabaseImplement.Models.Manufacturer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Manufacturers");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<DateTime>("DeliveryDate")
.HasColumnType("datetime2");
b.Property<byte[]>("Image")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<string>("Manufacturers")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Manufacturer
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Product
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public byte[] Image { get; set; }
[Required]
public string Manufacturers { get; set; }
[Required]
public DateTime DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace DatabaseImplement
{
public class ProductsDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-SPMUS7R;Initial Catalog=ProductsDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Product> Products { set; get; }
public virtual DbSet<Manufacturer> Manufacturers { set; get; }
}
}

View File

@ -1,2 +1,3 @@
# PIbd-33_Dyakonov_R_R_COP_14
Проект реализован с использованием компонентов преподавателя
При обновлении Продукта дата поставки не подтягивается в форму редактирования, т.к. в TextField некорректно реализован механизм установки Value (см. исходники ```ControlInputRegex```, ```public string Value```)

43
ShopProducts.sln Normal file
View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShopProducts", "ShopProducts\ShopProducts.csproj", "{E8F82DF1-6741-454A-B96D-C1F2FB29134D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{F2440E2E-293A-4107-980B-EC0020529692}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{344C1681-67A5-485B-8E99-89F7D5866078}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{80BABD36-989A-4181-9159-23A0BD3CF04A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8F82DF1-6741-454A-B96D-C1F2FB29134D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8F82DF1-6741-454A-B96D-C1F2FB29134D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8F82DF1-6741-454A-B96D-C1F2FB29134D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8F82DF1-6741-454A-B96D-C1F2FB29134D}.Release|Any CPU.Build.0 = Release|Any CPU
{F2440E2E-293A-4107-980B-EC0020529692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2440E2E-293A-4107-980B-EC0020529692}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2440E2E-293A-4107-980B-EC0020529692}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2440E2E-293A-4107-980B-EC0020529692}.Release|Any CPU.Build.0 = Release|Any CPU
{344C1681-67A5-485B-8E99-89F7D5866078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{344C1681-67A5-485B-8E99-89F7D5866078}.Debug|Any CPU.Build.0 = Debug|Any CPU
{344C1681-67A5-485B-8E99-89F7D5866078}.Release|Any CPU.ActiveCfg = Release|Any CPU
{344C1681-67A5-485B-8E99-89F7D5866078}.Release|Any CPU.Build.0 = Release|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1B480F8A-27B6-4A43-896B-4B570320DF49}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,63 @@
namespace ShopProducts
{
partial class FormManufacturers
{
/// <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()
{
dataGridView1 = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowTemplate.Height = 25;
dataGridView1.Size = new Size(642, 350);
dataGridView1.TabIndex = 0;
dataGridView1.CellContentClick += dataGridView1_CellContentClick;
dataGridView1.KeyDown += dataGridView1_KeyDown;
//
// FormManufacturers
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(663, 374);
Controls.Add(dataGridView1);
Name = "FormManufacturers";
Text = "FormManufacturers";
Load += FormManufacturers_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
}
}

View File

@ -0,0 +1,117 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
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 ShopProducts
{
public partial class FormManufacturers : Form
{
private readonly IManufacturerLogic _manufacturerLogic;
BindingList<ManufacturerBindingModel> list;
public FormManufacturers(IManufacturerLogic manufacturerLogic)
{
InitializeComponent();
_manufacturerLogic = manufacturerLogic;
list = new BindingList<ManufacturerBindingModel>();
// dataGridView1.AllowUserToAddRows = false;
}
private void LoadData()
{
try
{
var list1 = _manufacturerLogic.Read(null);
list.Clear();
foreach (var item in list1)
{
list.Add(new ManufacturerBindingModel
{
Id = item.Id,
Name = item.Name,
});
}
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormManufacturers_Load(object sender, EventArgs e)
{
LoadData();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
var typeName = (string)dataGridView1.CurrentRow.Cells[1].Value;
if (!string.IsNullOrEmpty(typeName))
{
if (dataGridView1.CurrentRow.Cells[0].Value != null)
{
_manufacturerLogic.CreateOrUpdate(new ManufacturerBindingModel()
{
Id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value),
Name = (string)dataGridView1.CurrentRow.Cells[1].EditedFormattedValue
});
}
else
{
_manufacturerLogic.CreateOrUpdate(new ManufacturerBindingModel()
{
Name = (string)dataGridView1.CurrentRow.Cells[1].EditedFormattedValue
});
}
}
else
{
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Insert)
{
if (dataGridView1.Rows.Count == 0)
{
list.Add(new ManufacturerBindingModel());
dataGridView1.DataSource = new BindingList<ManufacturerBindingModel>(list);
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[1];
return;
}
if (dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value != null)
{
list.Add(new ManufacturerBindingModel());
dataGridView1.DataSource = new BindingList<ManufacturerBindingModel>(list);
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1];
return;
}
}
if (e.KeyData == Keys.Delete)
{
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_manufacturerLogic.Delete(new ManufacturerBindingModel() { Id = (int)dataGridView1.CurrentRow.Cells[0].Value });
LoadData();
}
}
}
}
}

View File

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

189
ShopProducts/FormProduct.Designer.cs generated Normal file
View File

@ -0,0 +1,189 @@
namespace ShopProducts
{
partial class FormProduct
{
/// <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()
{
textBoxName = new TextBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
customComboBoxManufacturers = new ControlsLibraryNet60.Selected.ControlSelectedComboBoxSingle();
label4 = new Label();
customTextBoxDate = new ControlsLibraryNet60.Input.ControlInputRegexDate();
buttonSave = new Button();
buttonCancel = new Button();
imageFileLabel = new Label();
pickFileButton = new Button();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(14, 36);
textBoxName.Margin = new Padding(3, 4, 3, 4);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(261, 27);
textBoxName.TabIndex = 0;
textBoxName.TextChanged += textBoxName_TextChanged;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(14, 12);
label1.Name = "label1";
label1.Size = new Size(49, 20);
label1.TabIndex = 1;
label1.Text = "Name";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(13, 71);
label2.Name = "label2";
label2.Size = new Size(51, 20);
label2.TabIndex = 2;
label2.Text = "Image";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(13, 129);
label3.Name = "label3";
label3.Size = new Size(103, 20);
label3.TabIndex = 4;
label3.Text = "Manufacturers";
//
// customComboBoxManufacturers
//
customComboBoxManufacturers.Location = new Point(16, 153);
customComboBoxManufacturers.Margin = new Padding(6, 4, 6, 4);
customComboBoxManufacturers.Name = "customComboBoxManufacturers";
customComboBoxManufacturers.SelectedElement = "";
customComboBoxManufacturers.Size = new Size(256, 32);
customComboBoxManufacturers.TabIndex = 5;
customComboBoxManufacturers.SelectedElementChange += customComboBoxManufacturers_SelectedElementChange;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(16, 189);
label4.Name = "label4";
label4.Size = new Size(41, 20);
label4.TabIndex = 6;
label4.Text = "Date";
//
// customTextBoxDate
//
customTextBoxDate.Location = new Point(16, 213);
customTextBoxDate.Margin = new Padding(6, 4, 6, 4);
customTextBoxDate.Name = "customTextBoxDate";
customTextBoxDate.Pattern = "^\\d{1,2} \\w{3,8} \\d{4}$";
customTextBoxDate.Size = new Size(256, 31);
customTextBoxDate.TabIndex = 7;
customTextBoxDate.Value = "";
customTextBoxDate.ElementChanged += customTextBoxDate_ElementChanged;
//
// buttonSave
//
buttonSave.Location = new Point(16, 272);
buttonSave.Margin = new Padding(3, 4, 3, 4);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(86, 31);
buttonSave.TabIndex = 8;
buttonSave.Text = "Save";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(186, 272);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(86, 31);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Cancel";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// imageFileLabel
//
imageFileLabel.AutoSize = true;
imageFileLabel.Location = new Point(16, 101);
imageFileLabel.Name = "imageFileLabel";
imageFileLabel.Size = new Size(54, 20);
imageFileLabel.TabIndex = 10;
imageFileLabel.Text = "No file";
//
// pickFileButton
//
pickFileButton.Location = new Point(135, 97);
pickFileButton.Name = "pickFileButton";
pickFileButton.Size = new Size(140, 29);
pickFileButton.TabIndex = 11;
pickFileButton.Text = "Pick file";
pickFileButton.UseVisualStyleBackColor = true;
pickFileButton.Click += pickFileButton_Click;
//
// FormProduct
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(287, 331);
Controls.Add(pickFileButton);
Controls.Add(imageFileLabel);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(customTextBoxDate);
Controls.Add(label4);
Controls.Add(customComboBoxManufacturers);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBoxName);
Margin = new Padding(3, 4, 3, 4);
Name = "FormProduct";
Text = "FormProduct";
Load += FormProduct_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label label1;
private Label label2;
private Label label3;
private ControlsLibraryNet60.Selected.ControlSelectedComboBoxSingle customComboBoxManufacturers;
private Label label4;
private ControlsLibraryNet60.Input.ControlInputRegexDate customTextBoxDate;
private Button buttonSave;
private Button buttonCancel;
private Label imageFileLabel;
private Button pickFileButton;
}
}

159
ShopProducts/FormProduct.cs Normal file
View File

@ -0,0 +1,159 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using DocumentFormat.OpenXml.Office2010.Excel;
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 ShopProducts
{
public partial class FormProduct : Form
{
public int Id { set { id = value; } }
private readonly IProductLogic _logic;
private readonly IManufacturerLogic _logicM;
private int? id;
private bool _wasChanged = false;
private byte[]? productImage = null;
public FormProduct(IProductLogic logic, IManufacturerLogic logicM)
{
InitializeComponent();
_logic = logic;
_logicM = logicM;
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (productImage == null)
{
MessageBox.Show("Выберите фото", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(customComboBoxManufacturers.SelectedElement))
{
MessageBox.Show("Выберите производителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(customTextBoxDate.Value))
{
MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var date = DateTime.ParseExact(customTextBoxDate.Value, "dd MMMM yyyy", new System.Globalization.CultureInfo("ru-RU"));
_logic.CreateOrUpdate(new ProductBindingModel
{
Id = id,
Image = productImage,
Name = textBoxName.Text,
Manufacturers = customComboBoxManufacturers.SelectedElement.ToString(),
DeliveryDate = date,
});
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
if (_wasChanged)
{
DialogResult dialogResult = MessageBox.Show("Есть внесенные изменения, вы точно хотите выйти?", "Предупреждение", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Close();
}
return;
}
DialogResult = DialogResult.Cancel;
Close();
}
private void textBoxName_TextChanged(object sender, EventArgs e)
{
_wasChanged = true;
}
private void textBoxImage_TextChanged(object sender, EventArgs e)
{
_wasChanged = true;
}
private void customComboBoxManufacturers_SelectedElementChange(object sender, EventArgs e)
{
_wasChanged = true;
}
private void customTextBoxDate_ElementChanged(object sender, EventArgs e)
{
_wasChanged = true;
}
private void FormProduct_Load(object sender, EventArgs e)
{
List<ManufacturerViewModel> mViews = _logicM.Read(null);
if (mViews != null)
{
for (int i = 0; i < mViews.Count; i++)
{
customComboBoxManufacturers.AddElement(mViews[i].Name);
}
}
if (id.HasValue)
{
ProductViewModel product = _logic.Read(new ProductBindingModel { Id = id.Value })?[0];
if (product != null)
{
textBoxName.Text = product.Name;
ChangeImageFile(product.Image);
customComboBoxManufacturers.SelectedElement = product.Manufacturers;
var date = product.DeliveryDate.ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("ru-RU"));
// Не работает
customTextBoxDate.Value = date;
}
}
}
private void pickFileButton_Click(object sender, EventArgs e)
{
using OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Изображения|*.jpg;*.jpeg;*.png;*.bmp"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
ChangeImageFile(File.ReadAllBytes(openFileDialog.FileName));
}
}
private void ChangeImageFile(byte[]? bytes)
{
productImage = bytes;
imageFileLabel.Text = bytes == null ? "No file" : "File picked";
}
}
}

View File

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

147
ShopProducts/FormProducts.Designer.cs generated Normal file
View File

@ -0,0 +1,147 @@
namespace ShopProducts
{
partial class FormProducts
{
/// <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()
{
components = new System.ComponentModel.Container();
controlDataTableRow1 = new ControlsLibraryNet60.Data.ControlDataTableRow();
contextMenuStrip1 = new ContextMenuStrip(components);
сохранитьВордtoolStripMenuItem = new ToolStripMenuItem();
сохранитьЭксельtoolStripMenuItem = new ToolStripMenuItem();
сохранитьПдфtoolStripMenuItem = new ToolStripMenuItem();
удалитьtoolStripMenuItem = new ToolStripMenuItem();
редактироватьtoolStripMenuItem = new ToolStripMenuItem();
добавитьtoolStripMenuItem = new ToolStripMenuItem();
справочникtoolStripMenuItem = new ToolStripMenuItem();
pdfWithImages1 = new WinFormsLibrary1.PdfWithImages(components);
componentDocumentWithTableHeaderRowExcel1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowExcel(components);
componentDocumentWithChartBarWord1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord(components);
contextMenuStrip1.SuspendLayout();
SuspendLayout();
//
// controlDataTableRow1
//
controlDataTableRow1.Location = new Point(89, 53);
controlDataTableRow1.Margin = new Padding(5, 4, 5, 4);
controlDataTableRow1.Name = "controlDataTableRow1";
controlDataTableRow1.SelectedRowIndex = -1;
controlDataTableRow1.Size = new Size(730, 479);
controlDataTableRow1.TabIndex = 0;
//
// contextMenuStrip1
//
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { сохранитьВордtoolStripMenuItem, сохранитьЭксельtoolStripMenuItem, сохранитьПдфtoolStripMenuItem, удалитьtoolStripMenuItem, редактироватьtoolStripMenuItem, добавитьtoolStripMenuItem, справочникtoolStripMenuItem });
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(255, 172);
//
// сохранитьВордtoolStripMenuItem
//
сохранитьВордtoolStripMenuItem.Name = "сохранитьВордtoolStripMenuItem";
сохранитьВордtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
сохранитьВордtoolStripMenuItem.Size = new Size(254, 24);
сохранитьВордtoolStripMenuItem.Text = "Сохранить Ворд";
сохранитьВордtoolStripMenuItem.Click += сохранитьВордToolStripMenuItem_Click;
//
// сохранитьЭксельtoolStripMenuItem
//
сохранитьЭксельtoolStripMenuItem.Name = "сохранитьЭксельtoolStripMenuItem";
сохранитьЭксельtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
сохранитьЭксельtoolStripMenuItem.Size = new Size(254, 24);
сохранитьЭксельtoolStripMenuItem.Text = "Сохранить Эксель";
сохранитьЭксельtoolStripMenuItem.Click += сохранитьЭксельToolStripMenuItem_Click;
//
// сохранитьПдфtoolStripMenuItem
//
сохранитьПдфtoolStripMenuItem.Name = "сохранитьПдфtoolStripMenuItem";
сохранитьПдфtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
сохранитьПдфtoolStripMenuItem.Size = new Size(254, 24);
сохранитьПдфtoolStripMenuItem.Text = "Сохранить ПДФ";
сохранитьПдфtoolStripMenuItem.Click += сохранитьПдфToolStripMenuItem_Click;
//
// удалитьtoolStripMenuItem
//
удалитьtoolStripMenuItem.Name = "удалитьtoolStripMenuItem";
удалитьtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
удалитьtoolStripMenuItem.Size = new Size(254, 24);
удалитьtoolStripMenuItem.Text = "Удалить";
удалитьtoolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
//
// редактироватьtoolStripMenuItem
//
редактироватьtoolStripMenuItem.Name = "редактироватьtoolStripMenuItem";
редактироватьtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
редактироватьtoolStripMenuItem.Size = new Size(254, 24);
редактироватьtoolStripMenuItem.Text = "Редактировать";
редактироватьtoolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
//
// добавитьtoolStripMenuItem
//
добавитьtoolStripMenuItem.Name = обавитьtoolStripMenuItem";
добавитьtoolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
добавитьtoolStripMenuItem.Size = new Size(254, 24);
добавитьtoolStripMenuItem.Text = "Добавить";
добавитьtoolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
//
// справочникtoolStripMenuItem
//
справочникtoolStripMenuItem.Name = "справочникtoolStripMenuItem";
справочникtoolStripMenuItem.Size = new Size(254, 24);
справочникtoolStripMenuItem.Text = "Справочник";
справочникtoolStripMenuItem.Click += справочникToolStripMenuItem_Click;
//
// FormProducts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 600);
Controls.Add(controlDataTableRow1);
Margin = new Padding(3, 4, 3, 4);
Name = "FormProducts";
Text = "Form1";
Load += FormProducts_Load;
contextMenuStrip1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ControlsLibraryNet60.Data.ControlDataTableRow controlDataTableRow1;
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem сохранитьВордtoolStripMenuItem;
private ToolStripMenuItem сохранитьЭксельtoolStripMenuItem;
private ToolStripMenuItem сохранитьПдфtoolStripMenuItem;
private ToolStripMenuItem удалитьtoolStripMenuItem;
private ToolStripMenuItem редактироватьtoolStripMenuItem;
private ToolStripMenuItem добавитьtoolStripMenuItem;
private ToolStripMenuItem справочникtoolStripMenuItem;
private WinFormsLibrary1.PdfWithImages pdfWithImages1;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowExcel componentDocumentWithTableHeaderRowExcel1;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord componentDocumentWithChartBarWord1;
}
}

View File

@ -0,0 +1,250 @@
using ComponentsLibraryNet60.Models;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Models;
using DocumentFormat.OpenXml.Drawing.Charts;
using WinFormsLibrary1.Configs.Image;
namespace ShopProducts
{
public partial class FormProducts : Form
{
private readonly IProductLogic _productLogic;
public FormProducts(IProductLogic productLogic)
{
InitializeComponent();
_productLogic = productLogic;
controlDataTableRow1.ContextMenuStrip = contextMenuStrip1;
InitTable();
}
private void InitTable()
{
var tableConfig = new List<DataTableColumnConfig>
{
new DataTableColumnConfig
{
ColumnHeader = "Id",
PropertyName = "Id",
Visible = false
},
new DataTableColumnConfig
{
ColumnHeader = "Name",
PropertyName = "Name",
Visible = true
},
new DataTableColumnConfig
{
ColumnHeader = "Manufacturers",
PropertyName = "Manufacturers",
Visible = true
},
new DataTableColumnConfig
{
ColumnHeader = "Delivery date",
PropertyName = "DeliveryDate",
Visible = true
}
};
controlDataTableRow1.LoadColumns(tableConfig);
}
private void LoadData()
{
try
{
controlDataTableRow1.Clear();
var list = _productLogic.Read(null);
for (int i = 0; i < list.Count; i++)
{
controlDataTableRow1.AddRow(list[i]);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormProducts_Load(object sender, EventArgs e)
{
LoadData();
}
private void AddNewElement()
{
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
if (service is FormProduct form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void UpdateElement()
{
var selectedProduct = controlDataTableRow1.GetSelectedObject<ProductViewModel>();
if (selectedProduct != null)
{
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
if (service is FormProduct form)
{
form.Id = Convert.ToInt32(selectedProduct.Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
else
{
MessageBox.Show("Âûáåðèòå êëèåíòà äëÿ ðåäàêòèðîâàíèÿ");
}
}
private void DeleteElement()
{
if (MessageBox.Show("Óäàëèòü çàïèñü", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedProduct = controlDataTableRow1.GetSelectedObject<ProductViewModel>();
try
{
int id = Convert.ToInt32(selectedProduct.Id);
_productLogic.Delete(new ProductBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
private void CreateWord()
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "Word Document (*.docx)|*.docx";
saveFileDialog.Title = "Ñîõðàíèòü Word ôàéë";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var data = _productLogic.GetWordInfo();
componentDocumentWithChartBarWord1.CreateDoc(new ComponentDocumentWithChartConfig
{
FilePath = saveFileDialog.FileName,
Header = "Ãèñòîãðàììà ïðîäóêòîâ",
ChartTitle = "Êîë-âî ïðîäóêöèè ïî ïðîèçâîäèòåëþ",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = new Dictionary<string, List<(int Date, double Value)>>
{
{ "TTT", data }
}
});
MessageBox.Show("Word óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void CreateExcel()
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx";
saveFileDialog.Title = "Ñîõðàíèòü Excel ôàéë";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var list = _productLogic.Read(null);
componentDocumentWithTableHeaderRowExcel1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<ProductViewModel>
{
FilePath = saveFileDialog.FileName,
Header = "Ïðîäóêòû",
UseUnion = true,
ColumnsRowsWidth = new List<(int, int)> { (5, 0), (10, 0), (10, 0), (10, 0) },
ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "ID", "Id"),
(1, 0, "Ïðîäóêò", ""),
(1, 1, "Íàçâàíèå", "Name"),
(2, 1, "Ïðîèçâîäèòåëü", "Manufacturers"),
(3, 0, "Äàòà ïîñòàâêè", "DeliveryDate"),
},
Data = list
});
MessageBox.Show("Excel óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void CreatePdf()
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "PDF Document (*.pdf)|*.pdf";
saveFileDialog.Title = "Ñîõðàíèòü PDF ôàéë";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var productImages = _productLogic.Read(null).Select(p => p.Image).ToList();
var config = new PdfWithImageConfig
{
FilePath = saveFileDialog.FileName,
Header = "Äîêóìåíò ñ èçîáðàæåíèÿìè",
Images = productImages
};
pdfWithImages1.CreatePdf(config);
MessageBox.Show("PDF óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void ñîõðàíèòüÂîðäToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void ñîõðàíèòüÝêñåëüToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateExcel();
}
private void ñîõðàíèòüÏäôToolStripMenuItem_Click(object sender, EventArgs e)
{
CreatePdf();
}
private void óäàëèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteElement();
}
private void ðåäàêòèðîâàòüToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateElement();
}
private void äîáàâèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewElement();
}
private void ñïðàâî÷íèêToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormManufacturers));
if (service is FormManufacturers form)
{
form.ShowDialog();
}
}
}
}

View File

@ -0,0 +1,132 @@
<?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>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pdfWithImages1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>202, 17</value>
</metadata>
<metadata name="componentDocumentWithTableHeaderRowExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>368, 17</value>
</metadata>
<metadata name="componentDocumentWithChartBarWord1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 58</value>
</metadata>
</root>

44
ShopProducts/Program.cs Normal file
View File

@ -0,0 +1,44 @@
using BusinessLogic;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace ShopProducts
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormProducts>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
});
services.AddTransient<IProductStorage, ProductStorage>();
services.AddTransient<IManufacturerStorage, ManufacturerStorage>();
services.AddTransient<IProductLogic, ProductLogic>();
services.AddTransient<IManufacturerLogic, ManufacturerLogic>();
services.AddTransient<FormProducts>();
services.AddTransient<FormProduct>();
services.AddTransient<FormManufacturers>();
}
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="WinFormsLibrary1" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
</Project>