Готово

This commit is contained in:
maxnes3 2023-05-05 22:16:51 +04:00
parent c66fb80196
commit cd4ced4d54
20 changed files with 522 additions and 223 deletions

View File

@ -20,6 +20,11 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics
_dealStorage = dealStorage ?? throw new ArgumentNullException(nameof(dealStorage)); _dealStorage = dealStorage ?? throw new ArgumentNullException(nameof(dealStorage));
} }
public bool ClearList()
{
return _dealStorage.ClearList();
}
public bool Create(DealBindingModel model) public bool Create(DealBindingModel model)
{ {
CheckModel(model); CheckModel(model);
@ -40,6 +45,16 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics
return true; 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) public DealViewModel? ReadElement(DealSearchModel model)
{ {
if (model == null) if (model == null)
@ -64,6 +79,11 @@ namespace PersonnelDepartmentBusinessLogic.BusinessLogics
return list; return list;
} }
public string SetTest(int count)
{
return _dealStorage.SetTest(count);
}
public bool Update(DealBindingModel model) public bool Update(DealBindingModel model)
{ {
CheckModel(model); CheckModel(model);

View File

@ -16,5 +16,9 @@ namespace PersonnelDepartmentContracts.BusinessLogicContracts
bool Create(DealBindingModel model); bool Create(DealBindingModel model);
bool Update(DealBindingModel model); bool Update(DealBindingModel model);
bool Delete(DealBindingModel model); bool Delete(DealBindingModel model);
string SetTest(int count);
string GetTest(int count);
string DiffGetTest(int count);
bool ClearList();
} }
} }

View File

@ -17,5 +17,9 @@ namespace PersonnelDepartmentContracts.StoragesContracts
DealViewModel? Insert(DealBindingModel model); DealViewModel? Insert(DealBindingModel model);
DealViewModel? Update(DealBindingModel model); DealViewModel? Update(DealBindingModel model);
DealViewModel? Delete(DealBindingModel model); DealViewModel? Delete(DealBindingModel model);
string SetTest(int count);
string GetTest(int count);
string DiffGetTest(int count);
bool ClearList();
} }
} }

View File

@ -1,4 +1,6 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using PersonnelDepartmentContracts.BindingModels; using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.SearchModels; using PersonnelDepartmentContracts.SearchModels;
using PersonnelDepartmentContracts.StoragesContracts; using PersonnelDepartmentContracts.StoragesContracts;
@ -6,6 +8,7 @@ using PersonnelDepartmentContracts.ViewModels;
using PersonnelDepartmentDatabaseImplement.Models; using PersonnelDepartmentDatabaseImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,6 +17,24 @@ namespace PersonnelDepartmentDatabaseImplement.Implements
{ {
public class DealStorage : IDealStorage 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) public DealViewModel? Delete(DealBindingModel model)
{ {
using var context = new PersonnelDepartmentDatabase(); using var context = new PersonnelDepartmentDatabase();
@ -32,6 +53,45 @@ namespace PersonnelDepartmentDatabaseImplement.Implements
return element.GetViewModel; 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) public DealViewModel? GetElement(DealSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue)
@ -83,6 +143,23 @@ namespace PersonnelDepartmentDatabaseImplement.Implements
.ToList(); .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) public DealViewModel? Insert(DealBindingModel model)
{ {
var newElement = Deal.Create(model); var newElement = Deal.Create(model);
@ -96,6 +173,30 @@ namespace PersonnelDepartmentDatabaseImplement.Implements
return GetElement(new DealSearchModel { Id = newElement.Id } ); 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) public DealViewModel? Update(DealBindingModel model)
{ {
using var context = new PersonnelDepartmentDatabase(); using var context = new PersonnelDepartmentDatabase();

View File

@ -1,183 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateFrom")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateTo")
.HasColumnType("timestamp with time zone");
b.Property<int>("DepartmentId")
.HasColumnType("integer");
b.Property<int>("EmployeeId")
.HasColumnType("integer");
b.Property<int>("PositionId")
.HasColumnType("integer");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Telephone")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Positions");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("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
}
}
}

View File

@ -1,34 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class SecMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "Telephone",
table: "Departments",
type: "bigint",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Telephone",
table: "Departments",
type: "integer",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint");
}
}
}

View File

@ -12,8 +12,8 @@ using PersonnelDepartmentDatabaseImplement;
namespace PersonnelDepartmentDatabaseImplement.Migrations namespace PersonnelDepartmentDatabaseImplement.Migrations
{ {
[DbContext(typeof(PersonnelDepartmentDatabase))] [DbContext(typeof(PersonnelDepartmentDatabase))]
[Migration("20230502183034_SecMig")] [Migration("20230505181232_Init")]
partial class SecMig partial class Init
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace PersonnelDepartmentDatabaseImplement.Migrations namespace PersonnelDepartmentDatabaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class InitMig : Migration public partial class Init : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@ -19,7 +19,7 @@ namespace PersonnelDepartmentDatabaseImplement.Migrations
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "text", nullable: false),
Telephone = table.Column<int>(type: "integer", nullable: false) Telephone = table.Column<long>(type: "bigint", nullable: false)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -15,7 +15,7 @@ namespace PersonnelDepartmentDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) 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); base.OnConfiguring(optionsBuilder);
} }

View File

@ -47,6 +47,7 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(230, 186); buttonCancel.Location = new Point(230, 186);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
@ -57,6 +58,7 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.Location = new Point(149, 186); buttonSave.Location = new Point(149, 186);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23); buttonSave.Size = new Size(75, 23);
@ -85,6 +87,7 @@
// //
// dateTimePickerFrom // dateTimePickerFrom
// //
dateTimePickerFrom.Anchor = AnchorStyles.Top | AnchorStyles.Right;
dateTimePickerFrom.Location = new Point(105, 12); dateTimePickerFrom.Location = new Point(105, 12);
dateTimePickerFrom.Name = "dateTimePickerFrom"; dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(200, 23); dateTimePickerFrom.Size = new Size(200, 23);
@ -92,6 +95,7 @@
// //
// dateTimePickerTo // dateTimePickerTo
// //
dateTimePickerTo.Anchor = AnchorStyles.Top | AnchorStyles.Right;
dateTimePickerTo.Location = new Point(105, 41); dateTimePickerTo.Location = new Point(105, 41);
dateTimePickerTo.Name = "dateTimePickerTo"; dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(200, 23); dateTimePickerTo.Size = new Size(200, 23);
@ -108,6 +112,7 @@
// //
// comboBoxType // comboBoxType
// //
comboBoxType.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxType.FormattingEnabled = true; comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(105, 70); comboBoxType.Location = new Point(105, 70);
comboBoxType.Name = "comboBoxType"; comboBoxType.Name = "comboBoxType";
@ -124,6 +129,7 @@
// //
// comboBoxEmployee // comboBoxEmployee
// //
comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxEmployee.FormattingEnabled = true; comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(105, 99); comboBoxEmployee.Location = new Point(105, 99);
comboBoxEmployee.Name = "comboBoxEmployee"; comboBoxEmployee.Name = "comboBoxEmployee";
@ -141,6 +147,7 @@
// //
// comboBoxDepartment // comboBoxDepartment
// //
comboBoxDepartment.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxDepartment.FormattingEnabled = true; comboBoxDepartment.FormattingEnabled = true;
comboBoxDepartment.Location = new Point(105, 128); comboBoxDepartment.Location = new Point(105, 128);
comboBoxDepartment.Name = "comboBoxDepartment"; comboBoxDepartment.Name = "comboBoxDepartment";
@ -158,6 +165,7 @@
// //
// comboBoxPosition // comboBoxPosition
// //
comboBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxPosition.FormattingEnabled = true; comboBoxPosition.FormattingEnabled = true;
comboBoxPosition.Location = new Point(105, 157); comboBoxPosition.Location = new Point(105, 157);
comboBoxPosition.Name = "comboBoxPosition"; comboBoxPosition.Name = "comboBoxPosition";

View File

@ -37,11 +37,14 @@
buttonEmployee = new Button(); buttonEmployee = new Button();
buttonPosition = new Button(); buttonPosition = new Button();
buttonType = new Button(); buttonType = new Button();
buttonGenerate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// dataGridView // dataGridView
// //
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 41); dataGridView.Location = new Point(12, 41);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
@ -51,6 +54,7 @@
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Anchor = AnchorStyles.Top;
buttonAdd.Location = new Point(12, 12); buttonAdd.Location = new Point(12, 12);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23); buttonAdd.Size = new Size(75, 23);
@ -61,6 +65,7 @@
// //
// buttonChange // buttonChange
// //
buttonChange.Anchor = AnchorStyles.Top;
buttonChange.Location = new Point(93, 12); buttonChange.Location = new Point(93, 12);
buttonChange.Name = "buttonChange"; buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23); buttonChange.Size = new Size(75, 23);
@ -71,6 +76,7 @@
// //
// buttonDelete // buttonDelete
// //
buttonDelete.Anchor = AnchorStyles.Top;
buttonDelete.Location = new Point(174, 12); buttonDelete.Location = new Point(174, 12);
buttonDelete.Name = "buttonDelete"; buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23); buttonDelete.Size = new Size(75, 23);
@ -81,6 +87,7 @@
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Anchor = AnchorStyles.Top;
buttonUpdate.Location = new Point(255, 12); buttonUpdate.Location = new Point(255, 12);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23); buttonUpdate.Size = new Size(75, 23);
@ -91,6 +98,7 @@
// //
// buttonDepartment // buttonDepartment
// //
buttonDepartment.Anchor = AnchorStyles.Top;
buttonDepartment.Location = new Point(336, 12); buttonDepartment.Location = new Point(336, 12);
buttonDepartment.Name = "buttonDepartment"; buttonDepartment.Name = "buttonDepartment";
buttonDepartment.Size = new Size(128, 23); buttonDepartment.Size = new Size(128, 23);
@ -101,6 +109,7 @@
// //
// buttonEmployee // buttonEmployee
// //
buttonEmployee.Anchor = AnchorStyles.Top;
buttonEmployee.Location = new Point(470, 12); buttonEmployee.Location = new Point(470, 12);
buttonEmployee.Name = "buttonEmployee"; buttonEmployee.Name = "buttonEmployee";
buttonEmployee.Size = new Size(152, 23); buttonEmployee.Size = new Size(152, 23);
@ -111,6 +120,7 @@
// //
// buttonPosition // buttonPosition
// //
buttonPosition.Anchor = AnchorStyles.Top;
buttonPosition.Location = new Point(628, 12); buttonPosition.Location = new Point(628, 12);
buttonPosition.Name = "buttonPosition"; buttonPosition.Name = "buttonPosition";
buttonPosition.Size = new Size(149, 23); buttonPosition.Size = new Size(149, 23);
@ -121,6 +131,7 @@
// //
// buttonType // buttonType
// //
buttonType.Anchor = AnchorStyles.Top;
buttonType.Location = new Point(783, 12); buttonType.Location = new Point(783, 12);
buttonType.Name = "buttonType"; buttonType.Name = "buttonType";
buttonType.Size = new Size(117, 23); buttonType.Size = new Size(117, 23);
@ -129,11 +140,24 @@
buttonType.UseVisualStyleBackColor = true; buttonType.UseVisualStyleBackColor = true;
buttonType.Click += ButtonType_Click; 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 // FormDeals
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 422); BackColor = SystemColors.Control;
ClientSize = new Size(914, 446);
Controls.Add(buttonGenerate);
Controls.Add(buttonType); Controls.Add(buttonType);
Controls.Add(buttonPosition); Controls.Add(buttonPosition);
Controls.Add(buttonEmployee); Controls.Add(buttonEmployee);
@ -162,5 +186,6 @@
private Button buttonEmployee; private Button buttonEmployee;
private Button buttonPosition; private Button buttonPosition;
private Button buttonType; private Button buttonType;
private Button buttonGenerate;
} }
} }

View File

@ -139,5 +139,14 @@ namespace PersonnelDepartmentView
{ {
LoadData(); LoadData();
} }
private void ButtonGenerate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGeneration));
if (service is FormGeneration form)
{
form.ShowDialog();
}
}
} }
} }

View File

@ -78,6 +78,8 @@
// //
// dataGridView // dataGridView
// //
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38); dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";

View File

@ -78,6 +78,8 @@
// //
// dataGridView // dataGridView
// //
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38); dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";

View File

@ -0,0 +1,228 @@
namespace PersonnelDepartmentView
{
partial class FormGeneration
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
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;
}
}

View File

@ -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);
}
}
}

View File

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

View File

@ -78,6 +78,8 @@
// //
// dataGridView // dataGridView
// //
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38); dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";

View File

@ -78,6 +78,8 @@
// //
// dataGridView // dataGridView
// //
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38); dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";

View File

@ -51,6 +51,7 @@ namespace PersonnelDepartmentView
services.AddTransient<FormPositions>(); services.AddTransient<FormPositions>();
services.AddTransient<FormType>(); services.AddTransient<FormType>();
services.AddTransient<FormTypes>(); services.AddTransient<FormTypes>();
services.AddTransient<FormGeneration>();
} }
} }
} }