Compare commits
3 Commits
3450efdfe8
...
617c65c4e7
Author | SHA1 | Date | |
---|---|---|---|
|
617c65c4e7 | ||
|
df730da8eb | ||
|
09de4581a8 |
@ -0,0 +1,14 @@
|
||||
<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>
|
@ -0,0 +1,94 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
NevaevaLibrary/AccountContracts/AccountContracts.csproj
Normal file
13
NevaevaLibrary/AccountContracts/AccountContracts.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AccountsDataModels\AccountsDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,18 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
18
NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs
Normal file
18
NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
}
|
19
NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs
Normal file
19
NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs
Normal file
@ -0,0 +1,19 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="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>
|
@ -0,0 +1,73 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
86
NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs
generated
Normal file
86
NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
// <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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
// <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
|
||||
}
|
||||
}
|
||||
}
|
64
NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs
Normal file
64
NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs
Normal file
@ -0,0 +1,64 @@
|
||||
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,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
55
NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
Normal file
55
NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
Normal file
@ -0,0 +1,55 @@
|
||||
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,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
7
NevaevaLibrary/AccountsDataModels/IId.cs
Normal file
7
NevaevaLibrary/AccountsDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace AccountsDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
16
NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs
Normal file
16
NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
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; }
|
||||
}
|
||||
}
|
13
NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs
Normal file
13
NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
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;}
|
||||
}
|
||||
}
|
29
NevaevaLibrary/AccountsView/AccountsView.csproj
Normal file
29
NevaevaLibrary/AccountsView/AccountsView.csproj
Normal file
@ -0,0 +1,29 @@
|
||||
<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>
|
153
NevaevaLibrary/AccountsView/FormAccount.Designer.cs
generated
Normal file
153
NevaevaLibrary/AccountsView/FormAccount.Designer.cs
generated
Normal file
@ -0,0 +1,153 @@
|
||||
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;
|
||||
}
|
||||
}
|
103
NevaevaLibrary/AccountsView/FormAccount.cs
Normal file
103
NevaevaLibrary/AccountsView/FormAccount.cs
Normal file
@ -0,0 +1,103 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
NevaevaLibrary/AccountsView/FormAccount.resx
Normal file
60
NevaevaLibrary/AccountsView/FormAccount.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
181
NevaevaLibrary/AccountsView/FormMain.Designer.cs
generated
Normal file
181
NevaevaLibrary/AccountsView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,181 @@
|
||||
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;
|
||||
}
|
||||
}
|
195
NevaevaLibrary/AccountsView/FormMain.cs
Normal file
195
NevaevaLibrary/AccountsView/FormMain.cs
Normal file
@ -0,0 +1,195 @@
|
||||
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("Документ создан");
|
||||
}
|
||||
}
|
||||
}
|
72
NevaevaLibrary/AccountsView/FormMain.resx
Normal file
72
NevaevaLibrary/AccountsView/FormMain.resx
Normal 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="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>
|
89
NevaevaLibrary/AccountsView/FormRoles.Designer.cs
generated
Normal file
89
NevaevaLibrary/AccountsView/FormRoles.Designer.cs
generated
Normal file
@ -0,0 +1,89 @@
|
||||
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;
|
||||
}
|
||||
}
|
105
NevaevaLibrary/AccountsView/FormRoles.cs
Normal file
105
NevaevaLibrary/AccountsView/FormRoles.cs
Normal file
@ -0,0 +1,105 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
66
NevaevaLibrary/AccountsView/FormRoles.resx
Normal file
66
NevaevaLibrary/AccountsView/FormRoles.resx
Normal file
@ -0,0 +1,66 @@
|
||||
<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>
|
41
NevaevaLibrary/AccountsView/Program.cs
Normal file
41
NevaevaLibrary/AccountsView/Program.cs
Normal file
@ -0,0 +1,41 @@
|
||||
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>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,17 @@ VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -21,6 +31,26 @@ Global
|
||||
{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.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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -82,7 +82,7 @@ namespace NevaevaLibrary.LogicalComponents
|
||||
int rangeIndex = 0;
|
||||
//number of cell
|
||||
int headerIndex = 0;
|
||||
List<FieldInfo> cellFields = new List<FieldInfo>();
|
||||
List<PropertyInfo> cellProperties = new List<PropertyInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < widths.Count; i++)
|
||||
{
|
||||
@ -101,15 +101,15 @@ namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) 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;
|
||||
|
||||
cellFields.Add(field);
|
||||
cellProperties.Add(property);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
@ -119,8 +119,8 @@ namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) 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);
|
||||
|
||||
@ -129,7 +129,7 @@ namespace NevaevaLibrary.LogicalComponents
|
||||
cell.Width = widths[i];
|
||||
cell.Range.Font.Size = 11;
|
||||
|
||||
cellFields.Add(field);
|
||||
cellProperties.Add(property);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
@ -145,10 +145,10 @@ namespace NevaevaLibrary.LogicalComponents
|
||||
foreach (T item in items)
|
||||
{
|
||||
int columnNum = 1;
|
||||
foreach (var cellField in cellFields)
|
||||
foreach (var cellProperty in cellProperties)
|
||||
{
|
||||
var cell = table.Cell(rowNum, columnNum);
|
||||
cell.Range.Text = cellField.GetValue(item)?.ToString();
|
||||
cell.Range.Text = cellProperty.GetValue(item)?.ToString();
|
||||
cell.Width = widths[columnNum - 1];
|
||||
cell.Range.Bold = 0;
|
||||
cell.Range.Font.Size = 11;
|
||||
|
@ -6,6 +6,7 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>$(VersionPrefix)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user