From 985c119bb9674132f1e7bd90530d5dc617426bb6 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sat, 3 Apr 2021 19:03:56 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B8=D1=81=D1=86=D0=B8=D0=BF=D0=B8?= =?UTF-8?q?=D0=BB=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/DatabaseCore/DatabaseContext.cs | 6 + .../20210403143118_AddDisciplines.Designer.cs | 535 ++++++++++++++++++ .../20210403143118_AddDisciplines.cs | 154 +++++ .../DatabaseContextModelSnapshot.cs | 94 ++- .../Models/Department/Classroom.cs | 2 +- .../Models/Department/Discipline.cs | 44 ++ .../Models/Department/DisciplineBlock.cs | 45 ++ .../Models/Department/Employee.cs | 10 +- .../Models/Department/EmployeeEmployeePost.cs | 4 +- .../Models/Department/EmployeePost.cs | 4 +- .../MainControls/GenericControlEntityList.cs | 9 +- .../ModuleTools/Enums/AccessOperation.cs | 6 +- .../BindingModels/DisciplineBindingModels.cs | 56 ++ .../DisciplineBlockBindingModels.cs | 39 ++ .../DisciplineBlockBusinessLogic.cs | 16 + .../BusinessLogics/DisciplineBusinessLogic.cs | 16 + .../Interfaces/IDisciplineBlockService.cs | 10 + .../Interfaces/IDisciplineService.cs | 10 + .../ViewModels/DisciplineBlockViewModels.cs | 40 ++ .../ViewModels/DisciplineViewModels.cs | 46 ++ .../EmployeeEmployeePostViewModels.cs | 6 +- .../DepartmentImplementationExtensions.cs | 4 +- .../Implementations/DisciplineBlockService.cs | 140 +++++ .../Implementations/DisciplineService.cs | 137 +++++ .../DepartmentWindowDesktopExtension.cs | 4 +- .../ControlClassroomElement.Designer.cs | 0 .../ControlClassroomElement.cs | 0 .../ControlClassroomElement.resx | 0 .../ControlClassroomList.Designer.cs | 0 .../{ => Classroom}/ControlClassroomList.cs | 3 + .../{ => Classroom}/ControlClassroomList.resx | 0 .../ControlDisciplineBlockElement.Designer.cs | 33 ++ .../ControlDisciplineBlockElement.cs | 27 + .../ControlDisciplineBlockElement.resx | 120 ++++ .../ControlDisciplineBlockList.Designer.cs | 33 ++ .../Discipline/ControlDisciplineBlockList.cs | 50 ++ .../ControlDisciplineBlockList.resx | 120 ++++ .../ControlDisciplineElement.Designer.cs | 33 ++ .../Discipline/ControlDisciplineElement.cs | 27 + .../Discipline/ControlDisciplineElement.resx | 120 ++++ .../ControlDisciplineList.Designer.cs | 33 ++ .../Discipline/ControlDisciplineList.cs | 92 +++ .../Discipline/ControlDisciplineList.resx | 120 ++++ .../Employee/ControlEmployeeList.cs | 3 + 44 files changed, 2228 insertions(+), 23 deletions(-) create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.Designer.cs create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.cs create mode 100644 DepartmentPortal/Common/DatabaseCore/Models/Department/Discipline.cs create mode 100644 DepartmentPortal/Common/DatabaseCore/Models/Department/DisciplineBlock.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBindingModels.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBlockBusinessLogic.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBusinessLogic.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineBlockService.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineService.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineBlockViewModels.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineViewModels.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomElement.Designer.cs (100%) rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomElement.cs (100%) rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomElement.resx (100%) rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomList.Designer.cs (100%) rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomList.cs (94%) rename DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/{ => Classroom}/ControlClassroomList.resx (100%) create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.Designer.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.resx create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.Designer.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.resx create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.Designer.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.resx create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.Designer.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.cs create mode 100644 DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.resx diff --git a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs index a32baca..0c0798d 100644 --- a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs +++ b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs @@ -37,6 +37,10 @@ namespace DatabaseCore modelBuilder.Entity().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique(); modelBuilder.Entity().HasIndex(p => new { p.Number }).IsUnique(); + + modelBuilder.Entity().HasIndex(p => new { p.Title }).IsUnique(); + + modelBuilder.Entity().HasIndex(p => new { p.DisciplineName }).IsUnique(); } #region Security @@ -52,6 +56,8 @@ namespace DatabaseCore public virtual DbSet Employees { set; get; } public virtual DbSet EmployeeEmployeePosts { set; get; } public virtual DbSet Classrooms { set; get; } + public virtual DbSet DisciplineBlocks { set; get; } + public virtual DbSet Disciplines { set; get; } #endregion } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.Designer.cs new file mode 100644 index 0000000..2148356 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.Designer.cs @@ -0,0 +1,535 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210403143118_AddDisciplines")] + partial class AddDisciplines + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("SecurityCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Square") + .HasColumnType("decimal(18,2)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("Number") + .IsUnique() + .HasFilter("[Number] IS NOT NULL"); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("EmployeePostId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("EmployeePostId"); + + b.ToTable("EmployeeEmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeePostName") + .HasColumnType("nvarchar(450)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployeePostName") + .IsUnique() + .HasFilter("[EmployeePostName] IS NOT NULL"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeeEmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost") + .WithMany("EmployeeEmployeePosts") + .HasForeignKey("EmployeePostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("EmployeePost"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeeEmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Navigation("EmployeeEmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.cs new file mode 100644 index 0000000..5c13b6f --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210403143118_AddDisciplines.cs @@ -0,0 +1,154 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class AddDisciplines : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Roles_RoleName", + table: "Roles"); + + migrationBuilder.AlterColumn( + name: "UserName", + table: "Users", + type: "nvarchar(450)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PasswordHash", + table: "Users", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RoleName", + table: "Roles", + type: "nvarchar(450)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.CreateTable( + name: "DisciplineBlocks", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Title = table.Column(type: "nvarchar(450)", nullable: false), + DisciplineBlockUseForGrouping = table.Column(type: "bit", nullable: false), + DisciplineBlockOrder = table.Column(type: "int", nullable: false), + DisciplineBlockBlueAsteriskName = table.Column(type: "nvarchar(max)", nullable: true), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DisciplineBlocks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Disciplines", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DisciplineBlockId = table.Column(type: "uniqueidentifier", nullable: false), + DisciplineName = table.Column(type: "nvarchar(450)", nullable: false), + DisciplineShortName = table.Column(type: "nvarchar(max)", nullable: true), + DisciplineBlueAsteriskName = table.Column(type: "nvarchar(max)", nullable: true), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Disciplines", x => x.Id); + table.ForeignKey( + name: "FK_Disciplines_DisciplineBlocks_DisciplineBlockId", + column: x => x.DisciplineBlockId, + principalTable: "DisciplineBlocks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Roles_RoleName", + table: "Roles", + column: "RoleName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_DisciplineBlocks_Title", + table: "DisciplineBlocks", + column: "Title", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Disciplines_DisciplineBlockId", + table: "Disciplines", + column: "DisciplineBlockId"); + + migrationBuilder.CreateIndex( + name: "IX_Disciplines_DisciplineName", + table: "Disciplines", + column: "DisciplineName", + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Disciplines"); + + migrationBuilder.DropTable( + name: "DisciplineBlocks"); + + migrationBuilder.DropIndex( + name: "IX_Roles_RoleName", + table: "Roles"); + + migrationBuilder.AlterColumn( + name: "UserName", + table: "Users", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)"); + + migrationBuilder.AlterColumn( + name: "PasswordHash", + table: "Users", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "RoleName", + table: "Roles", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)"); + + migrationBuilder.CreateIndex( + name: "IX_Roles_RoleName", + table: "Roles", + column: "RoleName", + unique: true, + filter: "[RoleName] IS NOT NULL"); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs index 73b7ed4..2a568c8 100644 --- a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs @@ -74,6 +74,78 @@ namespace DatabaseCore.Migrations b.ToTable("Classrooms"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => { b.Property("Id") @@ -269,6 +341,7 @@ namespace DatabaseCore.Migrations .HasColumnType("bit"); b.Property("RoleName") + .IsRequired() .HasColumnType("nvarchar(450)"); b.Property("RolePriority") @@ -277,8 +350,7 @@ namespace DatabaseCore.Migrations b.HasKey("Id"); b.HasIndex("RoleName") - .IsUnique() - .HasFilter("[RoleName] IS NOT NULL"); + .IsUnique(); b.ToTable("Roles"); }); @@ -313,9 +385,11 @@ namespace DatabaseCore.Migrations .HasColumnType("bit"); b.Property("PasswordHash") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("UserName") + .IsRequired() .HasColumnType("nvarchar(450)"); b.HasKey("Id"); @@ -365,6 +439,17 @@ namespace DatabaseCore.Migrations b.Navigation("Employee"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b => { b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") @@ -414,6 +499,11 @@ namespace DatabaseCore.Migrations b.Navigation("User"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => { b.Navigation("Classrooms"); diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Classroom.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Classroom.cs index d298dd7..056ca9d 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/Classroom.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Classroom.cs @@ -6,7 +6,7 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { /// - /// Класс, описывающий аудиторию в системе + /// Класс, описывающий аудиторию кафедры /// [DataContract] [EntityDescription("Classroom", "Аудитрия кафедры")] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Discipline.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Discipline.cs new file mode 100644 index 0000000..566ccef --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Discipline.cs @@ -0,0 +1,44 @@ +using ModuleTools.Attributes; +using ModuleTools.Interfaces; +using System; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; + +namespace DatabaseCore.Models.Department +{ + /// + /// Класс, описывающий дисципилну кафедры + /// + [DataContract] + [EntityDescription("Discipline", "Дисципилна кафедры")] + [EntityDependency("DisciplineBlock", "EmployeeId", "Сотрудник, отвечающий за аудиторию")] + public class Discipline : BaseEntity, IEntitySecurityExtenstion + { + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineBlockId")] + public Guid DisciplineBlockId { get; set; } + + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineName")] + public string DisciplineName { get; set; } + + [DataMember] + [MapConfiguration("DisciplineShortName")] + public string DisciplineShortName { get; set; } + + [MapConfiguration("DisciplineBlueAsteriskName")] + public string DisciplineBlueAsteriskName { get; set; } + + //------------------------------------------------------------------------- + + public virtual DisciplineBlock DisciplineBlock { get; set; } + + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + + public Discipline SecurityCheck(Discipline entity, bool allowFullData) => entity; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/DisciplineBlock.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/DisciplineBlock.cs new file mode 100644 index 0000000..3dbae0a --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/DisciplineBlock.cs @@ -0,0 +1,45 @@ +using ModuleTools.Attributes; +using ModuleTools.Interfaces; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace DatabaseCore.Models.Department +{ + /// + /// Класс, описывающий блок дисциплин + /// + [DataContract] + [EntityDescription("DisciplineBlock", "Аудитрия кафедры")] + public class DisciplineBlock : BaseEntity, IEntitySecurityExtenstion + { + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("Title")] + public string Title { get; set; } + + [DataMember] + [MapConfiguration("DisciplineBlockUseForGrouping")] + public bool DisciplineBlockUseForGrouping { get; set; } + + [DataMember] + [MapConfiguration("DisciplineBlockOrder")] + public int DisciplineBlockOrder { get; set; } + + [DataMember] + [MapConfiguration("DisciplineBlockBlueAsteriskName")] + public string DisciplineBlockBlueAsteriskName { get; set; } + + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + + [ForeignKey("DisciplineBlockId")] + public virtual List Disciplines { get; set; } + + //------------------------------------------------------------------------- + + public DisciplineBlock SecurityCheck(DisciplineBlock entity, bool allowFullData) => entity; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs index 4bad4c9..3391d87 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs @@ -7,11 +7,11 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { - /// - /// Класс, описывающий сотрудника в системе - /// - [DataContract] - [EntityDescription("Employee", "Сотрудника в системе")] + /// + /// Класс, описывающий сотрудника кафедры + /// + [DataContract] + [EntityDescription("Employee", "Сотрудника кафедры")] public class Employee : BaseEntity, IEntitySecurityExtenstion { [DataMember] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs index 2ce86c2..a22a8ae 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs @@ -6,10 +6,10 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { /// - /// Класс, описывающий связь сотрудника и должность в системе + /// Класс, описывающий связь сотрудника и должность кафедры /// [DataContract] - [EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность в системе")] + [EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")] [EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится сотрудник")] [EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")] public class EmployeeEmployeePost : BaseEntity, IEntitySecurityExtenstion diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs index 602235e..47270a6 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs @@ -7,10 +7,10 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { /// - /// Класс, описывающий должность сотрудника в системе + /// Класс, описывающий должность сотрудника кафедры /// [DataContract] - [EntityDescription("EmployeePost", "Должность сотрудника в системе")] + [EntityDescription("EmployeePost", "Должность сотрудника кафедры")] public class EmployeePost : BaseEntity, IEntitySecurityExtenstion { [DataMember] diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs index aed5d74..d819591 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs @@ -249,9 +249,12 @@ namespace DesktopTools.Controls toolStripLabelCountRecords.Visible = toolStripTextBoxCountRecords.Visible = toolStripButtonNext.Visible = false; toolStripComboBoxPageNames.Items.AddRange(config.PageNamesForPagination.ToArray()); - toolStripComboBoxPageNames.SelectedIndexChanged -= ToolStripComboBoxPageNamesSelectedIndexChanged; - toolStripComboBoxPageNames.SelectedIndex = 0; - toolStripComboBoxPageNames.SelectedIndexChanged += ToolStripComboBoxPageNamesSelectedIndexChanged; + if (toolStripComboBoxPageNames.Items.Count > 0) + { + toolStripComboBoxPageNames.SelectedIndexChanged -= ToolStripComboBoxPageNamesSelectedIndexChanged; + toolStripComboBoxPageNames.SelectedIndex = 0; + toolStripComboBoxPageNames.SelectedIndexChanged += ToolStripComboBoxPageNamesSelectedIndexChanged; + } toolStripComboBoxPageNames.Tag = config.ParentPropertyName; } } diff --git a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs index 057d361..27ac8f8 100644 --- a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs +++ b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs @@ -26,16 +26,16 @@ #region База Кафедра = 100, - Сотрудники = 101, + Сотрудники = 101, // + должности Аудитории = 102, + Дисциплины = 103, // + Блоки дисциплин + Направления = 102, Преподаватели = 103, // + должности, звания - Дисциплины = 104, // + Блоки дисциплин - Группы = 105, // Студенты = 106, diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBindingModels.cs new file mode 100644 index 0000000..54f0dae --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBindingModels.cs @@ -0,0 +1,56 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + /// + /// Получение дисциплины + /// + public class DisciplineGetBindingModel : GetBindingModel + { + /// + /// Выбрка по блокам + /// + public Guid? DisciplineBlockId { get; set; } + + /// + /// Поиск по названию + /// + public string DisciplineName { get; set; } + } + + /// + /// Сохранение дисциплины + /// + public class DisciplineSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineBlockId")] + public Guid DisciplineBlockId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineName")] + public string DisciplineName { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineShortName")] + public string DisciplineShortName { get; set; } + + [MapConfiguration("DisciplineBlueAsteriskName")] + public string DisciplineBlueAsteriskName { get; set; } + + /// + /// Используется только в расчетах, не сохраняется + /// + [MapConfiguration("DisciplineBlueAsteriskCode")] + public string DisciplineBlueAsteriskCode { get; set; } + + /// + /// Используется только в расчетах, не сохраняется + /// + [MapConfiguration("DisciplineBlueAsteriskPracticCode")] + public string DisciplineBlueAsteriskPracticCode { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs new file mode 100644 index 0000000..c861db5 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs @@ -0,0 +1,39 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + /// + /// Получение блока дисциплин + /// + public class DisciplineBlockGetBindingModel : GetBindingModel + { + } + + /// + /// Сохранение блока дисциплин + /// + public class DisciplineBlockSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("Title")] + public string Title { get; set; } + + [MapConfiguration("DisciplineBlockUseForGrouping")] + public bool DisciplineBlockUseForGrouping { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("DisciplineBlockOrder")] + public int DisciplineBlockOrder { get; set; } + + /// + /// Используется только в расчетах, не сохраняется + /// + [MapConfiguration("DisciplineBlockBlueAsteriskCode")] + public string DisciplineBlockBlueAsteriskCode { get; set; } + + [MapConfiguration("DisciplineBlockBlueAsteriskName")] + public string DisciplineBlockBlueAsteriskName { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBlockBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBlockBusinessLogic.cs new file mode 100644 index 0000000..6477882 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBlockBusinessLogic.cs @@ -0,0 +1,16 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с блоками дисциплин + /// + public class DisciplineBlockBusinessLogic : GenericBusinessLogic + { + public DisciplineBlockBusinessLogic(IDisciplineBlockService service) : base(service, "Аудитории", AccessOperation.Дисциплины) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBusinessLogic.cs new file mode 100644 index 0000000..5ae5abe --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/DisciplineBusinessLogic.cs @@ -0,0 +1,16 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с дисциплинами + /// + public class DisciplineBusinessLogic : GenericBusinessLogic + { + public DisciplineBusinessLogic(IDisciplineService service) : base(service, "Аудитории", AccessOperation.Дисциплины) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineBlockService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineBlockService.cs new file mode 100644 index 0000000..4032e34 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineBlockService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение блоков дисциплин + /// + public interface IDisciplineBlockService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineService.cs new file mode 100644 index 0000000..f1b897e --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IDisciplineService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение дисциплин + /// + public interface IDisciplineService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineBlockViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineBlockViewModels.cs new file mode 100644 index 0000000..cd41773 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineBlockViewModels.cs @@ -0,0 +1,40 @@ +using ModuleTools.Attributes; +using ModuleTools.Enums; +using ModuleTools.ViewModels; + +namespace DepartmentBusinessLogic.ViewModels +{ + /// + /// Список блоков дисциплин + /// + public class DisciplineBlockListViewModel : ListViewModel { } + + /// + /// Элемент блок дисциплины + /// + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] + [ViewModelControlElementDependenceEntity(Title = "Дисципилны", Order = 1, ParentPropertyName = "DisciplineBlockId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlDisciplineList, DepartmentWindowsDesktop")] + public class DisciplineBlockViewModel : ElementViewModel + { + [ViewModelControlListProperty("Название блока")] + [ViewModelControlElementProperty("Название блока", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("Title")] + public string Title { get; set; } + + [ViewModelControlElementProperty("Используется для группровки в расчетах", ControlType.ControlBool, MustHaveValue = true)] + [MapConfiguration("DisciplineBlockUseForGrouping")] + public bool DisciplineBlockUseForGrouping { get; set; } + + [ViewModelControlListProperty("Порядок", ColumnWidth = 100)] + [ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)] + [MapConfiguration("DisciplineBlockOrder")] + public int DisciplineBlockOrder { get; set; } + + [ViewModelControlElementProperty("Назв. в планах", ControlType.ControlString)] + [MapConfiguration("DisciplineBlockBlueAsteriskName")] + public string DisciplineBlockBlueAsteriskName { get; set; } + + public override string ToString() => Title; + } +} diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineViewModels.cs new file mode 100644 index 0000000..1d4a7d7 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/DisciplineViewModels.cs @@ -0,0 +1,46 @@ +using ModuleTools.Attributes; +using ModuleTools.Enums; +using ModuleTools.ViewModels; +using System; + +namespace DepartmentBusinessLogic.ViewModels +{ + class DisciplineViewModels + { + } + /// + /// Список дисциплин + /// + public class DisciplineListViewModel : ListViewModel { } + + /// + /// Элемент дисциплина + /// + [ViewModelControlElementClass()] + public class DisciplineViewModel : ElementViewModel + { + [ViewModelControlElementProperty("Блок дисциплин", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlDisciplineBlockList, DepartmentWindowsDesktop")] + [MapConfiguration("DisciplineBlockId")] + public Guid DisciplineBlockId { get; set; } + + [ViewModelControlListProperty("Блок дисциплин")] + [MapConfiguration("DisciplineBlock.Title", IsDifficle = true)] + public string DisciplineBlockTitle { get; set; } + + [ViewModelControlListProperty("Название дисциплины")] + [ViewModelControlElementProperty("Название дисциплины", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("DisciplineName")] + public string DisciplineName { get; set; } + + [ViewModelControlListProperty("Краткое название дисциплины")] + [ViewModelControlElementProperty("Краткое нисциплины", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("DisciplineShortName")] + public string DisciplineShortName { get; set; } + + [ViewModelControlElementProperty("Название в планах", ControlType.ControlString)] + [MapConfiguration("DisciplineBlueAsteriskName")] + public string DisciplineBlueAsteriskName { get; set; } + + public override string ToString() => DisciplineName; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs index 2f97791..510f5f1 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs @@ -16,16 +16,16 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlElementClass()] public class EmployeeEmployeePostViewModel : ElementViewModel { + [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")] [MapConfiguration("EmployeeId", AllowCopyWithoutRigth = false)] - [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")] - public Guid EmployeeId { get; set; } + public Guid EmployeeId { get; set; } [ViewModelControlListProperty("Сотрудник")] [MapConfiguration("Employee.LastName", IsDifficle = true)] public string EmployeeName { get; set; } - [MapConfiguration("EmployeePostId")] [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")] + [MapConfiguration("EmployeePostId")] public Guid EmployeePostId { get; set; } [ViewModelControlListProperty("Должность")] diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs index 72110f7..7c72622 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs @@ -13,8 +13,10 @@ namespace DepartmentDatabaseImplementation DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs new file mode 100644 index 0000000..509b079 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs @@ -0,0 +1,140 @@ +using DatabaseCore; +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Models; +using System; +using System.Linq; + +namespace DepartmentDatabaseImplementation.Implementations +{ + /// + /// Реализация IDisciplineBlockService + /// + public class DisciplineBlockService : IDisciplineBlockService + { + public OperationResultModel Create(DisciplineBlockSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var exsistEntity = context.DisciplineBlocks.FirstOrDefault(x => x.Title == model.Title); + if (exsistEntity == null) + { + var entity = Mapper.MapToClass(model, true); + context.DisciplineBlocks.Add(entity); + context.SaveChanges(); + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + else + { + if (exsistEntity.IsDeleted) + { + exsistEntity = Mapper.MapToClass(model, exsistEntity, true); + exsistEntity.IsDeleted = false; + context.SaveChanges(); + return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); + } + else + { + return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); + } + } + } + + public OperationResultModel Delete(DisciplineBlockGetBindingModel model) + { + using var context = DatabaseManager.GetContext; + using var transaction = context.Database.BeginTransaction(); + try + { + var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + else if (entity.IsDeleted) + { + return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); + } + var disciplines = context.Disciplines.Where(x => x.DisciplineBlockId == model.Id); + if (disciplines.Any()) + { + return OperationResultModel.Error("Error:", "Есть дисциплины, относящиеся к этому блоку", ResultServiceStatusCode.ExsistItem); + } + entity.IsDeleted = true; + entity.DateDelete = DateTime.Now; + + context.SaveChanges(); + + transaction.Commit(); + } + catch (Exception) + { + transaction.Rollback(); + throw; + } + + return OperationResultModel.Success(true); + } + + public OperationResultModel Read(DisciplineBlockGetBindingModel model) + { + int countPages = 0; + using var context = DatabaseManager.GetContext; + + // для одной записи + if (model.Id.HasValue) + { + var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id.Value); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); + } + + var query = context.DisciplineBlocks.Where(x => !x.IsDeleted).AsQueryable(); + + query = query.OrderBy(x => x.DisciplineBlockOrder); + + if (model.PageNumber.HasValue && model.PageSize.HasValue) + { + countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); + query = query + .Skip(model.PageSize.Value * model.PageNumber.Value) + .Take(model.PageSize.Value); + } + + var result = new DisciplineBlockListViewModel + { + MaxCount = countPages, + List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() + }; + + return OperationResultModel.Success(result); + } + + public OperationResultModel Update(DisciplineBlockSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + else if (entity.IsDeleted) + { + return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); + } + entity = Mapper.MapToClass(model, entity, true); + + context.SaveChanges(); + + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs new file mode 100644 index 0000000..47fedcf --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs @@ -0,0 +1,137 @@ +using DatabaseCore; +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using Microsoft.EntityFrameworkCore; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Extensions; +using ModuleTools.Models; +using System; +using System.Linq; + +namespace DepartmentDatabaseImplementation.Implementations +{ + /// + /// Реализация IDisciplineService + /// + public class DisciplineService : IDisciplineService + { + public OperationResultModel Create(DisciplineSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var exsistEntity = context.Disciplines.FirstOrDefault(x => x.DisciplineName == model.DisciplineName); + if (exsistEntity == null) + { + var entity = Mapper.MapToClass(model, true); + context.Disciplines.Add(entity); + context.SaveChanges(); + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + else + { + if (exsistEntity.IsDeleted) + { + exsistEntity = Mapper.MapToClass(model, exsistEntity, true); + exsistEntity.IsDeleted = false; + context.SaveChanges(); + return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); + } + else + { + return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); + } + } + } + + public OperationResultModel Delete(DisciplineGetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + else if (entity.IsDeleted) + { + return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); + } + entity.IsDeleted = true; + entity.DateDelete = DateTime.Now; + + context.SaveChanges(); + + return OperationResultModel.Success(true); + } + + public OperationResultModel Read(DisciplineGetBindingModel model) + { + int countPages = 0; + using var context = DatabaseManager.GetContext; + + // для одной записи + if (model.Id.HasValue) + { + var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id.Value); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); + } + + var query = context.Disciplines.Where(x => !x.IsDeleted).AsQueryable(); + if (model.DisciplineName.IsNotEmpty()) + { + query = query.Where(x => x.DisciplineName.Contains(model.DisciplineName)); + } + if (model.DisciplineBlockId.HasValue) + { + query = query.Where(x => x.DisciplineBlockId == model.DisciplineBlockId.Value); + } + + query = query.OrderBy(x => x.DisciplineBlock.DisciplineBlockOrder).ThenBy(x => x.DisciplineName); + + if (model.PageNumber.HasValue && model.PageSize.HasValue) + { + countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); + query = query + .Skip(model.PageSize.Value * model.PageNumber.Value) + .Take(model.PageSize.Value); + } + + query = query.Include(x => x.DisciplineBlock); + + var result = new DisciplineListViewModel + { + MaxCount = countPages, + List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() + }; + + return OperationResultModel.Success(result); + } + + public OperationResultModel Update(DisciplineSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + else if (entity.IsDeleted) + { + return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); + } + entity = Mapper.MapToClass(model, entity, true); + + context.SaveChanges(); + + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs index 6060c1f..d6c5f70 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs @@ -34,7 +34,9 @@ namespace DepartmentWindowsDesktop { new ControlEmployeePostList(), new ControlEmployeeList(), - new ControlClassroomList() + new ControlClassroomList(), + new ControlDisciplineBlockList(), + new ControlDisciplineList() }; foreach (var cntrl in _controls) diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.Designer.cs similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.Designer.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.Designer.cs diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.cs similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.cs diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.resx similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomElement.resx rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomElement.resx diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.Designer.cs similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.Designer.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.Designer.cs diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.cs similarity index 94% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.cs index f1d2016..a2f9824 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.cs @@ -11,6 +11,9 @@ using System.Collections.Generic; namespace DepartmentWindowsDesktop.EntityControls { + /// + /// Реализация контрола для списка аудиторий + /// public partial class ControlClassroomList : GenericControlEntityList, IGenericControlEntityList diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.resx similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/ControlClassroomList.resx rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Classroom/ControlClassroomList.resx diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.Designer.cs new file mode 100644 index 0000000..f6f9f32 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlDisciplineBlockElement + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.cs new file mode 100644 index 0000000..fa582f8 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.cs @@ -0,0 +1,27 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using System; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для блока дисциплин + /// + public partial class ControlDisciplineBlockElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlDisciplineBlockElement() + { + InitializeComponent(); + Title = "Блок дисципилн"; + ControlId = new Guid("8e2032c5-1412-4ccd-855c-f0b0836e3599"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlDisciplineBlockElement() { ControlId = Guid.NewGuid() }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockElement.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.Designer.cs new file mode 100644 index 0000000..3a616f5 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlDisciplineBlockList + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.cs new file mode 100644 index 0000000..d313ce8 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.cs @@ -0,0 +1,50 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Enums; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using ModuleTools.Enums; +using System; +using System.Collections.Generic; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для списка блоков дисциплин + /// + public partial class ControlDisciplineBlockList : + GenericControlEntityList, + IGenericControlEntityList + { + public ControlDisciplineBlockList() + { + InitializeComponent(); + Title = "Блоки дисциплин"; + ControlId = new Guid("1c115bda-fa08-4127-ac4b-daba79d65628"); + AccessOperation = AccessOperation.Дисциплины; + ControlViewEntityElement = new ControlDisciplineBlockElement(); + _genericControlViewEntityList = this; + } + + public IControl GetInstanceGenericControl() => new ControlDisciplineBlockList() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityListConfiguration GetConfigControl() => new() + { + PaginationOn = false, + HideToolStripButton = new List + { + ToolStripButtonListNames.toolStripButtonSearch + } + }; + + public DisciplineBlockListViewModel GetDataForControl() => _businessLogic.GetList(new DisciplineBlockGetBindingModel()); + + public DisciplineBlockListViewModel GetDataFromParentForControl(Guid id) => throw new NotImplementedException(); + + public DisciplineBlockListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException(); + + public DisciplineBlockListViewModel GetDataWithPageNumberForControl(int page, int count) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineBlockList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.Designer.cs new file mode 100644 index 0000000..3f63c74 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlDisciplineElement + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.cs new file mode 100644 index 0000000..b5afe4f --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.cs @@ -0,0 +1,27 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using System; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для дисциплины + /// + public partial class ControlDisciplineElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlDisciplineElement() + { + InitializeComponent(); + Title = "Дисципилна"; + ControlId = new Guid("8905d288-48c2-4bee-bf5e-2115bbccf6a7"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlDisciplineElement() { ControlId = Guid.NewGuid() }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineElement.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.Designer.cs new file mode 100644 index 0000000..a1bb482 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlDisciplineList + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.cs new file mode 100644 index 0000000..50875c4 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.cs @@ -0,0 +1,92 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.BaseControls; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using System; +using System.Linq; + +namespace DepartmentWindowsDesktop.EntityControls +{ + public partial class ControlDisciplineList : + GenericControlEntityList, + IGenericControlEntityList + { + private readonly DisciplineBlockBusinessLogic _disciplineBlockBusinessLogic; + + public ControlDisciplineList() + { + InitializeComponent(); + _disciplineBlockBusinessLogic = DependencyManager.Instance.Resolve(); + Title = "Дисциплины"; + ControlId = new Guid("1731f50b-b20b-44c4-aa56-b335764fae7a"); + AccessOperation = AccessOperation.Дисциплины; + ControlViewEntityElement = new ControlDisciplineElement(); + _genericControlViewEntityList = this; + FillSearchPanel(); + } + + public IControl GetInstanceGenericControl() => new ControlDisciplineList() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityListConfiguration GetConfigControl() => new() + { + PaginationOn = true, + PageNamesForPagination = _disciplineBlockBusinessLogic.GetList(new DisciplineBlockGetBindingModel())?.List?.Select(x => + new PageNamesForPaginationModel + { + Key = x.Id.ToString(), + Value = x.Title + })?.ToList(), + ParentPropertyName = "DisciplineBlockId" + }; + + public DisciplineListViewModel GetDataForControl() + { + var model = new DisciplineGetBindingModel(); + if (_searchValues != null) + { + var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch"); + if (cntrl != default) + { + model.DisciplineName = cntrl.Value.ToString(); + } + } + return _businessLogic.GetList(model); + } + + public DisciplineListViewModel GetDataFromParentForControl(Guid id) + { + var model = new DisciplineGetBindingModel { DisciplineBlockId = id }; + if (_searchValues != null) + { + var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch"); + if (cntrl != default) + { + model.DisciplineName = cntrl.Value.ToString(); + } + } + return _businessLogic.GetList(model); + } + + public DisciplineListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException(); + + public DisciplineListViewModel GetDataWithPageNumberForControl(int page, int count) => throw new NotImplementedException(); + + private void FillSearchPanel() + { + var control = new BaseControlString("DisciplineNameForSearch", false, false, 0) + { + Location = new System.Drawing.Point(10, 10), + Size = new System.Drawing.Size(400, 23), + Name = "SearchDisciplineName", + TabIndex = 0 + }; + control.SetTitleWidth(control.SetTitle("Название:")); + panelSearchControls.Controls.Add(control); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Discipline/ControlDisciplineList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeList.cs index 42e0c5d..45a0027 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeList.cs @@ -11,6 +11,9 @@ using System.Collections.Generic; namespace DepartmentWindowsDesktop.EntityControls { + /// + /// Реализация контрола для списка сотрудников + /// public partial class ControlEmployeeList : GenericControlEntityList, IGenericControlEntityList