diff --git a/SushiBar/SushiBar/FormMain.Designer.cs b/SushiBar/SushiBar/FormMain.Designer.cs
index 709f9ea..4a260c2 100644
--- a/SushiBar/SushiBar/FormMain.Designer.cs
+++ b/SushiBar/SushiBar/FormMain.Designer.cs
@@ -31,13 +31,15 @@
this.dataGridView = new System.Windows.Forms.DataGridView();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.directoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.sushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.storeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonSubmit = new System.Windows.Forms.Button();
this.buttonReady = new System.Windows.Forms.Button();
this.buttonIssue = new System.Windows.Forms.Button();
this.buttonReload = new System.Windows.Forms.Button();
- this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.sushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.buttonReplenishment = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@@ -65,11 +67,33 @@
//
this.directoryToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.componentsToolStripMenuItem,
- this.sushiToolStripMenuItem});
+ this.sushiToolStripMenuItem,
+ this.storeToolStripMenuItem});
this.directoryToolStripMenuItem.Name = "directoryToolStripMenuItem";
this.directoryToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
this.directoryToolStripMenuItem.Text = "Directory";
//
+ // componentsToolStripMenuItem
+ //
+ this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
+ this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.componentsToolStripMenuItem.Text = "Components";
+ this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
+ //
+ // sushiToolStripMenuItem
+ //
+ this.sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
+ this.sushiToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.sushiToolStripMenuItem.Text = "Sushi";
+ this.sushiToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
+ //
+ // storeToolStripMenuItem
+ //
+ this.storeToolStripMenuItem.Name = "storeToolStripMenuItem";
+ this.storeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.storeToolStripMenuItem.Text = "Store";
+ this.storeToolStripMenuItem.Click += new System.EventHandler(this.StoreToolStripMenuItem_Click);
+ //
// buttonCreateOrder
//
this.buttonCreateOrder.Location = new System.Drawing.Point(674, 27);
@@ -120,25 +144,22 @@
this.buttonReload.UseVisualStyleBackColor = true;
this.buttonReload.Click += new System.EventHandler(this.ButtonReload_Click);
//
- // componentsToolStripMenuItem
+ // buttonReplenishment
//
- this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
- this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.componentsToolStripMenuItem.Text = "Components";
- this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
- //
- // sushiToolStripMenuItem
- //
- this.sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
- this.sushiToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.sushiToolStripMenuItem.Text = "Sushi";
- this.sushiToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
+ this.buttonReplenishment.Location = new System.Drawing.Point(674, 415);
+ this.buttonReplenishment.Name = "buttonReplenishment";
+ this.buttonReplenishment.Size = new System.Drawing.Size(114, 23);
+ this.buttonReplenishment.TabIndex = 7;
+ this.buttonReplenishment.Text = "Replenishment";
+ this.buttonReplenishment.UseVisualStyleBackColor = true;
+ this.buttonReplenishment.Click += new System.EventHandler(this.ButtonReplenishment_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonReplenishment);
this.Controls.Add(this.buttonReload);
this.Controls.Add(this.buttonIssue);
this.Controls.Add(this.buttonReady);
@@ -170,5 +191,7 @@
private Button buttonReload;
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem sushiToolStripMenuItem;
+ private ToolStripMenuItem storeToolStripMenuItem;
+ private Button buttonReplenishment;
}
}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormMain.cs b/SushiBar/SushiBar/FormMain.cs
index b25ada8..2ca647b 100644
--- a/SushiBar/SushiBar/FormMain.cs
+++ b/SushiBar/SushiBar/FormMain.cs
@@ -170,5 +170,25 @@ namespace SushiBar
form.ShowDialog();
}
}
+
+ private void StoreToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormStores));
+
+ if (service is FormStores form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonReplenishment_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormStoreReplenishment));
+
+ if (service is FormStoreReplenishment form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/SushiBar/SushiBar/FormStore.Designer.cs b/SushiBar/SushiBar/FormStore.Designer.cs
new file mode 100644
index 0000000..9d9db1d
--- /dev/null
+++ b/SushiBar/SushiBar/FormStore.Designer.cs
@@ -0,0 +1,171 @@
+namespace SushiBar
+{
+ partial class FormStore
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.comboBoxName = new System.Windows.Forms.ComboBox();
+ this.textBoxAddress = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
+ this.SushiName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Cost = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.SushiName,
+ this.Cost,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(598, 426);
+ this.dataGridView.TabIndex = 0;
+ //
+ // comboBoxName
+ //
+ this.comboBoxName.FormattingEnabled = true;
+ this.comboBoxName.Location = new System.Drawing.Point(616, 12);
+ this.comboBoxName.Name = "comboBoxName";
+ this.comboBoxName.Size = new System.Drawing.Size(172, 23);
+ this.comboBoxName.TabIndex = 1;
+ this.comboBoxName.SelectedIndexChanged += new System.EventHandler(this.ComboBoxName_SelectedIndexChanged);
+ //
+ // textBoxAddress
+ //
+ this.textBoxAddress.Location = new System.Drawing.Point(616, 56);
+ this.textBoxAddress.Name = "textBoxAddress";
+ this.textBoxAddress.Size = new System.Drawing.Size(172, 23);
+ this.textBoxAddress.TabIndex = 2;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(616, 38);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(49, 15);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "Address";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(616, 82);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(80, 15);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "Date Opening";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(621, 415);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Save";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(702, 415);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(86, 23);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // dateTimePicker
+ //
+ this.dateTimePicker.Location = new System.Drawing.Point(616, 100);
+ this.dateTimePicker.Name = "dateTimePicker";
+ this.dateTimePicker.Size = new System.Drawing.Size(172, 23);
+ this.dateTimePicker.TabIndex = 8;
+ //
+ // SushiName
+ //
+ this.SushiName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SushiName.HeaderText = "Sushi";
+ this.SushiName.Name = "SushiName";
+ //
+ // Cost
+ //
+ this.Cost.HeaderText = "Cost";
+ this.Cost.Name = "Cost";
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Count";
+ this.Count.Name = "Count";
+ //
+ // FormStore
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.dateTimePicker);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.textBoxAddress);
+ this.Controls.Add(this.comboBoxName);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormStore";
+ this.Text = "FormStore";
+ this.Load += new System.EventHandler(this.FormStore_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private ComboBox comboBoxName;
+ private TextBox textBoxAddress;
+ private Label label1;
+ private Label label2;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private DateTimePicker dateTimePicker;
+ private DataGridViewTextBoxColumn SushiName;
+ private DataGridViewTextBoxColumn Cost;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormStore.cs b/SushiBar/SushiBar/FormStore.cs
new file mode 100644
index 0000000..035995c
--- /dev/null
+++ b/SushiBar/SushiBar/FormStore.cs
@@ -0,0 +1,141 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBar
+{
+ public partial class FormStore : Form
+ {
+ private readonly List? _listStores;
+ private readonly IStoreLogic _logic;
+ private readonly ILogger _logger;
+ public int id { get; set; }
+ public FormStore(ILogger logger, IStoreLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _listStores = logic.ReadList(null);
+ _logic = logic;
+ if (_listStores != null)
+ {
+ comboBoxName.DisplayMember = "StoreName";
+ comboBoxName.ValueMember = "Id";
+ comboBoxName.DataSource = _listStores;
+ comboBoxName.SelectedItem = null;
+ }
+ }
+
+ private void LoadData(bool extendDate = true)
+ {
+ try
+ {
+ var model = GetStore(extendDate ? id : Convert.ToInt32(comboBoxName.SelectedValue));
+ if (model != null)
+ {
+ comboBoxName.Text = model.StoreName;
+ textBoxAddress.Text = model.StoreAdress;
+ dateTimePicker.Text = Convert.ToString(model.OpeningDate);
+ dataGridView.Rows.Clear();
+ foreach (var el in model.Sushis.Values)
+ {
+ dataGridView.Rows.Add(new object[] { el.Item1.SushiName, el.Item1.Price, el.Item2 });
+ }
+ }
+ _logger.LogInformation("Load stores");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error on load");
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private IStoreModel? GetStore(int id)
+ {
+ if (_listStores == null)
+ {
+ return null;
+ }
+ foreach (var elem in _listStores)
+ {
+ if (elem.Id == id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(comboBoxName.Text))
+ {
+ MessageBox.Show("Select store name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxAddress.Text))
+ {
+ MessageBox.Show("Fill in address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Saving store");
+
+ try
+ {
+ DateTime.TryParse(dateTimePicker.Text, out var dateTime);
+ StoreBindingModel model = new()
+ {
+ StoreName = comboBoxName.Text,
+ StoreAdress = textBoxAddress.Text,
+ OpeningDate = dateTime
+ };
+ var search_model = GetStore(id);
+ bool operationResult = false;
+
+ if (search_model != null)
+ {
+ model.Id = search_model.Id;
+ operationResult = _logic.Update(model);
+ }
+ else
+ {
+ operationResult = _logic.Create(model);
+ }
+
+ if (!operationResult)
+ {
+ throw new Exception("Error on saving. Additional info below");
+ }
+
+ MessageBox.Show("Save is successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error on saving");
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void ComboBoxName_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ LoadData(false);
+ }
+
+ private void FormStore_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/FormStore.resx b/SushiBar/SushiBar/FormStore.resx
new file mode 100644
index 0000000..769b272
--- /dev/null
+++ b/SushiBar/SushiBar/FormStore.resx
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormStoreReplenishment.Designer.cs b/SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
new file mode 100644
index 0000000..c3ff031
--- /dev/null
+++ b/SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
@@ -0,0 +1,142 @@
+namespace SushiBar
+{
+ partial class FormStoreReplenishment
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.comboBoxStore = new System.Windows.Forms.ComboBox();
+ this.comboBoxSushi = new System.Windows.Forms.ComboBox();
+ this.labelSushi = new System.Windows.Forms.Label();
+ this.labelStore = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // comboBoxStore
+ //
+ this.comboBoxStore.FormattingEnabled = true;
+ this.comboBoxStore.Location = new System.Drawing.Point(73, 12);
+ this.comboBoxStore.Name = "comboBoxStore";
+ this.comboBoxStore.Size = new System.Drawing.Size(172, 23);
+ this.comboBoxStore.TabIndex = 0;
+ //
+ // comboBoxSushi
+ //
+ this.comboBoxSushi.FormattingEnabled = true;
+ this.comboBoxSushi.Location = new System.Drawing.Point(73, 41);
+ this.comboBoxSushi.Name = "comboBoxSushi";
+ this.comboBoxSushi.Size = new System.Drawing.Size(172, 23);
+ this.comboBoxSushi.TabIndex = 1;
+ //
+ // labelSushi
+ //
+ this.labelSushi.AutoSize = true;
+ this.labelSushi.Location = new System.Drawing.Point(12, 44);
+ this.labelSushi.Name = "labelSushi";
+ this.labelSushi.Size = new System.Drawing.Size(35, 15);
+ this.labelSushi.TabIndex = 2;
+ this.labelSushi.Text = "Sushi";
+ //
+ // labelStore
+ //
+ this.labelStore.AutoSize = true;
+ this.labelStore.Location = new System.Drawing.Point(12, 15);
+ this.labelStore.Name = "labelStore";
+ this.labelStore.Size = new System.Drawing.Size(34, 15);
+ this.labelStore.TabIndex = 3;
+ this.labelStore.Text = "Store";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(12, 101);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(113, 23);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Save";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(131, 101);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(114, 23);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 75);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(40, 15);
+ this.labelCount.TabIndex = 6;
+ this.labelCount.Text = "Count";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(73, 72);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(172, 23);
+ this.textBoxCount.TabIndex = 7;
+ //
+ // FormStoreReplenishment
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(257, 136);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.labelStore);
+ this.Controls.Add(this.labelSushi);
+ this.Controls.Add(this.comboBoxSushi);
+ this.Controls.Add(this.comboBoxStore);
+ this.Name = "FormStoreReplenishment";
+ this.Text = "FormStoreReplenishment";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxStore;
+ private ComboBox comboBoxSushi;
+ private Label labelSushi;
+ private Label labelStore;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormStoreReplenishment.cs b/SushiBar/SushiBar/FormStoreReplenishment.cs
new file mode 100644
index 0000000..36c2b40
--- /dev/null
+++ b/SushiBar/SushiBar/FormStoreReplenishment.cs
@@ -0,0 +1,95 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBar
+{
+ public partial class FormStoreReplenishment : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IStoreLogic _storeLogic;
+ private readonly ISushiLogic _sushiLogic;
+ private readonly List? _listStores;
+ private readonly List? _listSushi;
+ public FormStoreReplenishment(ILogger logger, IStoreLogic storeLogic, ISushiLogic sushiLogic)
+ {
+ InitializeComponent();
+ _storeLogic = storeLogic;
+ _sushiLogic = sushiLogic;
+ _logger = logger;
+ _listStores = storeLogic.ReadList(null);
+ if (_listStores != null)
+ {
+ comboBoxStore.DisplayMember = "StoreName";
+ comboBoxStore.ValueMember = "Id";
+ comboBoxStore.DataSource = _listStores;
+ comboBoxStore.SelectedItem = null;
+ }
+
+ _listSushi = sushiLogic.ReadList(null);
+ if (_listSushi != null)
+ {
+ comboBoxSushi.DisplayMember = "SushiName";
+ comboBoxSushi.ValueMember = "Id";
+ comboBoxSushi.DataSource = _listSushi;
+ comboBoxSushi.SelectedItem = null;
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (comboBoxStore.SelectedValue == null)
+ {
+ MessageBox.Show("Select store", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (comboBoxSushi.SelectedValue == null)
+ {
+ MessageBox.Show("Select sushi", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Add sushi to store");
+
+ try
+ {
+ var sushi = _sushiLogic.ReadElement(new()
+ {
+ Id = (int)comboBoxSushi.SelectedValue
+ });
+
+ if (sushi == null)
+ {
+ throw new Exception("Sushi is not found. Additional info below.");
+ }
+
+ var resultOperation = _storeLogic.AddPackage(
+ model: new() { Id = (int)comboBoxStore.SelectedValue },
+ sushi: sushi,
+ quantity: Convert.ToInt32(textBoxCount.Text)
+ );
+
+ if (!resultOperation)
+ {
+ throw new Exception("Error on saving. Additional info below.");
+ }
+
+ MessageBox.Show("Save is successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error on saving");
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/FormStoreReplenishment.resx b/SushiBar/SushiBar/FormStoreReplenishment.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SushiBar/SushiBar/FormStoreReplenishment.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormStores.Designer.cs b/SushiBar/SushiBar/FormStores.Designer.cs
new file mode 100644
index 0000000..2604a94
--- /dev/null
+++ b/SushiBar/SushiBar/FormStores.Designer.cs
@@ -0,0 +1,114 @@
+namespace SushiBar
+{
+ partial class FormStores
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonRemove = new System.Windows.Forms.Button();
+ this.buttonChange = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(605, 426);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(623, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(165, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Add";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonRemove
+ //
+ this.buttonRemove.Location = new System.Drawing.Point(623, 41);
+ this.buttonRemove.Name = "buttonRemove";
+ this.buttonRemove.Size = new System.Drawing.Size(165, 23);
+ this.buttonRemove.TabIndex = 2;
+ this.buttonRemove.Text = "Remove";
+ this.buttonRemove.UseVisualStyleBackColor = true;
+ this.buttonRemove.Click += new System.EventHandler(this.ButtonRemove_Click);
+ //
+ // buttonChange
+ //
+ this.buttonChange.Location = new System.Drawing.Point(623, 70);
+ this.buttonChange.Name = "buttonChange";
+ this.buttonChange.Size = new System.Drawing.Size(165, 23);
+ this.buttonChange.TabIndex = 3;
+ this.buttonChange.Text = "Change";
+ this.buttonChange.UseVisualStyleBackColor = true;
+ this.buttonChange.Click += new System.EventHandler(this.ButtonChange_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(623, 99);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(165, 23);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Update";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
+ //
+ // FormStores
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonChange);
+ this.Controls.Add(this.buttonRemove);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormStores";
+ this.Text = "FormStores";
+ this.Load += new System.EventHandler(this.FormStores_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonRemove;
+ private Button buttonChange;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormStores.cs b/SushiBar/SushiBar/FormStores.cs
new file mode 100644
index 0000000..2584d50
--- /dev/null
+++ b/SushiBar/SushiBar/FormStores.cs
@@ -0,0 +1,113 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+
+namespace SushiBar
+{
+ public partial class FormStores : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IStoreLogic _logic;
+ public FormStores(ILogger logger, IStoreLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["Sushis"].Visible = false;
+ }
+
+ _logger.LogInformation("Load stores");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error on loading");
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormStore));
+
+ if (service is FormStore form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonRemove_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Deleting store");
+
+ try
+ {
+ if (!_logic.Delete(new StoreBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Error on deleting. Additional info below.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error delete store");
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormStore));
+
+ if (service is FormStore form)
+ {
+ form.id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void FormStores_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/FormStores.resx b/SushiBar/SushiBar/FormStores.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SushiBar/SushiBar/FormStores.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormSushi.Designer.cs b/SushiBar/SushiBar/FormSushi.Designer.cs
index b25ccaf..31edf0e 100644
--- a/SushiBar/SushiBar/FormSushi.Designer.cs
+++ b/SushiBar/SushiBar/FormSushi.Designer.cs
@@ -168,7 +168,7 @@
//
// ID
//
- this.ID.HeaderText = "Id";
+ this.ID.HeaderText = "ID";
this.ID.Name = "ID";
this.ID.Visible = false;
//
diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs
index beb4c1c..845eae3 100644
--- a/SushiBar/SushiBar/Program.cs
+++ b/SushiBar/SushiBar/Program.cs
@@ -35,6 +35,8 @@ namespace SushiBar
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -42,6 +44,9 @@ namespace SushiBar
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs
index 1f0a7fc..9bcc52c 100644
--- a/SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs
@@ -146,7 +146,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
return true;
}
- private void CheckModel(StoreBindingModel model, bool withParams)
+ private void CheckModel(StoreBindingModel model, bool withParams=true)
{
if (model == null)
{
diff --git a/SushiBar/SushibarListImplement/Implements/StoreStorage.cs b/SushiBar/SushibarListImplement/Implements/StoreStorage.cs
index c8a30a0..1adbb11 100644
--- a/SushiBar/SushibarListImplement/Implements/StoreStorage.cs
+++ b/SushiBar/SushibarListImplement/Implements/StoreStorage.cs
@@ -116,4 +116,3 @@ namespace SushibarListImplement.Implements
}
}
}
-}
diff --git a/SushiBar/SushibarListImplement/Models/Store.cs b/SushiBar/SushibarListImplement/Models/Store.cs
index 35a94fc..5d7300d 100644
--- a/SushiBar/SushibarListImplement/Models/Store.cs
+++ b/SushiBar/SushibarListImplement/Models/Store.cs
@@ -50,4 +50,3 @@ namespace SushibarListImplement.Models
};
}
}
-}