7 Commits
Lab01 ... Lab03

Author SHA1 Message Date
91c5d7d040 Сдал 2023-11-16 10:15:21 +04:00
605cfdef56 Fix 2023-11-16 09:16:12 +04:00
66df1c294a Вроде теперь точно всё 2023-11-16 02:01:56 +04:00
a68eabe9c7 Вроде 3 готова 2023-11-16 00:09:22 +04:00
4bcc573fbb лвб 3 начал 2023-11-14 20:32:44 +04:00
96234cb606 Сдана 2023-11-01 19:53:25 +04:00
caca564260 Готово 2023-10-19 00:25:16 +04:00
51 changed files with 3070 additions and 4 deletions

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OrdersContracts\OrdersContracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,67 @@
using OrdersContracts.BindingModels;
using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.StorageContracts;
using OrdersContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrderBusinessLogic
{
public class OrderLogic : IOrderLogic
{
private readonly IOrderStorage _orderStorage;
public OrderLogic(IOrderStorage orderStorage)
{
_orderStorage = orderStorage;
}
public void CreateOrUpdate(OrderBindingModel model)
{
var element = _orderStorage.GetElement(
new OrderBindingModel
{
Info = model.Info,
Name = model.Name,
Status = model.Status,
Amount = model.Amount
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Такой заказ уже существует");
}
if (model.Id.HasValue)
{
_orderStorage.Update(model);
}
else
{
_orderStorage.Insert(model);
}
}
public void Delete(OrderBindingModel model)
{
var element = _orderStorage.GetElement(new OrderBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Заказ не найден");
}
_orderStorage.Delete(model);
}
public List<OrderViewModel> Read(OrderBindingModel model)
{
if (model == null)
{
return _orderStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<OrderViewModel> { _orderStorage.GetElement(model) };
}
return _orderStorage.GetFilteredList(model);
}
}
}

View File

@@ -0,0 +1,60 @@
using OrdersContracts.BindingModels;
using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.StorageContracts;
using OrdersContracts.ViewModels;
namespace OrderBusinessLogic
{
public class StatusLogic : IStatusLogic
{
private readonly IStatusStorage _statusStorage;
public StatusLogic(IStatusStorage statusStorage)
{
_statusStorage = statusStorage;
}
public void CreateOrUpdate(StatusBindingModel model)
{
var element = _statusStorage.GetElement(
new StatusBindingModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Такой статус уже существует");
}
if (model.Id.HasValue)
{
_statusStorage.Update(model);
}
else
{
_statusStorage.Insert(model);
}
}
public void Delete(StatusBindingModel model)
{
var element = _statusStorage.GetElement(new StatusBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Статус не найден");
}
_statusStorage.Delete(model);
}
public List<StatusViewModel> Read(StatusBindingModel model)
{
if (model == null)
{
return _statusStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<StatusViewModel> { _statusStorage.GetElement(model) };
}
return _statusStorage.GetFilteredList(model);
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersContracts.BindingModels
{
public class OrderBindingModel
{
public int? Id { get; set; }
public string Name { get; set; }
public string Info { get; set; }
public string Status { get; set; }
public string? Amount { get; set; }
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,21 @@
using OrdersContracts.BindingModels;
using OrdersContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersContracts.StorageContracts
{
public interface IStatusStorage
{
List<StatusViewModel> GetFullList();
List<StatusViewModel> GetFilteredList(StatusBindingModel model);
StatusViewModel GetElement(StatusBindingModel model);
void Insert(StatusBindingModel model);
void Update(StatusBindingModel model);
void Delete(StatusBindingModel model);
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersContracts.ViewModels
{
public class OrderViewModel
{
public int? Id { get; set; }
[DisplayName("ФИО")]
public string Name { get; set; }
[DisplayName("Описание")]
public string Info { get; set; }
[DisplayName("Статус")]
public string Status { get; set; }
[DisplayName("Сумма заказа")]
public string Amount { get; set; }
}
}

View File

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

View File

@@ -0,0 +1,125 @@
using OrdersContracts.BindingModels;
using OrdersContracts.StorageContracts;
using OrdersContracts.ViewModels;
using OrdersDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersDatabaseImplement.Implements
{
public class OrderStorage : IOrderStorage
{
public void Delete(OrderBindingModel model)
{
var context = new OrdersDatabase();
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
if (order != null)
{
context.Orders.Remove(order);
context.SaveChanges();
}
else
{
throw new Exception("Заказ не найден");
}
}
public OrderViewModel GetElement(OrderBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new OrdersDatabase();
var order = context.Orders
.ToList()
.FirstOrDefault(rec => rec.Id == model.Id);
return order != null ? CreateModel(order) : null;
}
public List<OrderViewModel> GetFilteredList(OrderBindingModel model)
{
var context = new OrdersDatabase();
return context.Orders
.Where(order => order.Name.Contains(model.Name) && order.Status.Contains(model.Status))
.ToList()
.Select(CreateModel)
.ToList();
}
public List<OrderViewModel> GetFullList()
{
using (var context = new OrdersDatabase())
{
return context.Orders
.ToList()
.Select(CreateModel)
.ToList();
}
}
public void Insert(OrderBindingModel model)
{
var context = new OrdersDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Orders.Add(CreateModel(model, new Order()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(OrderBindingModel model)
{
var context = new OrdersDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
if (order == null)
{
throw new Exception("Заказ не найден");
}
CreateModel(model, order);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
private static Order CreateModel(OrderBindingModel model, Order order)
{
order.Amount = model.Amount;
order.Name = model.Name;
order.Status = model.Status;
order.Info = model.Info;
return order;
}
private OrderViewModel CreateModel(Order order)
{
return new OrderViewModel
{
Id = order.Id,
Amount = order.Amount,
Name = order.Name,
Status = order.Status,
Info = order.Info
};
}
}
}

View File

@@ -0,0 +1,120 @@
using OrdersContracts.BindingModels;
using OrdersContracts.StorageContracts;
using OrdersContracts.ViewModels;
using OrdersDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersDatabaseImplement.Implements
{
public class StatusStorage : IStatusStorage
{
public void Delete(StatusBindingModel model)
{
var context = new OrdersDatabase();
var status = context.Statuses.FirstOrDefault(rec => rec.Id == model.Id);
if (status != null)
{
context.Statuses.Remove(status);
context.SaveChanges();
}
else
{
throw new Exception("Статус не найден");
}
}
public StatusViewModel GetElement(StatusBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new OrdersDatabase();
var status = context.Statuses
.ToList()
.FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
return status != null ? CreateModel(status) : null;
}
public List<StatusViewModel> GetFilteredList(StatusBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new OrdersDatabase();
return context.Statuses
.Where(rec => rec.Name.Contains(model.Name))
.Select(CreateModel)
.ToList();
}
public List<StatusViewModel> GetFullList()
{
using var context = new OrdersDatabase();
return context.Statuses
.Select(CreateModel)
.ToList();
}
public void Insert(StatusBindingModel model)
{
var context = new OrdersDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Statuses.Add(CreateModel(model, new Status()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(StatusBindingModel model)
{
var context = new OrdersDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var status = context.Statuses.FirstOrDefault(rec => rec.Id == model.Id);
if (status == null)
{
throw new Exception("Статус не найден");
}
CreateModel(model, status);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
private static Status CreateModel(StatusBindingModel model, Status status)
{
status.Name = model.Name;
return status;
}
private static StatusViewModel CreateModel(Status status)
{
return new StatusViewModel
{
Id = status.Id,
Name = status.Name
};
}
}
}

View File

@@ -0,0 +1,75 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OrdersDatabaseImplement;
#nullable disable
namespace OrdersDatabaseImplement.Migrations
{
[DbContext(typeof(OrdersDatabase))]
[Migration("20231114172558_mig2")]
partial class mig2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("OrdersDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("Amount")
.HasColumnType("integer");
b.Property<string>("Info")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("OrdersDatabaseImplement.Models.Status", 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("Statuses");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,54 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace OrdersDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class mig2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Info = table.Column<string>(type: "text", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
Amount = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Statuses",
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_Statuses", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Statuses");
}
}
}

View File

@@ -0,0 +1,74 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OrdersDatabaseImplement;
#nullable disable
namespace OrdersDatabaseImplement.Migrations
{
[DbContext(typeof(OrdersDatabase))]
[Migration("20231116050328_mig3")]
partial class mig3
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("OrdersDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Amount")
.HasColumnType("text");
b.Property<string>("Info")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("OrdersDatabaseImplement.Models.Status", 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("Statuses");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OrdersDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class mig3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Amount",
table: "Orders",
type: "text",
nullable: true,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Amount",
table: "Orders",
type: "integer",
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}

View File

@@ -0,0 +1,71 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OrdersDatabaseImplement;
#nullable disable
namespace OrdersDatabaseImplement.Migrations
{
[DbContext(typeof(OrdersDatabase))]
partial class OrdersDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("OrdersDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Amount")
.HasColumnType("text");
b.Property<string>("Info")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("OrdersDatabaseImplement.Models.Status", 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("Statuses");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrdersDatabaseImplement.Models
{
public class Order
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Info { get; set; }
[Required]
public string Status { get; set; }
public string? Amount { get; set; }
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using OrdersDatabaseImplement.Models;
namespace OrdersDatabaseImplement
{
public class OrdersDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=OrdersDatabase;Username=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Status> Statuses { set; get; }
}
}

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OrdersContracts\OrdersContracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class BigTable<T>
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty;
public List<ColumnDefinition> ColumnDefinitions;
public List<ColumnDefinition> ColumnDefinitions2;
public List<T> Data;
public List<int[]> MergedColumns;
public BigTable(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
{
FilePath = filePath;
DocumentTitle = documentTitle;
ColumnDefinitions = columnDefinitions;
Data = data;
MergedColumns = mergedColumns;
ColumnDefinitions2 = columnDefinitions2;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class ColumnDefinition
{
public string Header;
public string PropertyName;
public double Weight;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class DataLineChart
{
public string NameSeries { get; set; } = string.Empty;
public double[] Data { get; set; }
public DataLineChart(string nameSeries, double[] data)
{
NameSeries = nameSeries;
Data = data;
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses.Enums
{
public enum EnumAreaLegend
{
None,
Left,
Top,
Right,
Bottom,
TopRight
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class LargeText
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty;
public string[] TextData;
public LargeText(string filePath, string documentTitle, string[] textData)
{
FilePath = filePath;
DocumentTitle = documentTitle;
TextData = textData;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualComponentsLib.Components.SupportClasses.Enums;
namespace VisualComponentsLib.Components.SupportClasses
{
public class SimpleLineChart
{
public string FilePath = string.Empty;
public string FileHeader = string.Empty;
public string LineChartName = string.Empty;
public EnumAreaLegend AreaLegend;
public string[] NameData { get; set; }
public List<DataLineChart> DataList = new();
public SimpleLineChart(string filePath, string fileHeader, string lineChartName, EnumAreaLegend areaLegend, List<DataLineChart> dataList)
{
FilePath = filePath;
FileHeader = fileHeader;
LineChartName = lineChartName;
AreaLegend = areaLegend;
DataList = dataList;
}
}
}

View File

@@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class WordLineChart
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@@ -0,0 +1,84 @@
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Drawing.Charts;
using System.ComponentModel;
using VisualComponentsLib.Components.SupportClasses;
namespace VisualComponentsLib.Components
{
public partial class WordLineChart : Component
{
public WordLineChart()
{
InitializeComponent();
}
public WordLineChart(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void AddLineChart(SimpleLineChart simpleLineChart)
{
if (!CheckData(simpleLineChart.DataList))
{
throw new Exception("Не данные заполнены");
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Aspose.Words.Font font = builder.Font;
font.Size = 24;
font.Bold = true;
font.Color = Color.Black;
font.Name = "Times New Roman";
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.SpaceAfter = 24;
paragraphFormat.Alignment = ParagraphAlignment.Center;
paragraphFormat.KeepTogether = true;
builder.Writeln(simpleLineChart.FileHeader);
Shape shape = builder.InsertChart(ChartType.Line, 500, 270);
Chart chart = shape.Chart;
chart.Title.Text = simpleLineChart.LineChartName;
ChartSeriesCollection seriesColl = chart.Series;
Console.WriteLine(seriesColl.Count);
seriesColl.Clear();
foreach (var data in simpleLineChart.DataList)
{
seriesColl.Add(data.NameSeries, simpleLineChart.NameData, data.Data);
}
ChartLegend legend = chart.Legend;
legend.Position = (LegendPosition)simpleLineChart.AreaLegend;
legend.Overlay = true;
doc.Save(simpleLineChart.FilePath);
}
static bool CheckData(List<DataLineChart> data)
{
foreach (var _data in data)
{
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.Data.ToString())) //аккуратно
{
return false;
}
}
return true;
}
}
}

View File

@@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class WordTable
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@@ -0,0 +1,128 @@
using System.ComponentModel;
using Aspose.Words;
using Aspose.Words.Tables;
using VisualComponentsLib.Components.SupportClasses;
namespace VisualComponentsLib.Components
{
public partial class WordTable : Component
{
public WordTable()
{
InitializeComponent();
}
public WordTable(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateTable<T>(BigTable<T> bigTable)
{
if (bigTable.Data == null)
{
throw new ArgumentException("Не заданы все данные");
}
foreach (var columnDefinition in bigTable.ColumnDefinitions)
{
if (string.IsNullOrEmpty(columnDefinition.PropertyName))
{
throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}");
}
}
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
titleStyle.Font.Size = 16;
titleStyle.Font.Bold = true;
builder.ParagraphFormat.Style = titleStyle;
builder.Writeln(bigTable.DocumentTitle);
Table table = builder.StartTable();
foreach (var columnDefinition in bigTable.ColumnDefinitions)
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write(columnDefinition.Header);
}
foreach (var mergedColumn in bigTable.MergedColumns)
{
int startCellIndex = mergedColumn[0];
int endCellIndex = mergedColumn[mergedColumn.Length - 1];
for (int i = startCellIndex; i <= endCellIndex; i++)
{
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First;
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
}
for (int i = startCellIndex + 1; i <= endCellIndex; i++)
{
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
}
}
builder.EndRow();
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight);
builder.Write(columnDefinition2.Header);
}
builder.EndRow();
int columnIndex;
foreach (var columnDefinition in bigTable.ColumnDefinitions)
{
string currentPropertyName = columnDefinition.PropertyName;
columnIndex = 0;
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
{
string currentPropertyName1 = columnDefinition2.PropertyName;
if (currentPropertyName == currentPropertyName1)
{
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
}
columnIndex++;
}
}
foreach (var item in bigTable.Data)
{
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
{
builder.InsertCell();
var propertyValue = item.GetType()
.GetProperty(columnDefinition2.PropertyName)?
.GetValue(item)?.ToString();
builder.Write(propertyValue ?? "");
}
builder.EndRow();
}
builder.EndTable();
document.Save(bigTable.FilePath);
}
}
}

View File

@@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class WordText
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@@ -0,0 +1,133 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using System.ComponentModel;
using VisualComponentsLib.Components.SupportClasses;
namespace VisualComponentsLib.Components
{
public partial class WordText : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public WordText()
{
InitializeComponent();
}
public WordText(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateWordText(LargeText largeText)
{
if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || !CheckData(largeText.TextData))
{
throw new Exception("Не все данные заполнены");
}
_wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document);
//вытаскиваем главную часть из вордовского документа
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
//генерируем тело основной части документа
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
AddText(largeText);
}
private void AddText(LargeText largeText)
{
using (var document = WordprocessingDocument.Open(largeText.FilePath, true))
{
var doc = document.MainDocumentPart.Document;
#region Создание заголовка
ParagraphProperties paragraphProperties = new();
paragraphProperties.AppendChild(new Justification
{
Val = JustificationValues.Center
});
paragraphProperties.AppendChild(new Indentation());
Paragraph header = new();
header.AppendChild(paragraphProperties);
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize
{
Val = "48"
});
properties.AppendChild(new Bold());
docRun.AppendChild(properties);
docRun.AppendChild(new Text(largeText.DocumentTitle));
header.AppendChild(docRun);
doc.Body.Append(header);
#endregion
#region Создание текста
for (int i = 0; i < largeText.TextData.Length; i++)
{
ParagraphProperties paragraphProperties2 = new();
paragraphProperties2.AppendChild(new Justification
{
Val = JustificationValues.Both
});
paragraphProperties2.AppendChild(new Indentation());
Paragraph text = new();
text.AppendChild(paragraphProperties2);
var docRun2 = new Run();
var properties2 = new RunProperties();
properties2.AppendChild(new FontSize
{
Val = "24"
});
docRun2.AppendChild(properties2);
docRun2.AppendChild(new Text(largeText.TextData[i]));
text.AppendChild(docRun2);
doc.Body.Append(text);
}
#endregion
doc.Save();
}
}
bool CheckData(string[] data)
{
for (int i = 0; i < data.Length; i++)
{
if (string.IsNullOrEmpty(data[i])) return false;
}
return true;
}
}
}

View File

@@ -5,6 +5,13 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Words" Version="23.10.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="FreeSpire.Doc" Version="11.6.0" />
</ItemGroup>
</Project>

View File

@@ -4,8 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
ProjectSection(ProjectDependencies) = postProject
{00C86B65-4E95-4917-B348-398DCF0885C3} = {00C86B65-4E95-4917-B348-398DCF0885C3}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrdersContracts", "OrdersContracts\OrdersContracts.csproj", "{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrderBusinessLogic", "OrderBusinessLogic\OrderBusinessLogic.csproj", "{071BD445-8513-4B12-A60C-2531F2B795F5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrdersDatabaseImplement", "OrdersDatabaseImplement\OrdersDatabaseImplement.csproj", "{00C86B65-4E95-4917-B348-398DCF0885C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +30,18 @@ Global
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.Build.0 = Release|Any CPU
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.Build.0 = Release|Any CPU
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.Build.0 = Release|Any CPU
{00C86B65-4E95-4917-B348-398DCF0885C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00C86B65-4E95-4917-B348-398DCF0885C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00C86B65-4E95-4917-B348-398DCF0885C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00C86B65-4E95-4917-B348-398DCF0885C3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

159
WinForms/WinForms/FormMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,159 @@

namespace WinForms
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.добавитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.редактироватьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВВордToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВЭксельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВПдфToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.статусыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wordText1 = new VisualCompLib.Components.WordText(this.components);
this.excelChart = new UnvisableComponents.ExcelChart(this.components);
this.componentDocumentWithTableMultiHeaderPdf1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components);
this.TreeView = new VisableComponents.MyTreeView();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.добавитьToolStripMenuItem,
this.редактироватьToolStripMenuItem,
this.удалитьToolStripMenuItem,
this.сохранитьВВордToolStripMenuItem,
this.сохранитьВЭксельToolStripMenuItem,
this.сохранитьВПдфToolStripMenuItem,
this.статусыToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(255, 200);
//
// добавитьToolStripMenuItem
//
this.добавитьToolStripMenuItem.Name = обавитьToolStripMenuItem";
this.добавитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
this.добавитьToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.добавитьToolStripMenuItem.Text = "Добавить";
this.добавитьToolStripMenuItem.Click += new System.EventHandler(this.добавитьToolStripMenuItem_Click);
//
// редактироватьToolStripMenuItem
//
this.редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
this.редактироватьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.редактироватьToolStripMenuItem.Text = "Редактировать";
this.редактироватьToolStripMenuItem.Click += new System.EventHandler(this.редактироватьToolStripMenuItem_Click);
//
// удалитьToolStripMenuItem
//
this.удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
this.удалитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.удалитьToolStripMenuItem.Text = "Удалить";
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
//
// сохранитьВВордToolStripMenuItem
//
this.сохранитьВВордToolStripMenuItem.Name = "сохранитьВВордToolStripMenuItem";
this.сохранитьВВордToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.сохранитьВВордToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.сохранитьВВордToolStripMenuItem.Text = "Сохранить в Word";
this.сохранитьВВордToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВВордToolStripMenuItem_Click);
//
// сохранитьВЭксельToolStripMenuItem
//
this.сохранитьВЭксельToolStripMenuItem.Name = "сохранитьВЭксельToolStripMenuItem";
this.сохранитьВЭксельToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.сохранитьВЭксельToolStripMenuItem.Size = new System.Drawing.Size(254, 24);
this.сохранитьВЭксельToolStripMenuItem.Text = "Сохранить в Exel";
this.сохранитьВЭксельToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВЭксельToolStripMenuItem_Click);
//
// сохранитьВПдфToolStripMenuItem
//
this.сохранитьВПдфToolStripMenuItem.Name = "сохранитьВПдфToolStripMenuItem";
this.сохранитьВПдфToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
this.сохранитьВПдфToolStripMenuItem.Size = new System.Drawing.Size(254, 24);
this.сохранитьВПдфToolStripMenuItem.Text = "Сохранить в PDF";
this.сохранитьВПдфToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВПдфToolStripMenuItem_Click);
//
// статусыToolStripMenuItem
//
this.статусыToolStripMenuItem.Name = "статусыToolStripMenuItem";
this.статусыToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Tab)));
this.статусыToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.статусыToolStripMenuItem.Text = "Статусы";
this.статусыToolStripMenuItem.Click += new System.EventHandler(this.статусыToolStripMenuItem_Click);
//
// myTreeView1
//
this.TreeView.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.TreeView.BackColor = System.Drawing.SystemColors.ControlDark;
this.TreeView.Location = new System.Drawing.Point(12, 13);
this.TreeView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.TreeView.MinimumSize = new System.Drawing.Size(200, 200);
this.TreeView.Name = "TreeView";
this.TreeView.Size = new System.Drawing.Size(658, 372);
this.TreeView.TabIndex = 1;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(682, 398);
this.Controls.Add(this.TreeView);
this.Name = "FormMain";
this.Text = "Заказы";
this.Load += new System.EventHandler(this.FormMain_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem сохранитьВВордToolStripMenuItem;
private ToolStripMenuItem сохранитьВЭксельToolStripMenuItem;
private ToolStripMenuItem сохранитьВПдфToolStripMenuItem;
private ToolStripMenuItem статусыToolStripMenuItem;
private VisualCompLib.Components.WordText wordText1;
private UnvisableComponents.ExcelChart excelChart;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf1;
private VisableComponents.MyTreeView TreeView;
}
}

View File

@@ -0,0 +1,233 @@
using ComponentsLibraryNet60.DocumentWithTable;
using ComponentsLibraryNet60.Models;
using ControlsLibraryNet60.Input;
using OrdersContracts.BindingModels;
using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.ViewModels;
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 UnvisableComponents;
using VisualComponentsLib.Components;
namespace WinForms
{
public partial class FormMain : Form
{
private readonly IOrderLogic _orderLogic;
private readonly IStatusLogic _statusLogic;
public FormMain(IOrderLogic orderLogic, IStatusLogic statusLogic)
{
_orderLogic = orderLogic;
_statusLogic = statusLogic;
InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" };
TreeView.addToHierarchy(stringToHierachy);
ContextMenuStrip = contextMenuStrip1;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _orderLogic.Read(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Amount == null || list[i].Amount == "") { list[i].Amount = "Заказы, оплаченные скидками"; }
}
TreeView.LoadTree(list);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddNewElement()
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
if (!(service is FormOrder form)) return;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void UpdateElement()
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
if (!(service is FormOrder form)) return;
var selectedOrder = TreeView.GetNode(typeof(OrderBindingModel));
if (selectedOrder != null)
{
form.Id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
else
{
MessageBox.Show("Выберите заказ для редактирования");
}
}
private void DeleteElement()
{
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedOrder = TreeView.GetNode(typeof(OrderBindingModel));
int id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id);
try
{
_orderLogic.Delete(new OrderBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
private void CreateWord()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
List<string> textList = new List<string>();
var list = _orderLogic.Read(null);
if (list != null)
{
foreach (var item in list)
{
if (item.Amount == null || item.Amount == "")
{
string orders = string.Concat("ФИО заказчика: ", item.Name, " Описание: ", item.Info);
textList.Add(orders);
}
}
string[] textArray = textList.ToArray();
wordText1.CreateWordText(new(fileName, "Заказы, которые были оплачены скидками", textArray));
}
}
private void createExcel()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
var statuses = _statusLogic.Read(null);
var orders = _orderLogic.Read(null);
List<(string, int)> dates = new List<(string, int)>();
for (int i = 0; i < statuses.Count; i++)
{
int counter = 0;
for (int j = 0; j < orders.Count; j++)
{
if (orders[j].Status == statuses[i].Name && orders[j].Amount != null) counter++;
}
dates.Add((statuses[i].Name, counter));
}
excelChart.Load(new ChartInfo
{
Path = fileName,
Title = "Статусы заказов",
DiagrammTitle = "Круговая диаграмма",
Dates = dates,
DirLegend = DirectionLegend.Right
});
}
private void CreatePdf()
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
var orders = _orderLogic.Read(null);
for (int i = 0; i < orders.Count; i++)
{
if (orders[i].Amount == null || orders[i].Amount == "") { orders[i].Amount = "Заказы оплачен скидками"; }
}
componentDocumentWithTableMultiHeaderPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel>
{
FilePath = fileName,
Header = "Отчет по заказам",
ColumnsRowsWidth = new List<(int, int)> { (5, 5), (10, 5), (15, 0), (15, 0) },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "ФИО", "Name"),
(2, 0, "Статус", "Status"),
(3, 0, "Сумма заказа", "Amount")
},
Data = orders
});
}
private void статусыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormStatus));
if (!(service is FormStatus form)) return;
form.ShowDialog();
}
private void сохранитьВПдфToolStripMenuItem_Click(object sender, EventArgs e)
{
CreatePdf();
}
private void сохранитьВЭксельToolStripMenuItem_Click(object sender, EventArgs e)
{
createExcel();
}
private void сохранитьВВордToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteElement();
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateElement();
}
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewElement();
}
}
}

View File

@@ -0,0 +1,72 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>149, 17</value>
</metadata>
<metadata name="wordText1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>335, 17</value>
</metadata>
<metadata name="excelChart1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="componentDocumentWithTableMultiHeaderPdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>459, 17</value>
</metadata>
</root>

190
WinForms/WinForms/FormOrder.Designer.cs generated Normal file
View File

@@ -0,0 +1,190 @@
namespace WinForms
{
partial class FormOrder
{
/// <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.textBoxName = new System.Windows.Forms.TextBox();
this.LabelFIO = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.myDropDownList1 = new VisualComponentsLib.MyDropDownList();
this.label2 = new System.Windows.Forms.Label();
this.textBoxInfos = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.controlInputNullableInt1 = new ControlsLibraryNet60.Input.ControlInputNullableInt();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxName.Location = new System.Drawing.Point(12, 34);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(323, 27);
this.textBoxName.TabIndex = 2;
//
// LabelFIO
//
this.LabelFIO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LabelFIO.AutoSize = true;
this.LabelFIO.Location = new System.Drawing.Point(12, 9);
this.LabelFIO.Name = "LabelFIO";
this.LabelFIO.Size = new System.Drawing.Size(42, 20);
this.LabelFIO.TabIndex = 3;
this.LabelFIO.Text = "ФИО";
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 77);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(52, 20);
this.label1.TabIndex = 4;
this.label1.Text = "Статус";
//
// myDropDownList1
//
this.myDropDownList1.Location = new System.Drawing.Point(12, 101);
this.myDropDownList1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.myDropDownList1.Name = "myDropDownList1";
this.myDropDownList1.SelectedValue = "";
this.myDropDownList1.Size = new System.Drawing.Size(195, 48);
this.myDropDownList1.TabIndex = 5;
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 144);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 20);
this.label2.TabIndex = 6;
this.label2.Text = "Описание";
//
// textBoxInfos
//
this.textBoxInfos.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxInfos.Location = new System.Drawing.Point(12, 168);
this.textBoxInfos.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxInfos.Name = "textBoxInfos";
this.textBoxInfos.Size = new System.Drawing.Size(323, 27);
this.textBoxInfos.TabIndex = 7;
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 199);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(116, 20);
this.label3.TabIndex = 8;
this.label3.Text = "Сумма покупок";
//
// controlInputNullableInt1
//
this.controlInputNullableInt1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.controlInputNullableInt1.Location = new System.Drawing.Point(14, 227);
this.controlInputNullableInt1.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8);
this.controlInputNullableInt1.Name = "controlInputNullableInt1";
this.controlInputNullableInt1.Size = new System.Drawing.Size(321, 39);
this.controlInputNullableInt1.TabIndex = 13;
this.controlInputNullableInt1.Value = null;
//
// buttonSave
//
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.buttonSave.Location = new System.Drawing.Point(12, 269);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(323, 31);
this.buttonSave.TabIndex = 14;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(12, 308);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(323, 31);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Отменить";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(347, 368);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.controlInputNullableInt1);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBoxInfos);
this.Controls.Add(this.label2);
this.Controls.Add(this.myDropDownList1);
this.Controls.Add(this.label1);
this.Controls.Add(this.LabelFIO);
this.Controls.Add(this.textBoxName);
this.Name = "FormOrder";
this.Text = "FormOrder";
this.Load += new System.EventHandler(this.FormOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label LabelFIO;
private Label label1;
private VisualComponentsLib.MyDropDownList myDropDownList1;
private Label label2;
private TextBox textBoxInfos;
private Label label3;
private ControlsLibraryNet60.Input.ControlInputNullableInt controlInputNullableInt1;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@@ -0,0 +1,112 @@
using OrdersContracts.BindingModels;
using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.ViewModels;
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 WinForms
{
public partial class FormOrder : Form
{
public int Id { set { id = value; } }
private readonly IOrderLogic _logic;
private readonly IStatusLogic _logicS;
private int? id;
public FormOrder(IOrderLogic logic, IStatusLogic logicS)
{
InitializeComponent();
_logic = logic;
_logicS = logicS;
}
private void FormOrder_Load(object sender, EventArgs e)
{
List<StatusViewModel> viewS = _logicS.Read(null);
if (viewS != null)
{
List<string> list = new List<string>();
foreach (StatusViewModel s in viewS)
{
list.Add(s.Name);
}
myDropDownList1.LoadValues(list);
}
if (id.HasValue)
{
try
{
OrderViewModel view = _logic.Read(new OrderBindingModel { Id = id.Value })?[0];
if (view != null)
{
textBoxInfos.Text = view.Info;
textBoxName.Text = view.Name;
myDropDownList1.SelectedValue = view.Status;
if (view.Amount != null)
{
controlInputNullableInt1.Value = Int32.Parse(view.Amount);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(myDropDownList1.SelectedValue))
{
MessageBox.Show("Выберите заказ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBoxInfos.Text == null)
{
MessageBox.Show("Заполните описание", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string? amount = controlInputNullableInt1.Value.ToString();
if (controlInputNullableInt1.Value == null) amount = null;
try
{
_logic.CreateOrUpdate(new OrderBindingModel
{
Id = id,
Info = textBoxInfos.Text,
Name = textBoxName.Text,
Status = myDropDownList1.SelectedValue.ToString(),
Amount = amount
});
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

69
WinForms/WinForms/FormStatus.Designer.cs generated Normal file
View File

@@ -0,0 +1,69 @@
namespace WinForms
{
partial class FormStatus
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(14, 13);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(270, 292);
this.dataGridView.TabIndex = 0;
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
//
// FormStatus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(297, 321);
this.Controls.Add(this.dataGridView);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormStatus";
this.Text = "Статусы";
this.Load += new System.EventHandler(this.FormStatus_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

View File

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

View File

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

135
WinForms/WinForms/FormWord.Designer.cs generated Normal file
View File

@@ -0,0 +1,135 @@
namespace WinForms
{
partial class FormWord
{
/// <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.wordText = new VisualComponentsLib.Components.WordText(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.wordLineChart = new VisualComponentsLib.Components.WordLineChart(this.components);
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button3 = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.wordTable = new VisualComponentsLib.Components.WordTable(this.components);
this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(136, 80);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Большой текст";
//
// button1
//
this.button1.Location = new System.Drawing.Point(6, 45);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(124, 29);
this.button1.TabIndex = 0;
this.button1.Text = "Создать";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Location = new System.Drawing.Point(331, 12);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(141, 80);
this.groupBox3.TabIndex = 1;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Линейная диаграмма";
//
// button3
//
this.button3.Location = new System.Drawing.Point(6, 45);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(127, 29);
this.button3.TabIndex = 0;
this.button3.Text = "Создать";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button2);
this.groupBox2.Location = new System.Drawing.Point(171, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(142, 80);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Таблица";
//
// button2
//
this.button2.Location = new System.Drawing.Point(6, 45);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(130, 29);
this.button2.TabIndex = 0;
this.button2.Text = "Создать";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// FormWord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(493, 108);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox1);
this.Name = "FormWord";
this.Text = "Невизуальные компоненты";
this.groupBox1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private VisualComponentsLib.Components.WordText wordText;
private GroupBox groupBox1;
private Button button1;
private VisualComponentsLib.Components.WordLineChart wordLineChart;
private GroupBox groupBox3;
private Button button3;
private GroupBox groupBox2;
private Button button2;
private VisualComponentsLib.Components.WordTable wordTable;
}
}

View File

@@ -0,0 +1,132 @@
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 VisualComponentsLib.Components.SupportClasses.Enums;
using VisualComponentsLib.Components.SupportClasses;
using VisualComponentsLib.Object;
namespace WinForms
{
public partial class FormWord : Form
{
string[] testArray = { "Вселенная оценивается в возрасте около 13,8 миллиарда лет.", "Пчелы могут видеть ультрафиолетовый свет, что помогает им находить нектар.", "Гепард - самое быстрое наземное животное, способное развивать скорость до 100 километров в час.", "Всего 12 человек посетили Луну, и ни один человек не был там с 1972 года.", "Крокодилы существуют на Земле более 200 миллионов лет и остаются одними из самых древних видов" };
public FormWord()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
LargeText largeText = new(dialog.FileName, "Немножечко фактов.", testArray);
wordText.CreateWordText(largeText);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
List<int[]> mergedColumns = new()
{
new int[] { 0, 1, 2 }
};
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 },
new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 },
new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<Student> data = new List<Student>
{
new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Багиров" },
new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Ласков" },
new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Тейпова" }
};
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
BigTable<Student> bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
wordTable.CreateTable(bigTable);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
double[] profit1 = { 300, 440, 270 };
double[] profit2 = { 500, 620, 310 };
double[] profit3 = { 420, 189, 430 };
SimpleLineChart lineChart = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataLineChart> {
new DataLineChart("Компания 1", profit1),
new DataLineChart("Компания 2", profit2),
new DataLineChart("Компания 3", profit3),
});
lineChart.NameData = new string[] { "Январь", "Февраль", "Март" };
wordLineChart.AddLineChart(lineChart);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@@ -0,0 +1,69 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="wordText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="wordLineChart.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<metadata name="wordTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>285, 17</value>
</metadata>
</root>

View File

@@ -1,17 +1,39 @@
using Microsoft.Extensions.DependencyInjection;
using OrderBusinessLogic;
using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.StorageContracts;
using OrdersDatabaseImplement.Implements;
namespace WinForms
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormForComponents());
IServiceCollection services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetService<FormMain>());
}
private static void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IStatusLogic, StatusLogic>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IStatusStorage, StatusStorage>();
services.AddTransient<FormMain>();
services.AddTransient<FormOrder>();
services.AddTransient<FormStatus>();
}
}
}

View File

@@ -9,6 +9,20 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="UnvisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.9" />
<PackageReference Include="VisualCompLib" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OrderBusinessLogic\OrderBusinessLogic.csproj" />
<ProjectReference Include="..\OrdersDatabaseImplement\OrdersDatabaseImplement.csproj" />
<ProjectReference Include="..\VisualComponentsLib\VisualComponentsLib.csproj" />
</ItemGroup>