ничерта не работает
This commit is contained in:
parent
33954a91c4
commit
dcd9929b9c
@ -28,12 +28,58 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormChecker";
|
||||
dataGridView1 = new DataGridView();
|
||||
Id = new DataGridViewTextBoxColumn();
|
||||
FIO = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { Id, FIO });
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersWidth = 51;
|
||||
dataGridView1.RowTemplate.Height = 29;
|
||||
dataGridView1.Size = new Size(525, 403);
|
||||
dataGridView1.TabIndex = 0;
|
||||
dataGridView1.CellEndEdit += dataGridView1_CellEndEdit;
|
||||
dataGridView1.CellValidating += dataGridView1_CellValidating;
|
||||
dataGridView1.KeyDown += dataGridView1_KeyDown;
|
||||
//
|
||||
// Id
|
||||
//
|
||||
Id.HeaderText = "Id";
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
//
|
||||
// FIO
|
||||
//
|
||||
FIO.HeaderText = "Проверяющий";
|
||||
FIO.MinimumWidth = 6;
|
||||
FIO.Name = "FIO";
|
||||
//
|
||||
// FormChecker
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(524, 401);
|
||||
Controls.Add(dataGridView1);
|
||||
Name = "FormChecker";
|
||||
Text = "FormChecker";
|
||||
Load += FormChecker_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
private DataGridViewTextBoxColumn FIO;
|
||||
}
|
||||
}
|
@ -7,14 +7,147 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UchetLabBusinessLogic.BusinessLogic;
|
||||
using UchetLabContracts.BindingModels;
|
||||
using UchetLabContracts.BusinessLogicsContracts;
|
||||
using UchetLabContracts.SearchModels;
|
||||
|
||||
namespace WinFormUchetLab
|
||||
{
|
||||
public partial class FormChecker : Form
|
||||
{
|
||||
public FormChecker()
|
||||
private readonly ICheckerLogic _checkerLogic;
|
||||
public FormChecker(ICheckerLogic checkerLogic)
|
||||
{
|
||||
_checkerLogic = new CheckerLogic(SingletonDatabase.CheckerStorage);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void FormChecker_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var checkers = _checkerLogic.ReadList(new CheckerSearchModel());
|
||||
if (checkers == null)
|
||||
{
|
||||
MessageBox.Show("не удалось загрузить данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
dataGridView1.Rows.Clear();
|
||||
foreach (var difficulty in checkers)
|
||||
{
|
||||
dataGridView1.Rows.Add();
|
||||
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Id"].Value = difficulty.Id;
|
||||
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Проверяющий"].Value = difficulty.FIO;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка при загрузке данных: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Получаем текущую строку
|
||||
DataGridViewRow currentRow = dataGridView1.Rows[e.RowIndex];
|
||||
|
||||
// Проверяем, есть ли у строки ID (если его нет, считаем запись новой)
|
||||
if (currentRow.Cells["Id"].Value == null || Convert.ToInt32(currentRow.Cells["Id"].Value) == 0)
|
||||
{
|
||||
// Создание новой записи
|
||||
_checkerLogic.Create(new CheckerBindingModel()
|
||||
{
|
||||
FIO = currentRow.Cells["FIO"].Value.ToString() // Достаём текст из строки
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Обновление существующей записи
|
||||
_checkerLogic.Update(new CheckerBindingModel()
|
||||
{
|
||||
Id = Convert.ToInt32(currentRow.Cells["Id"].Value), // Достаём Id для обновления
|
||||
FIO = currentRow.Cells["FIO"].Value.ToString() // Достаём текст из строки
|
||||
});
|
||||
}
|
||||
// Сообщаем пользователю об успешном сохранении
|
||||
MessageBox.Show("Запись успешно сохранена", "Сохранение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
// Отложенный вызов функции загрузки данных
|
||||
this.BeginInvoke(new MethodInvoker(LoadData));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Выводим сообщение об ошибке
|
||||
MessageBox.Show($"Ошибка при сохранении записи: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Insert)
|
||||
{
|
||||
// Добавляем новую строку
|
||||
dataGridView1.Rows.Add();
|
||||
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Проверяющий"]; // Ставим фокус на новую строку
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.KeyCode == Keys.Delete && dataGridView1.SelectedRows.Count > 0)
|
||||
{
|
||||
// Подтверждение удаления
|
||||
DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранную запись?",
|
||||
"Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
|
||||
{
|
||||
if (!row.IsNewRow) // Не даём удалять последнюю "пустую" строку
|
||||
{
|
||||
// Получаем Id из столбца "Id"
|
||||
int id = Convert.ToInt32(row.Cells["Id"].Value); // Приводим значение Id к типу int
|
||||
|
||||
// Удаляем запись через логику
|
||||
_checkerLogic.Delete(new CheckerBindingModel()
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
// Удаляем строку из DataGridView
|
||||
dataGridView1.Rows.Remove(row);
|
||||
}
|
||||
}
|
||||
|
||||
// Сообщаем об успешном удалении
|
||||
MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Выводим сообщение об ошибке
|
||||
MessageBox.Show($"Ошибка при удалении записи: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
|
||||
{
|
||||
string? userInput = e.FormattedValue.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userInput))
|
||||
{
|
||||
MessageBox.Show("Нельзя сохранять пустую запись!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
e.Cancel = true; // Отменяем завершение редактирования, если строка пустая
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FIO.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
136
WinFormUchetLab/WinFormUchetLab/FormLab.Designer.cs
generated
136
WinFormUchetLab/WinFormUchetLab/FormLab.Designer.cs
generated
@ -28,12 +28,140 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormLab";
|
||||
textBoxTask = new TextBox();
|
||||
textBoxImage = new TextBox();
|
||||
customTextBox4Date1 = new Visual_components_Kouvshinoff.CustomTextBox4Date();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
controlSelectedListBoxSingle1 = new ControlsLibraryNet60.Selected.ControlSelectedListBoxSingle();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxTask
|
||||
//
|
||||
textBoxTask.Location = new Point(13, 32);
|
||||
textBoxTask.Name = "textBoxTask";
|
||||
textBoxTask.Size = new Size(468, 27);
|
||||
textBoxTask.TabIndex = 0;
|
||||
//
|
||||
// textBoxImage
|
||||
//
|
||||
textBoxImage.Location = new Point(13, 85);
|
||||
textBoxImage.Name = "textBoxImage";
|
||||
textBoxImage.Size = new Size(468, 27);
|
||||
textBoxImage.TabIndex = 1;
|
||||
textBoxImage.Click += textBoxImage_Click;
|
||||
//
|
||||
// customTextBox4Date1
|
||||
//
|
||||
customTextBox4Date1.Location = new Point(15, 285);
|
||||
customTextBox4Date1.Margin = new Padding(3, 4, 3, 4);
|
||||
customTextBox4Date1.Name = "customTextBox4Date1";
|
||||
customTextBox4Date1.pattern = null;
|
||||
customTextBox4Date1.Size = new Size(468, 59);
|
||||
customTextBox4Date1.TabIndex = 3;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(13, 351);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(387, 351);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(13, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(200, 20);
|
||||
label1.TabIndex = 6;
|
||||
label1.Text = "задание для лабораторной";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 62);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(105, 20);
|
||||
label2.TabIndex = 7;
|
||||
label2.Text = "изображение";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(13, 115);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(111, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "проверяющий";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(13, 261);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(83, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "дата сдачи";
|
||||
//
|
||||
// controlSelectedListBoxSingle1
|
||||
//
|
||||
controlSelectedListBoxSingle1.Location = new Point(12, 140);
|
||||
controlSelectedListBoxSingle1.Margin = new Padding(4, 5, 4, 5);
|
||||
controlSelectedListBoxSingle1.Name = "controlSelectedListBoxSingle1";
|
||||
controlSelectedListBoxSingle1.SelectedElement = "";
|
||||
controlSelectedListBoxSingle1.Size = new Size(471, 116);
|
||||
controlSelectedListBoxSingle1.TabIndex = 10;
|
||||
//
|
||||
// FormLab
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(495, 402);
|
||||
Controls.Add(controlSelectedListBoxSingle1);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(customTextBox4Date1);
|
||||
Controls.Add(textBoxImage);
|
||||
Controls.Add(textBoxTask);
|
||||
Name = "FormLab";
|
||||
Text = "FormLab";
|
||||
Load += FormLab_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxTask;
|
||||
private TextBox textBoxImage;
|
||||
private Visual_components_Kouvshinoff.CustomTextBox4Date customTextBox4Date1;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private ControlsLibraryNet60.Selected.ControlSelectedListBoxSingle controlSelectedListBoxSingle1;
|
||||
}
|
||||
}
|
@ -1,20 +1,137 @@
|
||||
using System;
|
||||
using ControlsLibraryNet60.Selected;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UchetLabContracts.BindingModels;
|
||||
using UchetLabContracts.BusinessLogicsContracts;
|
||||
using UchetLabContracts.SearchModels;
|
||||
|
||||
namespace WinFormUchetLab
|
||||
{
|
||||
public partial class FormLab : Form
|
||||
{
|
||||
public FormLab()
|
||||
private readonly ILabLogic _labLogic;
|
||||
private readonly ICheckerLogic _checkerLogic;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
public FormLab(ILabLogic labLogic, ICheckerLogic checkerLogic)
|
||||
{
|
||||
_labLogic = labLogic;
|
||||
_checkerLogic = checkerLogic;
|
||||
InitializeComponent();
|
||||
customTextBox4Date1.pattern = "dd.MM.yyyy";
|
||||
}
|
||||
|
||||
private void FormLab_Load(object sender, EventArgs e)
|
||||
{
|
||||
var listChecker = _checkerLogic.ReadList(null);
|
||||
if (listChecker != null)
|
||||
{
|
||||
foreach (var type in listChecker)
|
||||
{
|
||||
controlSelectedListBoxSingle1.AddElement(type.FIO);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_id.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var lab = _labLogic.ReadElement(new LabSearchModel { Id = _id.Value });
|
||||
if (lab == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
textBoxTask.Text = lab.LabTask;
|
||||
controlSelectedListBoxSingle1.SelectedElement = lab.Checker;
|
||||
textBoxImage.Text = lab.TaskImage;
|
||||
customTextBox4Date1.date = lab.CheckDate;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
customTextBox4Date1.pattern = "dd.MM.yyyy";
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxTask.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните задание", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxImage.Text))
|
||||
{
|
||||
MessageBox.Show("Приложите картинку!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(controlSelectedListBoxSingle1.SelectedElement))
|
||||
{
|
||||
MessageBox.Show("Выберите проверяющего!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (customTextBox4Date1.date == null)
|
||||
{
|
||||
MessageBox.Show("Введите дату сдачи!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var model = new LabBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
LabTask = textBoxTask.Text,
|
||||
TaskImage = textBoxImage.Text,
|
||||
Checker = controlSelectedListBoxSingle1.SelectedElement,
|
||||
CheckDate = customTextBox4Date1.date,
|
||||
};
|
||||
|
||||
var operatingResult = _id.HasValue ? _labLogic.Update(model) : _labLogic.Create(model);
|
||||
if (!operatingResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании сущности 'Счет'!");
|
||||
}
|
||||
|
||||
MessageBox.Show("Создание сущности 'Лабораторная' прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void textBoxImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dialog = new OpenFileDialog { Filter = "jpg|*.jpg" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
textBoxImage.Text = dialog.FileName.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace WinFormUchetLab
|
||||
{
|
||||
partial class Form1
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -29,7 +29,6 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
controlDataTableTable1 = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||
controlDataTableRow1 = new ControlsLibraryNet60.Data.ControlDataTableRow();
|
||||
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||
создатьToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -41,20 +40,15 @@
|
||||
лабаToolStripMenuItem = new ToolStripMenuItem();
|
||||
pdfImage = new CustomComponents.NonVisualComponents.PdfImage(components);
|
||||
customExcelTable = new Non_visual_components_Kouvshinoff.CustomComponentExcelTableWithHeader(components);
|
||||
componentDocumentWithChartBarWord1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord(components);
|
||||
contextMenuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// controlDataTableTable1
|
||||
//
|
||||
controlDataTableTable1.Location = new Point(0, 0);
|
||||
controlDataTableTable1.Margin = new Padding(4, 5, 4, 5);
|
||||
controlDataTableTable1.Name = "controlDataTableTable1";
|
||||
controlDataTableTable1.SelectedRowIndex = -1;
|
||||
controlDataTableTable1.Size = new Size(799, 447);
|
||||
controlDataTableTable1.TabIndex = 0;
|
||||
//
|
||||
// controlDataTableRow1
|
||||
//
|
||||
controlDataTableRow1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlDataTableRow1.AutoSize = true;
|
||||
controlDataTableRow1.ContextMenuStrip = contextMenuStrip1;
|
||||
controlDataTableRow1.Location = new Point(13, 65);
|
||||
controlDataTableRow1.Margin = new Padding(4, 5, 4, 5);
|
||||
controlDataTableRow1.Name = "controlDataTableRow1";
|
||||
@ -67,67 +61,73 @@
|
||||
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem, wordToolStripMenuItem, excelToolStripMenuItem, pdfToolStripMenuItem, лабаToolStripMenuItem });
|
||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
contextMenuStrip1.Size = new Size(146, 172);
|
||||
contextMenuStrip1.ShowImageMargin = false;
|
||||
contextMenuStrip1.Size = new Size(121, 172);
|
||||
//
|
||||
// создатьToolStripMenuItem
|
||||
//
|
||||
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||
создатьToolStripMenuItem.Size = new Size(145, 24);
|
||||
создатьToolStripMenuItem.Size = new Size(120, 24);
|
||||
создатьToolStripMenuItem.Text = "создать";
|
||||
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
|
||||
//
|
||||
// изменитьToolStripMenuItem
|
||||
//
|
||||
изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
|
||||
изменитьToolStripMenuItem.Size = new Size(145, 24);
|
||||
изменитьToolStripMenuItem.Size = new Size(120, 24);
|
||||
изменитьToolStripMenuItem.Text = "изменить";
|
||||
изменитьToolStripMenuItem.Click += изменитьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.Size = new Size(145, 24);
|
||||
удалитьToolStripMenuItem.Size = new Size(120, 24);
|
||||
удалитьToolStripMenuItem.Text = "удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// wordToolStripMenuItem
|
||||
//
|
||||
wordToolStripMenuItem.Name = "wordToolStripMenuItem";
|
||||
wordToolStripMenuItem.Size = new Size(145, 24);
|
||||
wordToolStripMenuItem.Size = new Size(120, 24);
|
||||
wordToolStripMenuItem.Text = "word";
|
||||
wordToolStripMenuItem.Click += wordToolStripMenuItem_Click;
|
||||
//
|
||||
// excelToolStripMenuItem
|
||||
//
|
||||
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
||||
excelToolStripMenuItem.Size = new Size(145, 24);
|
||||
excelToolStripMenuItem.Size = new Size(120, 24);
|
||||
excelToolStripMenuItem.Text = "excel";
|
||||
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
|
||||
//
|
||||
// pdfToolStripMenuItem
|
||||
//
|
||||
pdfToolStripMenuItem.Name = "pdfToolStripMenuItem";
|
||||
pdfToolStripMenuItem.Size = new Size(145, 24);
|
||||
pdfToolStripMenuItem.Size = new Size(120, 24);
|
||||
pdfToolStripMenuItem.Text = "pdf";
|
||||
pdfToolStripMenuItem.Click += pdfToolStripMenuItem_Click;
|
||||
//
|
||||
// лабаToolStripMenuItem
|
||||
//
|
||||
лабаToolStripMenuItem.Name = "лабаToolStripMenuItem";
|
||||
лабаToolStripMenuItem.Size = new Size(145, 24);
|
||||
лабаToolStripMenuItem.Size = new Size(120, 24);
|
||||
лабаToolStripMenuItem.Text = "лаба";
|
||||
лабаToolStripMenuItem.Click += лабаToolStripMenuItem_Click;
|
||||
//
|
||||
// Form1
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(controlDataTableRow1);
|
||||
Controls.Add(controlDataTableTable1);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
Load += Form1_Load;
|
||||
contextMenuStrip1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTableTable1;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableRow controlDataTableRow1;
|
||||
private ContextMenuStrip contextMenuStrip1;
|
||||
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||
@ -139,5 +139,6 @@
|
||||
private ToolStripMenuItem лабаToolStripMenuItem;
|
||||
private CustomComponents.NonVisualComponents.PdfImage pdfImage;
|
||||
private Non_visual_components_Kouvshinoff.CustomComponentExcelTableWithHeader customExcelTable;
|
||||
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord componentDocumentWithChartBarWord1;
|
||||
}
|
||||
}
|
@ -16,11 +16,11 @@ using UchetLabContracts.ViewModels;
|
||||
|
||||
namespace WinFormUchetLab
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILabLogic _labLogic;
|
||||
private readonly ICheckerLogic _checkerLogic;
|
||||
public Form1(ILabLogic dishLogic, ICheckerLogic orderLogic)
|
||||
public FormMain(ILabLogic dishLogic, ICheckerLogic orderLogic)
|
||||
{
|
||||
_labLogic = dishLogic;
|
||||
_checkerLogic = orderLogic;
|
||||
@ -111,7 +111,7 @@ namespace WinFormUchetLab
|
||||
var selectedLab = controlDataTableRow1.GetSelectedObject<LabViewModel>();
|
||||
if (selectedLab == null)
|
||||
{
|
||||
MessageBox.Show("Âûáåðèòå ñ÷åò äëÿ ðåäàêòèðîâàíèÿ!", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Âûáåðèòå ëàáîðàòîðíóþ äëÿ ðåäàêòèðîâàíèÿ!", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ namespace WinFormUchetLab
|
||||
}
|
||||
string[] imagesArray = images.ToArray();
|
||||
|
||||
pdfImage.CreatePdfDoc(new DataForImage(fileName, "Ñêàíû ÷åêîâ", imagesArray));
|
||||
pdfImage.CreatePdfDoc(new DataForImage(fileName, "Èçîáðàæåíèÿ ê ëàáîðàòîðíûì", imagesArray));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -229,22 +229,22 @@ namespace WinFormUchetLab
|
||||
|
||||
var data = new Dictionary<string, List<(int Date, double Value)>>();
|
||||
|
||||
var orders = _orderLogic.ReadList(null);
|
||||
var labs = _labLogic.ReadList(null);
|
||||
|
||||
var groupedOrders = orders.GroupBy(order => order.Dish)
|
||||
var groupedLabs = labs.GroupBy(lab => lab.Checker)
|
||||
.Select(group => new
|
||||
{
|
||||
DishName = group.Key,
|
||||
OrderCount = group.Count()
|
||||
CheckerName = group.Key,
|
||||
LabCount = group.Count()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
data["Áëþäà"] = new List<(int Date, double Value)>();
|
||||
data["Ïðîâåðÿþùèå"] = new List<(int Date, double Value)>();
|
||||
|
||||
int counter = 1;
|
||||
foreach (var group in groupedOrders)
|
||||
foreach (var group in groupedLabs)
|
||||
{
|
||||
data["Áëþäà"].Add((counter, group.OrderCount));
|
||||
data["Ïðîâåðÿþùèå"].Add((counter, group.LabCount));
|
||||
counter++;
|
||||
}
|
||||
|
||||
@ -252,11 +252,11 @@ namespace WinFormUchetLab
|
||||
|
||||
try
|
||||
{
|
||||
componentDocumentWithChartBarWord.CreateDoc(new ComponentDocumentWithChartConfig
|
||||
componentDocumentWithChartBarWord1.CreateDoc(new ComponentDocumentWithChartConfig
|
||||
{
|
||||
Header = "test",
|
||||
FilePath = fileName,
|
||||
ChartTitle = "Êîëè÷åñòâî çàêàçîâ îïðåäåëåííûõ áëþä",
|
||||
ChartTitle = "Êîëè÷åñòâî ëàáîðàòîðíûõ ó ïðîâåðÿþùèõ",
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||
Data = data
|
||||
});
|
||||
@ -266,7 +266,49 @@ namespace WinFormUchetLab
|
||||
MessageBox.Show(ex.Message, "Îøèáêà");
|
||||
}
|
||||
}
|
||||
private void ñîçäàòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddElement();
|
||||
}
|
||||
|
||||
private void èçìåíèòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateElement();
|
||||
}
|
||||
|
||||
private void óäàëèòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
DeleteElement();
|
||||
}
|
||||
|
||||
private void wordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateWord();
|
||||
}
|
||||
|
||||
private void excelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateExcel();
|
||||
}
|
||||
|
||||
private void pdfToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreatePdf();
|
||||
}
|
||||
private void ShowFormChecker()
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormChecker));
|
||||
if (!(service is FormChecker form))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void ëàáàToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowFormChecker();
|
||||
}
|
||||
}
|
||||
}
|
@ -126,4 +126,7 @@
|
||||
<metadata name="customExcelTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>323, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithChartBarWord1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>496, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -28,7 +28,7 @@ namespace WinFormUchetLab
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
Application.Run(_serviceProvider.GetRequiredService<Form1>());
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
@ -48,7 +48,7 @@ namespace WinFormUchetLab
|
||||
services.AddTransient<ICheckerLogic, CheckerLogic>();
|
||||
|
||||
// IoC-êîíòåéíåð, ôîðìû îòîáðàæåíèÿ
|
||||
services.AddTransient<Form1>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormLab>();
|
||||
services.AddTransient<FormChecker>();
|
||||
}
|
||||
|
35
WinFormUchetLab/WinFormUchetLab/SingletonDatabase.cs
Normal file
35
WinFormUchetLab/WinFormUchetLab/SingletonDatabase.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UchetLabContracts.StorageContracts;
|
||||
using UchetLabDatabaseImplement.Implements;
|
||||
|
||||
namespace WinFormUchetLab
|
||||
{
|
||||
public static class SingletonDatabase
|
||||
{
|
||||
private static ILabStorage? _labStorage = null;
|
||||
public static ILabStorage LabStorage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_labStorage == null)
|
||||
_labStorage = new LabStorage();
|
||||
return _labStorage;
|
||||
}
|
||||
}
|
||||
|
||||
private static ICheckerStorage? _checkerStorage = null;
|
||||
public static ICheckerStorage CheckerStorage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_checkerStorage == null)
|
||||
_checkerStorage = new CheckerStorage();
|
||||
return _checkerStorage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user