Да
This commit is contained in:
parent
0bd1b174eb
commit
6a7c428cdb
22
Contracts/BindingModels/BookBindingModel.cs
Normal file
22
Contracts/BindingModels/BookBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class BookBindingModel : IBook
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Readers { get; set; } = string.Empty;
|
||||
|
||||
public string Shape { get; set; } = string.Empty;
|
||||
|
||||
public string Annotation { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
16
Contracts/BindingModels/ShapeBindingModel.cs
Normal file
16
Contracts/BindingModels/ShapeBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class ShapeBindingModel : IShape
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
13
Contracts/Contracts.csproj
Normal file
13
Contracts/Contracts.csproj
Normal 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="..\DataModels\DataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
Contracts/SearchModels/BookSearchModel.cs
Normal file
14
Contracts/SearchModels/BookSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class BookSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
14
Contracts/SearchModels/ShapeSearchModel.cs
Normal file
14
Contracts/SearchModels/ShapeSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class ShapeSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
21
Contracts/StoragesContracts/IBookStorage.cs
Normal file
21
Contracts/StoragesContracts/IBookStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IBookStorage
|
||||
{
|
||||
List<BookViewModel> GetFullList();
|
||||
List<BookViewModel> GetFilteredList(BookSearchModel model);
|
||||
BookViewModel? GetElement(BookSearchModel model);
|
||||
BookViewModel? Insert(BookBindingModel model);
|
||||
BookViewModel? Update(BookBindingModel model);
|
||||
BookViewModel? Delete(BookBindingModel model);
|
||||
}
|
||||
}
|
21
Contracts/StoragesContracts/IShapeStorage.cs
Normal file
21
Contracts/StoragesContracts/IShapeStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.StoragesContracts
|
||||
{
|
||||
public interface IShapeStorage
|
||||
{
|
||||
List<ShapeViewModel> GetFullList();
|
||||
List<ShapeViewModel> GetFilteredList(ShapeSearchModel model);
|
||||
ShapeViewModel? GetElement(ShapeSearchModel model);
|
||||
ShapeViewModel? Insert(ShapeBindingModel model);
|
||||
ShapeViewModel? Update(ShapeBindingModel model);
|
||||
ShapeViewModel? Delete(ShapeBindingModel model);
|
||||
}
|
||||
}
|
22
Contracts/ViewModels/BookViewModel.cs
Normal file
22
Contracts/ViewModels/BookViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class BookViewModel : IBook
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Readers { get; set; } = string.Empty;
|
||||
|
||||
public string Shape { get; set; } = string.Empty;
|
||||
|
||||
public string Annotation { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
23
Contracts/ViewModels/ShapeViewModel.cs
Normal file
23
Contracts/ViewModels/ShapeViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.ViewModels
|
||||
{
|
||||
public class ShapeViewModel : IShape
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public ShapeViewModel() { }
|
||||
|
||||
public ShapeViewModel(IShape shape)
|
||||
{
|
||||
Id = shape.Id;
|
||||
Name = shape.Name;
|
||||
}
|
||||
}
|
||||
}
|
9
DataModels/DataModels.csproj
Normal file
9
DataModels/DataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
13
DataModels/IId.cs
Normal file
13
DataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
16
DataModels/Models/IBook.cs
Normal file
16
DataModels/Models/IBook.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IBook: IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Readers { get; }
|
||||
string Shape { get; }
|
||||
string Annotation { get; }
|
||||
}
|
||||
}
|
13
DataModels/Models/IShape.cs
Normal file
13
DataModels/Models/IShape.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public interface IShape: IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
26
DatabaseImplement/COPcontext.cs
Normal file
26
DatabaseImplement/COPcontext.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using DatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement
|
||||
{
|
||||
public class COPcontext: DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder
|
||||
optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-ON2V3BB\SQLEXPRESS;Initial Catalog=COPDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Book> Books { set; get; }
|
||||
public virtual DbSet<Shape> Shapes { set; get; }
|
||||
}
|
||||
}
|
23
DatabaseImplement/DatabaseImplement.csproj
Normal file
23
DatabaseImplement/DatabaseImplement.csproj
Normal file
@ -0,0 +1,23 @@
|
||||
<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.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
<ProjectReference Include="..\DataModels\DataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
94
DatabaseImplement/Implements/BookStorage.cs
Normal file
94
DatabaseImplement/Implements/BookStorage.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class BookStorage : IBookStorage
|
||||
{
|
||||
public BookViewModel? Delete(BookBindingModel model)
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
var element = context.Books.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Books.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BookViewModel? GetElement(BookSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
return context.Books
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Name) && x.Name ==
|
||||
model.Name) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<BookViewModel> GetFilteredList(BookSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
return context.Books
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<BookViewModel> GetFullList()
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
return context.Books
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public BookViewModel? Insert(BookBindingModel model)
|
||||
{
|
||||
var newComponent = Book.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
context.Books.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public BookViewModel? Update(BookBindingModel model)
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
var component = context.Books.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
93
DatabaseImplement/Implements/ShapeStorage.cs
Normal file
93
DatabaseImplement/Implements/ShapeStorage.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
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 ShapeStorage : IShapeStorage
|
||||
{
|
||||
public ShapeViewModel? Delete(ShapeBindingModel model)
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
var element = context.Shapes.FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Shapes.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShapeViewModel? GetElement(ShapeSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
return context.Shapes
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Name) && x.Name ==
|
||||
model.Name) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ShapeViewModel> GetFilteredList(ShapeSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
return context.Shapes
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShapeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
return context.Shapes
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ShapeViewModel? Insert(ShapeBindingModel model)
|
||||
{
|
||||
var newComponent = Shape.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new COPcontext();
|
||||
context.Shapes.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public ShapeViewModel? Update(ShapeBindingModel model)
|
||||
{
|
||||
using var context = new COPcontext();
|
||||
var component = context.Shapes.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
74
DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs
generated
Normal file
74
DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
||||
// <auto-generated />
|
||||
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(COPcontext))]
|
||||
[Migration("20231116180013_Migration1")]
|
||||
partial class Migration1
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Book", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("Annotation")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Readers")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Shape")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Books");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Shape", 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("Shapes");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
50
DatabaseImplement/Migrations/20231116180013_Migration1.cs
Normal file
50
DatabaseImplement/Migrations/20231116180013_Migration1.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DatabaseImplement.Migrations
|
||||
{
|
||||
public partial class Migration1 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Books",
|
||||
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),
|
||||
Readers = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Shape = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Annotation = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Books", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shapes",
|
||||
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_Shapes", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Books");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shapes");
|
||||
}
|
||||
}
|
||||
}
|
72
DatabaseImplement/Migrations/COPcontextModelSnapshot.cs
Normal file
72
DatabaseImplement/Migrations/COPcontextModelSnapshot.cs
Normal file
@ -0,0 +1,72 @@
|
||||
// <auto-generated />
|
||||
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(COPcontext))]
|
||||
partial class COPcontextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Book", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("Annotation")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Readers")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Shape")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Books");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DatabaseImplement.Models.Shape", 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("Shapes");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
65
DatabaseImplement/Models/Book.cs
Normal file
65
DatabaseImplement/Models/Book.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
public class Book : IBook
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Readers { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Shape { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Annotation { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Book? Create(BookBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Book()
|
||||
{
|
||||
Id = model.Id,
|
||||
Annotation = model.Annotation,
|
||||
Name = model.Name,
|
||||
Readers = model.Readers,
|
||||
Shape = model.Shape
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(BookBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Readers = model.Readers;
|
||||
Shape = model.Shape;
|
||||
Annotation = model.Annotation;
|
||||
|
||||
}
|
||||
public BookViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Annotation = Annotation,
|
||||
Name = Name,
|
||||
Readers = Readers,
|
||||
Shape = Shape
|
||||
|
||||
};
|
||||
}
|
||||
}
|
51
DatabaseImplement/Models/Shape.cs
Normal file
51
DatabaseImplement/Models/Shape.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using DataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
|
||||
public class Shape : IShape
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }=string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public static Shape? Create(ShapeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shape()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShapeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
Name = model.Name;
|
||||
}
|
||||
public ShapeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
}
|
26
KOP_Labs.sln
26
KOP_Labs.sln
@ -5,7 +5,15 @@ VisualStudioVersion = 17.5.33424.131
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KOP_Labs", "KOP_Labs\KOP_Labs.csproj", "{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForm", "WinForm\WinForm.csproj", "{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForm", "WinForm\WinForm.csproj", "{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{4F141B46-CBC9-455D-8A34-27F950FD62C2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin", "Plugin\Plugin.csproj", "{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -21,6 +29,22 @@ Global
|
||||
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F141B46-CBC9-455D-8A34-27F950FD62C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F141B46-CBC9-455D-8A34-27F950FD62C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F141B46-CBC9-455D-8A34-27F950FD62C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F141B46-CBC9-455D-8A34-27F950FD62C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
31
KOP_Labs/BooksForm.Designer.cs
generated
31
KOP_Labs/BooksForm.Designer.cs
generated
@ -28,45 +28,46 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxComponent = new GroupBox();
|
||||
listBoxComponent = new ListBox();
|
||||
groupBoxComponent = new GroupBox();
|
||||
groupBoxComponent.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxComponent
|
||||
//
|
||||
groupBoxComponent.Controls.Add(listBoxComponent);
|
||||
groupBoxComponent.Location = new Point(19, 28);
|
||||
groupBoxComponent.Name = "groupBoxComponent";
|
||||
groupBoxComponent.Size = new Size(517, 183);
|
||||
groupBoxComponent.TabIndex = 0;
|
||||
groupBoxComponent.TabStop = false;
|
||||
groupBoxComponent.Text = "Компонент";
|
||||
//
|
||||
// listBoxComponent
|
||||
//
|
||||
listBoxComponent.FormattingEnabled = true;
|
||||
listBoxComponent.ItemHeight = 20;
|
||||
listBoxComponent.Location = new Point(24, 35);
|
||||
listBoxComponent.Location = new Point(37, 48);
|
||||
listBoxComponent.Name = "listBoxComponent";
|
||||
listBoxComponent.Size = new Size(476, 124);
|
||||
listBoxComponent.Size = new Size(196, 44);
|
||||
listBoxComponent.TabIndex = 0;
|
||||
listBoxComponent.SelectedIndexChanged += listBoxComponent_SelectedIndexChanged;
|
||||
//
|
||||
// groupBoxComponent
|
||||
//
|
||||
groupBoxComponent.Controls.Add(listBoxComponent);
|
||||
groupBoxComponent.Dock = DockStyle.Fill;
|
||||
groupBoxComponent.Location = new Point(0, 0);
|
||||
groupBoxComponent.Name = "groupBoxComponent";
|
||||
groupBoxComponent.Size = new Size(283, 132);
|
||||
groupBoxComponent.TabIndex = 0;
|
||||
groupBoxComponent.TabStop = false;
|
||||
groupBoxComponent.Text = "Компонент";
|
||||
//
|
||||
// BooksForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(groupBoxComponent);
|
||||
Name = "BooksForm";
|
||||
Size = new Size(563, 258);
|
||||
Size = new Size(283, 132);
|
||||
groupBoxComponent.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxComponent;
|
||||
private ListBox listBoxComponent;
|
||||
private GroupBox groupBoxComponent;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace KOP_Labs
|
||||
|
||||
private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_selectChanged?.Invoke(this, e);
|
||||
_selectChanged?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace KOP_Labs.Classes
|
||||
{
|
||||
|
||||
public string Author { get; private set; } = string.Empty;
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public string Annotation { get; private set; } = string.Empty;
|
||||
@ -20,10 +20,10 @@ namespace KOP_Labs.Classes
|
||||
{
|
||||
|
||||
}
|
||||
public Book(string author, int id, string name, string annotation)
|
||||
public Book(string author, string name, string annotation)
|
||||
{
|
||||
Author = author;
|
||||
Id = id;
|
||||
|
||||
Name = name;
|
||||
Annotation = annotation;
|
||||
|
||||
|
@ -5,11 +5,14 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="23.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.25" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
11
KOP_Labs/TableComponent.Designer.cs
generated
11
KOP_Labs/TableComponent.Designer.cs
generated
@ -34,16 +34,17 @@
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(36, 29);
|
||||
dataGridView.Location = new Point(17, 22);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(300, 188);
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(304, 200);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.SelectionChanged += SelectionChanged;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
//
|
||||
// TableComponent
|
||||
//
|
||||
@ -51,7 +52,7 @@
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(dataGridView);
|
||||
Name = "TableComponent";
|
||||
Size = new Size(542, 301);
|
||||
Size = new Size(342, 239);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace KOP_Labs
|
||||
public void TableConfiguration(int countCol, List<TableParameters> parameters)
|
||||
{
|
||||
if (parameters.Count != parameters.Count) { return; }
|
||||
for (int i = 0; i < countCol; i++)
|
||||
for (int i = 0; i < countCol; i++)
|
||||
{
|
||||
DataGridViewColumn column = new DataGridViewColumn();
|
||||
column.Name = parameters[i]._name;
|
||||
@ -67,7 +67,7 @@ namespace KOP_Labs
|
||||
|
||||
dataGridView.Rows.Add(row);
|
||||
}
|
||||
|
||||
|
||||
public T GetSelectedObject<T>() where T : new()
|
||||
{
|
||||
if (dataGridView.SelectedCells.Count == 0)
|
||||
|
7
Plugin/Class1.cs
Normal file
7
Plugin/Class1.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Plugin
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
65
Plugin/IPluginsConvention.cs
Normal file
65
Plugin/IPluginsConvention.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{/*
|
||||
/// <summary>
|
||||
/// Название плагина
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
/// <summary>
|
||||
/// Получение контрола для вывода набора данных
|
||||
/// </summary>
|
||||
UserControl GetControl { get; }
|
||||
/// <summary>
|
||||
/// Получение элемента, выбранного в контроле
|
||||
/// </summary>
|
||||
PluginsConventionElement GetElement { get; }
|
||||
/// <summary>
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Получение формы для работы со справочником
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Form GetThesaurus();
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
3
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument
|
||||
saveDocument);
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);*/
|
||||
}
|
||||
}
|
9
Plugin/Plugin.csproj
Normal file
9
Plugin/Plugin.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
14
Plugin/PluginsConventionElement.cs
Normal file
14
Plugin/PluginsConventionElement.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
}
|
13
Plugin/PluginsConventionSaveDocument.cs
Normal file
13
Plugin/PluginsConventionSaveDocument.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
@ -45,9 +45,9 @@ namespace WinForm
|
||||
|
||||
private void buttonTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
tableComponent.AddRow(new Book("gfgdf",1, "book1", "lalala"));
|
||||
tableComponent.AddRow(new Book("Pushkin", 1, "book2", "lalala2"));
|
||||
tableComponent.AddRow(new Book("Pushkin", 1, "book3", "lalala"));
|
||||
tableComponent.AddRow(new Book("gfgdf", "book1", "lalala"));
|
||||
tableComponent.AddRow(new Book("Pushkin","book2", "lalala2"));
|
||||
tableComponent.AddRow(new Book("Pushkin", "book3", "lalala"));
|
||||
|
||||
}
|
||||
|
||||
|
153
WinForm/FormCreateBook.Designer.cs
generated
Normal file
153
WinForm/FormCreateBook.Designer.cs
generated
Normal file
@ -0,0 +1,153 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class FormCreateBook
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBoxReaders = new TextBox();
|
||||
booksForm1 = new KOP_Labs.BooksForm();
|
||||
textBoxAnnotation = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
buttonSave = new Button();
|
||||
input_text1 = new ViewComponents.Input_text();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxReaders
|
||||
//
|
||||
textBoxReaders.Location = new Point(120, 95);
|
||||
textBoxReaders.Name = "textBoxReaders";
|
||||
textBoxReaders.Size = new Size(509, 27);
|
||||
textBoxReaders.TabIndex = 1;
|
||||
//
|
||||
// booksForm1
|
||||
//
|
||||
booksForm1.Location = new Point(120, 154);
|
||||
booksForm1.Name = "booksForm1";
|
||||
booksForm1.SelectedValue = null;
|
||||
booksForm1.Size = new Size(509, 111);
|
||||
booksForm1.TabIndex = 2;
|
||||
//
|
||||
// textBoxAnnotation
|
||||
//
|
||||
textBoxAnnotation.Location = new Point(105, 345);
|
||||
textBoxAnnotation.Multiline = true;
|
||||
textBoxAnnotation.Name = "textBoxAnnotation";
|
||||
textBoxAnnotation.Size = new Size(509, 138);
|
||||
textBoxAnnotation.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 34);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(80, 20);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Название:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 95);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(76, 20);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Читатели:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(16, 192);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(60, 20);
|
||||
label3.TabIndex = 6;
|
||||
label3.Text = "Форма:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(2, 345);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(89, 20);
|
||||
label4.TabIndex = 7;
|
||||
label4.Text = "Аннотация:";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(535, 489);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click_1;
|
||||
//
|
||||
// input_text1
|
||||
//
|
||||
input_text1.Element = "Range exeption";
|
||||
input_text1.Location = new Point(105, 2);
|
||||
input_text1.MaxLen = -1;
|
||||
input_text1.MinLen = -1;
|
||||
input_text1.Name = "input_text1";
|
||||
input_text1.Size = new Size(542, 68);
|
||||
input_text1.TabIndex = 9;
|
||||
//
|
||||
// FormCreateBook
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
ClientSize = new Size(659, 528);
|
||||
Controls.Add(input_text1);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxAnnotation);
|
||||
Controls.Add(booksForm1);
|
||||
Controls.Add(textBoxReaders);
|
||||
Name = "FormCreateBook";
|
||||
Text = "FormCreateBook";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private TextBox textBoxReaders;
|
||||
private KOP_Labs.BooksForm booksForm1;
|
||||
private TextBox textBoxAnnotation;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Button buttonSave;
|
||||
private ViewComponents.Input_text input_text1;
|
||||
}
|
||||
}
|
75
WinForm/FormCreateBook.cs
Normal file
75
WinForm/FormCreateBook.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.StoragesContracts;
|
||||
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 WinForm
|
||||
{
|
||||
public partial class FormCreateBook : Form
|
||||
{
|
||||
|
||||
public readonly IBookStorage _bookStorage;
|
||||
public readonly IShapeStorage _shapeStorage;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormCreateBook(IBookStorage bookStorage, IShapeStorage shapeStorage)
|
||||
{
|
||||
InitializeComponent();
|
||||
_bookStorage = bookStorage;
|
||||
_shapeStorage = shapeStorage;
|
||||
|
||||
input_text1.MinLen = 2;
|
||||
input_text1.MaxLen = 40;
|
||||
LoadData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var list = _shapeStorage.GetFullList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
booksForm1.FillValues(item.Name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (String.IsNullOrEmpty(input_text1.Element) || String.IsNullOrEmpty(textBoxReaders.Text) || booksForm1.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Заполните поля");
|
||||
}
|
||||
else
|
||||
{
|
||||
var model = new BookBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Name = input_text1.Element,
|
||||
Readers = textBoxReaders.Text,
|
||||
Shape = booksForm1.SelectedValue.ToString(),
|
||||
Annotation = textBoxAnnotation.Text,
|
||||
};
|
||||
if (!_id.HasValue)
|
||||
{
|
||||
_bookStorage.Insert(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bookStorage.Update(model);
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
WinForm/FormCreateBook.resx
Normal file
60
WinForm/FormCreateBook.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>
|
162
WinForm/FormMain.Designer.cs
generated
Normal file
162
WinForm/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
||||
namespace WinForm
|
||||
{
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
listBoxObjects1 = new CustomComponents.ListBoxObjects();
|
||||
menuStrip1 = new MenuStrip();
|
||||
добавитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
изменитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
справочникToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчёт2ToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчёт3ToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordTableComponent1 = new KOP_Labs.NonVisualComponents.WordTableComponent(components);
|
||||
listBoxObjects2 = new CustomComponents.ListBoxObjects();
|
||||
componentDocumentWithTableHeaderColumnPdf1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderColumnPdf(components);
|
||||
pdfTable1 = new ViewComponents.NotVisualComponents.PdfTable(components);
|
||||
diagramComponent1 = new CustomComponents.DiagramComponent(components);
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBoxObjects1
|
||||
//
|
||||
listBoxObjects1.Location = new Point(0, 31);
|
||||
listBoxObjects1.Name = "listBoxObjects1";
|
||||
listBoxObjects1.SelectedIndex = -1;
|
||||
listBoxObjects1.Size = new Size(459, 151);
|
||||
listBoxObjects1.TabIndex = 0;
|
||||
listBoxObjects1.KeyDown += listBoxObjects1_KeyDown;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem, справочникToolStripMenuItem, отчётToolStripMenuItem, отчёт2ToolStripMenuItem, отчёт3ToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(914, 28);
|
||||
menuStrip1.TabIndex = 1;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
menuStrip1.KeyDown += menuStrip1_KeyDown;
|
||||
//
|
||||
// добавитьToolStripMenuItem
|
||||
//
|
||||
добавитьToolStripMenuItem.Name = "добавитьToolStripMenuItem";
|
||||
добавитьToolStripMenuItem.Size = new Size(90, 24);
|
||||
добавитьToolStripMenuItem.Text = "Добавить";
|
||||
добавитьToolStripMenuItem.Click += CreateToolStripMenuItem_Click;
|
||||
//
|
||||
// изменитьToolStripMenuItem
|
||||
//
|
||||
изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
|
||||
изменитьToolStripMenuItem.Size = new Size(92, 24);
|
||||
изменитьToolStripMenuItem.Text = "Изменить";
|
||||
изменитьToolStripMenuItem.Click += изменитьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.Size = new Size(79, 24);
|
||||
удалитьToolStripMenuItem.Text = "Удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// справочникToolStripMenuItem
|
||||
//
|
||||
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
||||
справочникToolStripMenuItem.Size = new Size(108, 24);
|
||||
справочникToolStripMenuItem.Text = "Справочник";
|
||||
справочникToolStripMenuItem.Click += справочникToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётToolStripMenuItem
|
||||
//
|
||||
отчётToolStripMenuItem.Name = "отчётToolStripMenuItem";
|
||||
отчётToolStripMenuItem.Size = new Size(62, 24);
|
||||
отчётToolStripMenuItem.Text = "Отчёт";
|
||||
отчётToolStripMenuItem.Click += отчётToolStripMenuItem_Click;
|
||||
//
|
||||
// отчёт2ToolStripMenuItem
|
||||
//
|
||||
отчёт2ToolStripMenuItem.Name = "отчёт2ToolStripMenuItem";
|
||||
отчёт2ToolStripMenuItem.Size = new Size(70, 24);
|
||||
отчёт2ToolStripMenuItem.Text = "Отчёт2";
|
||||
отчёт2ToolStripMenuItem.Click += отчёт2ToolStripMenuItem_Click;
|
||||
//
|
||||
// отчёт3ToolStripMenuItem
|
||||
//
|
||||
отчёт3ToolStripMenuItem.Name = "отчёт3ToolStripMenuItem";
|
||||
отчёт3ToolStripMenuItem.Size = new Size(70, 24);
|
||||
отчёт3ToolStripMenuItem.Text = "Отчёт3";
|
||||
отчёт3ToolStripMenuItem.Click += отчёт3ToolStripMenuItem_Click;
|
||||
//
|
||||
// listBoxObjects2
|
||||
//
|
||||
listBoxObjects2.Location = new Point(455, 31);
|
||||
listBoxObjects2.Name = "listBoxObjects2";
|
||||
listBoxObjects2.SelectedIndex = -1;
|
||||
listBoxObjects2.Size = new Size(572, 195);
|
||||
listBoxObjects2.TabIndex = 2;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(914, 183);
|
||||
Controls.Add(listBoxObjects2);
|
||||
Controls.Add(listBoxObjects1);
|
||||
Controls.Add(menuStrip1);
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
KeyDown += FormMain_KeyDown;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CustomComponents.ListBoxObjects listBoxObjects1;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem добавитьToolStripMenuItem;
|
||||
private ToolStripMenuItem изменитьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem справочникToolStripMenuItem;
|
||||
private KOP_Labs.NonVisualComponents.WordTableComponent wordTableComponent1;
|
||||
private ToolStripMenuItem отчётToolStripMenuItem;
|
||||
private CustomComponents.ListBoxObjects listBoxObjects2;
|
||||
private ToolStripMenuItem отчёт2ToolStripMenuItem;
|
||||
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderColumnPdf componentDocumentWithTableHeaderColumnPdf1;
|
||||
private ViewComponents.NotVisualComponents.PdfTable pdfTable1;
|
||||
private ToolStripMenuItem отчёт3ToolStripMenuItem;
|
||||
private CustomComponents.DiagramComponent diagramComponent1;
|
||||
}
|
||||
}
|
432
WinForm/FormMain.cs
Normal file
432
WinForm/FormMain.cs
Normal file
@ -0,0 +1,432 @@
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.StoragesContracts;
|
||||
using Contracts.ViewModels;
|
||||
using CustomComponents;
|
||||
using DatabaseImplement.Models;
|
||||
using DataModels.Models;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using KOP_Labs.Classes;
|
||||
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;
|
||||
using ViewComponents.NotVisualComponents;
|
||||
using Book = DatabaseImplement.Models.Book;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly IBookStorage _bookStorage;
|
||||
private readonly IShapeStorage _shapeStorage;
|
||||
public FormMain(IBookStorage bookStorage, IShapeStorage shapeStorage)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
_bookStorage = bookStorage;
|
||||
_shapeStorage = shapeStorage;
|
||||
|
||||
LoadData();
|
||||
|
||||
}
|
||||
public void LoadData()
|
||||
{
|
||||
listBoxObjects1.deleteAll();
|
||||
listBoxObjects2.deleteAll();
|
||||
var books = _bookStorage.GetFullList();
|
||||
listBoxObjects1.SetLayoutInfo("Название *Name* Читатели *Readers* Форма *Shape* Аннотация *Annotation* Id *Id*", "*", "*");
|
||||
listBoxObjects2.SetLayoutInfo("Форма *Shape* Аннотация *Annotation* Id *Id*", "*", "*");
|
||||
|
||||
foreach (var book in books)
|
||||
{
|
||||
listBoxObjects1.AddInListBox(book);
|
||||
listBoxObjects2.AddInListBox(book);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CreateToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateBook));
|
||||
|
||||
if (service is FormCreateBook form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void изменитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = listBoxObjects1.GetObjectFromStr<Book>().Id;
|
||||
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateBook));
|
||||
|
||||
if (service is FormCreateBook form)
|
||||
{
|
||||
form.Id = id;
|
||||
|
||||
form.ShowDialog();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Ошибка операции", "Необходимо выбрать элемент списка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
int id = listBoxObjects1.GetObjectFromStr<Book>().Id;
|
||||
|
||||
|
||||
DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранную запись?" + id, "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
_bookStorage.Delete(new BookBindingModel
|
||||
{
|
||||
Id = id
|
||||
|
||||
});
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void справочникToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShapes));
|
||||
|
||||
if (service is FormShapes form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
public void CreateSimpleDocItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//фильтрация файлов для диалогового окна
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var list = _bookStorage.GetFullList().OrderBy(l => l.Shape).ToList();
|
||||
|
||||
var disciplines = _shapeStorage.GetFullList().OrderBy(d => d.Name).ToList();
|
||||
|
||||
List<string[,]> totalList = new();
|
||||
|
||||
List<BookViewModel> supportList = new();
|
||||
|
||||
foreach (var discipline in disciplines)
|
||||
{
|
||||
|
||||
foreach (var elem in list)
|
||||
{
|
||||
if (elem.Shape.Equals(discipline.Name))
|
||||
{
|
||||
supportList.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
supportList = supportList.OrderBy(sl => sl.Name).ToList();
|
||||
|
||||
totalList.Add(new string[,] { { "Форма", discipline.Name } });
|
||||
|
||||
foreach (var elem in supportList)
|
||||
{
|
||||
var listFCs = elem.Readers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
string[,] newArray = { { elem.Name, listFCs[listFCs.Count - 1] } };
|
||||
|
||||
totalList.Add(newArray);
|
||||
}
|
||||
|
||||
supportList.Clear();
|
||||
}
|
||||
|
||||
MyTable table = new(dialog.FileName, "Первое задание", totalList);
|
||||
|
||||
wordTableComponent1.CreateDoc(table);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void отчётToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateSimpleDocItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void отчёт2ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<BookViewModel>? list = _bookStorage.GetFullList().OrderBy(l => l.Name).ToList();
|
||||
|
||||
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
componentDocumentWithTableHeaderColumnPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<BookViewModel>
|
||||
{
|
||||
FilePath = dialog.FileName,
|
||||
Header = "Отчет PDF",
|
||||
UseUnion = true,
|
||||
ColumnsRowsWidth = new List<(int, int)> { (0, 25), (0, 25), (0, 25), },
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
|
||||
(0, 0, "Название", "Name"),
|
||||
(1, 0, "Описание", ""),
|
||||
(1, 1, "Форма", "Shape"),
|
||||
(2, 1, "Аннотация", "Annotation"),
|
||||
|
||||
},
|
||||
Data = list
|
||||
});
|
||||
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CreateReportExcel(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var list = _bookStorage.GetFullList();
|
||||
|
||||
var shapes = _shapeStorage.GetFullList();
|
||||
|
||||
|
||||
int[,] supportList = new int[4, shapes.Count];
|
||||
|
||||
|
||||
int c = 0;
|
||||
|
||||
for (int i = 0; i < shapes.Count; i++)
|
||||
{
|
||||
|
||||
|
||||
foreach (var elem in list)
|
||||
{
|
||||
if (shapes[i].Name.Equals(elem.Shape))
|
||||
|
||||
{
|
||||
c++;
|
||||
if (elem.Annotation.Length >= 0 && elem.Annotation.Length < 10)
|
||||
{
|
||||
supportList[0, i]++;
|
||||
|
||||
}
|
||||
|
||||
if (elem.Annotation.Length >= 10 && elem.Annotation.Length < 150)
|
||||
{
|
||||
supportList[1, i]++;
|
||||
|
||||
}
|
||||
|
||||
if (elem.Annotation.Length >= 150 && elem.Annotation.Length < 200)
|
||||
{
|
||||
supportList[2, i]++;
|
||||
|
||||
}
|
||||
|
||||
if (elem.Annotation.Length >= 200 && elem.Annotation.Length < 250)
|
||||
{
|
||||
supportList[3, i]++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
string[] Names = { "50-150", "100-150", "150-200", "200-250" };
|
||||
|
||||
|
||||
var list2D = new Dictionary<string, List<int>>();
|
||||
|
||||
|
||||
for (var i = 0; i < Names.Length; i++)
|
||||
{
|
||||
var curlist = new List<int>();
|
||||
for (int j = 0; j < shapes.Count; j++)
|
||||
{
|
||||
|
||||
curlist.Add(supportList[i, j]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
list2D.Add(Names[i], curlist);
|
||||
}
|
||||
|
||||
|
||||
DiagramComponent diagram = new DiagramComponent();
|
||||
|
||||
|
||||
diagram.CreateExcel(new CustomComponents.MyNonVisualComponents.LineChartConfig
|
||||
{
|
||||
ChartTitle = "diagramm",
|
||||
FilePath = dialog.FileName,
|
||||
Header = "Diagramm",
|
||||
Values = list2D
|
||||
});
|
||||
|
||||
MessageBox.Show(" " + c);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void отчёт3ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateReportExcel(sender, e);
|
||||
|
||||
}
|
||||
|
||||
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
CreateToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.U:
|
||||
изменитьToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.D:
|
||||
удалитьToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.S:
|
||||
справочникToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.T:
|
||||
отчётToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.C:
|
||||
отчёт2ToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.M:
|
||||
отчёт3ToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listBoxObjects1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
CreateToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
/*case Keys.U:
|
||||
EditProviderItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.D:
|
||||
RemoveProviderItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.S:
|
||||
GetSimpleDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.T:
|
||||
GetTableDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.C:
|
||||
GetDiagramDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.M:
|
||||
OpenListToolStripMenuItem_Click(sender, e);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void menuStrip1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
CreateToolStripMenuItem_Click(sender, e);
|
||||
break;
|
||||
/*case Keys.U:
|
||||
EditProviderItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.D:
|
||||
RemoveProviderItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.S:
|
||||
GetSimpleDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.T:
|
||||
GetTableDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.C:
|
||||
GetDiagramDocumentItem_Click(sender, e);
|
||||
break;
|
||||
case Keys.M:
|
||||
OpenListToolStripMenuItem_Click(sender, e);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
WinForm/FormMain.resx
Normal file
75
WinForm/FormMain.resx
Normal file
@ -0,0 +1,75 @@
|
||||
<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="wordTableComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithTableHeaderColumnPdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>365, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>770, 17</value>
|
||||
</metadata>
|
||||
<metadata name="diagramComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>891, 17</value>
|
||||
</metadata>
|
||||
</root>
|
64
WinForm/FormShapes.Designer.cs
generated
Normal file
64
WinForm/FormShapes.Designer.cs
generated
Normal file
@ -0,0 +1,64 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class FormShapes
|
||||
{
|
||||
/// <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.Dock = DockStyle.Fill;
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersWidth = 51;
|
||||
dataGridView1.RowTemplate.Height = 29;
|
||||
dataGridView1.Size = new Size(800, 450);
|
||||
dataGridView1.TabIndex = 0;
|
||||
dataGridView1.CellValueChanged += dataGridView1_CellValueChanged;
|
||||
dataGridView1.KeyDown += dataGridView1_KeyDown;
|
||||
//
|
||||
// FormShapes
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridView1);
|
||||
Name = "FormShapes";
|
||||
Text = "FormShapes";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView1;
|
||||
}
|
||||
}
|
148
WinForm/FormShapes.cs
Normal file
148
WinForm/FormShapes.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
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 WinForm
|
||||
{
|
||||
public partial class FormShapes : Form
|
||||
{
|
||||
IShapeStorage _shapeStorage;
|
||||
public FormShapes(IShapeStorage shapeStorage)
|
||||
{
|
||||
_shapeStorage = shapeStorage;
|
||||
InitializeComponent();
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var list = _shapeStorage.GetFullList();
|
||||
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Columns["Id"].Visible = false;
|
||||
dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void AddShape()
|
||||
{
|
||||
var list = _shapeStorage.GetFullList();
|
||||
list.Add(new());
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Columns["Id"].Visible = false;
|
||||
dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
//просто найти кнопку
|
||||
if (e.Control)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete)
|
||||
{
|
||||
AddShape();
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Delete)
|
||||
{
|
||||
RemoveShape();
|
||||
}
|
||||
}
|
||||
private void RemoveShape()
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(
|
||||
"Вы уверены, что хотите удалить выбранные записи?",
|
||||
"Подтверждение удаления",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_shapeStorage.Delete(new ShapeBindingModel() { Id = (int)dataGridView1.CurrentRow.Cells[1].Value });
|
||||
LoadData();
|
||||
}
|
||||
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Выберите");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
|
||||
|
||||
int id = Convert.ToInt32(row.Cells["Id"].Value);
|
||||
string? name = row.Cells["Name"].Value?.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
|
||||
MessageBox.Show("Нельзя сохранить запись с пустым именем!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
var model = new ShapeBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name
|
||||
};
|
||||
|
||||
if (model.Id == 0)
|
||||
{
|
||||
_shapeStorage.Insert(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shapeStorage.Update(model);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
60
WinForm/FormShapes.resx
Normal file
60
WinForm/FormShapes.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>
|
@ -79,7 +79,7 @@ namespace WinForm
|
||||
|
||||
wordHistogramm1.CreateHistogramm(histogram);
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -91,12 +91,12 @@ namespace WinForm
|
||||
}
|
||||
|
||||
List<Book> books;
|
||||
Book book1 = new Book("Pushkin", 1, "fgsddsdf", "fdsds");
|
||||
Book book2 = new Book("Pushkin", 2, "aa", "fdads");
|
||||
Book book3 = new Book("Pushkin", 3, "fgdf", "ffsds");
|
||||
Book book4 = new Book("Lermontov", 4, "ffsssff", "asdss");
|
||||
Book book5 = new Book("Lermontov", 5, "ffdsff", "asdsss");
|
||||
Book book6 = new Book("Pushkin", 6, "fgdf", "ffsds");
|
||||
Book book1 = new Book("Pushkin", "fgsddsdf", "fdsds");
|
||||
Book book2 = new Book("Pushkin", "aa", "fdads");
|
||||
Book book3 = new Book("Pushkin", "fgdf", "ffsds");
|
||||
Book book4 = new Book("Lermontov", "ffsssff", "asdss");
|
||||
Book book5 = new Book("Lermontov", "ffdsff", "asdsss");
|
||||
Book book6 = new Book("Pushkin", "fgdf", "ffsds");
|
||||
|
||||
Dictionary<int, ColumnParameters> colData;
|
||||
private void buttonHead_Click(object sender, EventArgs e)
|
||||
|
@ -1,7 +1,16 @@
|
||||
using Contracts.StoragesContracts;
|
||||
using DatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
internal static class Program
|
||||
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +20,21 @@ namespace WinForm
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new NonVisualForm());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddTransient<IBookStorage, BookStorage>();
|
||||
services.AddTransient<IShapeStorage, ShapeStorage>();
|
||||
services.AddTransient<NonVisualForm>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormCreateBook>();
|
||||
services.AddTransient<FormShapes>();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,10 +9,21 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004" />
|
||||
<PackageReference Include="SergComponent" Version="1.0.0" />
|
||||
<PackageReference Include="ViewComponents" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\KOP_Labs\KOP_Labs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user