Agliullov D. A. Lab Work 5 Hard #16

Closed
d.agliullov wants to merge 49 commits from Lab5_Hard into Lab4_Hard
2 changed files with 115 additions and 83 deletions
Showing only changes of commit 4314a0d712 - Show all commits

View File

@ -28,109 +28,129 @@
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.comboBoxPastry = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.NumericUpDown();
this.textBoxSum = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).BeginInit();
this.SuspendLayout();
label1 = new Label();
label2 = new Label();
label3 = new Label();
buttonCancel = new Button();
buttonSave = new Button();
comboBoxPastry = new ComboBox();
textBoxCount = new NumericUpDown();
textBoxSum = new TextBox();
label4 = new Label();
comboBoxClient = new ComboBox();
((System.ComponentModel.ISupportInitialize)textBoxCount).BeginInit();
SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Изделие:";
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(56, 15);
label1.TabIndex = 0;
label1.Text = "Изделие:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15);
this.label2.TabIndex = 1;
this.label2.Text = "Количество:";
label2.AutoSize = true;
label2.Location = new Point(12, 40);
label2.Name = "label2";
label2.Size = new Size(75, 15);
label2.TabIndex = 1;
label2.Text = "Количество:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 68);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 15);
this.label3.TabIndex = 2;
this.label3.Text = "Сумма:";
label3.AutoSize = true;
label3.Location = new Point(12, 68);
label3.Name = "label3";
label3.Size = new Size(48, 15);
label3.TabIndex = 2;
label3.Text = "Сумма:";
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(221, 109);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(95, 23);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(221, 133);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(95, 23);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSave.Location = new System.Drawing.Point(141, 109);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(77, 23);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.Location = new Point(141, 133);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(77, 23);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// comboBoxPastry
//
this.comboBoxPastry.FormattingEnabled = true;
this.comboBoxPastry.Location = new System.Drawing.Point(101, 9);
this.comboBoxPastry.Name = "comboBoxPastry";
this.comboBoxPastry.Size = new System.Drawing.Size(214, 23);
this.comboBoxPastry.TabIndex = 5;
this.comboBoxPastry.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPastry_SelectedIndexChanged);
comboBoxPastry.FormattingEnabled = true;
comboBoxPastry.Location = new Point(101, 9);
comboBoxPastry.Name = "comboBoxPastry";
comboBoxPastry.Size = new Size(214, 23);
comboBoxPastry.TabIndex = 5;
comboBoxPastry.SelectedIndexChanged += ComboBoxPastry_SelectedIndexChanged;
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(101, 38);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(214, 23);
this.textBoxCount.TabIndex = 6;
this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
textBoxCount.Location = new Point(101, 38);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(214, 23);
textBoxCount.TabIndex = 6;
textBoxCount.ValueChanged += TextBoxCount_TextChanged;
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(101, 65);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(214, 23);
this.textBoxSum.TabIndex = 7;
textBoxSum.Location = new Point(101, 65);
textBoxSum.Name = "textBoxSum";
textBoxSum.Size = new Size(214, 23);
textBoxSum.TabIndex = 7;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(12, 99);
label4.Name = "label4";
label4.Size = new Size(49, 15);
label4.TabIndex = 8;
label4.Text = "Клиент:";
//
// comboBoxClient
//
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(101, 96);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(215, 23);
comboBoxClient.TabIndex = 9;
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(327, 144);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxPastry);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FormCreateOrder";
this.Text = "Создание заказа";
((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(327, 168);
Controls.Add(comboBoxClient);
Controls.Add(label4);
Controls.Add(textBoxSum);
Controls.Add(textBoxCount);
Controls.Add(comboBoxPastry);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormCreateOrder";
Text = "Создание заказа";
((System.ComponentModel.ISupportInitialize)textBoxCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -143,5 +163,7 @@
private ComboBox comboBoxPastry;
private NumericUpDown textBoxCount;
private TextBox textBoxSum;
private Label label4;
private ComboBox comboBoxClient;
}
}

View File

@ -12,14 +12,16 @@ namespace ConfectioneryView
private readonly ILogger _logger;
private readonly IPastryLogic _logicP;
private readonly IOrderLogic _logicO;
private readonly IClientLogic _clientLogic;
private readonly List<PastryViewModel>? _list;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPastryLogic logicP, IOrderLogic logicO)
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPastryLogic logicP, IOrderLogic logicO, IClientLogic clientLogic)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicO = logicO;
_clientLogic = clientLogic;
_list = logicP.ReadList(null);
if (_list != null)
{
@ -28,6 +30,14 @@ namespace ConfectioneryView
comboBoxPastry.DataSource = _list;
comboBoxPastry.SelectedItem = null;
}
var clients = _clientLogic.ReadList(null);
if (clients != null)
{
comboBoxClient.DisplayMember = "clientFIO";
comboBoxClient.ValueMember = "Id";
comboBoxClient.DataSource = clients;
comboBoxClient.SelectedItem = null;
}
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
@ -72,15 +82,15 @@ namespace ConfectioneryView
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPastry.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try