Compare commits
4 Commits
8a71a24eee
...
c14f3a0b73
Author | SHA1 | Date | |
---|---|---|---|
|
c14f3a0b73 | ||
|
1f0aa9538c | ||
|
e0ef3d6e81 | ||
|
1ff19e93e5 |
91
COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs
generated
Normal file
91
COP/PortalAccountsDatabaseImplement/Migrations/20241022165136_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,91 @@
|
||||
// <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 PortalAccountsDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PortalAccountsDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PortalAccountsDatabase))]
|
||||
[Migration("20241022165136_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double?>("Rating")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Warnings")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", 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("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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PortalAccountsDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Roles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Accounts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Login = table.Column<string>(type: "text", nullable: false),
|
||||
Warnings = table.Column<string>(type: "text", nullable: true),
|
||||
RoleId = table.Column<int>(type: "integer", nullable: false),
|
||||
Rating = table.Column<double>(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");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Accounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Roles");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
// <auto-generated />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double?>("Rating")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Warnings")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PortalAccountsDatabaseImplement.Models.Role", 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("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
|
||||
}
|
||||
}
|
||||
}
|
53
COP/PortalAccountsView/FormAccount.Designer.cs
generated
53
COP/PortalAccountsView/FormAccount.Designer.cs
generated
@ -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;
|
||||
|
@ -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(
|
||||
|
44
COP/PortalAccountsView/FormRoles.Designer.cs
generated
44
COP/PortalAccountsView/FormRoles.Designer.cs
generated
@ -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
|
||||
//
|
||||
@ -56,32 +63,25 @@
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
Id.Width = 125;
|
||||
//
|
||||
// Name
|
||||
//
|
||||
NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
NameCol.HeaderText = "Название";
|
||||
NameCol.MinimumWidth = 6;
|
||||
NameCol.Name = "Name";
|
||||
Id.Width = 6;
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -50,18 +50,16 @@ 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()))
|
||||
{
|
||||
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() });
|
||||
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[e.ColumnIndex].Value;
|
||||
if (name is null)
|
||||
return;
|
||||
_logic.Create(new RoleBindingModel { Id = 0, Name = name.ToString() });
|
||||
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;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId;
|
||||
@ -83,7 +81,10 @@ 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 (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);
|
||||
}
|
||||
}
|
||||
@ -91,8 +92,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);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,4 @@
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user