доработал лабу 3

This commit is contained in:
Stepan 2024-11-12 23:06:42 +04:00
parent 07b4a0d7bd
commit 2be92b4f12
9 changed files with 210 additions and 161 deletions

View File

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace Contracts.BusinessLogicsContracts
{
/// <summary>
/// Интерфейс для описания работы бизнес-логики для сущности "Счет"
/// Интерфейс для описания работы бизнес-логики для сущности "Книга"
/// </summary>
public interface IBookLogic
{

View File

@ -40,7 +40,6 @@
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(384, 211);
dataGridView.TabIndex = 0;
dataGridView.CellEndEdit += dataGridView_CellEndEdit;
@ -53,11 +52,10 @@
ClientSize = new Size(384, 211);
Controls.Add(dataGridView);
Name = "FormAuthor";
Text = "Блюда";
Text = "Авторы";
Load += FormAuthor_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion

View File

@ -49,7 +49,7 @@ namespace Forms
var operatingResult = id != 0 ? _authorLogic.Update(model) : _authorLogic.Create(model);
if (!operatingResult)
{
throw new Exception("Ошибка при создании сущности 'Заказанное блюдо'!");
throw new Exception("Ошибка при создании сущности 'Автор'!");
}
}
else

View File

@ -41,18 +41,16 @@
//
// textBoxTitleFullName
//
textBoxTitleFullName.Location = new Point(13, 33);
textBoxTitleFullName.Margin = new Padding(3, 4, 3, 4);
textBoxTitleFullName.Location = new Point(11, 25);
textBoxTitleFullName.Name = "textBoxTitleFullName";
textBoxTitleFullName.Size = new Size(250, 27);
textBoxTitleFullName.Size = new Size(219, 23);
textBoxTitleFullName.TabIndex = 0;
//
// buttonSave
//
buttonSave.Location = new Point(13, 545);
buttonSave.Margin = new Padding(3, 4, 3, 4);
buttonSave.Location = new Point(11, 409);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(114, 31);
buttonSave.Size = new Size(100, 23);
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
@ -60,10 +58,9 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(177, 545);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Location = new Point(155, 409);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(86, 31);
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 2;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
@ -72,35 +69,35 @@
// label1
//
label1.AutoSize = true;
label1.Location = new Point(13, 9);
label1.Location = new Point(11, 7);
label1.Name = "label1";
label1.Size = new Size(129, 20);
label1.Size = new Size(64, 15);
label1.TabIndex = 6;
label1.Text = "ФИО официанта*";
label1.Text = "Название*";
//
// labelAuthor
//
labelAuthor.AutoSize = true;
labelAuthor.Location = new Point(13, 117);
labelAuthor.Location = new Point(11, 88);
labelAuthor.Name = "labelAuthor";
labelAuthor.Size = new Size(146, 20);
labelAuthor.Size = new Size(45, 15);
labelAuthor.TabIndex = 7;
labelAuthor.Text = "Заказанное блюдо*";
labelAuthor.Text = "Автор*";
//
// customTextBox1
//
customTextBox1.DatePattern = null;
customTextBox1.Location = new Point(13, 401);
customTextBox1.Margin = new Padding(3, 4, 3, 4);
customTextBox1.Location = new Point(11, 301);
customTextBox1.Name = "customTextBox1";
customTextBox1.Size = new Size(242, 89);
customTextBox1.Size = new Size(212, 67);
customTextBox1.TabIndex = 9;
//
// textBoxScan
//
textBoxScan.Location = new Point(13, 87);
textBoxScan.Location = new Point(11, 65);
textBoxScan.Margin = new Padding(3, 2, 3, 2);
textBoxScan.Name = "textBoxScan";
textBoxScan.Size = new Size(125, 27);
textBoxScan.Size = new Size(110, 23);
textBoxScan.TabIndex = 10;
textBoxScan.Text = "Нажми сюда";
textBoxScan.Click += textBoxScan_Click;
@ -108,26 +105,26 @@
// label2
//
label2.AutoSize = true;
label2.Location = new Point(13, 64);
label2.Location = new Point(11, 48);
label2.Name = "label2";
label2.Size = new Size(77, 20);
label2.Size = new Size(58, 15);
label2.TabIndex = 12;
label2.Text = "Скан чека";
label2.Text = "Обложка";
//
// controlSelectedListBoxSingle
//
controlSelectedListBoxSingle.Location = new Point(13, 142);
controlSelectedListBoxSingle.Margin = new Padding(4, 5, 4, 5);
controlSelectedListBoxSingle.Location = new Point(11, 106);
controlSelectedListBoxSingle.Margin = new Padding(4);
controlSelectedListBoxSingle.Name = "controlSelectedListBoxSingle";
controlSelectedListBoxSingle.SelectedElement = "";
controlSelectedListBoxSingle.Size = new Size(250, 233);
controlSelectedListBoxSingle.Size = new Size(219, 175);
controlSelectedListBoxSingle.TabIndex = 13;
//
// FormBook
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(275, 589);
ClientSize = new Size(241, 442);
Controls.Add(controlSelectedListBoxSingle);
Controls.Add(label2);
Controls.Add(textBoxScan);
@ -137,9 +134,8 @@
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxTitleFullName);
Margin = new Padding(3, 4, 3, 4);
Name = "FormBook";
Text = "Счет";
Text = "Книга";
Load += FormBook_Load;
ResumeLayout(false);
PerformLayout();

View File

@ -88,22 +88,22 @@ namespace WinForms
if (string.IsNullOrEmpty(textBoxTitleFullName.Text))
{
MessageBox.Show("Заполните ФИО официанта!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Заполните Название!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxScan.Text))
{
MessageBox.Show("Приложите скан чека!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Приложите обложку!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(controlSelectedListBoxSingle.SelectedElement))
{
MessageBox.Show("Выберите блюдо!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Выберите автора!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(customTextBox1.TextBoxValue))
{
MessageBox.Show("Введите дату заказа!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Введите дату издания!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
@ -121,10 +121,10 @@ namespace WinForms
var operatingResult = _id.HasValue ? _bookLogic.Update(model) : _bookLogic.Create(model);
if (!operatingResult)
{
throw new Exception("Ошибка при создании сущности 'Счет'!");
throw new Exception("Ошибка при создании сущности 'Книга'!");
}
MessageBox.Show("Создание сущности 'Счет' прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Создание сущности 'Книга' прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}

View File

@ -1,4 +1,6 @@
namespace Forms
using System.Windows.Forms;
namespace Forms
{
partial class FormMain
{
@ -33,109 +35,108 @@
tableComponent = new Components.NonVisualComponents.TableComponent(components);
pdfImage = new ComponentProgramming.NonVisualComponents.PdfImage(components);
componentDocumentWithChartBarWord = new COP_V6.NoVisualComponent.HistogramToDoc(components);
button1 = new Button();
button2 = new Button();
button3 = new Button();
button4 = new Button();
button5 = new Button();
button6 = new Button();
button7 = new Button();
книгаToolStripMenuItem = new ToolStripMenuItem();
созToolStripMenuItem = new ToolStripMenuItem();
редактироватьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem();
авторToolStripMenuItem = new ToolStripMenuItem();
документыToolStripMenuItem = new ToolStripMenuItem();
wordToolStripMenuItem = new ToolStripMenuItem();
excelToolStripMenuItem = new ToolStripMenuItem();
pdfToolStripMenuItem = new ToolStripMenuItem();
contextMenuStrip = new ContextMenuStrip(components);
contextMenuStrip.SuspendLayout();
SuspendLayout();
//
// controlDataGridView1
//
controlDataGridView1.Location = new Point(174, 14);
controlDataGridView1.Location = new Point(60, 14);
controlDataGridView1.Margin = new Padding(4, 5, 4, 5);
controlDataGridView1.Name = "controlDataGridView1";
controlDataGridView1.Size = new Size(613, 275);
controlDataGridView1.Size = new Size(678, 344);
controlDataGridView1.TabIndex = 1;
//
// button1
// книгаToolStripMenuItem
//
button1.Location = new Point(35, 28);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 2;
button1.Text = "Добавить";
button1.UseVisualStyleBackColor = true;
button1.Click += btnAdd_Click;
книгаToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { созToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem });
книгаToolStripMenuItem.Name = "книгаToolStripMenuItem";
книгаToolStripMenuItem.Size = new Size(137, 22);
книгаToolStripMenuItem.Text = "Книга";
//
// button2
// созToolStripMenuItem
//
button2.Location = new Point(35, 57);
button2.Name = "button2";
button2.Size = new Size(75, 23);
button2.TabIndex = 3;
button2.Text = "Обновить";
button2.UseVisualStyleBackColor = true;
button2.Click += btnUpdate_Click;
созToolStripMenuItem.Name = "созToolStripMenuItem";
созToolStripMenuItem.Size = new Size(154, 22);
созToolStripMenuItem.Text = "Создать";
созToolStripMenuItem.Click += созToolStripMenuItem_Click;
//
// button3
// редактироватьToolStripMenuItem
//
button3.Location = new Point(35, 86);
button3.Name = "button3";
button3.Size = new Size(75, 23);
button3.TabIndex = 4;
button3.Text = "Удалить";
button3.UseVisualStyleBackColor = true;
button3.Click += btnDelete_Click;
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
редактироватьToolStripMenuItem.Size = new Size(154, 22);
редактироватьToolStripMenuItem.Text = "Редактировать";
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
//
// button4
// удалитьToolStripMenuItem
//
button4.Location = new Point(35, 115);
button4.Name = "button4";
button4.Size = new Size(75, 23);
button4.TabIndex = 5;
button4.Text = "Word";
button4.UseVisualStyleBackColor = true;
button4.Click += btnCreateWord_Click;
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.Size = new Size(154, 22);
удалитьToolStripMenuItem.Text = "Удалить";
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
//
// button5
// авторToolStripMenuItem
//
button5.Location = new Point(35, 144);
button5.Name = "button5";
button5.Size = new Size(75, 23);
button5.TabIndex = 6;
button5.Text = "Excel";
button5.UseVisualStyleBackColor = true;
button5.Click += btnCreateExcel_Click;
авторToolStripMenuItem.Name = "авторToolStripMenuItem";
авторToolStripMenuItem.Size = new Size(137, 22);
авторToolStripMenuItem.Text = "Автор";
авторToolStripMenuItem.Click += авторToolStripMenuItem_Click;
//
// button6
// документыToolStripMenuItem
//
button6.Location = new Point(35, 173);
button6.Name = "button6";
button6.Size = new Size(75, 23);
button6.TabIndex = 7;
button6.Text = "Pdf";
button6.UseVisualStyleBackColor = true;
button6.Click += btnCreatePdf_Click;
документыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { wordToolStripMenuItem, excelToolStripMenuItem, pdfToolStripMenuItem });
документыToolStripMenuItem.Name = окументыToolStripMenuItem";
документыToolStripMenuItem.Size = new Size(137, 22);
документыToolStripMenuItem.Text = "Документы";
//
// button7
// wordToolStripMenuItem
//
button7.Location = new Point(35, 202);
button7.Name = "button7";
button7.Size = new Size(75, 23);
button7.TabIndex = 8;
button7.Text = "Авторы";
button7.UseVisualStyleBackColor = true;
button7.Click += btnShowFormAuthor_Click;
wordToolStripMenuItem.Name = "wordToolStripMenuItem";
wordToolStripMenuItem.Size = new Size(103, 22);
wordToolStripMenuItem.Text = "Word";
wordToolStripMenuItem.Click += wordToolStripMenuItem_Click;
//
// excelToolStripMenuItem
//
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
excelToolStripMenuItem.Size = new Size(103, 22);
excelToolStripMenuItem.Text = "Excel";
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
//
// pdfToolStripMenuItem
//
pdfToolStripMenuItem.Name = "pdfToolStripMenuItem";
pdfToolStripMenuItem.Size = new Size(103, 22);
pdfToolStripMenuItem.Text = "Pdf";
pdfToolStripMenuItem.Click += pdfToolStripMenuItem_Click;
//
// contextMenuStrip
//
contextMenuStrip.ImageScalingSize = new Size(20, 20);
contextMenuStrip.Items.AddRange(new ToolStripItem[] { книгаToolStripMenuItem, авторToolStripMenuItem, документыToolStripMenuItem });
contextMenuStrip.Name = "contextMenuStrip";
contextMenuStrip.Size = new Size(138, 70);
contextMenuStrip.Text = "Управление";
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 426);
Controls.Add(button7);
Controls.Add(button6);
Controls.Add(button5);
Controls.Add(button4);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(controlDataGridView1);
Name = "FormMain";
Text = "FormMain";
Load += FormMain_Load;
contextMenuStrip.ResumeLayout(false);
ResumeLayout(false);
}
@ -144,12 +145,15 @@
private ComponentProgramming.NonVisualComponents.PdfImage pdfImage;
private COP_V6.NoVisualComponent.HistogramToDoc componentDocumentWithChartBarWord;
private COP_V6.ControlDataGridView controlDataGridView1;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private Button button6;
private Button button7;
private ContextMenuStrip contextMenuStrip;
private ToolStripMenuItem книгаToolStripMenuItem;
private ToolStripMenuItem созToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem авторToolStripMenuItem;
private ToolStripMenuItem документыToolStripMenuItem;
private ToolStripMenuItem wordToolStripMenuItem;
private ToolStripMenuItem excelToolStripMenuItem;
private ToolStripMenuItem pdfToolStripMenuItem;
}
}

View File

@ -98,7 +98,7 @@ namespace Forms
var selectedBook = controlDataGridView1.GetRow<BookViewModel>();
if (selectedBook == null)
{
MessageBox.Show("Выберите счет для редактирования!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Выберите книгу для редактирования!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
@ -156,7 +156,7 @@ namespace Forms
}
string[] imagesArray = images.ToArray();
pdfImage.CreatePdfDoc(new DataForImage(fileName, "Сканы чеков", imagesArray));
pdfImage.CreatePdfDoc(new DataForImage(fileName, "Обложки", imagesArray));
}
}
catch (Exception ex)
@ -182,14 +182,14 @@ namespace Forms
List<MergeCells> mergeCells = new List<MergeCells>()
{
new MergeCells("Счет", new int[] { 1, 2})
new MergeCells("Книга", new int[] { 1, 2})
};
List<ColumnInfo> columns = new List<ColumnInfo>()
{
new ColumnInfo("Id", "Идент.", 10),
new ColumnInfo("TitleFullName", "ФИО официанта", 20),
new ColumnInfo("Author", "Блюдо", 20),
new ColumnInfo("BookDate", "Дата оплаты чека", 30),
new ColumnInfo("TitleFullName", "Название", 20),
new ColumnInfo("Author", "Автор", 20),
new ColumnInfo("BookDate", "Дата издания", 30),
new ColumnInfo("", "заглушка", 0),
};
@ -264,40 +264,88 @@ namespace Forms
private void btnAdd_Click(object sender, EventArgs e)
private void созToolStripMenuItem_Click(object sender, EventArgs e)
{
AddElement();
}
private void btnUpdate_Click(object sender, EventArgs e)
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateElement();
}
private void btnDelete_Click(object sender, EventArgs e)
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteElement();
}
private void btnCreateWord_Click(object sender, EventArgs e)
private void wordToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void btnCreateExcel_Click(object sender, EventArgs e)
private void excelToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateExcel();
}
private void btnCreatePdf_Click(object sender, EventArgs e)
private void pdfToolStripMenuItem_Click(object sender, EventArgs e)
{
CreatePdf();
}
private void btnShowFormAuthor_Click(object sender, EventArgs e)
private void авторToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowFormAuthor();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Ctrl+A - добавить запись
if (keyData == (Keys.Control | Keys.A))
{
AddElement();
return true;
}
// Ctrl+U - редактировать запись
if (keyData == (Keys.Control | Keys.U))
{
UpdateElement();
return true;
}
// Ctrl+D - удалить запись
if (keyData == (Keys.Control | Keys.D))
{
DeleteElement();
return true;
}
// Ctrl+S - создать документ Word
if (keyData == (Keys.Control | Keys.S))
{
CreateWord();
return true;
}
// Ctrl+T - создать документ Excel
if (keyData == (Keys.Control | Keys.T))
{
CreateExcel();
return true;
}
// Ctrl+C - создать документ Pdf
if (keyData == (Keys.Control | Keys.C))
{
CreatePdf();
return true;
}
// Ctrl+M - вывести форму списка авторов
if (keyData == (Keys.Control | Keys.M))
{
ShowFormAuthor();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
private void ShowFormAuthor()
{
var service = Program.ServiceProvider?.GetService(typeof(FormAuthor));

View File

@ -126,4 +126,7 @@
<metadata name="componentDocumentWithChartBarWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>415, 17</value>
</metadata>
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>