From 7169347a450cfb1317e4a0ce7776dbc2f304b52b Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Fri, 5 May 2023 22:38:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=20=D0=B2?= =?UTF-8?q?=20=D0=BD=D0=BE=D1=80=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC?= =?UTF-8?q?=20=D0=B2=D0=B8=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/DealStorage.cs | 16 ++++++++++++---- .../FormGeneration.Designer.cs | 13 +++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs index b9ab0da..74adffc 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentDatabaseImplement/Implements/DealStorage.cs @@ -177,6 +177,14 @@ namespace PersonnelDepartmentDatabaseImplement.Implements { Random rnd = new Random(); using var context = new PersonnelDepartmentDatabase(); + var listDepartments = context.Departments.Select(x => x.GetViewModel).ToList(); + var listEmployees = context.Employees.Select(x => x.GetViewModel).ToList(); + var listPositions = context.Positions.Select(x => x.GetViewModel).ToList(); + var listTypes = context.Types.Select(x => x.GetViewModel).ToList(); + if (listDepartments.Count < 1 || listEmployees.Count < 1 || listPositions.Count < 1 || listTypes.Count < 1) + { + throw new Exception("Недостаточно для генерации!"); + } for (int i = 0; i < count; ++i) { context.Deals.Add(Deal.Create(new DealBindingModel @@ -184,10 +192,10 @@ namespace PersonnelDepartmentDatabaseImplement.Implements Id = 0, DateFrom = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), - DepartmentId = 1, - EmployeeId = 1, - TypeId = 1, - PositionId = 1 + DepartmentId = listDepartments[rnd.Next(listDepartments.Count)].Id, + EmployeeId = listEmployees[rnd.Next(listEmployees.Count)].Id, + TypeId = listTypes[rnd.Next(listTypes.Count)].Id, + PositionId = listPositions[rnd.Next(listPositions.Count)].Id })); } Stopwatch stopwatch = new(); diff --git a/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs index f241733..8abb0c5 100644 --- a/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs +++ b/PersonnelDepartmentView/PersonnelDepartmentView/FormGeneration.Designer.cs @@ -64,7 +64,7 @@ // // textBoxGet // - textBoxGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + textBoxGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; textBoxGet.Location = new Point(221, 51); textBoxGet.Name = "textBoxGet"; textBoxGet.ReadOnly = true; @@ -73,7 +73,7 @@ // // numericGet // - numericGet.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + 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"; @@ -106,7 +106,7 @@ // // textBoxDiffGet // - textBoxDiffGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + textBoxDiffGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; textBoxDiffGet.Location = new Point(221, 51); textBoxDiffGet.Name = "textBoxDiffGet"; textBoxDiffGet.ReadOnly = true; @@ -115,7 +115,7 @@ // // numericDiffGet // - numericDiffGet.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + 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"; @@ -148,7 +148,7 @@ // // textBoxSet // - textBoxSet.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + textBoxSet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; textBoxSet.Location = new Point(221, 51); textBoxSet.Name = "textBoxSet"; textBoxSet.ReadOnly = true; @@ -157,7 +157,7 @@ // // numericSet // - numericSet.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + 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"; @@ -196,6 +196,7 @@ Controls.Add(groupBox2); Controls.Add(groupBox1); Name = "FormGeneration"; + StartPosition = FormStartPosition.CenterScreen; Text = "FormGeneration"; groupBox1.ResumeLayout(false); groupBox1.PerformLayout();