diff --git a/PersonnelDepartmentView/PersonnelDepartmentBusinessLogic/BusinessLogics/DealLogic.cs b/PersonnelDepartmentView/PersonnelDepartmentBusinessLogic/BusinessLogics/DealLogic.cs index 2260055..b2d139c 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentBusinessLogic/BusinessLogics/DealLogic.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentBusinessLogic/BusinessLogics/DealLogic.cs @@ -20,6 +20,11 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics _dealStorage = dealStorage ?? throw new ArgumentNullException(nameof(dealStorage)); } + public bool ClearList() + { + return _dealStorage.ClearList(); + } + public bool Create(DealBindingModel model) { CheckModel(model); @@ -40,6 +45,16 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics return true; } + public string DiffGetTest(int count) + { + return _dealStorage.DiffGetTest(count); + } + + public string GetTest(int count) + { + return _dealStorage.GetTest(count); + } + public DealViewModel? ReadElement(DealSearchModel model) { if (model == null) @@ -64,6 +79,11 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics return list; } + public string SetTest(int count) + { + return _dealStorage.SetTest(count); + } + public bool Update(DealBindingModel model) { CheckModel(model); diff --git a/PersonnelDepartmentView/PersonnelDepartmentContracts/BusinessLogicContracts/IDealLogic.cs b/PersonnelDepartmentView/PersonnelDepartmentContracts/BusinessLogicContracts/IDealLogic.cs index 2666977..3f49d1a 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentContracts/BusinessLogicContracts/IDealLogic.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentContracts/BusinessLogicContracts/IDealLogic.cs @@ -16,5 +16,9 @@ namespace PersonnelDepartmentContracts.BusinessLogicContracts bool Create(DealBindingModel model); bool Update(DealBindingModel model); bool Delete(DealBindingModel model); + string SetTest(int count); + string GetTest(int count); + string DiffGetTest(int count); + bool ClearList(); } } diff --git a/PersonnelDepartmentView/PersonnelDepartmentContracts/StoragesContracts/IDealStorage.cs b/PersonnelDepartmentView/PersonnelDepartmentContracts/StoragesContracts/IDealStorage.cs index 9428b61..07c864f 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentContracts/StoragesContracts/IDealStorage.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentContracts/StoragesContracts/IDealStorage.cs @@ -17,5 +17,9 @@ namespace PersonnelDepartmentContracts.StoragesContracts DealViewModel? Insert(DealBindingModel model); DealViewModel? Update(DealBindingModel model); DealViewModel? Delete(DealBindingModel model); + string SetTest(int count); + string GetTest(int count); + string DiffGetTest(int count); + bool ClearList(); } } diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs index 7892d0d..b9ab0da 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs @@ -1,4 +1,6 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using PersonnelDepartmentContracts.BindingModels; using PersonnelDepartmentContracts.SearchModels; using PersonnelDepartmentContracts.StoragesContracts; @@ -6,6 +8,7 @@ using PersonnelDepartmentContracts.ViewModels; using PersonnelDepartmentDatabaseImplement.Models; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,6 +17,24 @@ namespace PersonnelDepartmentDatabaseImplement.Implements { public class DealStorage : IDealStorage { + public bool ClearList() + { + try + { + using var context = new PersonnelDepartmentDatabase(); + /*var list = context.Deals.ToList(); + context.Deals.RemoveRange(list); + context.SaveChanges();*/ + var tableName = context.Model.FindEntityType(typeof(Deal)).GetTableName(); + context.Database.ExecuteSqlRaw($"DELETE FROM \"{ tableName }\""); + } + catch (Exception) + { + return false; + } + return true; + } + public DealViewModel? Delete(DealBindingModel model) { using var context = new PersonnelDepartmentDatabase(); @@ -32,6 +53,45 @@ namespace PersonnelDepartmentDatabaseImplement.Implements return element.GetViewModel; } + public string DiffGetTest(int count) + { + using var context = new PersonnelDepartmentDatabase(); + Stopwatch stopwatch = new(); + stopwatch.Start(); + var list = context.Deals + .Include(x => x.Department) + .Include(x => x.Employee) + .Include(x => x.Type) + .Include(x => x.Position) + .Join(context.Departments, + deal => deal.DepartmentId, + department => department.Id, + (deal, department) => new { Deal = deal, Department = department }) + .Join(context.Employees, + deal => deal.Deal.EmployeeId, + employee => employee.Id, + (deal, employee) => new { deal.Deal, deal.Department, Employee = employee }) + .Join(context.Positions, + deal => deal.Deal.PositionId, + position => position.Id, + (deal, position) => new { deal.Deal, deal.Department, deal.Employee, Position = position }) + .Join(context.Types, + deal => deal.Deal.TypeId, + type => type.Id, + (deal, type) => new { deal.Deal, deal.Department, deal.Employee, deal.Position, Type = type }) + .Select(deal => new + { + Deal = deal.Deal.GetViewModel, + Department = deal.Department.GetViewModel, + Type = deal.Type.GetViewModel, + Position = deal.Position.GetViewModel + }) + .Take(count) + .ToList(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + public DealViewModel? GetElement(DealSearchModel model) { if (!model.Id.HasValue) @@ -83,6 +143,23 @@ namespace PersonnelDepartmentDatabaseImplement.Implements .ToList(); } + public string GetTest(int count) + { + using var context = new PersonnelDepartmentDatabase(); + Stopwatch stopwatch = new(); + stopwatch.Start(); + var list = context.Deals + .Include(x => x.Department) + .Include(x => x.Employee) + .Include(x => x.Type) + .Include(x => x.Position) + .Take(count) + .Select(x => x.GetViewModel) + .ToList(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + public DealViewModel? Insert(DealBindingModel model) { var newElement = Deal.Create(model); @@ -96,6 +173,30 @@ namespace PersonnelDepartmentDatabaseImplement.Implements return GetElement(new DealSearchModel { Id = newElement.Id } ); } + public string SetTest(int count) + { + Random rnd = new Random(); + using var context = new PersonnelDepartmentDatabase(); + for (int i = 0; i < count; ++i) + { + context.Deals.Add(Deal.Create(new DealBindingModel + { + Id = 0, + DateFrom = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), + DepartmentId = 1, + EmployeeId = 1, + TypeId = 1, + PositionId = 1 + })); + } + Stopwatch stopwatch = new(); + stopwatch.Start(); + context.SaveChanges(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + public DealViewModel? Update(DealBindingModel model) { using var context = new PersonnelDepartmentDatabase(); diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.Designer.cs deleted file mode 100644 index 18d0857..0000000 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.Designer.cs +++ /dev/null @@ -1,183 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using PersonnelDepartmentDatabaseImplement; - -#nullable disable - -namespace PersonnelDepartmentDatabaseImplement.Migrations -{ - [DbContext(typeof(PersonnelDepartmentDatabase))] - [Migration("20230502180408_InitMig")] - partial class InitMig - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DateFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("DateTo") - .HasColumnType("timestamp with time zone"); - - b.Property("DepartmentId") - .HasColumnType("integer"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("PositionId") - .HasColumnType("integer"); - - b.Property("TypeId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("DepartmentId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("PositionId"); - - b.HasIndex("TypeId"); - - b.ToTable("Deals"); - }); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Telephone") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Departments"); - }); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("Patronymic") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Employees"); - }); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Positions"); - }); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Types"); - }); - - modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => - { - b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department") - .WithMany() - .HasForeignKey("DepartmentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position") - .WithMany() - .HasForeignKey("PositionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Department"); - - b.Navigation("Employee"); - - b.Navigation("Position"); - - b.Navigation("Type"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.cs deleted file mode 100644 index 13622bf..0000000 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PersonnelDepartmentDatabaseImplement.Migrations -{ - /// - public partial class SecMig : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Telephone", - table: "Departments", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Telephone", - table: "Departments", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - } - } -} diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.Designer.cs similarity index 98% rename from PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.Designer.cs rename to PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.Designer.cs index a973736..84092ea 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502183034_SecMig.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.Designer.cs @@ -12,8 +12,8 @@ using PersonnelDepartmentDatabaseImplement; namespace PersonnelDepartmentDatabaseImplement.Migrations { [DbContext(typeof(PersonnelDepartmentDatabase))] - [Migration("20230502183034_SecMig")] - partial class SecMig + [Migration("20230505181232_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.cs similarity index 98% rename from PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.cs rename to PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.cs index f454544..7981f21 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230502180408_InitMig.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Migrations/20230505181232_Init.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace PersonnelDepartmentDatabaseImplement.Migrations { /// - public partial class InitMig : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -19,7 +19,7 @@ namespace PersonnelDepartmentDatabaseImplement.Migrations Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), - Telephone = table.Column(type: "integer", nullable: false) + Telephone = table.Column(type: "bigint", nullable: false) }, constraints: table => { diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/PersonnelDepartmentDatabase.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/PersonnelDepartmentDatabase.cs index 43e2b16..b26827b 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/PersonnelDepartmentDatabase.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/PersonnelDepartmentDatabase.cs @@ -15,7 +15,7 @@ namespace PersonnelDepartmentDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=PersonnelDepartment;Username=postgres;Password=adam200396789"); + optionsBuilder.UseNpgsql(@"Host=192.168.0.102;Port=5432;Database=PersonnelDepartment;Username=postgres;Password=postgres"); } base.OnConfiguring(optionsBuilder); } diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeal.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeal.Designer.cs index 4315b45..1d5d725 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeal.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeal.Designer.cs @@ -47,6 +47,7 @@ // // buttonCancel // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Location = new Point(230, 186); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(75, 23); @@ -57,6 +58,7 @@ // // buttonSave // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonSave.Location = new Point(149, 186); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(75, 23); @@ -85,6 +87,7 @@ // // dateTimePickerFrom // + dateTimePickerFrom.Anchor = AnchorStyles.Top | AnchorStyles.Right; dateTimePickerFrom.Location = new Point(105, 12); dateTimePickerFrom.Name = "dateTimePickerFrom"; dateTimePickerFrom.Size = new Size(200, 23); @@ -92,6 +95,7 @@ // // dateTimePickerTo // + dateTimePickerTo.Anchor = AnchorStyles.Top | AnchorStyles.Right; dateTimePickerTo.Location = new Point(105, 41); dateTimePickerTo.Name = "dateTimePickerTo"; dateTimePickerTo.Size = new Size(200, 23); @@ -108,6 +112,7 @@ // // comboBoxType // + comboBoxType.Anchor = AnchorStyles.Top | AnchorStyles.Right; comboBoxType.FormattingEnabled = true; comboBoxType.Location = new Point(105, 70); comboBoxType.Name = "comboBoxType"; @@ -124,6 +129,7 @@ // // comboBoxEmployee // + comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Right; comboBoxEmployee.FormattingEnabled = true; comboBoxEmployee.Location = new Point(105, 99); comboBoxEmployee.Name = "comboBoxEmployee"; @@ -141,6 +147,7 @@ // // comboBoxDepartment // + comboBoxDepartment.Anchor = AnchorStyles.Top | AnchorStyles.Right; comboBoxDepartment.FormattingEnabled = true; comboBoxDepartment.Location = new Point(105, 128); comboBoxDepartment.Name = "comboBoxDepartment"; @@ -158,6 +165,7 @@ // // comboBoxPosition // + comboBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Right; comboBoxPosition.FormattingEnabled = true; comboBoxPosition.Location = new Point(105, 157); comboBoxPosition.Name = "comboBoxPosition"; diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.Designer.cs index aa31200..d26c542 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.Designer.cs @@ -37,11 +37,14 @@ buttonEmployee = new Button(); buttonPosition = new Button(); buttonType = new Button(); + buttonGenerate = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.DarkSeaGreen; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Location = new Point(12, 41); dataGridView.Name = "dataGridView"; @@ -51,6 +54,7 @@ // // buttonAdd // + buttonAdd.Anchor = AnchorStyles.Top; buttonAdd.Location = new Point(12, 12); buttonAdd.Name = "buttonAdd"; buttonAdd.Size = new Size(75, 23); @@ -61,6 +65,7 @@ // // buttonChange // + buttonChange.Anchor = AnchorStyles.Top; buttonChange.Location = new Point(93, 12); buttonChange.Name = "buttonChange"; buttonChange.Size = new Size(75, 23); @@ -71,6 +76,7 @@ // // buttonDelete // + buttonDelete.Anchor = AnchorStyles.Top; buttonDelete.Location = new Point(174, 12); buttonDelete.Name = "buttonDelete"; buttonDelete.Size = new Size(75, 23); @@ -81,6 +87,7 @@ // // buttonUpdate // + buttonUpdate.Anchor = AnchorStyles.Top; buttonUpdate.Location = new Point(255, 12); buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Size = new Size(75, 23); @@ -91,6 +98,7 @@ // // buttonDepartment // + buttonDepartment.Anchor = AnchorStyles.Top; buttonDepartment.Location = new Point(336, 12); buttonDepartment.Name = "buttonDepartment"; buttonDepartment.Size = new Size(128, 23); @@ -101,6 +109,7 @@ // // buttonEmployee // + buttonEmployee.Anchor = AnchorStyles.Top; buttonEmployee.Location = new Point(470, 12); buttonEmployee.Name = "buttonEmployee"; buttonEmployee.Size = new Size(152, 23); @@ -111,6 +120,7 @@ // // buttonPosition // + buttonPosition.Anchor = AnchorStyles.Top; buttonPosition.Location = new Point(628, 12); buttonPosition.Name = "buttonPosition"; buttonPosition.Size = new Size(149, 23); @@ -121,6 +131,7 @@ // // buttonType // + buttonType.Anchor = AnchorStyles.Top; buttonType.Location = new Point(783, 12); buttonType.Name = "buttonType"; buttonType.Size = new Size(117, 23); @@ -129,11 +140,24 @@ buttonType.UseVisualStyleBackColor = true; buttonType.Click += ButtonType_Click; // + // buttonGenerate + // + buttonGenerate.Anchor = AnchorStyles.Bottom; + buttonGenerate.Location = new Point(391, 415); + buttonGenerate.Name = "buttonGenerate"; + buttonGenerate.Size = new Size(163, 23); + buttonGenerate.TabIndex = 9; + buttonGenerate.Text = "Сгенерировать сущности"; + buttonGenerate.UseVisualStyleBackColor = true; + buttonGenerate.Click += ButtonGenerate_Click; + // // FormDeals // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(914, 422); + BackColor = SystemColors.Control; + ClientSize = new Size(914, 446); + Controls.Add(buttonGenerate); Controls.Add(buttonType); Controls.Add(buttonPosition); Controls.Add(buttonEmployee); @@ -162,5 +186,6 @@ private Button buttonEmployee; private Button buttonPosition; private Button buttonType; + private Button buttonGenerate; } } \ No newline at end of file diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.cs index cdc010f..c736fd2 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormDeals.cs @@ -139,5 +139,14 @@ namespace PersonnelDepartmentView { LoadData(); } + + private void ButtonGenerate_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormGeneration)); + if (service is FormGeneration form) + { + form.ShowDialog(); + } + } } } \ No newline at end of file diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormDepartments.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormDepartments.Designer.cs index 31c1c65..cb8ca0b 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormDepartments.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormDepartments.Designer.cs @@ -78,6 +78,8 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.DarkSeaGreen; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Location = new Point(12, 38); dataGridView.Name = "dataGridView"; diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormEmployees.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormEmployees.Designer.cs index 6a0aaec..7f47834 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormEmployees.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormEmployees.Designer.cs @@ -78,6 +78,8 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.DarkSeaGreen; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Location = new Point(12, 38); dataGridView.Name = "dataGridView"; diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs new file mode 100644 index 0000000..caec92e --- /dev/null +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs @@ -0,0 +1,228 @@ +namespace PersonnelDepartmentView +{ + partial class FormGeneration + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBox1 = new GroupBox(); + textBoxGet = new TextBox(); + numericGet = new NumericUpDown(); + buttonGetTest = new Button(); + groupBox2 = new GroupBox(); + textBoxDiffGet = new TextBox(); + numericDiffGet = new NumericUpDown(); + buttonDiffGetTest = new Button(); + groupBox3 = new GroupBox(); + textBoxSet = new TextBox(); + numericSet = new NumericUpDown(); + buttonSetTest = new Button(); + buttonClear = new Button(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericGet).BeginInit(); + groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericDiffGet).BeginInit(); + groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericSet).BeginInit(); + SuspendLayout(); + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(textBoxGet); + groupBox1.Controls.Add(numericGet); + groupBox1.Controls.Add(buttonGetTest); + groupBox1.Location = new Point(12, 12); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(470, 93); + groupBox1.TabIndex = 0; + groupBox1.TabStop = false; + groupBox1.Text = "Тест обычного запроса:"; + // + // textBoxGet + // + textBoxGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + textBoxGet.Location = new Point(221, 51); + textBoxGet.Name = "textBoxGet"; + textBoxGet.ReadOnly = true; + textBoxGet.Size = new Size(243, 23); + textBoxGet.TabIndex = 2; + // + // numericGet + // + numericGet.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericGet.Location = new Point(221, 22); + numericGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericGet.Name = "numericGet"; + numericGet.Size = new Size(243, 23); + numericGet.TabIndex = 1; + // + // buttonGetTest + // + buttonGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right; + buttonGetTest.Location = new Point(6, 22); + buttonGetTest.Name = "buttonGetTest"; + buttonGetTest.Size = new Size(209, 52); + buttonGetTest.TabIndex = 0; + buttonGetTest.Text = "GetTest"; + buttonGetTest.UseVisualStyleBackColor = true; + buttonGetTest.Click += ButtonGetTest_Click; + // + // groupBox2 + // + groupBox2.Anchor = AnchorStyles.Left | AnchorStyles.Right; + groupBox2.Controls.Add(textBoxDiffGet); + groupBox2.Controls.Add(numericDiffGet); + groupBox2.Controls.Add(buttonDiffGetTest); + groupBox2.Location = new Point(12, 111); + groupBox2.Name = "groupBox2"; + groupBox2.Size = new Size(470, 93); + groupBox2.TabIndex = 1; + groupBox2.TabStop = false; + groupBox2.Text = "Тест сложного запроса:"; + // + // textBoxDiffGet + // + textBoxDiffGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + textBoxDiffGet.Location = new Point(221, 51); + textBoxDiffGet.Name = "textBoxDiffGet"; + textBoxDiffGet.ReadOnly = true; + textBoxDiffGet.Size = new Size(243, 23); + textBoxDiffGet.TabIndex = 2; + // + // numericDiffGet + // + numericDiffGet.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericDiffGet.Location = new Point(221, 22); + numericDiffGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericDiffGet.Name = "numericDiffGet"; + numericDiffGet.Size = new Size(243, 23); + numericDiffGet.TabIndex = 1; + // + // buttonDiffGetTest + // + buttonDiffGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right; + buttonDiffGetTest.Location = new Point(6, 22); + buttonDiffGetTest.Name = "buttonDiffGetTest"; + buttonDiffGetTest.Size = new Size(209, 52); + buttonDiffGetTest.TabIndex = 0; + buttonDiffGetTest.Text = "GetDiffTest"; + buttonDiffGetTest.UseVisualStyleBackColor = true; + buttonDiffGetTest.Click += ButtonDiffGetTest_Click; + // + // groupBox3 + // + groupBox3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox3.Controls.Add(textBoxSet); + groupBox3.Controls.Add(numericSet); + groupBox3.Controls.Add(buttonSetTest); + groupBox3.Location = new Point(12, 210); + groupBox3.Name = "groupBox3"; + groupBox3.Size = new Size(470, 93); + groupBox3.TabIndex = 3; + groupBox3.TabStop = false; + groupBox3.Text = "Тест на заполнение:"; + // + // textBoxSet + // + textBoxSet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + textBoxSet.Location = new Point(221, 51); + textBoxSet.Name = "textBoxSet"; + textBoxSet.ReadOnly = true; + textBoxSet.Size = new Size(243, 23); + textBoxSet.TabIndex = 2; + // + // numericSet + // + numericSet.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericSet.Location = new Point(221, 22); + numericSet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericSet.Name = "numericSet"; + numericSet.Size = new Size(243, 23); + numericSet.TabIndex = 1; + // + // buttonSetTest + // + buttonSetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right; + buttonSetTest.Location = new Point(6, 22); + buttonSetTest.Name = "buttonSetTest"; + buttonSetTest.Size = new Size(209, 52); + buttonSetTest.TabIndex = 0; + buttonSetTest.Text = "SetTest"; + buttonSetTest.UseVisualStyleBackColor = true; + buttonSetTest.Click += ButtonSetTest_Click; + // + // buttonClear + // + buttonClear.Anchor = AnchorStyles.Bottom; + buttonClear.Location = new Point(149, 309); + buttonClear.Name = "buttonClear"; + buttonClear.Size = new Size(162, 23); + buttonClear.TabIndex = 4; + buttonClear.Text = "Очистить сущность"; + buttonClear.UseVisualStyleBackColor = true; + buttonClear.Click += ButtonClear_Click; + // + // FormGeneration + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(493, 344); + Controls.Add(buttonClear); + Controls.Add(groupBox3); + Controls.Add(groupBox2); + Controls.Add(groupBox1); + Name = "FormGeneration"; + Text = "FormGeneration"; + groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericGet).EndInit(); + groupBox2.ResumeLayout(false); + groupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericDiffGet).EndInit(); + groupBox3.ResumeLayout(false); + groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericSet).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBox1; + private TextBox textBoxGet; + private NumericUpDown numericGet; + private Button buttonGetTest; + private GroupBox groupBox2; + private TextBox textBoxDiffGet; + private NumericUpDown numericDiffGet; + private Button buttonDiffGetTest; + private GroupBox groupBox3; + private TextBox textBoxSet; + private NumericUpDown numericSet; + private Button buttonSetTest; + private Button buttonClear; + } +} \ No newline at end of file diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.cs new file mode 100644 index 0000000..5f37982 --- /dev/null +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.cs @@ -0,0 +1,48 @@ +using PersonnelDepartmentContracts.BusinessLogicContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PersonnelDepartmentView +{ + public partial class FormGeneration : Form + { + private readonly IDealLogic _dealLogic; + public FormGeneration(IDealLogic dealLogic) + { + InitializeComponent(); + _dealLogic = dealLogic; + } + + private void ButtonGetTest_Click(object sender, EventArgs e) + { + textBoxGet.Text = _dealLogic.GetTest(Convert.ToInt32(numericGet.Value)) + "мс"; + } + + private void ButtonDiffGetTest_Click(object sender, EventArgs e) + { + textBoxDiffGet.Text = _dealLogic.DiffGetTest(Convert.ToInt32(numericDiffGet.Value)) + "мс"; + } + + private void ButtonSetTest_Click(object sender, EventArgs e) + { + textBoxSet.Text = _dealLogic.SetTest(Convert.ToInt32(numericSet.Value)) + "мс"; + } + + private void ButtonClear_Click(object sender, EventArgs e) + { + if (_dealLogic.ClearList()) + { + MessageBox.Show("Удаление записей завершено", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + MessageBox.Show("Удаление записей провалилось", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.resx b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/PersonnelDepartmentView/PersonnelDepartmentView/FormPositions.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormPositions.Designer.cs index 8aeab07..32f23ba 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormPositions.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormPositions.Designer.cs @@ -78,6 +78,8 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.DarkSeaGreen; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Location = new Point(12, 38); dataGridView.Name = "dataGridView"; diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormTypes.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormTypes.Designer.cs index 128d21f..dc89524 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormTypes.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormTypes.Designer.cs @@ -78,6 +78,8 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.DarkSeaGreen; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Location = new Point(12, 38); dataGridView.Name = "dataGridView"; diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/Program.cs b/PersonnelDepartmentView/PersonnelDepartmentView/Program.cs index cab0296..deab47a 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/Program.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/Program.cs @@ -51,6 +51,7 @@ namespace PersonnelDepartmentView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file