From 1ff19e93e5f151f2270189e58130af4e58cdc0df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= <Илья@WIN-RANNDDD>
Date: Tue, 22 Oct 2024 21:37:03 +0400
Subject: [PATCH 1/3] =?UTF-8?q?=D0=9C=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8?=
=?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?=
=?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80?=
=?UTF-8?q?=D1=84=D0=B5=D0=B9=D1=81=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?=
=?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../20241022165136_InitialCreate.Designer.cs | 91 +++++++++++++++++++
.../20241022165136_InitialCreate.cs | 65 +++++++++++++
.../PortalAccountsDatabaseModelSnapshot.cs | 88 ++++++++++++++++++
.../FormAccount.Designer.cs | 53 +++++------
COP/PortalAccountsView/FormRoles.Designer.cs | 42 ++++-----
COP/PortalAccountsView/FormRoles.cs | 24 +++--
COP/PortalAccountsView/FormRoles.resx | 3 -
.../ComboBoxControl.Designer.cs | 8 +-
8 files changed, 308 insertions(+), 66 deletions(-)
create mode 100644 COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs
create mode 100644 COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.cs
create mode 100644 COP/PortalAccountsDatabaseImplement/Migrations/PortalAccountsDatabaseModelSnapshot.cs
diff --git a/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs b/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs
new file mode 100644
index 0000000..77aeb79
--- /dev/null
+++ b/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs
@@ -0,0 +1,91 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using PortalAccountsDatabaseImplement;
+
+#nullable disable
+
+namespace PortalAccountsDatabaseImplement.Migrations
+{
+ [DbContext(typeof(PortalAccountsDatabase))]
+ [Migration("20241022165136_InitialCreate")]
+ partial class InitialCreate
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.11")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Account", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Rating")
+ .HasColumnType("double precision");
+
+ b.Property("RoleId")
+ .HasColumnType("integer");
+
+ b.Property("Warnings")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("Accounts");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Account", b =>
+ {
+ b.HasOne("PortalAccountsDatabaseImplement.Models.Role", "Role")
+ .WithMany("Accounts")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", b =>
+ {
+ b.Navigation("Accounts");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.cs b/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.cs
new file mode 100644
index 0000000..756d6ae
--- /dev/null
+++ b/COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.cs
@@ -0,0 +1,65 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace PortalAccountsDatabaseImplement.Migrations
+{
+ ///
+ public partial class InitialCreate : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Roles",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Name = table.Column(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Roles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Accounts",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Login = table.Column(type: "text", nullable: false),
+ Warnings = table.Column(type: "text", nullable: true),
+ RoleId = table.Column(type: "integer", nullable: false),
+ Rating = table.Column(type: "double precision", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Accounts", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Accounts_Roles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "Roles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Accounts_RoleId",
+ table: "Accounts",
+ column: "RoleId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Accounts");
+
+ migrationBuilder.DropTable(
+ name: "Roles");
+ }
+ }
+}
diff --git a/COP/PortalAccountsDatabaseImplement/Migrations/PortalAccountsDatabaseModelSnapshot.cs b/COP/PortalAccountsDatabaseImplement/Migrations/PortalAccountsDatabaseModelSnapshot.cs
new file mode 100644
index 0000000..9df3f52
--- /dev/null
+++ b/COP/PortalAccountsDatabaseImplement/Migrations/PortalAccountsDatabaseModelSnapshot.cs
@@ -0,0 +1,88 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using PortalAccountsDatabaseImplement;
+
+#nullable disable
+
+namespace PortalAccountsDatabaseImplement.Migrations
+{
+ [DbContext(typeof(PortalAccountsDatabase))]
+ partial class PortalAccountsDatabaseModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.11")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Account", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Rating")
+ .HasColumnType("double precision");
+
+ b.Property("RoleId")
+ .HasColumnType("integer");
+
+ b.Property("Warnings")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("Accounts");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Account", b =>
+ {
+ b.HasOne("PortalAccountsDatabaseImplement.Models.Role", "Role")
+ .WithMany("Accounts")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+ });
+
+ modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", b =>
+ {
+ b.Navigation("Accounts");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/COP/PortalAccountsView/FormAccount.Designer.cs b/COP/PortalAccountsView/FormAccount.Designer.cs
index 9d7854d..d6a3f72 100644
--- a/COP/PortalAccountsView/FormAccount.Designer.cs
+++ b/COP/PortalAccountsView/FormAccount.Designer.cs
@@ -43,39 +43,36 @@
// controlInputRating
//
controlInputRating.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- controlInputRating.Location = new Point(8, 197);
- controlInputRating.Margin = new Padding(4, 6, 4, 6);
+ controlInputRating.Location = new Point(9, 263);
+ controlInputRating.Margin = new Padding(5, 8, 5, 8);
controlInputRating.Name = "controlInputRating";
- controlInputRating.Size = new Size(329, 27);
+ controlInputRating.Size = new Size(376, 36);
controlInputRating.TabIndex = 0;
controlInputRating.Value = null;
//
// textBoxLogin
//
textBoxLogin.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- textBoxLogin.Location = new Point(15, 86);
- textBoxLogin.Margin = new Padding(3, 2, 3, 2);
+ textBoxLogin.Location = new Point(17, 115);
textBoxLogin.Name = "textBoxLogin";
- textBoxLogin.Size = new Size(323, 23);
+ textBoxLogin.Size = new Size(369, 27);
textBoxLogin.TabIndex = 2;
textBoxLogin.TextChanged += TextBoxLogin_TextChanged;
//
// textBoxWarnings
//
textBoxWarnings.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- textBoxWarnings.Location = new Point(15, 143);
- textBoxWarnings.Margin = new Padding(3, 2, 3, 2);
+ textBoxWarnings.Location = new Point(17, 191);
textBoxWarnings.Name = "textBoxWarnings";
- textBoxWarnings.Size = new Size(323, 23);
+ textBoxWarnings.Size = new Size(369, 27);
textBoxWarnings.TabIndex = 3;
textBoxWarnings.TextChanged += TextBoxWarnings_TextChanged;
//
// buttonSave
//
- buttonSave.Location = new Point(25, 232);
- buttonSave.Margin = new Padding(3, 2, 3, 2);
+ buttonSave.Location = new Point(29, 309);
buttonSave.Name = "buttonSave";
- buttonSave.Size = new Size(92, 27);
+ buttonSave.Size = new Size(105, 36);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
@@ -84,55 +81,54 @@
// labelLogin
//
labelLogin.AutoSize = true;
- labelLogin.Location = new Point(15, 64);
+ labelLogin.Location = new Point(17, 85);
labelLogin.Name = "labelLogin";
- labelLogin.Size = new Size(41, 15);
+ labelLogin.Size = new Size(52, 20);
labelLogin.TabIndex = 4;
labelLogin.Text = "Логин";
//
// labelWarnings
//
labelWarnings.AutoSize = true;
- labelWarnings.Location = new Point(15, 120);
+ labelWarnings.Location = new Point(17, 160);
labelWarnings.Name = "labelWarnings";
- labelWarnings.Size = new Size(102, 15);
+ labelWarnings.Size = new Size(131, 20);
labelWarnings.TabIndex = 5;
labelWarnings.Text = "Предупреждения";
//
// labelRating
//
labelRating.AutoSize = true;
- labelRating.Location = new Point(19, 174);
+ labelRating.Location = new Point(22, 232);
labelRating.Name = "labelRating";
- labelRating.Size = new Size(51, 15);
+ labelRating.Size = new Size(64, 20);
labelRating.TabIndex = 6;
labelRating.Text = "Рейтинг";
//
// labelRole
//
labelRole.AutoSize = true;
- labelRole.Location = new Point(18, 12);
+ labelRole.Location = new Point(21, 16);
labelRole.Name = "labelRole";
- labelRole.Size = new Size(34, 15);
+ labelRole.Size = new Size(42, 20);
labelRole.TabIndex = 7;
labelRole.Text = "Роль";
//
// comboBoxControlRole
//
comboBoxControlRole.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- comboBoxControlRole.Location = new Point(15, 33);
- comboBoxControlRole.Margin = new Padding(3, 2, 3, 2);
+ comboBoxControlRole.Location = new Point(17, 44);
+ comboBoxControlRole.Margin = new Padding(3, 4, 3, 4);
comboBoxControlRole.Name = "comboBoxControlRole";
comboBoxControlRole.SelectedValue = "";
- comboBoxControlRole.Size = new Size(327, 26);
+ comboBoxControlRole.Size = new Size(369, 35);
comboBoxControlRole.TabIndex = 8;
//
// buttonCancel
//
- buttonCancel.Location = new Point(147, 232);
- buttonCancel.Margin = new Padding(3, 2, 3, 2);
+ buttonCancel.Location = new Point(168, 309);
buttonCancel.Name = "buttonCancel";
- buttonCancel.Size = new Size(92, 27);
+ buttonCancel.Size = new Size(105, 36);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
@@ -140,9 +136,9 @@
//
// FormAccount
//
- AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(357, 272);
+ ClientSize = new Size(408, 363);
Controls.Add(buttonCancel);
Controls.Add(comboBoxControlRole);
Controls.Add(labelRole);
@@ -153,7 +149,6 @@
Controls.Add(textBoxWarnings);
Controls.Add(textBoxLogin);
Controls.Add(controlInputRating);
- Margin = new Padding(3, 2, 3, 2);
Name = "FormAccount";
Text = "Аккаунт";
FormClosing += FormAccount_FormClosing;
diff --git a/COP/PortalAccountsView/FormRoles.Designer.cs b/COP/PortalAccountsView/FormRoles.Designer.cs
index b51488a..d369b5a 100644
--- a/COP/PortalAccountsView/FormRoles.Designer.cs
+++ b/COP/PortalAccountsView/FormRoles.Designer.cs
@@ -29,8 +29,8 @@
private void InitializeComponent()
{
dataGridView = new DataGridView();
- Id = new DataGridViewTextBoxColumn();
NameCol = new DataGridViewTextBoxColumn();
+ Id = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
@@ -38,17 +38,24 @@
//
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, NameCol });
- dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
- dataGridView.Location = new System.Drawing.Point(0, 0);
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { NameCol, Id });
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
- dataGridView.Size = new System.Drawing.Size(800, 450);
+ dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 0;
- dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellValueChanged);
- dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.DataGridView_UserDeletingRow);
- dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.DataGridView_KeyUp);
+ dataGridView.CellValueChanged += DataGridView_CellValueChanged;
+ dataGridView.UserDeletingRow += DataGridView_UserDeletingRow;
+ dataGridView.KeyUp += DataGridView_KeyUp;
+ //
+ // NameCol
+ //
+ NameCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ NameCol.HeaderText = "Название";
+ NameCol.MinimumWidth = 6;
+ NameCol.Name = "NameCol";
//
// Id
//
@@ -58,30 +65,23 @@
Id.Visible = false;
Id.Width = 125;
//
- // Name
- //
- NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- NameCol.HeaderText = "Название";
- NameCol.MinimumWidth = 6;
- NameCol.Name = "Name";
- //
// FormRoles
//
- AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- ClientSize = new System.Drawing.Size(800, 450);
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Name = "FormRoles";
Text = "FormRoles";
- Load += new System.EventHandler(this.FormRoles_Load);
- ((System.ComponentModel.ISupportInitialize)(dataGridView)).EndInit();
+ Load += FormRoles_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
- private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn NameCol;
+ private DataGridViewTextBoxColumn Id;
}
}
\ No newline at end of file
diff --git a/COP/PortalAccountsView/FormRoles.cs b/COP/PortalAccountsView/FormRoles.cs
index 4f74a9a..0fbb901 100644
--- a/COP/PortalAccountsView/FormRoles.cs
+++ b/COP/PortalAccountsView/FormRoles.cs
@@ -50,18 +50,19 @@ namespace PortalAccountsView
{
if (dataLoading || e.RowIndex < 0 || e.ColumnIndex != 0)
return;
- if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
+ if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null)
{
- var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
- if (name is null) return;
- _logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() });
+ var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
+ if (string.IsNullOrEmpty(name))
+ return;
+ _logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name });
}
else
{
- var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
- if (name is null)
+ var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
+ if (string.IsNullOrEmpty(name))
return;
- _logic.Create(new RoleBindingModel { Id = 0, Name = name.ToString() });
+ _logic.Create(new RoleBindingModel { Id = 0, Name = name });
var list = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список ролей");
int newRoleId = list.Last().Id;
dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId;
@@ -83,7 +84,8 @@ namespace PortalAccountsView
for (int i = 0; i < rows.Count; i++)
{
DataGridViewRow row = rows[i];
- if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
+ if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) }))
+ throw new Exception($"Ошибка удаления строки: {row.Cells[0].Value}");
dataGridView.Rows.Remove(row);
}
}
@@ -91,8 +93,10 @@ namespace PortalAccountsView
private void DataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
e.Cancel = true;
- if (dataGridView.SelectedRows == null) return;
- if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
+ if (dataGridView.SelectedRows == null)
+ return;
+ if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No)
+ return;
DeleteRows(dataGridView.SelectedRows);
}
}
diff --git a/COP/PortalAccountsView/FormRoles.resx b/COP/PortalAccountsView/FormRoles.resx
index 9d0eaa3..91e09cb 100644
--- a/COP/PortalAccountsView/FormRoles.resx
+++ b/COP/PortalAccountsView/FormRoles.resx
@@ -120,7 +120,4 @@
True
-
- True
-
\ No newline at end of file
diff --git a/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs b/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs
index 45e9dc6..22e7ad8 100644
--- a/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs
+++ b/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs
@@ -36,18 +36,20 @@
comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBox.FormattingEnabled = true;
comboBox.Location = new Point(1, 0);
+ comboBox.Margin = new Padding(3, 4, 3, 4);
comboBox.Name = "comboBox";
- comboBox.Size = new Size(323, 23);
+ comboBox.Size = new Size(874, 28);
comboBox.TabIndex = 0;
comboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
//
// ComboBoxControl
//
- AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(comboBox);
+ Margin = new Padding(3, 4, 3, 4);
Name = "ComboBoxControl";
- Size = new Size(327, 26);
+ Size = new Size(875, 35);
ResumeLayout(false);
}
From e0ef3d6e81b814a69ba8d87e09da08f9dca8e452 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= <Илья@WIN-RANNDDD>
Date: Tue, 22 Oct 2024 23:15:39 +0400
Subject: [PATCH 2/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?=
=?UTF-8?q?=D0=BB=20=D0=B2=D1=81=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D0=B2?=
=?UTF-8?q?=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B5=20=D1=84=D0=BE=D1=80?=
=?UTF-8?q?=D0=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
COP/PortalAccountsView/FormAccount.cs | 3 ++-
COP/PortalAccountsView/FormMain.cs | 4 +++-
COP/PortalAccountsView/FormRoles.Designer.cs | 2 +-
COP/PortalAccountsView/FormRoles.cs | 15 ++++++---------
COP/PortalAccountsView/PortalAccountsView.csproj | 1 +
5 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/COP/PortalAccountsView/FormAccount.cs b/COP/PortalAccountsView/FormAccount.cs
index 81985d1..a6b5e34 100644
--- a/COP/PortalAccountsView/FormAccount.cs
+++ b/COP/PortalAccountsView/FormAccount.cs
@@ -45,6 +45,7 @@ namespace PortalAccountsView
textBoxWarnings.Text = account.Warnings;
controlInputRating.Value = account.Rating;
comboBoxControlRole.SelectedValue = account.RoleName;
+ _isModified = false;
}
}
catch (Exception ex)
@@ -122,7 +123,7 @@ namespace PortalAccountsView
private void FormAccount_FormClosing(object sender, FormClosingEventArgs e)
{
- if (!_isModified)
+ if (!_isModified || DialogResult == DialogResult.OK)
return;
var result = MessageBox.Show(
diff --git a/COP/PortalAccountsView/FormMain.cs b/COP/PortalAccountsView/FormMain.cs
index a98e724..71903ec 100644
--- a/COP/PortalAccountsView/FormMain.cs
+++ b/COP/PortalAccountsView/FormMain.cs
@@ -4,6 +4,7 @@ using PortalAccountsContracts.BindingModels;
using PortalAccountsContracts.BusinessLogicsContracts;
using PortalAccountsContracts.ViewModels;
using RodionovLibrary.NonVisualComponents.HelperModels;
+using System.Text;
namespace PortalAccountsView
{
@@ -176,6 +177,7 @@ namespace PortalAccountsView
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
using var dialog = new SaveFileDialog
{
Filter = "PDF Files|*.pdf"
@@ -201,7 +203,7 @@ namespace PortalAccountsView
(2, 0, "", "RoleName"),
(3, 0, "", "OutputRating")
},
- Data = accounts
+ Data = accounts.OrderBy(x => x.Id).ToList()
});
MessageBox.Show("!");
}
diff --git a/COP/PortalAccountsView/FormRoles.Designer.cs b/COP/PortalAccountsView/FormRoles.Designer.cs
index d369b5a..e6abf9a 100644
--- a/COP/PortalAccountsView/FormRoles.Designer.cs
+++ b/COP/PortalAccountsView/FormRoles.Designer.cs
@@ -63,7 +63,7 @@
Id.MinimumWidth = 6;
Id.Name = "Id";
Id.Visible = false;
- Id.Width = 125;
+ Id.Width = 6;
//
// FormRoles
//
diff --git a/COP/PortalAccountsView/FormRoles.cs b/COP/PortalAccountsView/FormRoles.cs
index 0fbb901..ab1d2a5 100644
--- a/COP/PortalAccountsView/FormRoles.cs
+++ b/COP/PortalAccountsView/FormRoles.cs
@@ -50,18 +50,15 @@ namespace PortalAccountsView
{
if (dataLoading || e.RowIndex < 0 || e.ColumnIndex != 0)
return;
- if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null)
- {
- var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
- if (string.IsNullOrEmpty(name))
- return;
+ if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null) {
+ var name = dataGridView.Rows[e.RowIndex].Cells[0].Value?.ToString()
+ ?? throw new Exception("Не заполнено название роли");
_logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name });
}
else
{
- var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
- if (string.IsNullOrEmpty(name))
- return;
+ var name = dataGridView.Rows[e.RowIndex].Cells[0].Value?.ToString()
+ ?? throw new Exception("Не заполнено название роли");
_logic.Create(new RoleBindingModel { Id = 0, Name = name });
var list = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список ролей");
int newRoleId = list.Last().Id;
@@ -84,7 +81,7 @@ namespace PortalAccountsView
for (int i = 0; i < rows.Count; i++)
{
DataGridViewRow row = rows[i];
- if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) }))
+ if (row.Cells[1].Value != null && !_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) }))
throw new Exception($"Ошибка удаления строки: {row.Cells[0].Value}");
dataGridView.Rows.Remove(row);
}
diff --git a/COP/PortalAccountsView/PortalAccountsView.csproj b/COP/PortalAccountsView/PortalAccountsView.csproj
index cd605b7..684861d 100644
--- a/COP/PortalAccountsView/PortalAccountsView.csproj
+++ b/COP/PortalAccountsView/PortalAccountsView.csproj
@@ -17,6 +17,7 @@
+
From 1f0aa9538c407e57c6e17ae045d5fdeeb540d024 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= <Илья@WIN-RANNDDD>
Date: Wed, 23 Oct 2024 10:46:11 +0400
Subject: [PATCH 3/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?=
=?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BF=D1=80?=
=?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B5=20=D1=83?=
=?UTF-8?q?=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D1=81?=
=?UTF-8?q?=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B9=20=D1=81=D1=82=D1=80=D0=BE?=
=?UTF-8?q?=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20?=
=?UTF-8?q?=D1=80=D0=BE=D0=BB=D0=B5=D0=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
COP/PortalAccountsView/FormRoles.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/COP/PortalAccountsView/FormRoles.cs b/COP/PortalAccountsView/FormRoles.cs
index ab1d2a5..cd8831a 100644
--- a/COP/PortalAccountsView/FormRoles.cs
+++ b/COP/PortalAccountsView/FormRoles.cs
@@ -81,6 +81,8 @@ namespace PortalAccountsView
for (int i = 0; i < rows.Count; i++)
{
DataGridViewRow row = rows[i];
+ if (row.IsNewRow)
+ continue;
if (row.Cells[1].Value != null && !_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) }))
throw new Exception($"Ошибка удаления строки: {row.Cells[0].Value}");
dataGridView.Rows.Remove(row);