From 32e651c219b00b7c60c2a312f0f5ed0ceb2f19d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A7=D1=83=D0=B1?= =?UTF-8?q?=D1=8B=D0=BA=D0=B8=D0=BD=D0=B0?= Date: Mon, 28 Oct 2024 20:39:56 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B4=D1=80=D0=BE=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChubykinaComponents.csproj | 2 +- .../Components/UserTreeView.cs | 7 +- .../ExcelDiagramComponent.cs | 6 +- .../ClientDataBaseImplement.csproj | 1 - .../Implements/ClientStorage.cs | 8 +- .../ClientsDataModels.csproj | 4 - COP/WinFormsTest/FormClient.Designer.cs | 50 +++--- COP/WinFormsTest/FormClient.cs | 20 +-- COP/WinFormsTest/FormMain.Designer.cs | 144 +++++++++++++++++- COP/WinFormsTest/FormMain.cs | 132 +++++++++++++++- COP/WinFormsTest/FormTest.Designer.cs | 24 +-- COP/WinFormsTest/FormTest.cs | 4 +- COP/WinFormsTest/Program.cs | 2 +- COP/WinFormsTest/WinFormsTest.csproj | 2 +- 14 files changed, 338 insertions(+), 68 deletions(-) diff --git a/COP/ChubykinaComponents/ChubykinaComponents.csproj b/COP/ChubykinaComponents/ChubykinaComponents.csproj index 89d5eb4..03c84ac 100644 --- a/COP/ChubykinaComponents/ChubykinaComponents.csproj +++ b/COP/ChubykinaComponents/ChubykinaComponents.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0-windows enable true enable diff --git a/COP/ChubykinaComponents/Components/UserTreeView.cs b/COP/ChubykinaComponents/Components/UserTreeView.cs index 7f75c08..917e351 100644 --- a/COP/ChubykinaComponents/Components/UserTreeView.cs +++ b/COP/ChubykinaComponents/Components/UserTreeView.cs @@ -31,6 +31,7 @@ namespace ChubykinaComponents.Components else treeView.SelectedNode = value >= 0 && value < treeView.SelectedNode.Nodes.Count ? treeView.SelectedNode.Nodes[value] : treeView.SelectedNode; } } + public T? getSelecetedNodeValue() { if (treeView.SelectedNode == null || treeView.SelectedNode.Nodes.Count > 0) return default(T); @@ -83,5 +84,9 @@ namespace ChubykinaComponents.Components } } } + public void clear() + { + treeView.Nodes.Clear(); + } } -} +} \ No newline at end of file diff --git a/COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.cs b/COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.cs index 78d254e..0b9828b 100644 --- a/COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.cs +++ b/COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.cs @@ -31,9 +31,9 @@ namespace ChubykinaComponents.LogicalComponents { Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1); - FieldInfo? seriesName = typeof(T).GetField(seriesNameField); - FieldInfo? value = typeof(T).GetField(valueField); - if (seriesName == null || value == null) throw new ArgumentException("Переданного поля не существует"); + PropertyInfo? seriesName = typeof(T).GetProperty(seriesNameField); + PropertyInfo? value = typeof(T).GetProperty(valueField); + if (seriesName == null || value == null) throw new ArgumentException("Переданного свойства не существует"); int columnCount = 2; foreach (var item in data) { diff --git a/COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj b/COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj index f1c0ef6..2db3f9f 100644 --- a/COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj +++ b/COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj @@ -18,7 +18,6 @@ - diff --git a/COP/ClientDataBaseImplement/Implements/ClientStorage.cs b/COP/ClientDataBaseImplement/Implements/ClientStorage.cs index 6367a59..6a9efd6 100644 --- a/COP/ClientDataBaseImplement/Implements/ClientStorage.cs +++ b/COP/ClientDataBaseImplement/Implements/ClientStorage.cs @@ -65,14 +65,14 @@ namespace ClientDataBaseImplement.Implements public ClientViewModel? Update(ClientBindingModel model) { using var context = new ClientsDatabase(); - var account = context.Clients.FirstOrDefault(x => x.Id == model.Id); - if (account == null) + var client = context.Clients.FirstOrDefault(x => x.Id == model.Id); + if (client == null) { return null; } - account.Update(model, context); + client.Update(model, context); context.SaveChanges(); - return account.GetViewModel; + return client.GetViewModel; } public ClientViewModel? Delete(ClientBindingModel model) { diff --git a/COP/ClientsDataModels/ClientsDataModels.csproj b/COP/ClientsDataModels/ClientsDataModels.csproj index 6aa140a..132c02c 100644 --- a/COP/ClientsDataModels/ClientsDataModels.csproj +++ b/COP/ClientsDataModels/ClientsDataModels.csproj @@ -6,8 +6,4 @@ enable - - - - diff --git a/COP/WinFormsTest/FormClient.Designer.cs b/COP/WinFormsTest/FormClient.Designer.cs index ff44df7..6c8d41b 100644 --- a/COP/WinFormsTest/FormClient.Designer.cs +++ b/COP/WinFormsTest/FormClient.Designer.cs @@ -29,12 +29,12 @@ private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); - this.textBoxLogin = new System.Windows.Forms.TextBox(); + this.textBoxFio = new System.Windows.Forms.TextBox(); this.textBoxPassword = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); - this.mailControl = new BulatovaComponents.Components.UserEmailTextBox(); - this.UserCheckedListBox = new Components.Components.UserCheckedListBox(); + this.mailControl = new BulatovaComponents.MailControl(); + this.userCheckedListBox = new ChubykinaComponents.Components.UserCheckedListBox(); this.label4 = new System.Windows.Forms.Label(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); @@ -50,15 +50,15 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(52, 20); this.label1.TabIndex = 0; - this.label1.Text = "Логин"; + this.label1.Text = "ФИО"; // - // textBoxLogin + // textBoxFio // - this.textBoxLogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxLogin.Location = new System.Drawing.Point(12, 32); - this.textBoxLogin.Name = "textBoxLogin"; - this.textBoxLogin.Size = new System.Drawing.Size(389, 27); - this.textBoxLogin.TabIndex = 1; + this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxFio.Location = new System.Drawing.Point(12, 32); + this.textBoxFio.Name = "textBoxFio"; + this.textBoxFio.Size = new System.Drawing.Size(389, 27); + this.textBoxFio.TabIndex = 1; // // textBoxPassword // @@ -98,14 +98,14 @@ this.mailControl.TabIndex = 5; this.mailControl.validateEmailRegex = null; // - // UserCheckedListBox + // userCheckedListBox // - this.UserCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.UserCheckedListBox.Location = new System.Drawing.Point(12, 207); - this.UserCheckedListBox.Name = "UserCheckedListBox"; - this.UserCheckedListBox.selectedItem = null; - this.UserCheckedListBox.Size = new System.Drawing.Size(389, 130); - this.UserCheckedListBox.TabIndex = 6; + this.userCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.userCheckedListBox.Location = new System.Drawing.Point(12, 207); + this.userCheckedListBox.Name = "UserCheckedListBox"; + this.userCheckedListBox.selectedItem = null; + this.userCheckedListBox.Size = new System.Drawing.Size(389, 130); + this.userCheckedListBox.TabIndex = 6; // // label4 // @@ -147,11 +147,11 @@ this.buttonAvatar.Name = "buttonAvatar"; this.buttonAvatar.Size = new System.Drawing.Size(389, 29); this.buttonAvatar.TabIndex = 10; - this.buttonAvatar.Text = "Выбрать аватар"; + this.buttonAvatar.Text = "Выбрать фото"; this.buttonAvatar.UseVisualStyleBackColor = true; this.buttonAvatar.Click += new System.EventHandler(this.buttonAvatar_Click); // - // FormAccount + // FormClient // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -160,15 +160,15 @@ this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.label4); - this.Controls.Add(this.UserCheckedListBox); + this.Controls.Add(this.userCheckedListBox); this.Controls.Add(this.mailControl); this.Controls.Add(this.label3); this.Controls.Add(this.textBoxPassword); this.Controls.Add(this.label2); - this.Controls.Add(this.textBoxLogin); + this.Controls.Add(this.textBoxFio); this.Controls.Add(this.label1); this.Name = "FormClient"; - this.Text = "Аккаунт"; + this.Text = "Клиент"; this.Load += new System.EventHandler(this.FormClient_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -178,12 +178,12 @@ #endregion private Label label1; - private TextBox textBoxLogin; + private TextBox textBoxFio; private TextBox textBoxPassword; private Label label2; private Label label3; - private BulatovaComponents.Components.UserEmailTextBox mailControl; - private Components.Components.UserCheckedListBox UserCheckedListBox; + private BulatovaComponents.MailControl mailControl; + private ChubykinaComponents.Components.UserCheckedListBox userCheckedListBox; private Label label4; private Button buttonSave; private Button buttonCancel; diff --git a/COP/WinFormsTest/FormClient.cs b/COP/WinFormsTest/FormClient.cs index 1cd9ff0..65619ac 100644 --- a/COP/WinFormsTest/FormClient.cs +++ b/COP/WinFormsTest/FormClient.cs @@ -10,7 +10,7 @@ using System.Windows.Forms; using ClientsContracts.BusinessLogicContracts; using ClientsContracts.ViewModels; using ClientsContracts.SearchModels; -using Components.Components; +using ChubykinaComponents.Components; using ClientsContracts.BindingModels; namespace WinFormsTest @@ -35,7 +35,7 @@ namespace WinFormsTest private void FormClient_Load(object sender, EventArgs e) { _categories = _categoryLogic.ReadList(null); - UserCheckedListBox.addItems(_categories.Select(x => x.Name).ToList()); + userCheckedListBox.addItems(_categories.Select(x => x.Name).ToList()); mailControl.validateEmailRegex = new System.Text.RegularExpressions.Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); mailControl.setTooltipText("name@example.com"); if (_id.HasValue) @@ -45,11 +45,11 @@ namespace WinFormsTest var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value }); if (view != null) { - textBoxLogin.Text = view.Fio; + textBoxFio.Text = view.Fio; mailControl.Email = view.Email; photo = view.Photo; - UserCheckedListBox.selectedItem = view.CategoryName; + userCheckedListBox.selectedItem = view.CategoryName; } } catch (Exception ex) @@ -67,7 +67,7 @@ namespace WinFormsTest private void buttonSave_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(textBoxLogin.Text)) + if (string.IsNullOrEmpty(textBoxFio.Text)) { MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -77,14 +77,14 @@ namespace WinFormsTest MessageBox.Show("Заполните почту или исправьте написание почты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (UserCheckedListBox.selectedItem == null) + if (userCheckedListBox.selectedItem == null) { - MessageBox.Show("Заполните интересы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните категории", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (photo == null) { - MessageBox.Show("Выберите аватар", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите фото", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try @@ -92,9 +92,9 @@ namespace WinFormsTest var model = new ClientBindingModel { Id = _id ?? 0, - Fio = textBoxLogin.Text, + Fio = textBoxFio.Text, Email = mailControl.Email, - CategoryId = _categories.First(x => x.Name == UserCheckedListBox.selectedItem).Id, + CategoryId = _categories.First(x => x.Name == userCheckedListBox.selectedItem).Id, Photo = photo }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); diff --git a/COP/WinFormsTest/FormMain.Designer.cs b/COP/WinFormsTest/FormMain.Designer.cs index af36509..1ff8f5d 100644 --- a/COP/WinFormsTest/FormMain.Designer.cs +++ b/COP/WinFormsTest/FormMain.Designer.cs @@ -29,11 +29,153 @@ 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.controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable(); + this.excelImagesComponent = new ChubykinaComponents.LogicalComponents.ExcelImagesComponent(this.components); + this.wordTableComponentClient = new BulatovaComponents.LogicalComponents.WordTableComponent(this.components); + this.componentDocumentWithChartBarPdf = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf(this.components); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.клиентыToolStripMenuItem, + this.отчётыToolStripMenuItem, + this.категорииToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(800, 28); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // клиенты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(88, 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.A))); + this.создатьToolStripMenuItem.Size = new System.Drawing.Size(246, 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.U))); + this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(246, 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.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"; + this.категорииToolStripMenuItem.Size = new System.Drawing.Size(92, 24); + this.категорииToolStripMenuItem.Text = "Интересы"; + this.категорииToolStripMenuItem.Click += new System.EventHandler(this.категорииToolStripMenuItem_Click); + // + // controlDataTable + // + this.controlDataTable.Dock = System.Windows.Forms.DockStyle.Fill; + this.controlDataTable.Location = new System.Drawing.Point(0, 28); + this.controlDataTable.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.controlDataTable.Name = "controlDataTable"; + this.controlDataTable.SelectedRowIndex = -1; + this.controlDataTable.Size = new System.Drawing.Size(800, 422); + this.controlDataTable.TabIndex = 2; + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormMain"; + this.Controls.Add(this.controlDataTable); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "FormMain"; + this.Text = "Клиенты"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + private MenuStrip menuStrip1; + private ToolStripMenuItem клиентыToolStripMenuItem; + private ToolStripMenuItem создатьToolStripMenuItem; + private ToolStripMenuItem редактироватьToolStripMenuItem; + private ToolStripMenuItem удалитьToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem документToolStripMenuItem; + private ToolStripMenuItem документСТаблицейToolStripMenuItem; + private ToolStripMenuItem документСДиаграммойToolStripMenuItem; + private ToolStripMenuItem категорииToolStripMenuItem; + private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable; + private ChubykinaComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent; + private BulatovaComponents.LogicalComponents.WordTableComponent wordTableComponentClient; + private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf componentDocumentWithChartBarPdf; } } \ No newline at end of file diff --git a/COP/WinFormsTest/FormMain.cs b/COP/WinFormsTest/FormMain.cs index 4a4ff40..bd0ede1 100644 --- a/COP/WinFormsTest/FormMain.cs +++ b/COP/WinFormsTest/FormMain.cs @@ -1,4 +1,12 @@ -using System; +using ComponentsLibraryNet60.DocumentWithChart; +using ComponentsLibraryNet60.Models; +using ControlsLibraryNet60.Core; +using ControlsLibraryNet60.Models; +using ClientsContracts.BusinessLogicContracts; +using ClientsContracts.BindingModels; +using ClientsContracts.ViewModels; +using ChubykinaComponents.LogicalComponents; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +20,129 @@ namespace WinFormsTest { public partial class FormMain : Form { - public FormMain() + private IClientLogic _logic; + + public FormMain(IClientLogic logic) { InitializeComponent(); + _logic = logic; + controlDataTable.LoadColumns(new List { + new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10}, + new DataTableColumnConfig { ColumnHeader = "ФИО", PropertyName = "Fio", Visible = true, Width = 200}, + new DataTableColumnConfig { ColumnHeader = "Выбранная категория", PropertyName = "CategoryName", Visible = true, Width = 200}, + new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200}, + }); + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } + + private void создатьToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClient)); + if (service is FormClient form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void категорииToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCategories)); + if (service is FormCategories form) + { + form.ShowDialog(); + } + } + + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + controlDataTable.Clear(); + var clients = _logic.ReadList(null); + if (clients != null) + { + controlDataTable.AddTable(clients); + } + } + + private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClient)); + if (service is FormClient form) + { + form.Id = controlDataTable.GetSelectedObject().Id; + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void удалитьToolStripMenuItem_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + if (_logic.Delete(new ClientBindingModel { Id = controlDataTable.GetSelectedObject().Id })) + { + LoadData(); + } + } + } + + private void документToolStripMenuItem_Click(object sender, EventArgs e) + { + List photos = new List(); + foreach (var client in _logic.ReadList(null)) + { + photos.Add(client.Photo); + } + string path = AppDomain.CurrentDomain.BaseDirectory + "Фото.xlsx"; + if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фото", photos.ToArray()))) MessageBox.Show("Документ создан"); + } + + private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e) + { + string path = AppDomain.CurrentDomain.BaseDirectory + "Интересы.pdf"; + Dictionary> data = new Dictionary>(); + + data = _logic + .ReadList(null) + .GroupBy(x => x.CategoryName) + .ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count()) }); + + componentDocumentWithChartBarPdf.CreateDoc(new ComponentDocumentWithChartConfig + { + Header = "Интересы", + FilePath = path, + ChartTitle = "Интересы", + LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom, + Data = data, + }); + + MessageBox.Show("Успех"); + } + + private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e) + { + string path = AppDomain.CurrentDomain.BaseDirectory + "Клиенты.docx"; + List<(int, int)> merges = new List<(int, int)> { (1, 2) }; + List widths = new List { 100, 100, 100, 100 }; + List<(string, string)> headers = new List<(string, string)> { + ("Id", "Идентификатор"), + ("", "Личные данные"), + ("Fio", "ФИО"), + ("Email", "Эл. почта"), + ("CategoryName", "Выбранная категория") + }; + + wordTableComponentClient.createWithTable(path, "Список клиентов", merges, widths, headers, _logic.ReadList(null)); } } } + diff --git a/COP/WinFormsTest/FormTest.Designer.cs b/COP/WinFormsTest/FormTest.Designer.cs index 0677660..9b78a16 100644 --- a/COP/WinFormsTest/FormTest.Designer.cs +++ b/COP/WinFormsTest/FormTest.Designer.cs @@ -29,15 +29,15 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.userCheckedListBox = new Components.Components.UserCheckedListBox(); + this.userCheckedListBox = new ChubykinaComponents.Components.UserCheckedListBox(); this.buttonAdd = new System.Windows.Forms.Button(); this.buttonClear = new System.Windows.Forms.Button(); this.buttonSelected = new System.Windows.Forms.Button(); - this.userDatePicker = new Components.Components.UserDatePicker(); + this.userDatePicker = new ChubykinaComponents.Components.UserDatePicker(); this.buttonBoundries = new System.Windows.Forms.Button(); this.buttonSetDate = new System.Windows.Forms.Button(); this.buttonGetDate = new System.Windows.Forms.Button(); - this.userTreeView = new Components.Components.UserTreeView(); + this.userTreeView = new ChubykinaComponents.Components.UserTreeView(); this.buttonSetHierarchy = new System.Windows.Forms.Button(); this.buttonAddWorkers = new System.Windows.Forms.Button(); this.buttonGetValue = new System.Windows.Forms.Button(); @@ -47,9 +47,9 @@ this.buttonExcelTable = new System.Windows.Forms.Button(); this.buttonExcelImages = new System.Windows.Forms.Button(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.excelTableComponent = new Components.LogicalComponents.ExcelTableComponent(this.components); - this.excelDiagramComponent = new Components.LogicalComponents.ExcelDiagramComponent(this.components); - this.excelImagesComponent = new Components.LogicalComponents.ExcelImagesComponent(this.components); + this.excelTableComponent = new ChubykinaComponents.LogicalComponents.ExcelTableComponent(this.components); + this.excelDiagramComponent = new ChubykinaComponents.LogicalComponents.ExcelDiagramComponent(this.components); + this.excelImagesComponent = new ChubykinaComponents.LogicalComponents.ExcelImagesComponent(this.components); this.SuspendLayout(); // // userCheckedListBox @@ -255,15 +255,15 @@ #endregion - private Components.Components.UserCheckedListBox userCheckedListBox; + private ChubykinaComponents.Components.UserCheckedListBox userCheckedListBox; private Button buttonAdd; private Button buttonClear; private Button buttonSelected; - private Components.Components.UserDatePicker userDatePicker; + private ChubykinaComponents.Components.UserDatePicker userDatePicker; private Button buttonBoundries; private Button buttonSetDate; private Button buttonGetDate; - private Components.Components.UserTreeView userTreeView; + private ChubykinaComponents.Components.UserTreeView userTreeView; private Button buttonSetHierarchy; private Button buttonAddWorkers; private Button buttonGetValue; @@ -273,8 +273,8 @@ private Button buttonExcelTable; private Button buttonExcelImages; private OpenFileDialog openFileDialog; - private Components.LogicalComponents.ExcelTableComponent excelTableComponent; - private Components.LogicalComponents.ExcelDiagramComponent excelDiagramComponent; - private Components.LogicalComponents.ExcelImagesComponent excelImagesComponent; + private ChubykinaComponents.LogicalComponents.ExcelTableComponent excelTableComponent; + private ChubykinaComponents.LogicalComponents.ExcelDiagramComponent excelDiagramComponent; + private ChubykinaComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent; } } \ No newline at end of file diff --git a/COP/WinFormsTest/FormTest.cs b/COP/WinFormsTest/FormTest.cs index cfb7286..5b92577 100644 --- a/COP/WinFormsTest/FormTest.cs +++ b/COP/WinFormsTest/FormTest.cs @@ -1,5 +1,5 @@ -using Components.Exceptions; -using Components.LogicalComponents; +using ChubykinaComponents.Exceptions; +using ChubykinaComponents.LogicalComponents; using Microsoft.Office.Core; using Microsoft.VisualBasic.ApplicationServices; using System; diff --git a/COP/WinFormsTest/Program.cs b/COP/WinFormsTest/Program.cs index 8482fd7..cc14bd8 100644 --- a/COP/WinFormsTest/Program.cs +++ b/COP/WinFormsTest/Program.cs @@ -22,7 +22,7 @@ namespace WinFormsTest var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); - Application.Run(new FormTest()); + Application.Run(_serviceProvider.GetRequiredService()); } private static void ConfigureServices(ServiceCollection services) diff --git a/COP/WinFormsTest/WinFormsTest.csproj b/COP/WinFormsTest/WinFormsTest.csproj index 7223cef..cc2e2d1 100644 --- a/COP/WinFormsTest/WinFormsTest.csproj +++ b/COP/WinFormsTest/WinFormsTest.csproj @@ -19,9 +19,9 @@ + - \ No newline at end of file