Compare commits

..

No commits in common. "Lab3" and "main" have entirely different histories.
Lab3 ... main

53 changed files with 4 additions and 2833 deletions

View File

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

View File

@ -1,94 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.SearchModels;
using AccountContracts.StoragesContracts;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static AccountBusinessLogic.BusinessLogic.AccountLogic;
namespace AccountBusinessLogic.BusinessLogic
{
public class AccountLogic : IAccountLogic
{
private readonly IAccountStorage _accountStorage;
public AccountLogic(IAccountStorage accountStorage)
{
_accountStorage = accountStorage;
}
public bool Create(AccountBindingModel model)
{
CheckModel(model);
if (_accountStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(AccountBindingModel model)
{
CheckModel(model, false);
if (_accountStorage.Delete(model) == null)
{
return false;
}
return true;
}
public AccountViewModel? ReadElement(AccountSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _accountStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<AccountViewModel>? ReadList(AccountSearchModel? model)
{
var list = _accountStorage.GetFullList();
if (list == null)
{
return null;
}
return list;
}
public bool Update(AccountBindingModel model)
{
CheckModel(model);
if (_accountStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(AccountBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Account's login is missing!", nameof(model.Login));
}
}
}
}

View File

@ -1,93 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.SearchModels;
using AccountContracts.StoragesContracts;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountBusinessLogic.BusinessLogic
{
public class RoleLogic : IRoleLogic
{
private readonly IRoleStorage _roleStorage;
public RoleLogic(IRoleStorage roleStorage)
{
_roleStorage = roleStorage;
}
public bool Create(RoleBindingModel model)
{
CheckModel(model);
if (_roleStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(RoleBindingModel model)
{
CheckModel(model, false);
if (_roleStorage.Delete(model) == null)
{
return false;
}
return true;
}
public RoleViewModel? ReadElement(RoleSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _roleStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<RoleViewModel>? ReadList()
{
var list = _roleStorage.GetFullList();
if (list == null)
{
return null;
}
return list;
}
public bool Update(RoleBindingModel model)
{
CheckModel(model);
if (_roleStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(RoleBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.RoleName))
{
throw new ArgumentNullException("Role's name is missing!", nameof(model.RoleName));
}
}
}
}

View File

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

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AccountsDataModels.Models;
namespace AccountContracts.BindingModels
{
public class AccountBindingModel : IAccountModel
{
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string? Warnings { get; set; } = string.Empty;
public float? Rating { get; set; } = null;
public int RoleId { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AccountsDataModels.Models;
namespace AccountContracts.BindingModels
{
public class RoleBindingModel : IRoleModel
{
public int Id { get; set; }
public string RoleName { get; set; } = string.Empty;
}
}

View File

@ -1,20 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.BusinessLogicsContracts
{
public interface IAccountLogic
{
List<AccountViewModel>? ReadList(AccountSearchModel? model);
AccountViewModel? ReadElement(AccountSearchModel model);
bool Create(AccountBindingModel model);
bool Update(AccountBindingModel model);
bool Delete(AccountBindingModel model);
}
}

View File

@ -1,20 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.BusinessLogicsContracts
{
public interface IRoleLogic
{
List<RoleViewModel> ReadList();
RoleViewModel? ReadElement(RoleSearchModel model);
bool Create(RoleBindingModel model);
bool Update(RoleBindingModel model);
bool Delete(RoleBindingModel model);
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.SearchModels
{
public class AccountSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.SearchModels
{
public class RoleSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -1,20 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.StoragesContracts
{
public interface IAccountStorage
{
List<AccountViewModel> GetFullList();
AccountViewModel? GetElement(AccountSearchModel model);
AccountViewModel? Insert(AccountBindingModel model);
AccountViewModel? Update(AccountBindingModel model);
AccountViewModel? Delete(AccountBindingModel model);
}
}

View File

@ -1,20 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.StoragesContracts
{
public interface IRoleStorage
{
List<RoleViewModel> GetFullList();
RoleViewModel? GetElement(RoleSearchModel model);
RoleViewModel? Insert(RoleBindingModel model);
RoleViewModel? Update(RoleBindingModel model);
RoleViewModel? Delete(RoleBindingModel model);
}
}

View File

@ -1,26 +0,0 @@
using AccountsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.ViewModels
{
public class AccountViewModel : IAccountModel
{
public int Id { get; set; } = 0;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Рейтинг")]
public float? Rating { get; set; } = null;
[DisplayName("Предупреждения")]
public string? Warnings { get; set; } = string.Empty;
public int RoleId { get; set; } = 0;
[DisplayName("Роль")]
public string RoleName { get; set; } = string.Empty;
public float ViewRating { get; set; } = 0;
public string DocRating { get; set; } = string.Empty;
}
}

View File

@ -1,18 +0,0 @@
using AccountContracts.BusinessLogicsContracts;
using AccountsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountContracts.ViewModels
{
public class RoleViewModel : IRoleModel
{
public int Id { get; set; }
[DisplayName("Название")]
public string RoleName { get; set; } = string.Empty;
}
}

View File

@ -1,19 +0,0 @@
using AccountDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement
{
public class AccountDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql("Host=localhost;Database=AccountsDB;Username=postgres;Password=1234");
public virtual DbSet<Role> Roles { set; get; }
public virtual DbSet<Account> Accounts { set; get; }
}
}

View File

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

View File

@ -1,73 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.StoragesContracts;
using AccountContracts.ViewModels;
using AccountDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement.Implements
{
public class AccountStorage : IAccountStorage
{
public List<AccountViewModel> GetFullList()
{
using var context = new AccountDatabase();
return context.Accounts.Include(x => x.Role)
.Select(x => x.GetViewModel)
.ToList();
}
public AccountViewModel? GetElement(AccountSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new AccountDatabase();
return context.Accounts.Include(x => x.Role)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public AccountViewModel? Insert(AccountBindingModel model)
{
using var context = new AccountDatabase();
var newAccount = Account.Create(model, context);
if (newAccount == null)
{
return null;
}
context.Accounts.Add(newAccount);
context.SaveChanges();
return newAccount.GetViewModel;
}
public AccountViewModel? Update(AccountBindingModel model)
{
using var context = new AccountDatabase();
var account = context.Accounts.FirstOrDefault(x => x.Id == model.Id);
if (account == null)
{
return null;
}
account.Update(model);
context.SaveChanges();
return account.GetViewModel;
}
public AccountViewModel? Delete(AccountBindingModel model)
{
using var context = new AccountDatabase();
var element = context.Accounts.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Accounts.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -1,73 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.SearchModels;
using AccountContracts.StoragesContracts;
using AccountContracts.ViewModels;
using AccountDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement.Implements
{
public class RoleStorage : IRoleStorage
{
public List<RoleViewModel> GetFullList()
{
using var context = new AccountDatabase();
return context.Roles
.Select(x => x.GetViewModel)
.ToList();
}
public RoleViewModel? GetElement(RoleSearchModel model)
{
using var context = new AccountDatabase();
return context.Roles
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public RoleViewModel? Insert(RoleBindingModel model)
{
var newRole = Role.Create(model);
if (newRole == null)
{
return null;
}
using var context = new AccountDatabase();
context.Roles.Add(newRole);
context.SaveChanges();
return newRole.GetViewModel;
}
public RoleViewModel? Update(RoleBindingModel model)
{
using var context = new AccountDatabase();
var role = context.Roles.FirstOrDefault(x => x.Id == model.Id);
if (role == null)
{
return null;
}
role.Update(model);
context.SaveChanges();
return role.GetViewModel;
}
public RoleViewModel? Delete(RoleBindingModel model)
{
using var context = new AccountDatabase();
var element = context.Roles.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Roles.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -1,86 +0,0 @@
// <auto-generated />
using System;
using AccountDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AccountDatabaseImplement.Migrations
{
[DbContext(typeof(AccountDatabase))]
[Migration("20231130200453_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<float?>("Rating")
.HasColumnType("real");
b.Property<int>("RoleId")
.HasColumnType("integer");
b.Property<string>("Warnings")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accounts");
});
modelBuilder.Entity("AccountDatabaseImplement.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
{
b.HasOne("AccountDatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,65 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AccountDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleName = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Login = table.Column<string>(type: "text", nullable: false),
Warnings = table.Column<string>(type: "text", nullable: true),
Rating = table.Column<float>(type: "real", nullable: true),
RoleId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Accounts_RoleId",
table: "Accounts",
column: "RoleId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "Roles");
}
}
}

View File

@ -1,83 +0,0 @@
// <auto-generated />
using System;
using AccountDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AccountDatabaseImplement.Migrations
{
[DbContext(typeof(AccountDatabase))]
partial class AccountDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<float?>("Rating")
.HasColumnType("real");
b.Property<int>("RoleId")
.HasColumnType("integer");
b.Property<string>("Warnings")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accounts");
});
modelBuilder.Entity("AccountDatabaseImplement.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
{
b.HasOne("AccountDatabaseImplement.Models.Role", "Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,64 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.ViewModels;
using AccountsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement.Models
{
public class Account : IAccountModel
{
public int Id { get; private set; }
[Required]
public string Login { get; set; }
public string? Warnings { get; set; } = null;
public float? Rating { get; set; } = null;
[Required]
public int RoleId { get; set; }
public virtual Role Role { get; set; } = new();
public static Account? Create(AccountBindingModel? model, AccountDatabase context)
{
if (model == null)
{
return null;
}
return new Account()
{
Id = model.Id,
Login = model.Login,
Warnings = model.Warnings,
Rating = model.Rating,
RoleId = model.RoleId,
Role = context.Roles.First(x => x.Id == model.RoleId),
};
}
public void Update(AccountBindingModel? model)
{
if (model == null)
{
return;
}
Login = model.Login;
Warnings = model.Warnings;
Rating = model.Rating;
}
public AccountViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
Warnings = Warnings,
Rating = Rating,
RoleId = RoleId,
RoleName = Role.RoleName,
};
}
}

View File

@ -1,55 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.ViewModels;
using AccountsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement.Models
{
public class Role : IRoleModel
{
public int Id { get; private set; }
[Required]
public string RoleName { get; private set; } = string.Empty;
public static Role? Create(RoleBindingModel model)
{
if (model == null)
{
return null;
}
return new Role()
{
Id = model.Id,
RoleName = model.RoleName,
};
}
public static Role Create(RoleViewModel model)
{
return new Role
{
Id = model.Id,
RoleName = model.RoleName,
};
}
public void Update(RoleBindingModel model)
{
if (model == null)
{
return;
}
RoleName = model.RoleName;
}
public RoleViewModel GetViewModel => new()
{
Id = Id,
RoleName = RoleName,
};
}
}

View File

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

View File

@ -1,7 +0,0 @@
namespace AccountsDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountsDataModels.Models
{
public interface IAccountModel : IId
{
string Login { get; }
float? Rating { get; }
string? Warnings { get; }
int RoleId { get; }
}
}

View File

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

View File

@ -1,29 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AbazovViewComponents" Version="5.0.0" />
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AccountBusinessLogic\AccountBusinessLogic.csproj" />
<ProjectReference Include="..\AccountContracts\AccountContracts.csproj" />
<ProjectReference Include="..\AccountDatabaseImplement\AccountDatabaseImplement.csproj" />
<ProjectReference Include="..\NevaevaLibrary\NevaevaLibrary.csproj" />
</ItemGroup>
</Project>

View File

@ -1,153 +0,0 @@
namespace AccountsView
{
partial class FormAccount
{
/// <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.controlInputRating = new ControlsLibraryNet60.Input.ControlInputNullableDouble();
this.comboBoxControlRole = new NevaevaLibrary.ComboBoxControl();
this.textBoxLogin = new System.Windows.Forms.TextBox();
this.textBoxWarnings = new System.Windows.Forms.TextBox();
this.labelLogin = new System.Windows.Forms.Label();
this.labelWarnings = new System.Windows.Forms.Label();
this.labelRating = new System.Windows.Forms.Label();
this.labelAccount = new System.Windows.Forms.Label();
this.buttonAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// controlInputRating
//
this.controlInputRating.Location = new System.Drawing.Point(14, 219);
this.controlInputRating.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8);
this.controlInputRating.Name = "controlInputRating";
this.controlInputRating.Size = new System.Drawing.Size(331, 36);
this.controlInputRating.TabIndex = 0;
this.controlInputRating.Value = null;
//
// comboBoxControlRole
//
this.comboBoxControlRole.Location = new System.Drawing.Point(22, 34);
this.comboBoxControlRole.Name = "comboBoxControlRole";
this.comboBoxControlRole.SelectedValue = "";
this.comboBoxControlRole.Size = new System.Drawing.Size(333, 44);
this.comboBoxControlRole.TabIndex = 1;
//
// textBoxLogin
//
this.textBoxLogin.Location = new System.Drawing.Point(22, 93);
this.textBoxLogin.Name = "textBoxLogin";
this.textBoxLogin.Size = new System.Drawing.Size(323, 27);
this.textBoxLogin.TabIndex = 2;
//
// textBoxWarnings
//
this.textBoxWarnings.Location = new System.Drawing.Point(22, 151);
this.textBoxWarnings.Name = "textBoxWarnings";
this.textBoxWarnings.Size = new System.Drawing.Size(323, 27);
this.textBoxWarnings.TabIndex = 3;
//
// labelLogin
//
this.labelLogin.AutoSize = true;
this.labelLogin.Location = new System.Drawing.Point(22, 70);
this.labelLogin.Name = "labelLogin";
this.labelLogin.Size = new System.Drawing.Size(52, 20);
this.labelLogin.TabIndex = 4;
this.labelLogin.Text = "Логин";
//
// labelWarnings
//
this.labelWarnings.AutoSize = true;
this.labelWarnings.Location = new System.Drawing.Point(22, 128);
this.labelWarnings.Name = "labelWarnings";
this.labelWarnings.Size = new System.Drawing.Size(131, 20);
this.labelWarnings.TabIndex = 5;
this.labelWarnings.Text = "Предупреждения";
//
// labelRating
//
this.labelRating.AutoSize = true;
this.labelRating.Location = new System.Drawing.Point(26, 191);
this.labelRating.Name = "labelRating";
this.labelRating.Size = new System.Drawing.Size(64, 20);
this.labelRating.TabIndex = 6;
this.labelRating.Text = "Рейтинг";
//
// labelAccount
//
this.labelAccount.AutoSize = true;
this.labelAccount.Location = new System.Drawing.Point(25, 8);
this.labelAccount.Name = "labelAccount";
this.labelAccount.Size = new System.Drawing.Size(63, 20);
this.labelAccount.TabIndex = 7;
this.labelAccount.Text = "Аккаунт";
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(36, 262);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
this.buttonAdd.TabIndex = 8;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonSave_Click);
//
// FormAccount
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(404, 307);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.labelAccount);
this.Controls.Add(this.labelRating);
this.Controls.Add(this.labelWarnings);
this.Controls.Add(this.labelLogin);
this.Controls.Add(this.textBoxWarnings);
this.Controls.Add(this.textBoxLogin);
this.Controls.Add(this.comboBoxControlRole);
this.Controls.Add(this.controlInputRating);
this.Name = "FormAccount";
this.Text = "FormAccount";
this.Load += new System.EventHandler(this.FormAccount_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ControlsLibraryNet60.Input.ControlInputNullableDouble controlInputRating;
private NevaevaLibrary.ComboBoxControl comboBoxControlRole;
private TextBox textBoxLogin;
private TextBox textBoxWarnings;
private Label labelLogin;
private Label labelWarnings;
private Label labelRating;
private Label labelAccount;
private Button buttonAdd;
}
}

View File

@ -1,103 +0,0 @@
using AbazovViewComponents.Components;
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.SearchModels;
using AccountContracts.ViewModels;
using NevaevaLibrary;
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 AccountsView
{
public partial class FormAccount : Form
{
private int? _id;
private readonly IAccountLogic _logic;
private readonly IRoleLogic _roleLogic;
private List<RoleViewModel> _roles;
public int Id { set { _id = value; } }
public FormAccount(IAccountLogic logic, IRoleLogic roleLogic)
{
InitializeComponent();
_logic = logic;
_roleLogic = roleLogic;
_roles = new List<RoleViewModel>();
}
private void FormAccount_Load(object sender, EventArgs e)
{
_roles = _roleLogic.ReadList();
comboBoxControlRole.addItems(_roles.Select(x => x.RoleName).ToList());
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new AccountSearchModel { Id = _id.Value });
if (view != null)
{
textBoxLogin.Text = view.Login;
textBoxWarnings.Text = view.Warnings;
controlInputRating.Value = view.Rating;
comboBoxControlRole.SelectedValue = view.RoleName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxLogin.Text))
{
MessageBox.Show("Заполните логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(comboBoxControlRole.SelectedValue))
{
MessageBox.Show("Выберете роль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new AccountBindingModel
{
Id = _id ?? 0,
Login = textBoxLogin.Text,
Warnings = textBoxWarnings.Text,
Rating = controlInputRating.Value.HasValue ? (float)controlInputRating.Value.GetValueOrDefault() : null,
RoleId = _roles.First(x => x.RoleName == comboBoxControlRole.SelectedValue).Id,
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,181 +0,0 @@
namespace AccountsView
{
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.menuStrip1 = new System.Windows.Forms.MenuStrip();
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.документСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ролиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.abazovTreeView = new AbazovViewComponents.Components.AbazovTreeView();
this.wordLongTextComponent = new NevaevaLibrary.LogicalComponents.WordLongTextComponent(this.components);
this.excelDiagramComponent = new AbazovViewComponents.LogicalComponents.ExcelDiagramComponent(this.components);
this.componentDocumentWithTableMultiHeaderPdf = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components);
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.аккаунтыToolStripMenuItem,
this.отчётыToolStripMenuItem,
this.ролиToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 28);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// аккаунтыToolStripMenuItem
//
this.аккаунтыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.создатьToolStripMenuItem,
this.редактироватьToolStripMenuItem,
this.удалитьToolStripMenuItem});
this.аккаунтыToolStripMenuItem.Name = "аккаунтыToolStripMenuItem";
this.аккаунтыToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
this.аккаунтыToolStripMenuItem.Text = "Аккаунты";
//
// создать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(246, 26);
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(246, 26);
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(246, 26);
this.удалитьToolStripMenuItem.Text = "Удалить";
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
//
// отчётыToolStripMenuItem
//
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.документToolStripMenuItem,
this.документСТаблицейToolStripMenuItem,
this.документСДиаграммойToolStripMenuItem});
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчётыToolStripMenuItem.Text = "Отчёты";
//
// документ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(313, 26);
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.T)));
this.документСТаблицейToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
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.C)));
this.документСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
this.документСДиаграммойToolStripMenuItem.Text = "Документ с диаграммой";
this.документСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.документСДиаграммойToolStripMenuItem_Click);
//
// ролиToolStripMenuItem
//
this.ролиToolStripMenuItem.Name = "ролиToolStripMenuItem";
this.ролиToolStripMenuItem.Size = new System.Drawing.Size(57, 24);
this.ролиToolStripMenuItem.Text = "Роли";
this.ролиToolStripMenuItem.Click += new System.EventHandler(this.ролиToolStripMenuItem_Click);
//
// abazovTreeView
//
this.abazovTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.abazovTreeView.Location = new System.Drawing.Point(0, 28);
this.abazovTreeView.Name = "abazovTreeView";
this.abazovTreeView.SelectedNodeIndex = -1;
this.abazovTreeView.Size = new System.Drawing.Size(800, 422);
this.abazovTreeView.TabIndex = 1;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.abazovTreeView);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMain";
this.Text = "Аккаунты";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem аккаунтыToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem ролиToolStripMenuItem;
private AbazovViewComponents.Components.AbazovTreeView abazovTreeView;
private ToolStripMenuItem создатьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem документToolStripMenuItem;
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
private NevaevaLibrary.LogicalComponents.WordLongTextComponent wordLongTextComponent;
private AbazovViewComponents.LogicalComponents.ExcelDiagramComponent excelDiagramComponent;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf;
}
}

View File

@ -1,195 +0,0 @@
using AbazovViewComponents.LogicalComponents;
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.ViewModels;
using AccountDatabaseImplement.Models;
using ComponentsLibraryNet60.Models;
using ControlsLibraryNet60.Core;
using NevaevaLibrary.LogicalComponents;
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 AccountsView
{
public partial class FormMain : Form
{
private IAccountLogic _logic;
public FormMain(IAccountLogic logic)
{
InitializeComponent();
_logic = logic;
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("ViewRating", false), ("Id", true), ("Login", true) });
}
private void ролиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRoles));
if (service is FormRoles form)
{
form.ShowDialog();
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
abazovTreeView.clear();
var accounts = _logic.ReadList(null);
if (accounts != null)
{
foreach (var account in accounts)
{
if (!account.Rating.HasValue)
{
account.ViewRating = 0;
}
else
{
account.ViewRating = account.Rating.Value;
}
}
abazovTreeView.addItems(accounts);
}
}
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
{
var selected = abazovTreeView.getSelecetedNodeValue<AccountViewModel>();
if (selected == null) return;
form.Id = selected.Id;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
var selected = abazovTreeView.getSelecetedNodeValue<AccountViewModel>();
if (selected == null) return;
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (_logic.Delete(new AccountBindingModel { Id = selected.Id }))
{
LoadData();
}
}
}
private void документToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new()
{
Filter = "Word Files|*.docx"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
foreach (var account in _logic.ReadList(null))
{
if (account.Rating == null)
{
paragraphs.Add(account.Login + ": " + account.Warnings);
}
}
string path = saveFileDialog.FileName;
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Аккаунты без рейтинга", paragraphs.ToArray()));
MessageBox.Show("Документ создан");
}
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new()
{
Filter = "Excel Files|*.xlsx"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
string path = saveFileDialog.FileName;
var data = _logic.ReadList(null).Where(x => x.Rating == null).GroupBy(x => x.RoleName).Select(x => new
{
RoleName = x.Key,
RoleCount = x.Count(),
}).ToList();
excelDiagramComponent.createWithDiagram(path, "Роли без рейтинга", "Роли без рейтинга", AbazovViewComponents.LogicalComponents.DiagramLegendEnum.BottomRight,
data, "RoleName", "RoleCount");
MessageBox.Show("Документ создан");
}
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
SaveFileDialog saveFileDialog = new()
{
Filter = "PDF Files|*.pdf"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
string path = saveFileDialog.FileName;
var accounts = _logic.ReadList(null);
foreach (var account in accounts)
{
if (!account.Rating.HasValue)
{
account.DocRating = "нет";
}
else
{
account.DocRating = account.Rating.Value.ToString();
}
}
ComponentDocumentWithTableHeaderDataConfig<AccountViewModel> config = new ComponentsLibraryNet60.Models.ComponentDocumentWithTableHeaderDataConfig<AccountViewModel>
{
Data = accounts,
UseUnion = false,
Header = "Аккаунты",
ColumnsRowsDataCount = (4, 1),
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "Логин", "Login"),
(2, 0, "Роль", "RoleName"),
(3, 0, "Рейтинг", "DocRating")
},
ColumnsRowsWidth = new List<(int Column, int Row)>
{
(10, 10),
(10, 10),
(10, 10),
(10, 10)
},
ColumnUnion = new List<(int StartIndex, int Count)>(),
FilePath = path
};
componentDocumentWithTableMultiHeaderPdf.CreateDoc(config);
MessageBox.Show("Документ создан");
}
}
}

View File

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

View File

@ -1,89 +0,0 @@
namespace AccountsView
{
partial class FormRoles
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.NameCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.NameCol,
this.Id});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(800, 450);
this.dataGridView.TabIndex = 0;
this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged);
this.dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dataGridView_UserDeletingRow);
this.dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyUp);
//
// NameCol
//
this.NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.NameCol.HeaderText = "Название";
this.NameCol.MinimumWidth = 6;
this.NameCol.Name = "NameCol";
//
// Id
//
this.Id.HeaderText = "Id";
this.Id.MinimumWidth = 6;
this.Id.Name = "Id";
this.Id.Visible = false;
this.Id.Width = 125;
//
// FormRoles
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dataGridView);
this.Name = "FormRoles";
this.Text = "FormRoles";
this.Load += new System.EventHandler(this.FormRoles_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn NameCol;
private DataGridViewTextBoxColumn Id;
}
}

View File

@ -1,105 +0,0 @@
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AccountsView
{
public partial class FormRoles : Form
{
private readonly IRoleLogic _logic;
private bool loading = false;
public FormRoles(IRoleLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormRoles_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
loading = true;
try
{
var list = _logic.ReadList();
if (list != null)
{
foreach (var role in list)
{
int rowIndex = dataGridView.Rows.Add();
dataGridView.Rows[rowIndex].Cells[0].Value = role.RoleName;
dataGridView.Rows[rowIndex].Cells[1].Value = role.Id;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
loading = false;
}
}
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
{
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (name is null) return;
_logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), RoleName = name.ToString() });
}
else
{
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (name is null) return;
_logic.Create(new RoleBindingModel { Id = 0, RoleName = name.ToString() });
int newRoleId = _logic.ReadList().ToList().Last().Id;
dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId;
}
}
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Insert:
dataGridView.Rows.Add();
break;
}
}
private void deleteRows(DataGridViewSelectedRowCollection rows)
{
for (int i = 0; i < rows.Count; i++)
{
DataGridViewRow row = rows[i];
if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
dataGridView.Rows.Remove(row);
}
}
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
e.Cancel = true;
if (dataGridView.SelectedRows == null) return;
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
deleteRows(dataGridView.SelectedRows);
}
}
}

View File

@ -1,66 +0,0 @@
<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="NameCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -1,41 +0,0 @@
using AccountBusinessLogic.BusinessLogic;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.StoragesContracts;
using AccountDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
namespace AccountsView
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IRoleStorage, RoleStorage>();
services.AddTransient<IAccountStorage, AccountStorage>();
services.AddTransient<IRoleLogic, RoleLogic>();
services.AddTransient<IAccountLogic, AccountLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormAccount>();
services.AddTransient<FormRoles>();
}
}
}

View File

@ -5,17 +5,7 @@ VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsView", "AccountsView\AccountsView.csproj", "{B7A72992-283B-4364-864E-337DDD9B0E83}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsDataModels", "AccountsDataModels\AccountsDataModels.csproj", "{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountContracts", "AccountContracts\AccountContracts.csproj", "{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountBusinessLogic", "AccountBusinessLogic\AccountBusinessLogic.csproj", "{4EB11E48-32B2-4300-A134-BEC339991D95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountDatabaseImplement", "AccountDatabaseImplement\AccountDatabaseImplement.csproj", "{E25D2269-2C4C-4176-B5E0-9D44B084306D}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -31,26 +21,6 @@ Global
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.Build.0 = Release|Any CPU {38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.Build.0 = Release|Any CPU
{B7A72992-283B-4364-864E-337DDD9B0E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7A72992-283B-4364-864E-337DDD9B0E83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7A72992-283B-4364-864E-337DDD9B0E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7A72992-283B-4364-864E-337DDD9B0E83}.Release|Any CPU.Build.0 = Release|Any CPU
{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Release|Any CPU.Build.0 = Release|Any CPU
{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Release|Any CPU.Build.0 = Release|Any CPU
{4EB11E48-32B2-4300-A134-BEC339991D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EB11E48-32B2-4300-A134-BEC339991D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EB11E48-32B2-4300-A134-BEC339991D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EB11E48-32B2-4300-A134-BEC339991D95}.Release|Any CPU.Build.0 = Release|Any CPU
{E25D2269-2C4C-4176-B5E0-9D44B084306D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E25D2269-2C4C-4176-B5E0-9D44B084306D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E25D2269-2C4C-4176-B5E0-9D44B084306D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E25D2269-2C4C-4176-B5E0-9D44B084306D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NevaevaLibrary.LogicalComponents
{
public enum DiagramLegendEnum
{
TopLeft = 0,
TopRight = 1,
BottomRight = 2,
BottomLeft = 3,
}
}

View File

@ -1,36 +0,0 @@
namespace NevaevaLibrary.LogicalComponents
{
partial class WordDiagramComponent
{
/// <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

@ -1,142 +0,0 @@
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace NevaevaLibrary.LogicalComponents
{
public partial class WordDiagramComponent : Component
{
public WordDiagramComponent()
{
InitializeComponent();
}
public WordDiagramComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
private object missing = System.Reflection.Missing.Value;
private string GetExcelColumnName(int columnNumber)
{
string columnName = "";
while (columnNumber > 0)
{
int modulo = (columnNumber - 1) % 26;
columnName = Convert.ToChar('A' + modulo) + columnName;
columnNumber = (columnNumber - modulo) / 26;
}
return columnName;
}
public void createWithDiagram<T>(string path, string title, string diagramTitle, DiagramLegendEnum diagramLegendAnchor, List<T> data, string seriesNameField, string valueField)
{
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
FieldInfo? seriesName = typeof(T).GetField(seriesNameField);
FieldInfo? value = typeof(T).GetField(valueField);
if (seriesName == null || value == null) throw new ArgumentException("Переданного поля не существует");
int offsetX = 1;
int offsetYMax = -1;
foreach (var item in data)
{
string columnChar = GetExcelColumnName(offsetX);
var cell = worksheet.get_Range(columnChar + "2", columnChar + "2");
cell.Font.Size = 14;
cell.Font.Name = "Times New Roman";
cell.ColumnWidth = 8;
cell.RowHeight = 25;
cell.HorizontalAlignment = Constants.xlCenter;
cell.VerticalAlignment = Constants.xlCenter;
cell.Value2 = seriesName.GetValue(item);
int offsetY = 3;
foreach (var val in (value.GetValue(item) as IEnumerable))
{
cell = worksheet.get_Range(columnChar + offsetY, columnChar + offsetY);
cell.Value2 = val;
offsetY++;
}
if (offsetY > offsetYMax) offsetYMax = offsetY;
offsetX++;
}
var charts = worksheet.ChartObjects() as ChartObjects;
int chartWidth = 300;
int chartHeight = 300;
var chartObject = charts.Add(250, 10, chartWidth, chartHeight);
var chart = chartObject.Chart;
var endColumn = GetExcelColumnName(offsetX - 1);
var range = worksheet.get_Range($"A2", endColumn + (offsetYMax - 1));
chart.SetSourceData(range);
chart.ChartType = XlChartType.xlLine;
switch (diagramLegendAnchor)
{
case DiagramLegendEnum.TopLeft:
chart.Legend.Top = 0;
chart.Legend.Left = 0;
break;
case DiagramLegendEnum.TopRight:
chart.Legend.Top = 0;
chart.Legend.Left = chartWidth - chart.Legend.Width;
break;
case DiagramLegendEnum.BottomLeft:
chart.Legend.Top = chartHeight - chart.Legend.Height;
chart.Legend.Left = 0;
break;
case DiagramLegendEnum.BottomRight:
chart.Legend.Top = chartHeight - chart.Legend.Height;
chart.Legend.Left = chartWidth - chart.Legend.Width;
break;
}
chart.ChartWizard(Source: range, Title: diagramTitle);
chart.Export(path.Substring(0, path.Length - 5) + ".jpg", "JPG", false);
workbook.Close(SaveChanges: false);
excelApp.Quit();
var winword = new Microsoft.Office.Interop.Word.Application();
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
document.PageSetup.RightMargin = 50;
document.PageSetup.LeftMargin = 50;
var header = document.Content.Paragraphs.Add(Type.Missing);
header.Range.Text = title;
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
header.Range.Font.Name = "Times New Roman";
header.Range.Font.Size = 22;
header.Range.Font.Bold = 2;
header.Format.SpaceAfter = 18;
header.Range.InsertParagraphAfter();
document.Shapes.AddPicture(path.Substring(0, path.Length - 5) + ".jpg", Top: 200);
document.SaveAs(path, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
document.Close(ref missing, ref missing, ref missing);
document = null;
winword.Quit(ref missing, ref missing, ref missing);
}
}
}

View File

@ -1,36 +0,0 @@
namespace NevaevaLibrary.LogicalComponents
{
partial class WordLongTextComponent
{
/// <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

@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Word;
using static System.Net.Mime.MediaTypeNames;
namespace NevaevaLibrary.LogicalComponents
{
public partial class WordLongTextComponent : Component
{
public WordLongTextComponent()
{
InitializeComponent();
}
public WordLongTextComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
private object missing = System.Reflection.Missing.Value;
public void createWithLongText(WordLongTextInfo wordInfo)
{
var winword = new Microsoft.Office.Interop.Word.Application();
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
document.PageSetup.RightMargin = 50;
document.PageSetup.LeftMargin = 50;
var header = document.Content.Paragraphs.Add(Type.Missing);
header.Range.Text = wordInfo.header;
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
header.Range.Font.Name = "Times New Roman";
header.Range.Font.Size = 22;
header.Range.Font.Bold = 2;
header.Format.SpaceAfter = 18;
header.Range.InsertParagraphAfter();
foreach (string text in wordInfo.paragraphs)
{
var paragraph = document.Content.Paragraphs.Add(Type.Missing);
paragraph.Range.Text = text;
paragraph.Format.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
paragraph.Range.Font.Name = "Times New Roman";
paragraph.Range.Font.Size = 14;
paragraph.Range.Font.Bold = 0;
paragraph.Format.SpaceAfter = 18;
paragraph.Range.InsertParagraphAfter();
}
document.SaveAs(wordInfo.path, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
document.Close(ref missing, ref missing, ref missing);
document = null;
winword.Quit(ref missing, ref missing, ref missing);
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NevaevaLibrary.LogicalComponents
{
public class WordLongTextInfo
{
public string path;
public string header;
public string[] paragraphs;
public WordLongTextInfo(string path, string header, string[] paragraphs)
{
this.path = path;
this.header = header;
this.paragraphs = paragraphs;
}
}
}

View File

@ -1,36 +0,0 @@
namespace NevaevaLibrary.LogicalComponents
{
partial class WordTableComponent
{
/// <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

@ -1,171 +0,0 @@
using Microsoft.Office.Interop.Word;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace NevaevaLibrary.LogicalComponents
{
public partial class WordTableComponent : Component
{
public WordTableComponent()
{
InitializeComponent();
}
public WordTableComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
private object missing = System.Reflection.Missing.Value;
public void createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> widths, List<(string, string)> headers, List<T> items)
{
if (merges.Count == 0 || widths.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
int[] cellsArray = new int[widths.Count];
foreach (var merge in merges)
{
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
for (int i = merge.Item1; i < merge.Item2 + 1; i++)
{
cellsArray[i]++;
}
}
foreach (int cell in cellsArray)
{
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
}
var winword = new Microsoft.Office.Interop.Word.Application();
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
document.PageSetup.RightMargin = 50;
document.PageSetup.LeftMargin = 50;
document.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
var header = document.Content.Paragraphs.Add(Type.Missing);
header.Range.Text = title;
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
header.Range.Font.Name = "Times New Roman";
header.Range.Font.Size = 22;
header.Range.Font.Bold = 2;
header.Format.SpaceAfter = 18;
header.Range.InsertParagraphAfter();
var table = document.Tables.Add(document.Bookmarks.get_Item("\\endofdoc").Range,
items.Count + 2, widths.Count, Type.Missing, Type.Missing);
table.Borders.Enable = 1;
for (int i = 0; i < widths.Count; i++)
{
table.Cell(1, i + 1).Width = widths[i];
table.Cell(1, i + 1).Height = 20;
table.Cell(2, i + 1).Width = widths[i];
table.Cell(2, i + 1).Height = 20;
}
//checks
List<Cell> ranges = new List<Cell>();
foreach (var merge in merges)
{
ranges.Add(table.Rows[1].Cells[merge.Item1 + 1]);
}
//number of merged cell
int rangeIndex = 0;
//number of cell
int headerIndex = 0;
List<PropertyInfo> cellProperties = new List<PropertyInfo>();
var type = typeof(T);
for (int i = 0; i < widths.Count; i++)
{
if (cellsArray[i] == 1)
{
//work with merge
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
var headerCell = ranges[rangeIndex];
headerCell.Range.Text = headers[headerIndex].Item2;
headerCell.Range.Font.Size = 11;
headerIndex++;
//work with cells in merge
for (; i <= merges[rangeIndex].Item2; i++)
{
//work with cell
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
var property = type.GetProperty(headers[headerIndex].Item1);
if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
//format header
var cell = table.Cell(2, i + 1);
cell.Range.Text = headers[headerIndex].Item2;
cell.Width = widths[i];
cell.Range.Font.Size = 11;
cellProperties.Add(property);
headerIndex++;
}
i--;
rangeIndex++;
}
else
{
//work with cell
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
var property = type.GetProperty(headers[headerIndex].Item1);
if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
//format header
var cell = table.Cell(1, i + 1);
cell.Merge(table.Cell(2, i + 1));
cell.Range.Text = headers[headerIndex].Item2;
cell.Width = widths[i];
cell.Range.Font.Size = 11;
cellProperties.Add(property);
headerIndex++;
}
}
int xOffset = 0;
foreach (var merge in merges)
{
table.Cell(1, merge.Item1 + 1 - xOffset).Merge(table.Cell(1, merge.Item2 + 1 - xOffset));
xOffset += merge.Item2 - merge.Item1;
}
int rowNum = 3;
foreach (T item in items)
{
int columnNum = 1;
foreach (var cellProperty in cellProperties)
{
var cell = table.Cell(rowNum, columnNum);
cell.Range.Text = cellProperty.GetValue(item)?.ToString();
cell.Width = widths[columnNum - 1];
cell.Range.Bold = 0;
cell.Range.Font.Size = 11;
cell.Height = 20;
columnNum++;
}
rowNum++;
}
document.SaveAs(path, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
document.Close(ref missing, ref missing, ref missing);
document = null;
winword.Quit(ref missing, ref missing, ref missing);
}
}
}

View File

@ -5,38 +5,6 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>$(VersionPrefix)</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Interop.Access.Dao">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>12</VersionMajor>
<Guid>4ac9e1da-5bad-4ac7-86e3-24f4cdceca28</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="Microsoft.Office.Interop.Word">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>7</VersionMinor>
<VersionMajor>8</VersionMajor>
<Guid>00020905-0000-0000-c000-000000000046</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="Microsoft.Office.Interop.Excel">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>9</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>00020813-0000-0000-c000-000000000046</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
</Project> </Project>

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestApp
{
public class Department
{
public string name;
public List<int> sells;
public Department(string name, List<int> sells)
{
this.name = name;
this.sells = sells;
}
}
}

View File

@ -28,7 +28,6 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.comboBoxControl = new NevaevaLibrary.ComboBoxControl(); this.comboBoxControl = new NevaevaLibrary.ComboBoxControl();
this.buttonInsert = new System.Windows.Forms.Button(); this.buttonInsert = new System.Windows.Forms.Button();
this.buttonClear = new System.Windows.Forms.Button(); this.buttonClear = new System.Windows.Forms.Button();
@ -39,13 +38,6 @@
this.listBoxControl = new NevaevaLibrary.ListBoxControl(); this.listBoxControl = new NevaevaLibrary.ListBoxControl();
this.buttonInsertList = new System.Windows.Forms.Button(); this.buttonInsertList = new System.Windows.Forms.Button();
this.buttonGetSelectedList = new System.Windows.Forms.Button(); this.buttonGetSelectedList = new System.Windows.Forms.Button();
this.buttonWordText = new System.Windows.Forms.Button();
this.wordLongTextComponent = new NevaevaLibrary.LogicalComponents.WordLongTextComponent(this.components);
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.buttonTable = new System.Windows.Forms.Button();
this.wordTableComponent = new NevaevaLibrary.LogicalComponents.WordTableComponent(this.components);
this.wordDiagramComponent = new NevaevaLibrary.LogicalComponents.WordDiagramComponent(this.components);
this.buttonDiagram = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// comboBoxControl // comboBoxControl
@ -99,7 +91,7 @@
// //
// mailControl // mailControl
// //
this.mailControl.Email = null; this.mailControl.Email = "";
this.mailControl.Location = new System.Drawing.Point(11, 95); this.mailControl.Location = new System.Drawing.Point(11, 95);
this.mailControl.Name = "mailControl"; this.mailControl.Name = "mailControl";
this.mailControl.Size = new System.Drawing.Size(312, 94); this.mailControl.Size = new System.Drawing.Size(312, 94);
@ -144,48 +136,11 @@
this.buttonGetSelectedList.UseVisualStyleBackColor = true; this.buttonGetSelectedList.UseVisualStyleBackColor = true;
this.buttonGetSelectedList.Click += new System.EventHandler(this.buttonGetSelectedList_Click); this.buttonGetSelectedList.Click += new System.EventHandler(this.buttonGetSelectedList_Click);
// //
// buttonWordText
//
this.buttonWordText.Location = new System.Drawing.Point(10, 319);
this.buttonWordText.Name = "buttonWordText";
this.buttonWordText.Size = new System.Drawing.Size(145, 29);
this.buttonWordText.TabIndex = 10;
this.buttonWordText.Text = "Word (текст)";
this.buttonWordText.UseVisualStyleBackColor = true;
this.buttonWordText.Click += new System.EventHandler(this.buttonWordText_Click);
//
// openFileDialog
//
this.openFileDialog.FileName = "openFileDialog1";
//
// buttonTable
//
this.buttonTable.Location = new System.Drawing.Point(178, 319);
this.buttonTable.Name = "buttonTable";
this.buttonTable.Size = new System.Drawing.Size(145, 29);
this.buttonTable.TabIndex = 11;
this.buttonTable.Text = "Word (таблица)";
this.buttonTable.UseVisualStyleBackColor = true;
this.buttonTable.Click += new System.EventHandler(this.buttonTable_Click);
//
// buttonDiagram
//
this.buttonDiagram.Location = new System.Drawing.Point(345, 319);
this.buttonDiagram.Name = "buttonDiagram";
this.buttonDiagram.Size = new System.Drawing.Size(145, 29);
this.buttonDiagram.TabIndex = 12;
this.buttonDiagram.Text = "Word (диаграмма)";
this.buttonDiagram.UseVisualStyleBackColor = true;
this.buttonDiagram.Click += new System.EventHandler(this.buttonDiagram_Click);
//
// FormTest // FormTest
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1109, 363); this.ClientSize = new System.Drawing.Size(1109, 316);
this.Controls.Add(this.buttonDiagram);
this.Controls.Add(this.buttonTable);
this.Controls.Add(this.buttonWordText);
this.Controls.Add(this.buttonGetSelectedList); this.Controls.Add(this.buttonGetSelectedList);
this.Controls.Add(this.buttonInsertList); this.Controls.Add(this.buttonInsertList);
this.Controls.Add(this.listBoxControl); this.Controls.Add(this.listBoxControl);
@ -214,12 +169,5 @@
private NevaevaLibrary.ListBoxControl listBoxControl; private NevaevaLibrary.ListBoxControl listBoxControl;
private Button buttonInsertList; private Button buttonInsertList;
private Button buttonGetSelectedList; private Button buttonGetSelectedList;
private Button buttonWordText;
private NevaevaLibrary.LogicalComponents.WordLongTextComponent wordLongTextComponent;
private OpenFileDialog openFileDialog;
private Button buttonTable;
private NevaevaLibrary.LogicalComponents.WordTableComponent wordTableComponent;
private NevaevaLibrary.LogicalComponents.WordDiagramComponent wordDiagramComponent;
private Button buttonDiagram;
} }
} }

View File

@ -1,5 +1,4 @@
using NevaevaLibrary.LogicalComponents; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -67,50 +66,5 @@ namespace TestApp
Worker? worker = listBoxControl.getSelectedItem<Worker>(); Worker? worker = listBoxControl.getSelectedItem<Worker>();
if (worker is not null) MessageBox.Show(worker.ToString() + $"\n{worker.name}, {worker.department}, {worker.workYears}"); if (worker is not null) MessageBox.Show(worker.ToString() + $"\n{worker.name}, {worker.department}, {worker.workYears}");
} }
private void buttonWordText_Click(object sender, EventArgs e)
{
string[] paragraphs = { "test1", "Составлен в соответствии с учебным планом направления 09.03.04. Цель данного практикума ориентировать студентов на содержание и порядок выполнения лабораторных задач во время прохождения ими курсов «Методы искусственного интеллекта» и «Машинное обучение». Даются задания на лабораторные работы. ",
"Работа подготовлена на кафедре «Информационные системы»." };
openFileDialog.Dispose();
string path = AppDomain.CurrentDomain.BaseDirectory + "test.docx";
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Header", paragraphs));
MessageBox.Show("Готово!");
}
private void buttonTable_Click(object sender, EventArgs e)
{
List<OfficeWorker> workers = new List<OfficeWorker>();
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
workers.Add(new OfficeWorker(2, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
workers.Add(new OfficeWorker(3, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
string path = AppDomain.CurrentDomain.BaseDirectory + "test2.docx";
List<(int, int)> merges = new List<(int, int)>();
merges.Add((1, 3));
merges.Add((4, 6));
List<int> widths = Enumerable.Repeat(70, 8).ToList();
List<(string, string)> headers = new List<(string, string)> { ("id", "id"), ("", "Личные данные"),
("lastName", "Фамилия"), ("firstName", "Имя"),
("age", "Возраст"), ("", "Работа"),
("department", "Отдел"), ("position", "Должность"),
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон")};
wordTableComponent.createWithTable(path, "header", merges, widths, headers, workers);
MessageBox.Show("Готово!");
}
private void buttonDiagram_Click(object sender, EventArgs e)
{
List<Department> departments = new List<Department>();
departments.Add(new Department("Dep 1", new List<int> { 330, 220, 400, 500 }));
departments.Add(new Department("Dep 2", new List<int> { 400, 300, 302 }));
departments.Add(new Department("Dep 3", new List<int> { 200, 220, 270 }));
string path = AppDomain.CurrentDomain.BaseDirectory + "test3.docx";
wordDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells");
MessageBox.Show("Готово!");
}
} }
} }

View File

@ -57,16 +57,4 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="wordLongTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
<metadata name="wordTableComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>407, 17</value>
</metadata>
<metadata name="wordDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>612, 17</value>
</metadata>
</root> </root>

View File

@ -1,34 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestApp
{
public class OfficeWorker
{
public OfficeWorker(int id, string lastName, string firstName, int age, string department, string position, int boxNumber, string phoneNumber, bool isInVacation = false)
{
this.id = id;
this.lastName = lastName;
this.firstName = firstName;
this.age = age;
this.department = department;
this.position = position;
this.boxNumber = boxNumber;
this.phoneNumber = phoneNumber;
this.isInVacation = isInVacation;
}
public int id;
public string lastName;
public string firstName;
public int age;
public string department;
public string position;
public int boxNumber;
public string phoneNumber;
public bool isInVacation;
}
}