почти готовая лаба 1
This commit is contained in:
parent
b4a88a1231
commit
9210394589
@ -16,18 +16,18 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IPastryStorage _iceCreamStorage;
|
||||
private readonly IPastryStorage _pastryStorage;
|
||||
|
||||
public PastryLogic(ILogger<PastryLogic> logger, IPastryStorage iceCreamStorage)
|
||||
public PastryLogic(ILogger<PastryLogic> logger, IPastryStorage pastryStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_iceCreamStorage = iceCreamStorage;
|
||||
_pastryStorage = pastryStorage;
|
||||
}
|
||||
|
||||
public List<PastryViewModel>? 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
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
{
|
||||
|
30
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
30
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
@ -28,7 +28,7 @@
|
||||
/// </summary>
|
||||
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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -57,7 +57,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
</root>
|
@ -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
|
||||
//
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -57,4 +57,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Number.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Component.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user