8 Commits
lab2 ... lab3

64 changed files with 5405 additions and 3 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,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
namespace BusinessLogic.BusinessLogic
{
public class DepartmentLogic : IDepartmentLogic
{
private readonly IDepartmentStorage _providerStorage;
public DepartmentLogic(IDepartmentStorage providerStorage)
{
_providerStorage = providerStorage;
}
public List<DepartmentViewModel>? ReadList(DepartmentSearchModel? model)
{
var list = model == null ? _providerStorage.GetFullList() : _providerStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public DepartmentViewModel? ReadElement(DepartmentSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _providerStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(DepartmentBindingModel model)
{
CheckModel(model);
if (_providerStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(DepartmentBindingModel model)
{
CheckModel(model);
if (_providerStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(DepartmentBindingModel model)
{
CheckModel(model, false);
if (_providerStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(DepartmentBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Введите название подразделения", nameof(model.Name));
}
if (string.IsNullOrEmpty(model.DepartmentType))
{
throw new ArgumentException("Введите тип подразделения", nameof(model.DepartmentType));
}
if (string.IsNullOrEmpty(model.Target))
{
throw new ArgumentException("Введите цель подразделения", nameof(model.Target));
}
}
}
}

View File

@@ -0,0 +1,93 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class DepartmentTypeLogic : IDepartmentTypeLogic
{
private readonly IDepartmentTypeStorage _orgTypeStorage;
public DepartmentTypeLogic(IDepartmentTypeStorage orgTypeStorage)
{
_orgTypeStorage = orgTypeStorage;
}
public List<DepartmentTypeViewModel>? ReadList(DepartmentTypeSearchModel? model)
{
var list = model == null ? _orgTypeStorage.GetFullList() : _orgTypeStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public DepartmentTypeViewModel? ReadElement(DepartmentTypeSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _orgTypeStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(DepartmentTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(DepartmentTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(DepartmentTypeBindingModel model)
{
CheckModel(model, false);
if (_orgTypeStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(DepartmentTypeBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Введите название доставки", nameof(model.Name));
}
}
}
}

View File

@@ -3,9 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35219.272
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "Components\Components.csproj", "{2CCE7E87-C678-473B-A49E-12D715DC1882}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "Components\Components.csproj", "{2CCE7E87-C678-473B-A49E-12D715DC1882}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "..\Test\Test.csproj", "{F498BD7C-5822-4357-B434-BC4756C46295}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "..\Test\Test.csproj", "{F498BD7C-5822-4357-B434-BC4756C46295}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{9A516EC7-5169-423C-83F9-20128F1C7792}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{9F0A73D6-0ED0-4119-B395-446919E80734}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{DA24AA43-2169-4192-8CE0-94C4C6D45317}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{88BB4B87-99A3-48CD-80BC-9CD6D208554E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{D6BA2561-10C4-4470-BC53-522EED0FBB0F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{C7E3704E-F2D2-46DD-958C-A0E955121FDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginApp", "PluginApp\PluginApp.csproj", "{38DA0D49-AD97-409F-BBD0-74F14E0167F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +35,34 @@ Global
{F498BD7C-5822-4357-B434-BC4756C46295}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F498BD7C-5822-4357-B434-BC4756C46295}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F498BD7C-5822-4357-B434-BC4756C46295}.Release|Any CPU.Build.0 = Release|Any CPU
{9A516EC7-5169-423C-83F9-20128F1C7792}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A516EC7-5169-423C-83F9-20128F1C7792}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A516EC7-5169-423C-83F9-20128F1C7792}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A516EC7-5169-423C-83F9-20128F1C7792}.Release|Any CPU.Build.0 = Release|Any CPU
{9F0A73D6-0ED0-4119-B395-446919E80734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F0A73D6-0ED0-4119-B395-446919E80734}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F0A73D6-0ED0-4119-B395-446919E80734}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F0A73D6-0ED0-4119-B395-446919E80734}.Release|Any CPU.Build.0 = Release|Any CPU
{DA24AA43-2169-4192-8CE0-94C4C6D45317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA24AA43-2169-4192-8CE0-94C4C6D45317}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA24AA43-2169-4192-8CE0-94C4C6D45317}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA24AA43-2169-4192-8CE0-94C4C6D45317}.Release|Any CPU.Build.0 = Release|Any CPU
{88BB4B87-99A3-48CD-80BC-9CD6D208554E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88BB4B87-99A3-48CD-80BC-9CD6D208554E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88BB4B87-99A3-48CD-80BC-9CD6D208554E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88BB4B87-99A3-48CD-80BC-9CD6D208554E}.Release|Any CPU.Build.0 = Release|Any CPU
{D6BA2561-10C4-4470-BC53-522EED0FBB0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6BA2561-10C4-4470-BC53-522EED0FBB0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6BA2561-10C4-4470-BC53-522EED0FBB0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6BA2561-10C4-4470-BC53-522EED0FBB0F}.Release|Any CPU.Build.0 = Release|Any CPU
{C7E3704E-F2D2-46DD-958C-A0E955121FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7E3704E-F2D2-46DD-958C-A0E955121FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7E3704E-F2D2-46DD-958C-A0E955121FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7E3704E-F2D2-46DD-958C-A0E955121FDB}.Release|Any CPU.Build.0 = Release|Any CPU
{38DA0D49-AD97-409F-BBD0-74F14E0167F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38DA0D49-AD97-409F-BBD0-74F14E0167F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38DA0D49-AD97-409F-BBD0-74F14E0167F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38DA0D49-AD97-409F-BBD0-74F14E0167F8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -5,10 +5,15 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,18 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class DepartmentBindingModel : IDepartmentModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Target { get; set; } = string.Empty;
public string DepartmentType { get; set; } = string.Empty;
public string? ReportDate { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class DepartmentTypeBindingModel : IDepartmentTypeModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,28 @@
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.BusinessLogicContracts
{
public interface IDepartmentLogic
{
int Id { get; set; }
List<DepartmentViewModel>? ReadList(DepartmentSearchModel? model);
DepartmentViewModel? ReadElement(DepartmentSearchModel? model);
bool Create(DepartmentBindingModel model);
bool Update(DepartmentBindingModel model);
bool Delete(DepartmentBindingModel model);
bool Delete(global::Forms.DepartmentBindingModel departmentBindingModel);
bool Delete(global::Forms.DepartmentBindingModel departmentBindingModel);
bool Delete(global::Forms.DepartmentBindingModel departmentBindingModel);
bool Update(global::Forms.DepartmentBindingModel model);
}
}

View File

@@ -0,0 +1,22 @@
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.BusinessLogicContracts
{
public interface IDepartmentTypeLogic
{
List<DepartmentTypeViewModel>? ReadList(DepartmentTypeSearchModel? model);
DepartmentTypeViewModel? ReadElement(DepartmentTypeSearchModel? model);
bool Create(DepartmentTypeBindingModel model);
bool Update(DepartmentTypeBindingModel model);
bool Delete(DepartmentTypeBindingModel model);
}
}

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="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class DepartmentSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? DepartmentType { get; set; }
public string? ReportDate { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class DepartmentTypeSearchModel
{
public string? Name { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
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.StorageContracts
{
public interface IDepartmentStorage
{
List<DepartmentViewModel> GetFullList();
List<DepartmentViewModel> GetFilteredList(DepartmentSearchModel model);
DepartmentViewModel? GetElement(DepartmentSearchModel model);
DepartmentViewModel? Insert(DepartmentBindingModel model);
DepartmentViewModel? Update(DepartmentBindingModel model);
DepartmentViewModel? Delete(DepartmentBindingModel model);
}
}

View File

@@ -0,0 +1,22 @@
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.StorageContracts
{
public interface IDepartmentTypeStorage
{
List<DepartmentTypeViewModel> GetFullList();
List<DepartmentTypeViewModel> GetFilteredList(DepartmentTypeSearchModel model);
DepartmentTypeViewModel? GetElement(DepartmentTypeSearchModel model);
DepartmentTypeViewModel? Insert(DepartmentTypeBindingModel model);
DepartmentTypeViewModel? Update(DepartmentTypeBindingModel model);
DepartmentTypeViewModel? Delete(DepartmentTypeBindingModel model);
}
}

View File

@@ -0,0 +1,18 @@
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class DepartmentTypeViewModel : IDepartmentTypeModel
{
public int Id { get; set; }
[DisplayName("Название типа подразделения")]
public string Name { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,28 @@
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class DepartmentViewModel : IDepartmentModel
{
public string Wishes;
public string FCs;
public string DepartmentDate;
public int Id { get; set; }
[DisplayName("Название подразделения")]
public string Name { get; set; } = string.Empty;
[DisplayName("Цель подразделения")]
public string Target { get; set; } = string.Empty;
[DisplayName("Тип подразделения")]
public string DepartmentType { get; set; } = string.Empty;
[DisplayName("Дата отчёта")]
public string? ReportDate { get; set; }
public string Departmentype { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement
{
public class Database : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Server=localhost;Port=5432;Database=test;User Id=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
public virtual DbSet<Department>? Departments { get; set; }
public virtual DbSet<DepartmentType>? DepartmentTypes { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
<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.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.29" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,75 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
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 DepartmentStorage : IDepartmentStorage
{
public List<DepartmentViewModel> GetFullList()
{
using var context = new Database();
return context.Departments.Select(x => x.GetViewModel).ToList();
}
public List<DepartmentViewModel> GetFilteredList(DepartmentSearchModel model)
{
if (string.IsNullOrEmpty(model.DepartmentType))
{
return new();
}
using var context = new Database();
return context.Departments.Where(x => x.DepartmentType == model.DepartmentType).Select(x => x.GetViewModel).ToList();
}
public DepartmentViewModel? GetElement(DepartmentSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.Departments.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public DepartmentViewModel? Insert(DepartmentBindingModel model)
{
var newDepartment = Department.Create(model);
if (newDepartment == null) return null;
using var context = new Database();
context.Departments.Add(newDepartment);
context.SaveChanges();
return newDepartment.GetViewModel;
}
public DepartmentViewModel? Update(DepartmentBindingModel model)
{
using var context = new Database();
var provider = context.Departments.FirstOrDefault(x => x.Id == model.Id);
if (provider == null) return null;
provider.Update(model);
context.SaveChanges();
return provider.GetViewModel;
}
public DepartmentViewModel? Delete(DepartmentBindingModel model)
{
using var context = new Database();
var element = context.Departments.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
context.Departments.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@@ -0,0 +1,76 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
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 DepartmentTypeStorage : IDepartmentTypeStorage
{
public List<DepartmentTypeViewModel> GetFullList()
{
using var context = new Database();
return context.DepartmentTypes.Select(x => x.GetViewModel).ToList();
}
public List<DepartmentTypeViewModel> GetFilteredList(DepartmentTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
return context.DepartmentTypes.Where(x => x.Name == model.Name).Select(x => x.GetViewModel).ToList();
}
public DepartmentTypeViewModel? GetElement(DepartmentTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return null;
}
using var context = new Database();
return context.DepartmentTypes.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
}
public DepartmentTypeViewModel? Insert(DepartmentTypeBindingModel model)
{
var newType = DepartmentType.Create(model);
if (newType == null) return null;
using var context = new Database();
context.DepartmentTypes.Add(newType);
context.SaveChanges();
return newType.GetViewModel;
}
public DepartmentTypeViewModel? Update(DepartmentTypeBindingModel model)
{
using var context = new Database();
var type = context.DepartmentTypes.FirstOrDefault(x => x.Id == model.Id);
if (type == null) return null;
type.Update(model);
context.SaveChanges();
return type.GetViewModel;
}
public DepartmentTypeViewModel? Delete(DepartmentTypeBindingModel model)
{
using var context = new Database();
var element = context.DepartmentTypes.FirstOrDefault(x => x.Name == model.Name);
if (element != null)
{
context.DepartmentTypes.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@@ -0,0 +1,73 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20250925161551_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.35")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DepartmentType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ReportDate")
.HasColumnType("text");
b.Property<string>("Target")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("DatabaseImplement.Models.DepartmentType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("DepartmentTypes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Departments",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
DepartmentType = table.Column<string>(type: "text", nullable: false),
Target = table.Column<string>(type: "text", nullable: false),
ReportDate = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Departments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DepartmentTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DepartmentTypes", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Departments");
migrationBuilder.DropTable(
name: "DepartmentTypes");
}
}
}

View File

@@ -0,0 +1,71 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
partial class DatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.35")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DepartmentType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ReportDate")
.HasColumnType("text");
b.Property<string>("Target")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("DatabaseImplement.Models.DepartmentType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("DepartmentTypes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,63 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using Models;
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 Department : IDepartmentModel
{
[Key]
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string DepartmentType { get; private set; } = string.Empty;
[Required]
public string Target { get; private set; } = string.Empty;
public string? ReportDate { get; private set; }
public static Department? Create(DepartmentBindingModel model)
{
if (model == null) return null;
return new Department
{
Id = model.Id,
Name = model.Name,
ReportDate = model.ReportDate,
DepartmentType = model.DepartmentType,
Target = model.Target,
};
}
public void Update(DepartmentBindingModel model)
{
if (model == null) return;
Name = model.Name;
ReportDate = model.ReportDate;
Target = model.Target;
DepartmentType = model.DepartmentType;
}
public DepartmentViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
ReportDate = ReportDate,
Target = Target,
DepartmentType = DepartmentType,
};
}
}

View File

@@ -0,0 +1,46 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using Models;
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 DepartmentType : IDepartmentTypeModel
{
[Key]
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
public static DepartmentType? Create(DepartmentTypeBindingModel model)
{
if (model == null) return null;
return new DepartmentType
{
Id = model.Id,
Name = model.Name,
};
}
public void Update(DepartmentTypeBindingModel model)
{
if (model == null) return;
Name = model.Name;
}
public DepartmentTypeViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
};
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,39 @@
namespace DepartmentForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

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

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>

View File

@@ -0,0 +1,17 @@
namespace DepartmentForm
{
internal static class Program
{
/// <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();
Application.Run(new Form1());
}
}
}

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

View File

@@ -0,0 +1,11 @@
namespace CreateVisualComponent
{
internal class InputComponent
{
public InputComponent()
{
}
public object Value { get; internal set; }
}
}

View File

@@ -0,0 +1,220 @@
namespace Forms
{
partial class DepartmentForm
{
/// <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()
{
tableLayoutPanel1 = new TableLayoutPanel();
comboBoxType = new ComboBox();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label1 = new Label();
inputComponentDate = new CreateVisualComponent.InputComponent();
textBoxFCs = new TextBox();
textBoxWishes = new TextBox();
tableLayoutPanel2 = new TableLayoutPanel();
buttonSave = new Button();
buttonCancel = new Button();
tableLayoutPanel1.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.ColumnCount = 4;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.Controls.Add(comboBoxType, 2, 1);
tableLayoutPanel1.Controls.Add(label2, 1, 0);
tableLayoutPanel1.Controls.Add(label3, 2, 0);
tableLayoutPanel1.Controls.Add(label4, 3, 0);
tableLayoutPanel1.Controls.Add(label1, 0, 0);
tableLayoutPanel1.Controls.Add(inputComponentDate, 3, 1);
tableLayoutPanel1.Controls.Add(textBoxFCs, 0, 1);
tableLayoutPanel1.Controls.Add(textBoxWishes, 1, 1);
tableLayoutPanel1.Location = new Point(12, 34);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 2;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 30.2325573F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 69.76744F));
tableLayoutPanel1.Size = new Size(912, 92);
tableLayoutPanel1.TabIndex = 1;
//
// comboBoxType
//
comboBoxType.Anchor = AnchorStyles.Left | AnchorStyles.Right;
comboBoxType.Cursor = Cursors.IBeam;
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(459, 45);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(222, 28);
comboBoxType.TabIndex = 2;
comboBoxType.SelectedIndexChanged += OnInputChange;
//
// label2
//
label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label2.AutoSize = true;
label2.Location = new Point(231, 0);
label2.Name = "label2";
label2.Size = new Size(222, 20);
label2.TabIndex = 1;
label2.Text = "Пожелания по доставке";
label2.TextAlign = ContentAlignment.MiddleCenter;
//
// label3
//
label3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label3.AutoSize = true;
label3.Location = new Point(459, 0);
label3.Name = "label3";
label3.Size = new Size(222, 20);
label3.TabIndex = 2;
label3.Text = "Тип доставки";
label3.TextAlign = ContentAlignment.MiddleCenter;
//
// label4
//
label4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label4.AutoSize = true;
label4.Location = new Point(687, 0);
label4.Name = "label4";
label4.Size = new Size(222, 20);
label4.TabIndex = 3;
label4.Text = "Дата доставки";
label4.TextAlign = ContentAlignment.MiddleCenter;
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(3, 0);
label1.Name = "label1";
label1.Size = new Size(222, 20);
label1.TabIndex = 0;
label1.Text = "ФИО";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// inputComponentDate
//
inputComponentDate.Anchor = AnchorStyles.Left | AnchorStyles.Right;
inputComponentDate.Location = new Point(687, 30);
inputComponentDate.Name = "inputComponentDate";
inputComponentDate.Size = new Size(222, 59);
inputComponentDate.TabIndex = 4;
//
// textBoxFCs
//
textBoxFCs.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxFCs.Location = new Point(3, 46);
textBoxFCs.Name = "textBoxFCs";
textBoxFCs.Size = new Size(222, 27);
textBoxFCs.TabIndex = 6;
textBoxFCs.TextChanged += OnInputChange;
//
// textBoxWishes
//
textBoxWishes.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxWishes.Location = new Point(231, 46);
textBoxWishes.Name = "textBoxWishes";
textBoxWishes.Size = new Size(222, 27);
textBoxWishes.TabIndex = 5;
textBoxWishes.TextChanged += OnInputChange;
//
// tableLayoutPanel2
//
tableLayoutPanel2.ColumnCount = 2;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Controls.Add(buttonSave, 0, 0);
tableLayoutPanel2.Controls.Add(buttonCancel, 1, 0);
tableLayoutPanel2.Location = new Point(12, 132);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Size = new Size(250, 36);
tableLayoutPanel2.TabIndex = 2;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonSave.Location = new Point(3, 3);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(119, 30);
buttonSave.TabIndex = 0;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonCancel.Location = new Point(128, 3);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(119, 30);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// DeliveryForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(936, 209);
Controls.Add(tableLayoutPanel2);
Controls.Add(tableLayoutPanel1);
Name = "DeliveryForm";
Text = "DeliveryForm";
FormClosing += ProviderForm_FormClosing;
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ListBox listBox1;
private TableLayoutPanel tableLayoutPanel1;
private Label label2;
private Label label3;
private Label label4;
private Label label1;
private CreateVisualComponent.InputComponent inputComponentDate;
private ComboBox comboBoxType;
private TextBox textBoxWishes;
private TextBox textBoxFCs;
private TableLayoutPanel tableLayoutPanel2;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@@ -0,0 +1,146 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using ControlsLibraryNet60.Input;
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 Forms
{
public partial class DepartmentForm : Form
{
private int? _id;
private readonly IDepartmentLogic _dLogic;
private readonly IDepartmentLogic _dtLogic;
private bool isEdited;
public DepartmentForm(IDepartmentLogic dLogic, IDepartmentLogic dtLogic, int? id = null)
{
InitializeComponent();
_id = id;
_dLogic = dLogic;
_dtLogic = dtLogic;
isEdited = false;
LoadData();
}
public DepartmentForm(IDepartmentLogic dlogic, IDepartmentTypeLogic dtlogic, object value)
{
}
public DepartmentForm(IDepartmentLogic dlogic, IDepartmentTypeLogic dtlogic)
{
}
private void LoadData()
{
var list = _dtLogic.ReadList(null);
if (list != null)
{
foreach (var item in list)
{
comboBoxType.Items.Add(item.Name);
}
}
if (_id.HasValue)
{
var view = _dLogic.ReadElement(new IDepartmentLogic
{
Id = _id.Value,
});
textBoxWishes.Text = view.Wishes;
textBoxFCs.Text = view.FCs;
if (view.DepartmentDate != "Даты доставки нет")
{
inputComponentDate.Value = Convert.ToDateTime(view.DepartmentDate);
}
else
{
inputComponentDate.Value = null;
}
comboBoxType.SelectedItem = view.DepartmentType;
isEdited = false;
}
}
private void OnInputChange(object sender, EventArgs e)
{
isEdited = true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFCs.Text))
{
MessageBox.Show("Заполните поле ФИО курьера", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxWishes.Text))
{
MessageBox.Show("Заполните Пожелания ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if ((comboBoxType.SelectedItem == null))
{
MessageBox.Show("Выберите Тип доставки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
isEdited = false;
try
{
var model = new DepartmentBindingModel
{
Id = _id ?? 0,
FCs = textBoxFCs.Text,
Wishes = textBoxWishes.Text,
DeliveryDate = inputComponentDate.Value.ToString().Length >= 10 ? inputComponentDate.Value.ToString().Substring(0, 10) : "Даты доставки нет",
DeliveryType = comboBoxType.SelectedItem.ToString(),
};
var OperationResult = _id.HasValue ? _dLogic.Update(model) : _dLogic.Create(model);
if (!OperationResult)
{
throw new Exception("Ошибка при создании курьера.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProviderForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isEdited) return;
var confirmResult = MessageBox.Show("Вы не сохранили изменения.\nВы действительно хотите выйти?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.No) e.Cancel = true;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
internal class DepartmentBindingModel
{
public int Id { get; set; }
public string FCs { get; set; }
public string Wishes { get; set; }
public object DeliveryDate { get; set; }
public string DeliveryType { get; set; }
}
}

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>

View File

@@ -0,0 +1,79 @@
namespace Forms
{
partial class DepartmentTypeForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
Type = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.BackgroundColor = Color.White;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Type });
dataGridView.GridColor = Color.Gray;
dataGridView.Location = new Point(14, 16);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(393, 276);
dataGridView.TabIndex = 0;
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
dataGridView.KeyDown += dataGridView_KeyDown;
//
// Type
//
Type.HeaderText = "Типы доставок";
Type.MinimumWidth = 6;
Type.Name = "Type";
//
// DeliveryTypeForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(419, 306);
Controls.Add(dataGridView);
Margin = new Padding(3, 4, 3, 4);
Name = "DeliveryTypeForm";
Text = "Типы";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Type;
}
}

View File

@@ -0,0 +1,118 @@
using Contracts.BindlingModels;
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 Forms
{
public partial class DepartmentTypeForm : Form
{
private readonly IDeliveryTypeLogic _logic;
private IDepartmentTypeLogic dtlogic;
public DepartmentTypeForm(IDeliveryTypeLogic logic)
{
InitializeComponent();
_logic = logic;
LoadData();
}
public DepartmentTypeForm(IDepartmentTypeLogic dtlogic)
{
this.dtlogic = dtlogic;
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.Rows.Clear();
foreach (var item in list)
{
int rowIndex = dataGridView.Rows.Add(item.Name);
dataGridView.Rows[rowIndex].Tag = item.Id;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
for (int i = 0; i < dataGridView.Rows.Count; i++)
{
if (dataGridView.Rows[i].Cells[0].Value == null)
{
return;
}
}
dataGridView.Rows.Add();
}
else if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Удалить строку?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
var name = dataGridView.SelectedCells[0].Value.ToString();
if (name != null)
{
_logic.Delete(new DeliveryTypeBindingModel
{
Name = name,
});
dataGridView.Rows.RemoveAt(dataGridView.SelectedCells[0].RowIndex);
}
}
}
}
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.Rows.Count > 0)
{
var row = dataGridView.Rows[e.RowIndex];
var name = row.Cells[0].Value?.ToString() ?? string.Empty;
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("Введите название!");
return;
}
var id = row.Tag as int?;
if (id != null)
{
_logic.Update(new DeliveryTypeBindingModel
{
Id = id.Value,
Name = name
});
}
else
{
var newId = _logic.Create(new DeliveryTypeBindingModel
{
Name = name
});
row.Tag = newId;
}
}
}
}
}

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>

252
Components/Forms/FormMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,252 @@
namespace Forms
{
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();
<<<<<<< Updated upstream
menuStrip1 = new MenuStrip();
созданиеДоставкиToolStripMenuItem = new ToolStripMenuItem();
создатьДоставкуToolStripMenuItem = new ToolStripMenuItem();
редактироватьДоставкуToolStripMenuItem = new ToolStripMenuItem();
удалитьДоставкуToolStripMenuItem = new ToolStripMenuItem();
созданиеТипаДоставкиToolStripMenuItem = new ToolStripMenuItem();
pDFДокументToolStripMenuItem = new ToolStripMenuItem();
excelОтчётToolStripMenuItem = new ToolStripMenuItem();
wordДиаграммаToolStripMenuItem = new ToolStripMenuItem();
редактироватьtoolStripMenuItem = new ToolStripMenuItem();
controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable();
largeTextComponent = new Controls.LargeTextComponent(components);
pieChartWord = new CustomComponents.NonViewComponents.PieChartWord(components);
componentDocumentWithTableMultiHeaderExcel = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel(components);
excelHardTable = new NotVisualComponent.ExcelHardTable(components);
menuStrip1.SuspendLayout();
=======
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
toolTip = new ToolTip(components);
buttonLargeText = new Button();
button1 = new Button();
button2 = new Button();
pictureBox1 = new PictureBox();
textBox1 = new TextBox();
customListBox1 = new Controls.CustomListBox();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
>>>>>>> Stashed changes
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { созданиеДоставкиToolStripMenuItem, созданиеТипаДоставкиToolStripMenuItem, pDFДокументToolStripMenuItem, excelОтчётToolStripMenuItem, wordДиаграммаToolStripMenuItem, редактироватьtoolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 28);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
//
// созданиеДоставкиToolStripMenuItem
//
<<<<<<< Updated upstream
созданиеДоставкиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьДоставкуToolStripMenuItem, редактироватьДоставкуToolStripMenuItem, удалитьДоставкуToolStripMenuItem });
созданиеДоставкиToolStripMenuItem.Name = "созданиеДоставкиToolStripMenuItem";
созданиеДоставкиToolStripMenuItem.Size = new Size(131, 24);
созданиеДоставкиToolStripMenuItem.Text = "Меню доставок";
=======
buttonLargeText.Location = new Point(24, 16);
buttonLargeText.Margin = new Padding(3, 2, 3, 2);
buttonLargeText.Name = "buttonLargeText";
buttonLargeText.Size = new Size(271, 38);
buttonLargeText.TabIndex = 9;
buttonLargeText.Text = "СОЗДАТЬ PDF ТЕКСТ";
buttonLargeText.UseVisualStyleBackColor = true;
buttonLargeText.Click += buttonLargeText_CLick;
>>>>>>> Stashed changes
//
// создатьДоставкуToolStripMenuItem
//
<<<<<<< Updated upstream
создатьДоставкуToolStripMenuItem.Name = "создатьДоставкуToolStripMenuItem";
создатьДоставкуToolStripMenuItem.Size = new Size(258, 26);
создатьДоставкуToolStripMenuItem.Text = "Создать доставку";
создатьДоставкуToolStripMenuItem.Click += созданиеДоставкиToolStripMenuItem_Click;
=======
button1.Location = new Point(24, 70);
button1.Margin = new Padding(3, 2, 3, 2);
button1.Name = "button1";
button1.Size = new Size(271, 50);
button1.TabIndex = 10;
button1.Text = "СОЗДАТЬ ТАБЛИЦУ PDF";
button1.UseVisualStyleBackColor = true;
button1.Click += buttonCreateTable_Click;
>>>>>>> Stashed changes
//
// редактироватьДоставкуToolStripMenuItem
//
<<<<<<< Updated upstream
редактироватьДоставкуToolStripMenuItem.Name = "редактироватьДоставкуToolStripMenuItem";
редактироватьДоставкуToolStripMenuItem.Size = new Size(258, 26);
редактироватьДоставкуToolStripMenuItem.Text = "Редактировать доставку";
редактироватьДоставкуToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
=======
button2.Location = new Point(24, 139);
button2.Margin = new Padding(3, 2, 3, 2);
button2.Name = "button2";
button2.Size = new Size(271, 54);
button2.TabIndex = 11;
button2.Text = "СОЗДАТЬ ДИАГРАММУ PDF";
button2.UseVisualStyleBackColor = true;
button2.Click += buttonDiagram_Click;
>>>>>>> Stashed changes
//
// удалитьДоставкуToolStripMenuItem
//
<<<<<<< Updated upstream
удалитьДоставкуToolStripMenuItem.Name = "удалитьДоставкуToolStripMenuItem";
удалитьДоставкуToolStripMenuItem.Size = new Size(258, 26);
удалитьДоставкуToolStripMenuItem.Text = "Удалить доставку";
удалитьДоставкуToolStripMenuItem.Click += deleteProviderToolStripMenuItem_Click;
=======
pictureBox1.BackgroundImage = (Image)resources.GetObject("pictureBox1.BackgroundImage");
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
pictureBox1.Location = new Point(314, 16);
pictureBox1.Margin = new Padding(3, 2, 3, 2);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(318, 261);
pictureBox1.TabIndex = 12;
pictureBox1.TabStop = false;
>>>>>>> Stashed changes
//
// созданиеТипаДоставкиToolStripMenuItem
//
<<<<<<< Updated upstream
созданиеТипаДоставкиToolStripMenuItem.Name = "созданиеТипаДоставкиToolStripMenuItem";
созданиеТипаДоставкиToolStripMenuItem.Size = new Size(192, 24);
созданиеТипаДоставкиToolStripMenuItem.Text = "Создание типа доставки";
созданиеТипаДоставкиToolStripMenuItem.Click += созданиеТипаДоставкиToolStripMenuItem_Click;
=======
textBox1.Location = new Point(325, 236);
textBox1.Margin = new Padding(3, 2, 3, 2);
textBox1.Name = "textBox1";
textBox1.Size = new Size(294, 23);
textBox1.TabIndex = 13;
textBox1.Text = "НАЖМИТЕ НА КНОПКУ ЧТОБЫ СОЗДАТЬ";
textBox1.TextAlign = HorizontalAlignment.Center;
textBox1.TextChanged += textBox1_TextChanged;
>>>>>>> Stashed changes
//
// pDFДокументToolStripMenuItem
//
<<<<<<< Updated upstream
pDFДокументToolStripMenuItem.Name = "pDFДокументToolStripMenuItem";
pDFДокументToolStripMenuItem.Size = new Size(118, 24);
pDFДокументToolStripMenuItem.Text = "PDF документ";
pDFДокументToolStripMenuItem.Click += pDFДокументToolStripMenuItem_Click;
//
// excelОтчётToolStripMenuItem
//
excelОтчётToolStripMenuItem.Name = "excelОтчётToolStripMenuItem";
excelОтчётToolStripMenuItem.Size = new Size(98, 24);
excelОтчётToolStripMenuItem.Text = "Excel отчёт";
excelОтчётToolStripMenuItem.Click += excelОтчётToolStripMenuItem_Click;
//
// wordДиаграммаToolStripMenuItem
//
wordДиаграммаToolStripMenuItem.Name = "wordДиаграммаToolStripMenuItem";
wordДиаграммаToolStripMenuItem.Size = new Size(141, 24);
wordДиаграммаToolStripMenuItem.Text = "Word диаграмма";
wordДиаграммаToolStripMenuItem.Click += wordДиаграммаToolStripMenuItem_Click;
//
// редактироватьtoolStripMenuItem
//
редактироватьtoolStripMenuItem.Name = "редактироватьtoolStripMenuItem";
редактироватьtoolStripMenuItem.Size = new Size(189, 24);
редактироватьtoolStripMenuItem.Text = "Редактировать доставку";
//
// controlDataTreeTable
//
controlDataTreeTable.Location = new Point(0, 33);
controlDataTreeTable.Margin = new Padding(4, 5, 4, 5);
controlDataTreeTable.Name = "controlDataTreeTable";
controlDataTreeTable.Size = new Size(787, 320);
controlDataTreeTable.TabIndex = 2;
=======
customListBox1.Location = new Point(87, 329);
customListBox1.Margin = new Padding(3, 2, 3, 2);
customListBox1.Name = "customListBox1";
customListBox1.SelectedIndex = -1;
customListBox1.Size = new Size(532, 199);
customListBox1.TabIndex = 14;
>>>>>>> Stashed changes
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
<<<<<<< Updated upstream
ClientSize = new Size(800, 367);
Controls.Add(controlDataTreeTable);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
=======
ClientSize = new Size(983, 596);
Controls.Add(customListBox1);
Controls.Add(textBox1);
Controls.Add(button2);
Controls.Add(buttonLargeText);
Controls.Add(button1);
Controls.Add(pictureBox1);
Margin = new Padding(3, 2, 3, 2);
>>>>>>> Stashed changes
Name = "FormMain";
Text = "FormMain";
Load += FormMain_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem созданиеДоставкиToolStripMenuItem;
private ToolStripMenuItem созданиеТипаДоставкиToolStripMenuItem;
private ToolStripMenuItem pDFДокументToolStripMenuItem;
private ToolStripMenuItem excelОтчётToolStripMenuItem;
private ToolStripMenuItem wordДиаграммаToolStripMenuItem;
private ToolStripMenuItem создатьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьДоставкуToolStripMenuItem;
private ToolStripMenuItem удалитьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьtoolStripMenuItem;
private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable;
private DocumentFormat.OpenXml.Spreadsheet.Controls.LargeTextComponent largeTextComponent;
private CustomComponents.NonViewComponents.PieChartWord pieChartWord;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel componentDocumentWithTableMultiHeaderExcel;
private NotVisualComponent.ExcelHardTable excelHardTable;
}
}

View File

@@ -0,0 +1,202 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using Controls;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using CustomComponents;
using CustomComponents.NonViewComponents.Enums;
using CustomComponents.NonViewComponents.SupportClasses;
using CustomComponents.NonViewComponents;
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 DatabaseImplement.Models;
using ComponentsLibraryNet60.DocumentWithTable;
using ComponentsLibraryNet60.Models;
using NotVisualComponent.Models;
using NotVisualComponent;
namespace Forms
{
public partial class FormMain : Form
{
private readonly IDeliveryLogic _dlogic;
private readonly IDeliveryTypeLogic _dtlogic;
public FormMain(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic)
{
InitializeComponent();
_dlogic = dLogic;
_dtlogic = dtLogic;
TreeConfig();
LoadData();
}
private void TreeConfig()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("FCs");
treeConfig.NodeNames.Enqueue("Wishes");
treeConfig.NodeNames.Enqueue("DeliveryType");
treeConfig.NodeNames.Enqueue("DeliveryDate");
controlDataTreeTable.LoadConfig(treeConfig);
}
private void LoadData()
{
var list = _dlogic.ReadList(null);
if (list != null)
{
controlDataTreeTable.Clear();
controlDataTreeTable.AddTable(list);
}
}
private void созданиеТипаДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DepartmentTypeForm));
if (service is DepartmentTypeForm form)
{
form.ShowDialog();
}
}
private void созданиеДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DepartmentForm));
if (service is DepartmentForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id);
DepartmentForm form = new DepartmentForm(_dlogic, _dtlogic, id);
form.ShowDialog();
LoadData();
}
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.Yes)
{
_dlogic.Delete(new DeliveryBindingModel
{
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id),
});
LoadData();
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void pDFДокументToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".pdf";
var list = _dlogic.ReadList(null);
if (list != null)
{
int i = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") i++;
}
string[] strings = new string[i];
int j = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") { strings[j] = ($"{item.FCs} : {item.Wishes}"); j++; }
}
largeTextComponent.CreateDocument(path, $"Отчет по доставкам без даты:", strings);
MessageBox.Show("Отчет готов");
}
}
private void wordДиаграммаToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".docx";
var list = _dlogic.ReadList(null);
var data = list
.Where(x => x.DeliveryDate != "Даты доставки нет")
.GroupBy(x => x.DeliveryType)
.Select(g => (type: g.Key, Value: g.Count()))
.ToList();
var categoriesX = data.Select(d => d.type).ToList();
var valuesY = data.Select(d => (double)d.Value).ToList();
var series = new List<SeriesData>
{
new()
{
SeriesName = "Количество доставок",
ValuesY = valuesY,
Color = Color.FromArgb(100, 150, 200)
}
};
pieChartWord.CreateDiagramDocument(new PieChartData()
{
FileName = path,
DocumentTitle = "Диаграмма",
DiagramTitle = "Количество доставок по типам",
LegendLayout = PieChartLegendAlign.Bottom,
CategoriesX = categoriesX,
SeriesData = series
});
MessageBox.Show("Отчет готов");
}
private void excelОтчётToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".xlsx";
var list = _dlogic.ReadList(null);
excelHardTable.CreateDoc(new TableWithHeaderConfig<DeliveryViewModel>
{
FilePath = path,
Header = "Deliveryies",
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (20, 5), (10, 0), (15, 0), },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "FCs", "FCs"),
(2, 0, "DeliveryType", "DeliveryType"),
(3, 0, "DeliveryDate", "DeliveryDate"),
},
Data = list
});
MessageBox.Show("Отчет готов");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<UserSecretsId>ef917bf4-6e2e-4411-843c-3f029db00506</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponents" Version="1.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
<PackageReference Include="NotVisualComponent" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Components\Components.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,188 @@
using BusinessLogic.BusinessLogic;
using Components;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using CustomComponents.NonViewComponents;
using CustomComponents.NonViewComponents.Enums;
using CustomComponents.NonViewComponents.SupportClasses;
using DatabaseImplement.Implements;
using NotVisualComponent;
using NotVisualComponent.Models;
using PluginsConventionLibrary;
namespace Forms
{
public class PluginsConvention : IPluginsConvention, IDisposable
{
private readonly IDepartmentLogic _dlogic;
private readonly IDepartmentTypeLogic _dtlogic;
private readonly ControlDataTreeTable _controlDataTreeTable = new();
private readonly LargeTextComponent _largeTextComponent = new();
private readonly ExcelHardTable excelHardTable = new();
private readonly PieChartWord pieChartWord = new();
public PluginsConvention()
{
_dtlogic = new DepartmentTypeLogic(new DepartmentTypeStorage());
_dlogic = new DepartmentLogic(new DepartmentStorage());
ReloadData();
}
public string PluginName => "PluginLab3";
public UserControl GetControl => _controlDataTreeTable;
public PluginsConventionElement GetElement
{
get
{
var selected = _controlDataTreeTable.GetSelectedObject<DepartmentViewModel>();
if (selected == null) throw new Exception("Не удалось получить выбранный элемент");
byte[] bytes = new byte[16];
BitConverter.GetBytes(selected.Id).CopyTo(bytes, 0);
return new PluginsConventionProvider()
{
Id = new Guid(bytes),
FCs = selected.FCs,
Wishes = selected.Wishes,
DeliveryType = selected.Departmentype,
DeliveryDate = selected.DepartmentDate,
};
}
}
public Form GetForm(PluginsConventionElement element)
{
var deliveryForm = new DepartmentForm(_dlogic, _dtlogic);
if (element != null)
{
deliveryForm = new DepartmentForm(_dlogic, _dtlogic, element.Id.GetHashCode());
}
return deliveryForm;
}
public Form GetThesaurus()
{
return new DepartmentTypeForm(_dtlogic);
}
public bool DeleteElement(PluginsConventionElement element)
{
return _dlogic.Delete(new DepartmentBindingModel
{
Id = element.Id.GetHashCode()
});
}
public void ReloadData()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("FCs");
treeConfig.NodeNames.Enqueue("Wishes");
treeConfig.NodeNames.Enqueue("DeliveryType");
treeConfig.NodeNames.Enqueue("DeliveryDate");
_controlDataTreeTable.LoadConfig(treeConfig);
var list = _dlogic.ReadList(null);
if (list != null)
{
_controlDataTreeTable.Clear();
_controlDataTreeTable.AddTable(list);
}
}
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _dlogic.ReadList(null);
if (list != null)
{
int i = 0;
foreach (var item in list)
{
if (item.DepartmentDate == "Даты доставки нет") i++;
}
string[] strings = new string[i];
int j = 0;
foreach (var item in list)
{
if (item.DepartmentDate == "Даты доставки нет") { strings[j] = ($"{item.FCs} : {item.Wishes}"); j++; }
}
_largeTextComponent.CreateDocument(saveDocument.FileName, $"Отчет по доставкам без даты:", strings);
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _dlogic.ReadList(null);
if (list != null)
{
excelHardTable.CreateDoc(new TableWithHeaderConfig<DepartmentViewModel>
{
FilePath = saveDocument.FileName,
Header = "Deliveryies",
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (20, 5), (10, 0), (15, 0), },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "FCs", "FCs"),
(2, 0, "DeliveryType", "DeliveryType"),
(3, 0, "DeliveryDate", "DeliveryDate"),
},
Data = list
});
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _dlogic.ReadList(null);
var data = list
.Where(x => x.DepartmentDate != "Даты доставки нет")
.GroupBy(x => x.Departmentype)
.Select(g => (type: g.Key, Value: g.Count()))
.ToList();
var categoriesX = data.Select(d => d.type).ToList();
var valuesY = data.Select(d => (double)d.Value).ToList();
if (list != null)
{
var series = new List<SeriesData>
{
new()
{
SeriesName = "Количество доставок",
ValuesY = valuesY,
Color = Color.FromArgb(100, 150, 200)
}
};
pieChartWord.CreateDiagramDocument(new PieChartData()
{
FileName = saveDocument.FileName,
DocumentTitle = "Диаграмма",
DiagramTitle = "Количество доставок по типам",
LegendLayout = PieChartLegendAlign.Bottom,
CategoriesX = categoriesX,
SeriesData = series
});
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
public void Dispose()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,20 @@
using PluginsConventionLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forms
{
public class PluginsConventionProvider : PluginsConventionElement
{
public string FCs { get; set; } = string.Empty;
public string Wishes { get; set; } = string.Empty;
public string DeliveryType { get; set; } = string.Empty;
public string? DeliveryDate { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using Test;
namespace Forms
{
internal static class Program
{
/// <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();
Application.Run(new Form1());
}
}
}

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Forms.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Forms.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

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>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IDepartmentModel : IId
{
string Name { get; }
string Target { get; }
string DepartmentType { get; }
string? ReportDate { get; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IDepartmentTypeModel : IId
{
string Name { get; }
}
}

13
Components/Models/IId.cs Normal file
View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IId
{
int Id { get; }
}
}

View File

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

39
Components/PluginApp/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,39 @@
namespace PluginApp
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

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

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>

View File

@@ -0,0 +1,23 @@
<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>
<ProjectReference Include="..\Components\Components.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="plugins\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
namespace PluginApp
{
internal static class Program
{
/// <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();
Application.Run(new Form1());
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibrary
{
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>
/// Удаление элемента
/// /// </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);
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibrary
{
public class PluginsConventionElement
{
public Guid Id { get; set; }
}
}

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,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibrary
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}

View File

@@ -9,7 +9,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Components\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Components\Components\Components.csproj" />
<ProjectReference Include="..\Components\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>