From e444bf107a1a6e773ac1a66c6ba0d30c894d4e81 Mon Sep 17 00:00:00 2001 From: dyakonovr Date: Tue, 29 Oct 2024 15:47:10 +0400 Subject: [PATCH] final --- Lab4/Form1.cs | 47 +++---------------------------- Plugins/IPluginsConvention.cs | 2 +- ShopProducts/PluginConvention.cs | 48 ++------------------------------ 3 files changed, 7 insertions(+), 90 deletions(-) diff --git a/Lab4/Form1.cs b/Lab4/Form1.cs index bdac933..249784b 100644 --- a/Lab4/Form1.cs +++ b/Lab4/Form1.cs @@ -33,7 +33,6 @@ namespace Lab4 if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface) { var plugin = (IPluginsConvention)Activator.CreateInstance(type)!; - plugins.Add(plugin.PluginName, plugin); } } @@ -69,45 +68,9 @@ namespace Lab4 }; ControlsStripMenuItem.DropDownItems.Add(menuItem); } - private void FormMain_KeyDown(object sender, KeyEventArgs e) + private void ShowCatalog() { - if (string.IsNullOrEmpty(_selectedPlugin) || - !_plugins.ContainsKey(_selectedPlugin)) - { - return; - } - if (!e.Control) - { - return; - } - switch (e.KeyCode) - { - case Keys.I: - ShowThesaurus(); - break; - case Keys.A: - AddNewElement(); - break; - case Keys.U: - UpdateElement(); - break; - case Keys.D: - DeleteElement(); - break; - case Keys.S: - CreateWordDoc(); - break; - case Keys.T: - CreatePdfDoc(); - break; - case Keys.C: - CreateExcelDoc(); - break; - } - } - private void ShowThesaurus() - { - _plugins[_selectedPlugin].GetThesaurus()?.Show(); + _plugins[_selectedPlugin].GetCatalog()?.Show(); } private void AddNewElement() { @@ -201,9 +164,7 @@ namespace Lab4 saveFileDialog.Title = "Ρξυπΰνθςό δθΰγπΰμμσ"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_plugins[_selectedPlugin].CreateExcelDocument(new - PluginsConventionSaveDocument() - { FileName = saveFileDialog.FileName })) + if (_plugins[_selectedPlugin].CreateExcelDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName })) { MessageBox.Show("Δξκσμενς ρξυπΰνεν", "Ρξηδΰνθε" + " δξκσμενςΰ", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -217,7 +178,7 @@ namespace Lab4 } } private void ThesaurusToolStripMenuItem_Click(object sender, - EventArgs e) => ShowThesaurus(); + EventArgs e) => ShowCatalog(); private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement(); private void UpdElementToolStripMenuItem_Click(object sender, diff --git a/Plugins/IPluginsConvention.cs b/Plugins/IPluginsConvention.cs index 206f5e3..4119a1a 100644 --- a/Plugins/IPluginsConvention.cs +++ b/Plugins/IPluginsConvention.cs @@ -6,7 +6,7 @@ UserControl GetControl { get; } PluginsConventionElement GetElement { get; } Form GetForm(PluginsConventionElement element); - Form GetThesaurus(); + Form GetCatalog(); bool DeleteElement(PluginsConventionElement element); void ReloadData(); bool CreateWordDocument(PluginsConventionSaveDocument saveDocument); diff --git a/ShopProducts/PluginConvention.cs b/ShopProducts/PluginConvention.cs index 6d535f8..5000aad 100644 --- a/ShopProducts/PluginConvention.cs +++ b/ShopProducts/PluginConvention.cs @@ -26,16 +26,14 @@ namespace ShopProducts { private readonly ProductLogic _ProductLogic = new ProductLogic(new ProductStorage()); private readonly ManufacturerLogic _ManufacturerLogic = new ManufacturerLogic(new ManufacturerStorage()); - /*private UserTreeView userTreeView1 = new UserTreeView();*/ private ControlDataTableRow controlDataTableRow1 = new ControlDataTableRow(); - public string PluginName { get; set; } = "Π›Π°Π±Π° 4"; + public string PluginName { get; set; } = "Products App"; public UserControl GetControl { get { Load(); - /*return userTreeView1;*/ return controlDataTableRow1; } } @@ -44,7 +42,6 @@ namespace ShopProducts { get { - /*var selectedProduct = userTreeView1.GetSelectedObject();*/ var selectedProduct = controlDataTableRow1.GetSelectedObject(); int? id = null; @@ -92,15 +89,6 @@ namespace ShopProducts }); return true; - - /*COP.PieChart pieChart1 = new COP.PieChart(); - string fileName = saveDocument.FileName; - var dates = _ProductLogic.GetExcelInfo(); - var chartData = dates.Select(x => new DataItem { Name = x.Item1, Value = x.Item2 }).ToList(); - pieChart1.GenerateDocument(new ExcelChartInfo(fileName, "Бколько ΠΊΠ»ΠΈΠ΅Π½Ρ‚ΠΎΠ² ΠΊΠ°ΠΊΠΎΠ³ΠΎ статуса ΡΠΎΠ²Π΅Ρ€ΡˆΠ°Π»ΠΈ ΠΏΠΎΠΊΡƒΠΏΠΊΠΈ", - "ΠšΡ€ΡƒΠ³ΠΎΠ²Π°Ρ Π΄ΠΈΠ°Π³Ρ€Π°ΠΌΠΌΠ°", COP.Enums.LegendPosition.Bottom, chartData)); - return true;*/ - } catch (Exception ex) { @@ -128,16 +116,6 @@ namespace ShopProducts } }); - /*string fileName = saveDocument.FileName; - List textList = new List(); - var list = _ProductLogic.Read(new ProductBindingModel { PurchaseSum = 0 }); - var rs = list.Select(item => string.Concat("ЀИО: ", item.Name, " ΠžΡ‚Π·Ρ‹Π²Ρ‹: ", item.Reviews, '\n')).ToArray(); - if (list != null) - { - BigTextDocument.CreateDocument(new BigTextDocumentInfo - (fileName, "Π”ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ ΠΏΠΎ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°ΠΌ, ΡΠΎΠ²Π΅Ρ€ΡˆΠ°Π²ΡˆΠΈΠΌ ΠΏΠΎΠΊΡƒΠΏΠΊΠΈ (ЀИО ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° ΠΈ Π΅Π³ΠΎ ΠΎΡ‚Π·Ρ‹Π²Ρ‹)", rs) - ); - }*/ return true; } catch (Exception ex) @@ -161,18 +139,6 @@ namespace ShopProducts }; pdf.CreatePdf(config); - /*string fileName = saveDocument.FileName; - KOP.PDFComponents.PdfTableComponent pdfTableComponent1 = new(); - var Products = _ProductLogic.Read(null); - for (int i = 0; i < Products.Count; i++) - { - if (Products[i].PurchaseSum == null || Products[i].PurchaseSum == "") { Products[i].PurchaseSum = "Π½Π΅Ρ‚"; } - } - pdfTableComponent1.CreateDocument(fileName, "ΠžΡ‚Ρ‡Ρ‘Ρ‚ ΠΏΠΎ всСм ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°ΠΌ", - new List { 2.0, 6.0, 4.0, 4.0 }, new List { 5.0, 3.0 }, - new List<(string, string)> { ("Id", "Id"), ("ЀИО", "Name"), ("Бтатус", "Manufacturer"), ("Π‘ΡƒΠΌΠΌΠ° ΠΏΠΎΠΊΡƒΠΏΠΎΠΊ", "PurchaseSum") }, - Products - );*/ return true; } catch (Exception ex) @@ -185,9 +151,6 @@ namespace ShopProducts private void Load() { - /*List stringToHierachy = new List() { "Manufacturer", "PurchaseSum", "Id", "Name" }; - userTreeView1.Hierarchy = stringToHierachy;*/ - var tableConfig = new List { new DataTableColumnConfig @@ -224,13 +187,6 @@ namespace ShopProducts { try { - /*var list = _ProductLogic.Read(null); - for (int i = 0; i < list.Count; i++) - { - if (list[i].PurchaseSum == null || list[i].PurchaseSum == "") { list[i].PurchaseSum = "Π½Π΅Ρ‚"; } - } - userTreeView1.PopulateTree(list);*/ - controlDataTableRow1.Clear(); var list = _ProductLogic.Read(null); @@ -278,7 +234,7 @@ namespace ShopProducts return null; } - public Form GetThesaurus() + public Form GetCatalog() { return new FormManufacturers(_ManufacturerLogic); }