diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs b/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs index a204b7f..31f120f 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs @@ -40,6 +40,7 @@ pdfTable = new NonVisualComponents.PdfTable(components); componentWord = new VisualComponentsLib.Components.ComponentWord(components); button1 = new Button(); + contextMenuStrip = new ContextMenuStrip(components); groupBox.SuspendLayout(); SuspendLayout(); // @@ -47,7 +48,7 @@ // labelCheck.AutoSize = true; labelCheck.BorderStyle = BorderStyle.FixedSingle; - labelCheck.Location = new Point(292, 134); + labelCheck.Location = new Point(292, 192); labelCheck.Name = "labelCheck"; labelCheck.Size = new Size(62, 17); labelCheck.TabIndex = 1; @@ -55,7 +56,7 @@ // // buttonCheck // - buttonCheck.Location = new Point(279, 166); + buttonCheck.Location = new Point(279, 224); buttonCheck.Name = "buttonCheck"; buttonCheck.Size = new Size(75, 23); buttonCheck.TabIndex = 2; @@ -65,7 +66,7 @@ // // myListBox // - myListBox.Location = new Point(6, 22); + myListBox.Location = new Point(6, 83); myListBox.MinimumSize = new Size(84, 53); myListBox.Name = "myListBox"; myListBox.SelectedString = null; @@ -74,14 +75,14 @@ // // textBoxInput // - textBoxInput.Location = new Point(254, 25); + textBoxInput.Location = new Point(254, 83); textBoxInput.Name = "textBoxInput"; textBoxInput.Size = new Size(100, 23); textBoxInput.TabIndex = 4; // // buttonAddList // - buttonAddList.Location = new Point(279, 54); + buttonAddList.Location = new Point(279, 112); buttonAddList.Name = "buttonAddList"; buttonAddList.Size = new Size(75, 23); buttonAddList.TabIndex = 5; @@ -91,7 +92,7 @@ // // buttonClear // - buttonClear.Location = new Point(279, 83); + buttonClear.Location = new Point(279, 141); buttonClear.Name = "buttonClear"; buttonClear.Size = new Size(75, 23); buttonClear.TabIndex = 6; @@ -107,9 +108,9 @@ groupBox.Controls.Add(buttonAddList); groupBox.Controls.Add(buttonCheck); groupBox.Controls.Add(textBoxInput); - groupBox.Location = new Point(12, 12); + groupBox.Location = new Point(12, 71); groupBox.Name = "groupBox"; - groupBox.Size = new Size(368, 271); + groupBox.Size = new Size(368, 329); groupBox.TabIndex = 7; groupBox.TabStop = false; groupBox.Text = "Первый компонент"; @@ -120,7 +121,7 @@ // // button1 // - button1.Location = new Point(407, 24); + button1.Location = new Point(411, 71); button1.Name = "button1"; button1.Size = new Size(75, 23); button1.TabIndex = 8; @@ -128,6 +129,11 @@ button1.UseVisualStyleBackColor = true; button1.Click += Button1_Click; // + // contextMenuStrip + // + contextMenuStrip.Name = "contextMenuStrip"; + contextMenuStrip.Size = new Size(61, 4); + // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); @@ -155,5 +161,6 @@ private NonVisualComponents.PdfTable pdfTable; private VisualComponentsLib.Components.ComponentWord componentWord; private Button button1; + private ContextMenuStrip contextMenuStrip; } } \ No newline at end of file diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.cs b/VisualComponentsForm/VisualComponentsForm/FormMain.cs index 504f130..7877ca1 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.cs +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.cs @@ -1,37 +1,65 @@ +using Contracts.SearchModel; +using Contracts.StorageContracts; +using DatabaseImplement.Implements; +using System; +using System.Windows.Forms; using VisualComponentsForm.Models; using VisualComponentsLib.SupportClass; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; namespace VisualComponentsForm { public partial class FormMain : Form { + private readonly ILabWorkStorage _labWorkStorage; + private int numberObject; private List peoples; private List info; - public FormMain() + public FormMain(ILabWorkStorage labWorkStorage) { numberObject = 0; peoples = new List { - new People(0, "", "", 20), - new People(1, "", "", 19), - new People(2, "", "", 25), - new People(3, "", "", 23) + new People(0, "Никита", "Сергеев", 20), + new People(1, "Дарья", "Балберова", 19), + new People(2, "Данил", "Малин", 25), + new People(3, "Николай", "Распаев", 23) }; info = new List { - new DataGridViewInfoCol("", "Id", 60, true), - new DataGridViewInfoCol("", "Name", 60, true), - new DataGridViewInfoCol("", "Surname", 60, true), - new DataGridViewInfoCol("", "Age", 60, true) + new DataGridViewInfoCol("Номер", "Id", 60, true), + new DataGridViewInfoCol("Имя", "Name", 60, true), + new DataGridViewInfoCol("Фамилия", "Surname", 60, true), + new DataGridViewInfoCol("Возраст", "Age", 60, true) }; InitializeComponent(); + + ToolStripMenuItem createLabWork = new("Создать лаб. раб."); + ToolStripMenuItem updateLabWork = new("Обновить лаб. раб."); + ToolStripMenuItem deleteLabWork = new("Удалить лаб. раб."); + ToolStripMenuItem createSimpleDocItem = new("Создать Word"); + ToolStripMenuItem createTableDocEntityItem = new("Создать Excel"); + ToolStripMenuItem createChartDocEntityItem = new("Создать Pdf"); + + contextMenuStrip.Items.AddRange(new[] { createLabWork, updateLabWork, deleteLabWork }); + myListBox.ContextMenuStrip = contextMenuStrip; + //valueTree.ContextMenuStrip = contextMenuStrip; + + createLabWork.Click += createLabWork_Click; + updateLabWork.Click += updateLabWork_Click; + deleteLabWork.Click += deleteLabWork_Click; + //createSimpleDocItem.Click += createSimpleDocItem_Click; + //createTableDocEntityItem.Click += createTableDocEntityItem_Click; + //createChartDocEntityItem.Click += createChartDocEntityItem_Click; + + _labWorkStorage = labWorkStorage; } private void ButtonCheck_Click(object sender, EventArgs e) @@ -51,24 +79,75 @@ namespace VisualComponentsForm myListBox.ClearAll(); } + public void createLabWork_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork)); + + if (service is FormCreateLabWork form) + { + form.ShowDialog(); + + //LoadData(); + } + } + + public void updateLabWork_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork)); + + if (service is FormCreateLabWork form) + { + form.Id = 1; + + form.ShowDialog(); + + //LoadData(); + } + } + + public void deleteLabWork_Click(object sender, EventArgs e) + { + // Удаление выбранных строк при нажатии на клавишу Delete + /* + if (dataGridView.SelectedRows.Count > 0) + { + DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранные записи?", "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + + if (result == DialogResult.Yes) + { + foreach (DataGridViewRow row in dataGridView.SelectedRows) + { + if (!row.IsNewRow) + { + int id = Convert.ToInt32(row.Cells["Id"].Value); + + var view = _disciplineStorage.GetElement(new DisciplineSearchModel + { + Id = id + }); + + _disciplineStorage.Delete(new(view!)); + + } + } + + //LoadData(); + } + } + */ + } + private void FormMain_KeyDown(object sender, KeyEventArgs e) { if (e.Control) { if (e.KeyCode == Keys.A) { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork)); - - if (service is FormCreateLabWork form) - { - form.ShowDialog(); - - //LoadData(); - } + createLabWork_Click(sender, e); } if (e.KeyCode == Keys.U) { - //updateOrderEntityItem_Click(sender, e); + updateLabWork_Click(sender, e); } if (e.KeyCode == Keys.D) { diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.resx b/VisualComponentsForm/VisualComponentsForm/FormMain.resx index c16a279..6c50c4b 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.resx +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.resx @@ -126,4 +126,7 @@ 245, 17 + + 390, 17 + \ No newline at end of file