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] =?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 @@ +