diff --git a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs index 781d3a1..549c7bd 100644 --- a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs @@ -16,18 +16,18 @@ namespace ConfectioneryBusinessLogic.BusinessLogics { private readonly ILogger _logger; - private readonly IPastryStorage _iceCreamStorage; + private readonly IPastryStorage _pastryStorage; - public PastryLogic(ILogger logger, IPastryStorage iceCreamStorage) + public PastryLogic(ILogger logger, IPastryStorage pastryStorage) { _logger = logger; - _iceCreamStorage = iceCreamStorage; + _pastryStorage = pastryStorage; } public List? ReadList(PastrySearchModel? model) { _logger.LogInformation("ReadList. PastryName: {PastryName}. Id: {Id}", model?.PastryName, model?.Id); - var list = model == null ? _iceCreamStorage.GetFullList() : _iceCreamStorage.GetFilteredList(model); + var list = model == null ? _pastryStorage.GetFullList() : _pastryStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -44,7 +44,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics throw new ArgumentNullException(nameof(model)); } _logger.LogInformation("ReadElement. PastryName: {PastryName}. Id: {Id}", model.PastryName, model.Id); - var element = _iceCreamStorage.GetElement(model); + var element = _pastryStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -57,7 +57,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics public bool Create(PastryBindingModel model) { CheckModel(model); - if (_iceCreamStorage.Insert(model) == null) + if (_pastryStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -68,7 +68,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics public bool Update(PastryBindingModel model) { CheckModel(model); - if (_iceCreamStorage.Update(model) == null) + if (_pastryStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -80,7 +80,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics { CheckModel(model, false); _logger.LogInformation("Delete. Id: {Id}", model.Id); - if (_iceCreamStorage.Delete(model) == null) + if (_pastryStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -111,7 +111,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics throw new ArgumentNullException("Мороженое должно состоять хотя бы из одного компонента"); } _logger.LogInformation("Pastry. PastryName: {PastryName}. Price: {Price}. Id: {Id}", model.PastryName, model.Price, model.Id); - var element = _iceCreamStorage.GetElement(new PastrySearchModel + var element = _pastryStorage.GetElement(new PastrySearchModel { PastryName = model.PastryName }); diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs index 44040db..1e7a083 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs +++ b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs @@ -70,7 +70,7 @@ this.comboBoxPastry.FormattingEnabled = true; this.comboBoxPastry.Location = new System.Drawing.Point(150, 22); this.comboBoxPastry.Name = "comboBoxPastry"; - this.comboBoxPastry.Size = new System.Drawing.Size(337, 28); + this.comboBoxPastry.Size = new System.Drawing.Size(429, 28); this.comboBoxPastry.TabIndex = 3; this.comboBoxPastry.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPastry_SelectedIndexChanged); // @@ -78,7 +78,7 @@ // this.textBoxCount.Location = new System.Drawing.Point(150, 60); this.textBoxCount.Name = "textBoxCount"; - this.textBoxCount.Size = new System.Drawing.Size(337, 27); + this.textBoxCount.Size = new System.Drawing.Size(429, 27); this.textBoxCount.TabIndex = 4; this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); // @@ -86,7 +86,7 @@ // this.textBoxSum.Location = new System.Drawing.Point(150, 95); this.textBoxSum.Name = "textBoxSum"; - this.textBoxSum.Size = new System.Drawing.Size(337, 27); + this.textBoxSum.Size = new System.Drawing.Size(429, 27); this.textBoxSum.TabIndex = 5; // // ButtonSave @@ -113,7 +113,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(499, 180); + this.ClientSize = new System.Drawing.Size(591, 180); this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.ButtonSave); this.Controls.Add(this.textBoxSum); diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.cs b/Confectionery/ConfectioneryView/FormCreateOrder.cs index d49bc4d..16fe46e 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.cs +++ b/Confectionery/ConfectioneryView/FormCreateOrder.cs @@ -29,8 +29,23 @@ namespace ConfectioneryView private void FormCreateOrder_Load(object sender, EventArgs e) { - _logger.LogInformation("Загрузка изделий для заказа"); - // прописать логику + _logger.LogInformation("Loading ice cream for order"); + try + { + var pastryList = _logicP.ReadList(null); + if (pastryList != null) + { + comboBoxPastry.DisplayMember = "PastryName"; + comboBoxPastry.ValueMember = "Id"; + comboBoxPastry.DataSource = pastryList; + comboBoxPastry.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading ice cream for order"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void CalcSum() { diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs index 61c24bb..a1b389c 100644 --- a/Confectionery/ConfectioneryView/FormMain.Designer.cs +++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.menuStrip = 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(); @@ -38,20 +38,20 @@ this.ButtonOrderReady = new System.Windows.Forms.Button(); this.ButtonIssuedOrder = new System.Windows.Forms.Button(); this.ButtonRef = new System.Windows.Forms.Button(); - this.menuStrip1.SuspendLayout(); + this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // - // menuStrip1 + // menuStrip // - this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1376, 28); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(1376, 28); + this.menuStrip.TabIndex = 0; + this.menuStrip.Text = "menuStrip"; // // справочникиToolStripMenuItem // @@ -147,13 +147,13 @@ this.Controls.Add(this.ButtonTakeOrderInWork); this.Controls.Add(this.ButtonCreateOrder); this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Name = "FormMain"; this.Text = "Кондитерская"; this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -162,7 +162,7 @@ #endregion - private MenuStrip menuStrip1; + private MenuStrip menuStrip; private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem; diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs index b6a28cf..a2460ec 100644 --- a/Confectionery/ConfectioneryView/FormMain.cs +++ b/Confectionery/ConfectioneryView/FormMain.cs @@ -70,8 +70,7 @@ namespace ConfectioneryView private void ButtonCreateOrder_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); if (service is FormCreateOrder form) { form.ShowDialog(); @@ -82,8 +81,7 @@ namespace ConfectioneryView { if (dataGridView.SelectedRows.Count == 1) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { diff --git a/Confectionery/ConfectioneryView/FormMain.resx b/Confectionery/ConfectioneryView/FormMain.resx index 938108a..076b77c 100644 --- a/Confectionery/ConfectioneryView/FormMain.resx +++ b/Confectionery/ConfectioneryView/FormMain.resx @@ -57,7 +57,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 + + 25 + \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormPastries.Designer.cs b/Confectionery/ConfectioneryView/FormPastries.Designer.cs index d1f2fa9..0fa90d8 100644 --- a/Confectionery/ConfectioneryView/FormPastries.Designer.cs +++ b/Confectionery/ConfectioneryView/FormPastries.Designer.cs @@ -54,6 +54,7 @@ this.ButtonUpd.TabIndex = 8; this.ButtonUpd.Text = "Изменить"; this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonEdit_Click); // // ButtonDel // @@ -63,6 +64,7 @@ this.ButtonDel.TabIndex = 7; this.ButtonDel.Text = "Удалить"; this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // ButtonRef // @@ -72,6 +74,7 @@ this.ButtonRef.TabIndex = 6; this.ButtonRef.Text = "Обновить"; this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonUpd_Click); // // ButtonAdd // @@ -81,6 +84,7 @@ this.ButtonAdd.TabIndex = 5; this.ButtonAdd.Text = "Добавить"; this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // // FormPastries // diff --git a/Confectionery/ConfectioneryView/FormPastry.Designer.cs b/Confectionery/ConfectioneryView/FormPastry.Designer.cs index 196a105..13090a7 100644 --- a/Confectionery/ConfectioneryView/FormPastry.Designer.cs +++ b/Confectionery/ConfectioneryView/FormPastry.Designer.cs @@ -40,6 +40,9 @@ this.ButtonCancel = new System.Windows.Forms.Button(); this.labelName = new System.Windows.Forms.Label(); this.labelPrice = new System.Windows.Forms.Label(); + this.Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.groupBox.SuspendLayout(); this.SuspendLayout(); @@ -61,6 +64,10 @@ // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Number, + this.Component, + this.Count}); this.dataGridView.Location = new System.Drawing.Point(6, 26); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; @@ -160,6 +167,28 @@ this.labelPrice.TabIndex = 10; this.labelPrice.Text = "Стоимость:"; // + // Number + // + this.Number.HeaderText = "Номер"; + this.Number.MinimumWidth = 6; + this.Number.Name = "Number"; + this.Number.Visible = false; + this.Number.Width = 125; + // + // Component + // + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + this.Component.Width = 125; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // // FormPastry // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -173,7 +202,8 @@ this.Controls.Add(this.textBoxPrice); this.Controls.Add(this.textBoxName); this.Name = "FormPastry"; - this.Text = "FormPastry"; + this.Text = "Выпечка"; + this.Load += new System.EventHandler(this.FormPastry_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.groupBox.ResumeLayout(false); this.ResumeLayout(false); @@ -195,5 +225,8 @@ private Button ButtonCancel; private Label labelName; private Label labelPrice; + private DataGridViewTextBoxColumn Number; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormPastry.resx b/Confectionery/ConfectioneryView/FormPastry.resx index f298a7b..ac1ce00 100644 --- a/Confectionery/ConfectioneryView/FormPastry.resx +++ b/Confectionery/ConfectioneryView/FormPastry.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + \ No newline at end of file