It is done

This commit is contained in:
ksenianeva 2023-12-01 02:29:05 +04:00
parent df730da8eb
commit 617c65c4e7
5 changed files with 189 additions and 8 deletions

View File

@ -10,15 +10,17 @@ namespace AccountContracts.ViewModels
{
public class AccountViewModel : IAccountModel
{
public int Id { get; set; }
public int Id { get; set; } = 0;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Рейтинг")]
public float? Rating { get; set; }
public float? Rating { get; set; } = null;
[DisplayName("Предупреждения")]
public string? Warnings { get; set; } = string.Empty;
public int RoleId { get; set; }
public int RoleId { get; set; } = 0;
[DisplayName("Роль")]
public string RoleName { get; set; }
public string RoleName { get; set; } = string.Empty;
public float ViewRating { get; set; } = 0;
public string DocRating { get; set; } = string.Empty;
}
}

View File

@ -9,13 +9,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AbazovViewComponents" Version="3.0.0" />
<PackageReference Include="AbazovViewComponents" Version="5.0.0" />
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -28,14 +28,21 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.аккаунтыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.создатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.редактироватьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.документToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.документСТаблицейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.документСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ролиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.abazovTreeView = new AbazovViewComponents.Components.AbazovTreeView();
this.wordLongTextComponent = new NevaevaLibrary.LogicalComponents.WordLongTextComponent(this.components);
this.excelDiagramComponent = new AbazovViewComponents.LogicalComponents.ExcelDiagramComponent(this.components);
this.componentDocumentWithTableMultiHeaderPdf = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components);
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -76,6 +83,7 @@
this.редактироватьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
this.редактироватьToolStripMenuItem.Text = "Редактировать";
this.редактироватьToolStripMenuItem.Click += new System.EventHandler(this.редактироватьToolStripMenuItem_Click);
//
// удалитьToolStripMenuItem
//
@ -83,13 +91,42 @@
this.удалитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
this.удалитьToolStripMenuItem.Text = "Удалить";
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
//
// отчётыToolStripMenuItem
//
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.документToolStripMenuItem,
this.документСТаблицейToolStripMenuItem,
this.документСДиаграммойToolStripMenuItem});
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчётыToolStripMenuItem.Text = "Отчёты";
//
// документToolStripMenuItem
//
this.документToolStripMenuItem.Name = окументToolStripMenuItem";
this.документToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.документToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
this.документToolStripMenuItem.Text = "Документ";
this.документToolStripMenuItem.Click += new System.EventHandler(this.документToolStripMenuItem_Click);
//
// документСТаблицейToolStripMenuItem
//
this.документСТаблицейToolStripMenuItem.Name = окументСТаблицейToolStripMenuItem";
this.документСТаблицейToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
this.документСТаблицейToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
this.документСТаблицейToolStripMenuItem.Text = "Документ с таблицей";
this.документСТаблицейToolStripMenuItem.Click += new System.EventHandler(this.документСТаблицейToolStripMenuItem_Click);
//
// документСДиаграммойToolStripMenuItem
//
this.документСДиаграммойToolStripMenuItem.Name = окументСДиаграммойToolStripMenuItem";
this.документСДиаграммойToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.документСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
this.документСДиаграммойToolStripMenuItem.Text = "Документ с диаграммой";
this.документСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.документСДиаграммойToolStripMenuItem_Click);
//
// ролиToolStripMenuItem
//
this.ролиToolStripMenuItem.Name = "ролиToolStripMenuItem";
@ -134,5 +171,11 @@
private ToolStripMenuItem создатьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem документToolStripMenuItem;
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
private NevaevaLibrary.LogicalComponents.WordLongTextComponent wordLongTextComponent;
private AbazovViewComponents.LogicalComponents.ExcelDiagramComponent excelDiagramComponent;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf;
}
}

View File

@ -1,5 +1,11 @@
using AccountContracts.BusinessLogicsContracts;
using AbazovViewComponents.LogicalComponents;
using AccountContracts.BindingModels;
using AccountContracts.BusinessLogicsContracts;
using AccountContracts.ViewModels;
using AccountDatabaseImplement.Models;
using ComponentsLibraryNet60.Models;
using ControlsLibraryNet60.Core;
using NevaevaLibrary.LogicalComponents;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -20,7 +26,7 @@ namespace AccountsView
{
InitializeComponent();
_logic = logic;
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("Rating", false), ("Id", true), ("Login", true) });
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("ViewRating", false), ("Id", true), ("Login", true) });
}
private void ролиToolStripMenuItem_Click(object sender, EventArgs e)
@ -47,7 +53,11 @@ namespace AccountsView
{
if (!account.Rating.HasValue)
{
account.Rating = 0;
account.ViewRating = 0;
}
else
{
account.ViewRating = account.Rating.Value;
}
}
abazovTreeView.addItems(accounts);
@ -65,5 +75,121 @@ namespace AccountsView
}
}
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
{
var selected = abazovTreeView.getSelecetedNodeValue<AccountViewModel>();
if (selected == null) return;
form.Id = selected.Id;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
var selected = abazovTreeView.getSelecetedNodeValue<AccountViewModel>();
if (selected == null) return;
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (_logic.Delete(new AccountBindingModel { Id = selected.Id }))
{
LoadData();
}
}
}
private void документToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new()
{
Filter = "Word Files|*.docx"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
foreach (var account in _logic.ReadList(null))
{
if (account.Rating == null)
{
paragraphs.Add(account.Login + ": " + account.Warnings);
}
}
string path = saveFileDialog.FileName;
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Аккаунты без рейтинга", paragraphs.ToArray()));
MessageBox.Show("Документ создан");
}
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new()
{
Filter = "Excel Files|*.xlsx"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
string path = saveFileDialog.FileName;
var data = _logic.ReadList(null).Where(x => x.Rating == null).GroupBy(x => x.RoleName).Select(x => new
{
RoleName = x.Key,
RoleCount = x.Count(),
}).ToList();
excelDiagramComponent.createWithDiagram(path, "Роли без рейтинга", "Роли без рейтинга", AbazovViewComponents.LogicalComponents.DiagramLegendEnum.BottomRight,
data, "RoleName", "RoleCount");
MessageBox.Show("Документ создан");
}
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
SaveFileDialog saveFileDialog = new()
{
Filter = "PDF Files|*.pdf"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
List<string> paragraphs = new List<string>();
string path = saveFileDialog.FileName;
var accounts = _logic.ReadList(null);
foreach (var account in accounts)
{
if (!account.Rating.HasValue)
{
account.DocRating = "нет";
}
else
{
account.DocRating = account.Rating.Value.ToString();
}
}
ComponentDocumentWithTableHeaderDataConfig<AccountViewModel> config = new ComponentsLibraryNet60.Models.ComponentDocumentWithTableHeaderDataConfig<AccountViewModel>
{
Data = accounts,
UseUnion = false,
Header = "Аккаунты",
ColumnsRowsDataCount = (4, 1),
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "Логин", "Login"),
(2, 0, "Роль", "RoleName"),
(3, 0, "Рейтинг", "DocRating")
},
ColumnsRowsWidth = new List<(int Column, int Row)>
{
(10, 10),
(10, 10),
(10, 10),
(10, 10)
},
ColumnUnion = new List<(int StartIndex, int Count)>(),
FilePath = path
};
componentDocumentWithTableMultiHeaderPdf.CreateDoc(config);
MessageBox.Show("Документ создан");
}
}
}

View File

@ -60,4 +60,13 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="wordLongTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<metadata name="excelDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>383, 17</value>
</metadata>
<metadata name="componentDocumentWithTableMultiHeaderPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>609, 17</value>
</metadata>
</root>