From 4008a5e2a5515ca9da9715e3480a745969da6d84 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sun, 11 Apr 2021 20:49:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=83=D1=87=D0=B1=D0=B5=D0=BD=D1=8B=D1=85=20=D0=BF?= =?UTF-8?q?=D0=BB=D0=B0=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0210408152438_ChangeAcademPlan.Designer.cs | 1130 +++++++++++++++++ .../20210408152438_ChangeAcademPlan.cs | 100 ++ .../DatabaseContextModelSnapshot.cs | 9 +- .../Models/Department/AcademicPlan.cs | 3 +- .../GenericControlEntityElement.cs | 5 +- .../MainControls/GenericControlEntityList.cs | 64 +- .../MainControlViewEntityList.Designer.cs | 8 + .../BusinessLogics/GenericBusinessLogic.cs | 10 +- .../AcademicPlanBindingModels.cs | 13 +- .../DisciplineBlockBindingModels.cs | 6 - .../AcademicPlanBusinessLogic.cs | 17 + .../Interfaces/IAcademicPlanService.cs | 11 +- .../AcademicPlanRecordViewModels.cs | 4 +- .../ViewModels/AcademicPlanViewModels.cs | 10 +- .../Implementations/AcademicPlanService.cs | 402 ++++++ .../Models/BlueAsteriskBlockType.cs | 18 + .../Models/BlueAsteriskNewHour.cs | 17 + .../Models/ParsPlxModel.cs | 35 + .../DepartmentWindowsDesktop.csproj | 1 + .../ControlAcademicPlanElement.cs | 41 +- .../AcademicPlan/ControlAcademicPlanList.cs | 41 +- .../ControlAcademicPlanRecordList.cs | 1 + .../Employee/ControlEmployeeElement.cs | 3 + .../Lecturer/ControlLecturerElement.cs | 3 + 24 files changed, 1900 insertions(+), 52 deletions(-) create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.Designer.cs create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskBlockType.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskNewHour.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/ParsPlxModel.cs diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.Designer.cs new file mode 100644 index 0000000..845ddc1 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.Designer.cs @@ -0,0 +1,1130 @@ +// +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("20210408152438_ChangeAcademPlan")] + partial class ChangeAcademPlan + { + 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.AcademicPlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EducationDirectionId", "YearEntrance") + .IsUnique() + .HasFilter("[EducationDirectionId] IS NOT NULL"); + + b.ToTable("AcademicPlans"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineId") + .HasColumnType("uniqueidentifier"); + + b.Property("InDepartment") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsFacultative") + .HasColumnType("bit"); + + b.Property("IsParent") + .HasColumnType("bit"); + + b.Property("Semester") + .HasColumnType("int"); + + b.Property("Zet") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("AcademicPlanId", "DisciplineId", "Semester") + .IsUnique(); + + b.ToTable("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PlanHours") + .HasColumnType("decimal(18,2)"); + + b.Property("TimeNormId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TimeNormId"); + + b.HasIndex("AcademicPlanRecordId", "TimeNormId") + .IsUnique(); + + b.ToTable("AcademicPlanRecordTimeNormHours"); + }); + + 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") + .IsRequired() + .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(); + + 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("Description") + .HasColumnType("nvarchar(max)"); + + 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.EducationDirection", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Cipher") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("Profile") + .HasColumnType("nvarchar(450)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("Title", "Profile") + .IsUnique() + .HasFilter("[Profile] IS NOT NULL"); + + b.ToTable("EducationDirections"); + }); + + 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("UserId"); + + 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.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("LecturerAcademicDegreeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerAcademicRankId") + .HasColumnType("uniqueidentifier"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("KindOfLoadAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskPracticName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TimeNormEducationDirectionQualification") + .HasColumnType("int"); + + b.Property("TimeNormName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("TimeNormOrder") + .HasColumnType("int"); + + b.Property("TimeNormShortName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("UseInLearningProgress") + .HasColumnType("bit"); + + b.Property("UseInSite") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("TimeNormName", "TimeNormShortName") + .IsUnique(); + + b.ToTable("TimeNorms"); + }); + + 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("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + 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.AcademicPlan", b => + { + b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") + .WithMany("AcademicPlans") + .HasForeignKey("EducationDirectionId"); + + b.Navigation("EducationDirection"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("AcademicPlanRecords") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Discipline", "Discipline") + .WithMany("AcademicPlanRecords") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + + b.Navigation("Discipline"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlanRecord", "AcademicPlanRecord") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("AcademicPlanRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.TimeNorm", "TimeNorm") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("TimeNormId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlanRecord"); + + b.Navigation("TimeNorm"); + }); + + 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.EducationDirection", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("EducationDirections") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("TimeNorms") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + 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.AcademicPlan", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + + b.Navigation("TimeNorms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.Navigation("AcademicPlans"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("EducationDirections"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.cs new file mode 100644 index 0000000..5ef1994 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210408152438_ChangeAcademPlan.cs @@ -0,0 +1,100 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class ChangeAcademPlan : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId", + table: "AcademicPlanRecordTimeNormHours"); + + migrationBuilder.DropForeignKey( + name: "FK_AcademicPlans_EducationDirections_EducationDirectionId", + table: "AcademicPlans"); + + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans"); + + migrationBuilder.AlterColumn( + name: "EducationDirectionId", + table: "AcademicPlans", + type: "uniqueidentifier", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "YearEntrance" }, + unique: true, + filter: "[EducationDirectionId] IS NOT NULL"); + + migrationBuilder.AddForeignKey( + name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId", + table: "AcademicPlanRecordTimeNormHours", + column: "TimeNormId", + principalTable: "TimeNorms", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + + migrationBuilder.AddForeignKey( + name: "FK_AcademicPlans_EducationDirections_EducationDirectionId", + table: "AcademicPlans", + column: "EducationDirectionId", + principalTable: "EducationDirections", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId", + table: "AcademicPlanRecordTimeNormHours"); + + migrationBuilder.DropForeignKey( + name: "FK_AcademicPlans_EducationDirections_EducationDirectionId", + table: "AcademicPlans"); + + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans"); + + migrationBuilder.AlterColumn( + name: "EducationDirectionId", + table: "AcademicPlans", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uniqueidentifier", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "YearEntrance" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId", + table: "AcademicPlanRecordTimeNormHours", + column: "TimeNormId", + principalTable: "TimeNorms", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_AcademicPlans_EducationDirections_EducationDirectionId", + table: "AcademicPlans", + column: "EducationDirectionId", + principalTable: "EducationDirections", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs index 4c24bb4..5e02c27 100644 --- a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs @@ -30,7 +30,7 @@ namespace DatabaseCore.Migrations b.Property("DateDelete") .HasColumnType("datetime2"); - b.Property("EducationDirectionId") + b.Property("EducationDirectionId") .HasColumnType("uniqueidentifier"); b.Property("IsDeleted") @@ -45,7 +45,8 @@ namespace DatabaseCore.Migrations b.HasKey("Id"); b.HasIndex("EducationDirectionId", "YearEntrance") - .IsUnique(); + .IsUnique() + .HasFilter("[EducationDirectionId] IS NOT NULL"); b.ToTable("AcademicPlans"); }); @@ -854,9 +855,7 @@ namespace DatabaseCore.Migrations { b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") .WithMany("AcademicPlans") - .HasForeignKey("EducationDirectionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EducationDirectionId"); b.Navigation("EducationDirection"); }); diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs index da721d5..ce74418 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs @@ -17,9 +17,8 @@ namespace DatabaseCore.Models.Department public class AcademicPlan : BaseEntity, IEntitySecurityExtenstion { [DataMember] - [Required(ErrorMessage = "required")] [MapConfiguration("EducationDirectionId")] - public Guid EducationDirectionId { get; set; } + public Guid? EducationDirectionId { get; set; } [DataMember] [Required(ErrorMessage = "required")] diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs index feb9cb0..3c005b6 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs @@ -10,7 +10,6 @@ using ModuleTools.Enums; using ModuleTools.Extensions; using ModuleTools.ViewModels; using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Windows.Forms; @@ -28,7 +27,7 @@ namespace DesktopTools.Controls /// /// Объект бизнес-логики для получения данных /// - private readonly BL _businessLogic; + protected readonly BL _businessLogic; /// /// Методы для реализации в generic-контроле @@ -45,7 +44,7 @@ namespace DesktopTools.Controls /// private readonly int _defaultControlWidth = 350; - private E _element = null; + protected E _element = null; /// /// Событие, вызываемое при закрытии контрола diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs index c587b01..fcee26f 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs @@ -42,6 +42,10 @@ namespace DesktopTools.Controls private readonly object _lockObject = new(); + private bool _usePages = false; + + private bool _useNames = false; + /// /// Объект бизнес-логики для получения данных /// @@ -236,12 +240,14 @@ namespace DesktopTools.Controls // пагинация по страницам if (config.CountElementsOnPage.HasValue) { + _usePages = true; toolStripTextBoxCountRecords.Text = config.CountElementsOnPage.Value.ToString(); toolStripLabelPageName.Visible = toolStripComboBoxPageNames.Visible = false; } // пагинация по названиям - else if (config.PageNamesForPagination != null) + if (config.PageNamesForPagination != null) { + _useNames = true; toolStripButtonPrev.Visible = toolStripLabelPage.Visible = toolStripTextBoxPage.Visible = toolStripLabelCountPages.Visible = toolStripLabelCountRecords.Visible = toolStripTextBoxCountRecords.Visible = toolStripButtonNext.Visible = false; @@ -264,7 +270,12 @@ namespace DesktopTools.Controls { panelHeader.Visible = false; toolStripButtonClose.Visible = false; - toolStripFooter.Visible = false; + toolStripSeparator6.Visible = false; + toolStripButtonSelect.Visible = false; + } + // Открытие через родительский элемент + if (_openMode == ControlOpenMode.Select) + { toolStripSeparator6.Visible = true; toolStripButtonSelect.Visible = true; } @@ -408,27 +419,24 @@ namespace DesktopTools.Controls } } // если включена пагинация - else if (toolStripFooter.Visible) + // постраничная + if (_usePages) { - // постраничная - if (toolStripTextBoxPage.Visible) + if (int.TryParse(toolStripTextBoxPage.Text, out int page) && int.TryParse(toolStripTextBoxCountRecords.Text.ToString(), out int count)) { - if (int.TryParse(toolStripTextBoxPage.Text, out int page) && int.TryParse(toolStripTextBoxCountRecords.Text.ToString(), out int count)) - { - model.PageNumber = page - 1; - model.PageSize = count; - } + model.PageNumber = page - 1; + model.PageSize = count; } - // поименная - else if (toolStripComboBoxPageNames.Visible) + } + // поименная + if (_useNames) + { + if (toolStripComboBoxPageNames.SelectedItem is PageNamesForPaginationModel key) { - if (toolStripComboBoxPageNames.SelectedItem is PageNamesForPaginationModel key) + var prop = typeof(G).GetProperty(toolStripComboBoxPageNames.Tag.ToString()); + if (prop != null) { - var prop = typeof(G).GetProperty(toolStripComboBoxPageNames.Tag.ToString()); - if (prop != null) - { - prop.SetValue(model, key.Key); - } + prop.SetValue(model, key.Key); } } } @@ -569,7 +577,7 @@ namespace DesktopTools.Controls control.ParentId = ParentId; control.ParentPropertyName = ParentPropertyName; } - if (toolStripFooter.Visible && toolStripComboBoxPageNames.Visible) + else if (toolStripFooter.Visible && toolStripComboBoxPageNames.Visible) { if (toolStripComboBoxPageNames.SelectedItem is PageNamesForPaginationModel key) { @@ -605,6 +613,24 @@ namespace DesktopTools.Controls } } + /// + /// Получение настроек для контрола + /// + /// private ControlViewEntityListConfiguration GetConfig() => _genericControlViewEntityList?.GetConfigControl(); + + /// + /// Получение списка идентификаторов выбранных записей + /// + /// + protected List GetSelectedIds() + { + List guids = new(); + foreach (DataGridViewRow selected in dataGridViewList.SelectedRows) + { + guids.Add(new Guid(selected.Cells[0].Value.ToString())); + } + return guids; + } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.Designer.cs b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.Designer.cs index dd9145c..51cd6b1 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.Designer.cs @@ -29,6 +29,7 @@ namespace DesktopTools.Controls /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.toolStripMenu = new System.Windows.Forms.ToolStrip(); this.toolStripButtonAdd = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); @@ -62,6 +63,7 @@ namespace DesktopTools.Controls this.dataGridViewList = new System.Windows.Forms.DataGridView(); this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButtonSelect = new System.Windows.Forms.ToolStripButton(); + this.contextMenuStripDataGrid = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenu.SuspendLayout(); this.panelHeader.SuspendLayout(); this.panelSearch.SuspendLayout(); @@ -328,6 +330,7 @@ namespace DesktopTools.Controls this.dataGridViewList.AllowUserToDeleteRows = false; this.dataGridViewList.AllowUserToResizeRows = false; this.dataGridViewList.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridViewList.ContextMenuStrip = this.contextMenuStripDataGrid; this.dataGridViewList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridViewList.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridViewList.Location = new System.Drawing.Point(0, 142); @@ -354,6 +357,11 @@ namespace DesktopTools.Controls this.toolStripButtonSelect.Text = "Выбрать"; this.toolStripButtonSelect.Visible = false; // + // contextMenuStripDataGrid + // + this.contextMenuStripDataGrid.Name = "contextMenuStripDataGrid"; + this.contextMenuStripDataGrid.Size = new System.Drawing.Size(61, 4); + // // ControlViewEntityList // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); diff --git a/DepartmentPortal/Common/ModuleTools/BusinessLogics/GenericBusinessLogic.cs b/DepartmentPortal/Common/ModuleTools/BusinessLogics/GenericBusinessLogic.cs index 9b175bf..9070282 100644 --- a/DepartmentPortal/Common/ModuleTools/BusinessLogics/GenericBusinessLogic.cs +++ b/DepartmentPortal/Common/ModuleTools/BusinessLogics/GenericBusinessLogic.cs @@ -54,7 +54,7 @@ namespace ModuleTools.BusinessLogics var result = Service.Read(model); if (!result.IsSucceeded) { - Errors.AddRange(Errors); + Errors.AddRange(result.Errors); return null; } @@ -85,7 +85,7 @@ namespace ModuleTools.BusinessLogics var result = Service.Read(model); if (!result.IsSucceeded) { - Errors.AddRange(Errors); + Errors.AddRange(result.Errors); return null; } return result.Result as E; @@ -114,7 +114,7 @@ namespace ModuleTools.BusinessLogics var result = Service.Create(model); if (!result.IsSucceeded) { - Errors.AddRange(Errors); + Errors.AddRange(result.Errors); return null; } @@ -144,7 +144,7 @@ namespace ModuleTools.BusinessLogics var result = Service.Update(model); if (!result.IsSucceeded) { - Errors.AddRange(Errors); + Errors.AddRange(result.Errors); return null; } @@ -174,7 +174,7 @@ namespace ModuleTools.BusinessLogics var result = Service.Delete(model); if (!result.IsSucceeded) { - Errors.AddRange(Errors); + Errors.AddRange(result.Errors); return false; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/AcademicPlanBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/AcademicPlanBindingModels.cs index 6620697..425274b 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/AcademicPlanBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/AcademicPlanBindingModels.cs @@ -18,9 +18,8 @@ namespace DepartmentBusinessLogic.BindingModels /// public class AcademicPlanSetBindingModel : SetBindingModel { - [Required(ErrorMessage = "required")] [MapConfiguration("EducationDirectionId")] - public Guid EducationDirectionId { get; set; } + public Guid? EducationDirectionId { get; set; } [Required(ErrorMessage = "required")] [MapConfiguration("YearEntrance")] @@ -30,4 +29,14 @@ namespace DepartmentBusinessLogic.BindingModels [MapConfiguration("YearFinish")] public int YearFinish { get; set; } } + + /// + /// Модель для зазгрузки планов + /// + public class AcademicPlanLoadPlxModel + { + public Guid AcademicPlanId { get; set; } + + public string FileName { get; set; } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs index c861db5..02d2c90 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/DisciplineBlockBindingModels.cs @@ -27,12 +27,6 @@ namespace DepartmentBusinessLogic.BindingModels [MapConfiguration("DisciplineBlockOrder")] public int DisciplineBlockOrder { get; set; } - /// - /// Используется только в расчетах, не сохраняется - /// - [MapConfiguration("DisciplineBlockBlueAsteriskCode")] - public string DisciplineBlockBlueAsteriskCode { get; set; } - [MapConfiguration("DisciplineBlockBlueAsteriskName")] public string DisciplineBlockBlueAsteriskName { get; set; } } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/AcademicPlanBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/AcademicPlanBusinessLogic.cs index b74b495..8bc2e89 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/AcademicPlanBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/AcademicPlanBusinessLogic.cs @@ -12,5 +12,22 @@ namespace DepartmentBusinessLogic.BusinessLogics public class AcademicPlanBusinessLogic : GenericBusinessLogic { public AcademicPlanBusinessLogic(IAcademicPlanService service) : base(service, "Учебные Планы", AccessOperation.УчебныеПланы) { } + + /// + /// Загрузка учебного плана + /// + /// + /// + public bool LoadPlx(AcademicPlanLoadPlxModel model) + { + Errors.Clear(); + var result = (Service as IAcademicPlanService).LoadPlx(model); + if (!result.IsSucceeded) + { + Errors.AddRange(result.Errors); + return false; + } + return true; + } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IAcademicPlanService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IAcademicPlanService.cs index ad67e5b..6528788 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IAcademicPlanService.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IAcademicPlanService.cs @@ -1,10 +1,19 @@ using DepartmentBusinessLogic.BindingModels; using ModuleTools.Interfaces; +using ModuleTools.Models; namespace DepartmentBusinessLogic.Interfaces { /// /// Хранение учебных планов /// - public interface IAcademicPlanService : IGenerticEntityService { } + public interface IAcademicPlanService : IGenerticEntityService + { + /// + /// Загрузка учебного плана + /// + /// + /// + public OperationResultModel LoadPlx(AcademicPlanLoadPlxModel model); + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanRecordViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanRecordViewModels.cs index 83f3545..877820b 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanRecordViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanRecordViewModels.cs @@ -35,7 +35,7 @@ namespace DepartmentBusinessLogic.ViewModels [MapConfiguration("InDepartment")] public bool InDepartment { get; set; } - [ViewModelControlListProperty("На кафедре", ColumnWidth = 80)] + [ViewModelControlListProperty("На кафедре", ColumnWidth = 100)] public string InDepartmentValue => InDepartment ? "Да" : "Нет"; [ViewModelControlElementProperty("Семестр", ControlType.ControlEnum, MustHaveValue = true)] @@ -61,7 +61,7 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlListProperty("ДВ", ColumnWidth = 50)] public string IsParentValue => IsParent ? "Да" : "Нет"; - [ViewModelControlListProperty("По выбору", ColumnWidth = 80)] + [ViewModelControlListProperty("По выбору", ColumnWidth = 100)] public string IsChildValue => AcademicPlanRecordParentId.HasValue ? "Да" : "Нет"; /// diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs index ad8e626..d7b872d 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs @@ -13,26 +13,26 @@ namespace DepartmentBusinessLogic.ViewModels /// /// Элемент учебного плана /// - [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 1200, Height = 800)] [ViewModelControlElementDependenceEntity(Title = "Записи плана", Order = 1, ParentPropertyName = "AcademicPlanId", ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanRecordList, DepartmentWindowsDesktop")] public class AcademicPlanViewModel : ElementViewModel { - [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] + [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] [MapConfiguration("EducationDirectionId")] - public Guid EducationDirectionId { get; set; } + public Guid? EducationDirectionId { get; set; } [ViewModelControlListProperty("Направление")] [MapConfiguration("EducationDirection.Cipher", IsDifficle = true)] public string EducationDirectionCipher { get; set; } [ViewModelControlListProperty("Дата начала", ColumnWidth = 120)] - [ViewModelControlElementProperty("Дата начала", ControlType.ControlString, MustHaveValue = true)] + [ViewModelControlElementProperty("Дата начала", ControlType.ControlInt, MustHaveValue = true)] [MapConfiguration("YearEntrance")] public int YearEntrance { get; set; } [ViewModelControlListProperty("Дата окончания", ColumnWidth = 120)] - [ViewModelControlElementProperty("Дата окончания", ControlType.ControlString, MustHaveValue = true)] + [ViewModelControlElementProperty("Дата окончания", ControlType.ControlInt, MustHaveValue = true)] [MapConfiguration("YearFinish")] public int YearFinish { get; set; } diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs index 592fb1c..514616d 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs @@ -1,12 +1,20 @@ using DatabaseCore; using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Enums; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; +using DepartmentDatabaseImplementation.Models; using Microsoft.EntityFrameworkCore; +using ModuleTools.Enums; +using ModuleTools.Extensions; using ModuleTools.Models; using System; +using System.Collections.Generic; using System.Linq; +using System.Text; +using System.Xml; +using System.Xml.Linq; namespace DepartmentDatabaseImplementation.Implementations { @@ -56,5 +64,399 @@ namespace DepartmentDatabaseImplementation.Implementations protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.EducationDirection); protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.YearEntrance); + + public OperationResultModel LoadPlx(AcademicPlanLoadPlxModel model) + { + + using var context = DatabaseManager.GetContext; + using var transaction = context.Database.BeginTransaction(); + var result = new OperationResultModel(); + try + { + #region Получаем настройки + //Получаем номер кафедры + var kafedraNumber = context.EnviromentSettings.FirstOrDefault(x => x.Key == "Кафедра"); + if (kafedraNumber == null) + { + throw new Exception("Настройки среды. Не найден ключ Кафедра"); + } + #endregion + + var academicPlan = context.AcademicPlans.Include(x => x.EducationDirection).FirstOrDefault(x => x.Id == model.AcademicPlanId && !x.IsDeleted && x.EducationDirectionId.HasValue); + if (academicPlan == null) + { + return OperationResultModel.Error("Error:", "Учебный план не найден", ResultServiceStatusCode.NotFound); + } + #region помечаем как удаленные все записи плана, потом все найденные восстановим + var aprs = context.AcademicPlanRecords.Where(x => x.AcademicPlanId == academicPlan.Id).ToList(); + foreach (var apr in aprs) + { + var apres = context.AcademicPlanRecordTimeNormHours.Where(x => x.AcademicPlanRecordId == apr.Id); + foreach (var apre in apres) + { + apre.IsDeleted = true; + apre.DateDelete = DateTime.Now; + } + apr.IsDeleted = true; + apr.DateDelete = DateTime.Now; + context.SaveChanges(); + } + #endregion + + var xml = XDocument.Load(model.FileName)?.Element("Документ")?.Elements()?.Elements()?.Elements(); + if (xml != null) + { + var plxModel = new ParsPlxModel + { + AcademicPlanId = academicPlan.Id, + BlockTypes = new(), + DisicplineTypes = new(), + DisciplineBlocks = new(), + TimeNorms = new(), + Practics = new(), + Hours = new(), + Disciplines = new() + }; + #region СправочникВидОбъекта - виды дисциплин - базовая, алтернативная и т.п. + foreach (var elem in xml.Where(x => x.Name.LocalName == "СправочникВидОбъекта")) + { + plxModel.DisicplineTypes.Add((TypeName: elem.Attribute("Наименование").Value, Code: elem.Attribute("Код").Value)); + } + #endregion + #region ПланыЦиклы + foreach (var elem in xml.Where(x => x.Name.LocalName == "ПланыЦиклы")) + { + plxModel.BlockTypes.Add(new BlueAsteriskBlockType + { + Identificator = elem.Attribute("Идентификатор").Value, + Code = elem.Attribute("Код").Value, + BlockName = elem.Attribute("Цикл").Value, + IsFacultative = Convert.ToBoolean(elem.Attribute("Факультативы").Value) + }); + } + #endregion + #region СправочникТипОбъекта - блоки дисциплин + foreach (var elem in xml.Where(x => x.Name.LocalName == "СправочникТипОбъекта")) + { + var disciplineBlock = context.DisciplineBlocks.FirstOrDefault(x => x.DisciplineBlockBlueAsteriskName == elem.Attribute("Название").Value); + if (disciplineBlock != null) + { + plxModel.DisciplineBlocks.Add(( + Code: elem.Attribute("Код").Value, + Entity: disciplineBlock + )); + } + } + #endregion + #region СправочникВидыРабот - нормы времени + foreach (var elem in xml.Where(x => x.Name.LocalName == "СправочникВидыРабот")) + { + if (!plxModel.TimeNorms.Exists(x => x.Code == elem.Attribute("Код").Value)) + { + var timeNorms = context.TimeNorms.Where(x => x.KindOfLoadBlueAsteriskName == elem.Attribute("Название").Value); + foreach (var tn in timeNorms) + { + plxModel.TimeNorms.Add(( + Code: elem.Attribute("Код").Value, + Entity: tn + )); + } + } + } + #endregion + #region СправочникВидыПрактик - нормы времени (практики) + foreach (var elem in xml.Where(x => x.Name.LocalName == "СправочникВидыПрактик")) + { + if (!plxModel.Practics.Exists(x => x.Code == elem.Attribute("Код").Value)) + { + var timeNorms = context.TimeNorms.Where(x => x.KindOfLoadBlueAsteriskPracticName == elem.Attribute("Наименование").Value); + foreach (var tn in timeNorms) + { + plxModel.Practics.Add(( + Code: elem.Attribute("Код").Value, + Entity: tn + )); + } + } + } + #endregion + #region ПланыНовыеЧасы - часы по дисциплинам + var attributeNames = plxModel.TimeNorms.Select(x => x.Entity.KindOfLoadBlueAsteriskAttributeName).Distinct(); + foreach (var elem in xml.Where(x => x.Name.LocalName == "ПланыНовыеЧасы")) + { + var objectCode = elem.Attribute("КодОбъекта")?.Value; + if (objectCode.IsEmpty()) + { + throw new Exception(string.Format("Не найден атрибут КодОбъекта")); + } + var timeNormCode = elem.Attribute("КодВидаРаботы")?.Value; + if (timeNormCode.IsEmpty()) + { + throw new Exception(string.Format("Не найден атрибут КодВидаРаботы")); + } + + var attributeKurs = elem.Attribute("Курс")?.Value; + if (attributeKurs.IsEmpty()) + { + throw new Exception(string.Format("Не найдена атрибут Курс")); + } + + var attributeSemester = elem.Attribute("Семестр")?.Value; + if (attributeSemester.IsEmpty()) + { + throw new Exception(string.Format("Не найдена атрибут Семестр")); + } + + var semester = attributeKurs switch + { + "1" => (attributeSemester == "1") ? Semester.Первый : Semester.Второй, + "2" => (attributeSemester == "1") ? Semester.Третий : Semester.Четвертый, + "3" => (attributeSemester == "1") ? Semester.Пятый : Semester.Шестой, + "4" => (attributeSemester == "1") ? Semester.Седьмой : Semester.Восьмой, + _ => Semester.Первый, + }; + + var hours = new Dictionary(); + + foreach (var attr in attributeNames) + { + if (attr.IsNotEmpty()) + { + var hour = elem.Attribute(attr)?.Value; + if (hour.IsNotEmpty() && !hours.ContainsKey(attr)) + { + if (decimal.TryParse(hour, out decimal h)) + { + hours.Add(attr, h); + } + else + { + if (hour.Contains('.')) + { + hour = hour.Replace('.', ','); + } + else if (hour.Contains(',')) + { + hour = hour.Replace(',', '.'); + } + + if (decimal.TryParse(hour, out h)) + { + hours.Add(attr, h); + } + } + } + } + } + + plxModel.Hours.Add(( + DisciplineCode: objectCode, + TimeNormCode: timeNormCode, + Semester: semester, + plxModel.TimeNorms.FirstOrDefault(x => x.Code == timeNormCode).Entity, + Hours: hours + )); + } + #endregion + #region ПланыСтроки - сами записи учебного плана + foreach (var elem in xml.Where(x => x.Name.LocalName == "ПланыСтроки")) + { + #region получение дисциплины + var disciplineBlock = plxModel.DisciplineBlocks.FirstOrDefault(x => x.Code == elem.Attribute("ТипОбъекта")?.Value).Entity; + if (disciplineBlock == null) + { + return OperationResultModel.Error("ошибка", $"Не найден блок дисциплин с кодом {elem.Attribute("ТипОбъекта")?.Value}", ResultServiceStatusCode.NotFound); + } + + var disciplineName = elem.Attribute("Дисциплина")?.Value; + // ищем по названию в планах дисциплину + var discipline = context.Disciplines.FirstOrDefault(x => x.DisciplineBlueAsteriskName == disciplineName); + if (discipline == null) + { + // ищем по названию дисциплину + discipline = context.Disciplines.FirstOrDefault(x => x.DisciplineName == disciplineName); + if (discipline == null) + { + discipline = new Discipline + { + DisciplineName = disciplineName, + DisciplineBlockId = disciplineBlock.Id, + DisciplineBlueAsteriskName = disciplineName + }; + context.Disciplines.Add(discipline); + context.SaveChanges(); + } + else + { + discipline.DisciplineBlueAsteriskName = disciplineName; + context.SaveChanges(); + } + } + + plxModel.Discipline = ( + Code: elem.Attribute("Код")?.Value, + Practic: elem.Attribute("ВидПрактики")?.Value, + Entity: discipline + ); + plxModel.Disciplines.Add(plxModel.Discipline); + #endregion + + //смотрим код кафедры + bool inKafedra = elem.Attribute("КодКафедры")?.Value == kafedraNumber.Value; + bool isFacultative = elem.Attribute("ДисциплинаКод")?.Value?.StartsWith("ФТД") ?? false; + var zet = elem.Attribute("ЗЕТфакт")?.Value; + // вытаскиваем часы по дисциплине + foreach (var hour in plxModel.Hours.Where(x => x.DisciplineCode == plxModel.Discipline.Code)) + { + #region Родитель + AcademicPlanRecord parent = null; + var parentValue = elem.Attribute("КодРодителя")?.Value; + if (parentValue.IsNotEmpty()) + { + var parentDiscipilne = plxModel.Disciplines.FirstOrDefault(x => x.Code == parentValue); + if (parentDiscipilne == default) + { + return OperationResultModel.Error("ошибка", $"Не найдена родительская дисциплина с кодом {parentValue}", ResultServiceStatusCode.NotFound); + } + + parent = context.AcademicPlanRecords.FirstOrDefault(apr => + apr.AcademicPlanId == model.AcademicPlanId && + apr.DisciplineId == parentDiscipilne.Entity.Id && + apr.Semester == (int)hour.Semester); + + if (parent == null) + { + // возмжно, родитель будет описан позже, заполняем данными дочернего класса пока что + parent = new AcademicPlanRecord + { + AcademicPlanId = model.AcademicPlanId, + DisciplineId = parentDiscipilne.Entity.Id, + InDepartment = inKafedra, + Semester = (int)hour.Semester, + Zet = zet.IsNotEmpty() ? Convert.ToInt32(zet) : 0, + IsParent = true, + IsFacultative = isFacultative + }; + context.AcademicPlanRecords.Add(parent); + context.SaveChanges(); + } + else if (parent.IsDeleted) + { + parent.IsDeleted = false; + parent.DateDelete = null; + context.SaveChanges(); + } + + if (!parent.IsParent) + { + parent.IsParent = true; + context.SaveChanges(); + } + } + #endregion + + #region Запись учебного плана + var record = context.AcademicPlanRecords.FirstOrDefault(apr => + apr.AcademicPlanId == model.AcademicPlanId && + apr.DisciplineId == discipline.Id && + apr.Semester == (int)hour.Semester); + + if (record == null) + { + record = new AcademicPlanRecord + { + AcademicPlanId = model.AcademicPlanId, + DisciplineId = discipline.Id, + Zet = zet.IsNotEmpty() ? Convert.ToInt32(zet) : 0, + Semester = (int)hour.Semester, + AcademicPlanRecordParentId = parent?.Id, + IsParent = false, + IsFacultative = isFacultative, + InDepartment = inKafedra + }; + + context.AcademicPlanRecords.Add(record); + context.SaveChanges(); + } + else if (record.IsDeleted) + { + record.IsDeleted = false; + record.DateDelete = null; + context.SaveChanges(); + } + #endregion + + #region + if (record != null) + { + var timeNorms = new List(); + // если перед нами практика, то выбираем только один нужный тип нагрузки + if (plxModel.Discipline.Practic.IsNotEmpty()) + { + timeNorms.AddRange(plxModel.Practics.Where(x => x.Code == hour.TimeNormCode && + x.Entity.DisciplineBlockId == plxModel.Discipline.Entity.DisciplineBlockId && + (!x.Entity.TimeNormEducationDirectionQualification.HasValue || + x.Entity.TimeNormEducationDirectionQualification == academicPlan.EducationDirection.Qualification) && + x.Code == plxModel.Discipline.Practic).Select(x => x.Entity)); + } + else + { + timeNorms.AddRange(plxModel.TimeNorms.Where(x => x.Code == hour.TimeNormCode && + x.Entity.DisciplineBlockId == plxModel.Discipline.Entity.DisciplineBlockId && + (!x.Entity.TimeNormEducationDirectionQualification.HasValue || + x.Entity.TimeNormEducationDirectionQualification == academicPlan.EducationDirection.Qualification)).Select(x => x.Entity)); + } + foreach (var timeNorm in timeNorms) + { + decimal planHours = 1; + if (timeNorm.KindOfLoadBlueAsteriskAttributeName.IsNotEmpty()) + { + if (!hour.Hours.ContainsKey(timeNorm.KindOfLoadBlueAsteriskAttributeName)) + { + return OperationResultModel.Error("ошибка", + $"Не найдена атрибут {timeNorm.KindOfLoadBlueAsteriskAttributeName} по дисциплине с кодом {plxModel.Discipline.Code}", ResultServiceStatusCode.NotFound); + } + planHours = Math.Abs(hour.Hours[timeNorm.KindOfLoadBlueAsteriskAttributeName]); + } + + var recordelement = context.AcademicPlanRecordTimeNormHours.FirstOrDefault(apre => + apre.AcademicPlanRecordId == record.Id && + apre.TimeNormId == timeNorm.Id); + + if (recordelement == null) + { + context.AcademicPlanRecordTimeNormHours.Add(new AcademicPlanRecordTimeNormHour + { + AcademicPlanRecordId = record.Id, + TimeNormId = timeNorm.Id, + PlanHours = planHours + }); + } + else + { + if (recordelement.IsDeleted) + { + recordelement.IsDeleted = false; + recordelement.DateDelete = null; + } + recordelement.PlanHours = planHours; + } + context.SaveChanges(); + } + } + #endregion + } + } + #endregion + } + transaction.Commit(); + return result; + } + catch (Exception ex) + { + transaction.Rollback(); + return OperationResultModel.Error(ex, ResultServiceStatusCode.Error); + } + } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskBlockType.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskBlockType.cs new file mode 100644 index 0000000..9b42b36 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskBlockType.cs @@ -0,0 +1,18 @@ +namespace DepartmentDatabaseImplementation.Models +{ + /// + /// Вспомогательный класс для загрузки учебных планов по синей звездочке + /// Фиксирует к какому циклу относится дисциплина + /// На данный момент нужна для отсеивания факультативов + /// + public class BlueAsteriskBlockType + { + public string BlockName { get; set; } + + public string Identificator { get; set; } + + public string Code { get; set; } + + public bool IsFacultative { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskNewHour.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskNewHour.cs new file mode 100644 index 0000000..629d5b7 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/BlueAsteriskNewHour.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace DepartmentDatabaseImplementation.Models +{ + public class BlueAsteriskNewHour + { + public int Kurs { get; set; } + + public int Semester { get; set; } + + public string ObjectCode { get; set; } + + public string TypeNormCode { get; set; } + + public Dictionary TimeNorms { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/ParsPlxModel.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/ParsPlxModel.cs new file mode 100644 index 0000000..7d34d67 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Models/ParsPlxModel.cs @@ -0,0 +1,35 @@ +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Enums; +using System; +using System.Collections.Generic; +using System.Xml; + +namespace DepartmentDatabaseImplementation.Models +{ + /// + /// Данные для разбора plx-файла с планом + /// + public class ParsPlxModel + { + public Guid AcademicPlanId { get; set; } + + public XmlNode Node { get; set; } + + public List<(string TypeName, string Code)> DisicplineTypes { get; set; } + + public List BlockTypes { get; set; } + + public List<(string Code, DisciplineBlock Entity)> DisciplineBlocks { get; set; } + + public (string Code, string Practic, Discipline Entity) Discipline { get; set; } + + public List<(string Code, string Practic, Discipline Entity)> Disciplines { get; set; } + + public List<(string Code, TimeNorm Entity)> TimeNorms { get; set; } + + public List<(string Code, TimeNorm Entity)> Practics { get; set; } + + public List<(string DisciplineCode, string TimeNormCode, Semester Semester, TimeNorm Entity, Dictionary Hours)> Hours { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowsDesktop.csproj b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowsDesktop.csproj index cfe8c8b..8190248 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowsDesktop.csproj +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowsDesktop.csproj @@ -7,6 +7,7 @@ + diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanElement.cs index 8424118..55c8198 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanElement.cs @@ -2,9 +2,12 @@ using DepartmentBusinessLogic.BusinessLogics; using DepartmentBusinessLogic.ViewModels; using DesktopTools.Controls; +using DesktopTools.Helpers; using DesktopTools.Interfaces; using DesktopTools.Models; using System; +using System.Collections.Generic; +using System.Windows.Forms; namespace DepartmentWindowsDesktop.EntityControls { @@ -25,6 +28,42 @@ namespace DepartmentWindowsDesktop.EntityControls public IControl GetInstanceGenericControl() => new ControlAcademicPlanElement() { ControlId = Guid.NewGuid() }; - public ControlViewEntityElementConfiguration GetConfigControl() => new(); + public ControlViewEntityElementConfiguration GetConfigControl() => new() + { + ControlOnMoveElem = new Dictionary + { + { "ToolStripMenuItemLoadPlan", ("Загрузить план", (object sender, EventArgs e) => { LoadPlx(); }) } + } + }; + + /// + /// Загрузка учебного плана + /// + private void LoadPlx() + { + if (_element != null) + { + var dialog = new OpenFileDialog + { + Filter = "plx|*.plx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + var result = _businessLogic.LoadPlx(new AcademicPlanLoadPlxModel + { + AcademicPlanId = _element.Id, + FileName = dialog.FileName + }); + if (result) + { + DialogHelper.MessageInformation("Загрузка прошла успешно", "Результат"); + } + else + { + DialogHelper.MessageException(_businessLogic.Errors, $"Ошибки при загрузке плана"); + } + } + } + } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanList.cs index a862058..d01d348 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanList.cs @@ -3,11 +3,13 @@ using DepartmentBusinessLogic.BusinessLogics; using DepartmentBusinessLogic.ViewModels; using DesktopTools.Controls; using DesktopTools.Enums; +using DesktopTools.Helpers; using DesktopTools.Interfaces; using DesktopTools.Models; using ModuleTools.Enums; using System; using System.Collections.Generic; +using System.Windows.Forms; namespace DepartmentWindowsDesktop.EntityControls { @@ -21,7 +23,7 @@ namespace DepartmentWindowsDesktop.EntityControls public ControlAcademicPlanList() { InitializeComponent(); - Title = "Учебнве планы"; + Title = "Учебные планы"; ControlId = new Guid("144d098c-ff55-4786-ae63-3105a92990cd"); AccessOperation = AccessOperation.УчебныеПланы; ControlViewEntityElement = new ControlAcademicPlanElement(); @@ -36,7 +38,44 @@ namespace DepartmentWindowsDesktop.EntityControls HideToolStripButton = new List { ToolStripButtonListNames.toolStripButtonSearch + }, + ControlOnMoveElem = new Dictionary + { + { "ToolStripMenuItemLoadPlx", ("Загрузить план", (object sender, EventArgs e) => { LoadPlx(); }) } } }; + + /// + /// Загрузка учебного плана + /// + private void LoadPlx() + { + var ids = GetSelectedIds(); + if (ids.Count != 1) + { + DialogHelper.MessageException("Должна быть выбрана одна запись", $"Ошибка"); + return; + } + var dialog = new OpenFileDialog + { + Filter = "plx|*.plx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + var result = _businessLogic.LoadPlx(new AcademicPlanLoadPlxModel + { + AcademicPlanId = ids[0], + FileName = dialog.FileName + }); + if (result) + { + DialogHelper.MessageInformation("Загрузка прошла успешно", "Результат"); + } + else + { + DialogHelper.MessageException(_businessLogic.Errors, $"Ошибки при загрузке плана"); + } + } + } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlanRecord/ControlAcademicPlanRecordList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlanRecord/ControlAcademicPlanRecordList.cs index 919dc26..b2d7c53 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlanRecord/ControlAcademicPlanRecordList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlanRecord/ControlAcademicPlanRecordList.cs @@ -42,6 +42,7 @@ namespace DepartmentWindowsDesktop.EntityControls Key = x, Value = x.ToString() })?.ToList(), + ParentPropertyName = "Semester", HideToolStripButton = new List { ToolStripButtonListNames.toolStripButtonSearch diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs index 5a705de..8610312 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs @@ -40,6 +40,9 @@ namespace DepartmentWindowsDesktop.EntityControls } }; + /// + /// Поиск пользователя под учетку, либо добавление нового, если не найдено + /// private void AddUser() { var model = new EmployeeSetBindingModel(); diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs index 3cf3b31..16d6534 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs @@ -37,6 +37,9 @@ namespace DepartmentWindowsDesktop.EntityControls } }; + /// + /// Поиск пользователя под учетку, либо добавление нового, если не найдено + /// private void AddUser() { var model = new LecturerSetBindingModel();