Исправил все баги в логике форм
This commit is contained in:
parent
1ff19e93e5
commit
e0ef3d6e81
@ -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(
|
||||
|
@ -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("Ãîòîâî!");
|
||||
}
|
||||
|
2
COP/PortalAccountsView/FormRoles.Designer.cs
generated
2
COP/PortalAccountsView/FormRoles.Designer.cs
generated
@ -63,7 +63,7 @@
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
Id.Width = 125;
|
||||
Id.Width = 6;
|
||||
//
|
||||
// FormRoles
|
||||
//
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user