Complete lab 1 hard
This commit is contained in:
parent
665aaab1a6
commit
b7ccba8acc
53
SushiBar/SushiBar/FormMain.Designer.cs
generated
53
SushiBar/SushiBar/FormMain.Designer.cs
generated
@ -31,13 +31,15 @@
|
|||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.directoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
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.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||||
this.buttonSubmit = new System.Windows.Forms.Button();
|
this.buttonSubmit = new System.Windows.Forms.Button();
|
||||||
this.buttonReady = new System.Windows.Forms.Button();
|
this.buttonReady = new System.Windows.Forms.Button();
|
||||||
this.buttonIssue = new System.Windows.Forms.Button();
|
this.buttonIssue = new System.Windows.Forms.Button();
|
||||||
this.buttonReload = new System.Windows.Forms.Button();
|
this.buttonReload = new System.Windows.Forms.Button();
|
||||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.buttonReplenishment = new System.Windows.Forms.Button();
|
||||||
this.sushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -65,11 +67,33 @@
|
|||||||
//
|
//
|
||||||
this.directoryToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.directoryToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.componentsToolStripMenuItem,
|
this.componentsToolStripMenuItem,
|
||||||
this.sushiToolStripMenuItem});
|
this.sushiToolStripMenuItem,
|
||||||
|
this.storeToolStripMenuItem});
|
||||||
this.directoryToolStripMenuItem.Name = "directoryToolStripMenuItem";
|
this.directoryToolStripMenuItem.Name = "directoryToolStripMenuItem";
|
||||||
this.directoryToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
|
this.directoryToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
|
||||||
this.directoryToolStripMenuItem.Text = "Directory";
|
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
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(674, 27);
|
this.buttonCreateOrder.Location = new System.Drawing.Point(674, 27);
|
||||||
@ -120,25 +144,22 @@
|
|||||||
this.buttonReload.UseVisualStyleBackColor = true;
|
this.buttonReload.UseVisualStyleBackColor = true;
|
||||||
this.buttonReload.Click += new System.EventHandler(this.ButtonReload_Click);
|
this.buttonReload.Click += new System.EventHandler(this.ButtonReload_Click);
|
||||||
//
|
//
|
||||||
// componentsToolStripMenuItem
|
// buttonReplenishment
|
||||||
//
|
//
|
||||||
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
this.buttonReplenishment.Location = new System.Drawing.Point(674, 415);
|
||||||
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.buttonReplenishment.Name = "buttonReplenishment";
|
||||||
this.componentsToolStripMenuItem.Text = "Components";
|
this.buttonReplenishment.Size = new System.Drawing.Size(114, 23);
|
||||||
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
this.buttonReplenishment.TabIndex = 7;
|
||||||
//
|
this.buttonReplenishment.Text = "Replenishment";
|
||||||
// sushiToolStripMenuItem
|
this.buttonReplenishment.UseVisualStyleBackColor = true;
|
||||||
//
|
this.buttonReplenishment.Click += new System.EventHandler(this.ButtonReplenishment_Click);
|
||||||
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);
|
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonReplenishment);
|
||||||
this.Controls.Add(this.buttonReload);
|
this.Controls.Add(this.buttonReload);
|
||||||
this.Controls.Add(this.buttonIssue);
|
this.Controls.Add(this.buttonIssue);
|
||||||
this.Controls.Add(this.buttonReady);
|
this.Controls.Add(this.buttonReady);
|
||||||
@ -170,5 +191,7 @@
|
|||||||
private Button buttonReload;
|
private Button buttonReload;
|
||||||
private ToolStripMenuItem componentsToolStripMenuItem;
|
private ToolStripMenuItem componentsToolStripMenuItem;
|
||||||
private ToolStripMenuItem sushiToolStripMenuItem;
|
private ToolStripMenuItem sushiToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem storeToolStripMenuItem;
|
||||||
|
private Button buttonReplenishment;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -170,5 +170,25 @@ namespace SushiBar
|
|||||||
form.ShowDialog();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
171
SushiBar/SushiBar/FormStore.Designer.cs
generated
Normal file
171
SushiBar/SushiBar/FormStore.Designer.cs
generated
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
namespace SushiBar
|
||||||
|
{
|
||||||
|
partial class FormStore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
141
SushiBar/SushiBar/FormStore.cs
Normal file
141
SushiBar/SushiBar/FormStore.cs
Normal file
@ -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<StoreViewModel>? _listStores;
|
||||||
|
private readonly IStoreLogic _logic;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
public int id { get; set; }
|
||||||
|
public FormStore(ILogger<FormStore> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
SushiBar/SushiBar/FormStore.resx
Normal file
69
SushiBar/SushiBar/FormStore.resx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="SushiName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Cost.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>
|
142
SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
generated
Normal file
142
SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
generated
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
namespace SushiBar
|
||||||
|
{
|
||||||
|
partial class FormStoreReplenishment
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
95
SushiBar/SushiBar/FormStoreReplenishment.cs
Normal file
95
SushiBar/SushiBar/FormStoreReplenishment.cs
Normal file
@ -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<StoreViewModel>? _listStores;
|
||||||
|
private readonly List<SushiViewModel>? _listSushi;
|
||||||
|
public FormStoreReplenishment(ILogger<FormStoreReplenishment> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SushiBar/SushiBar/FormStoreReplenishment.resx
Normal file
60
SushiBar/SushiBar/FormStoreReplenishment.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
114
SushiBar/SushiBar/FormStores.Designer.cs
generated
Normal file
114
SushiBar/SushiBar/FormStores.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace SushiBar
|
||||||
|
{
|
||||||
|
partial class FormStores
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
113
SushiBar/SushiBar/FormStores.cs
Normal file
113
SushiBar/SushiBar/FormStores.cs
Normal file
@ -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<FormStores> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SushiBar/SushiBar/FormStores.resx
Normal file
60
SushiBar/SushiBar/FormStores.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
2
SushiBar/SushiBar/FormSushi.Designer.cs
generated
2
SushiBar/SushiBar/FormSushi.Designer.cs
generated
@ -168,7 +168,7 @@
|
|||||||
//
|
//
|
||||||
// ID
|
// ID
|
||||||
//
|
//
|
||||||
this.ID.HeaderText = "Id";
|
this.ID.HeaderText = "ID";
|
||||||
this.ID.Name = "ID";
|
this.ID.Name = "ID";
|
||||||
this.ID.Visible = false;
|
this.ID.Visible = false;
|
||||||
//
|
//
|
||||||
|
@ -35,6 +35,8 @@ namespace SushiBar
|
|||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
services.AddTransient<ISushiLogic, SushiLogic>();
|
||||||
|
services.AddTransient<IStoreStorage, StoreStorage>();
|
||||||
|
services.AddTransient<IStoreLogic, StoreLogic>();
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
@ -42,6 +44,9 @@ namespace SushiBar
|
|||||||
services.AddTransient<FormSushi>();
|
services.AddTransient<FormSushi>();
|
||||||
services.AddTransient<FormSushiComponent>();
|
services.AddTransient<FormSushiComponent>();
|
||||||
services.AddTransient<FormSushiMoreThenOne>();
|
services.AddTransient<FormSushiMoreThenOne>();
|
||||||
|
services.AddTransient<FormStores>();
|
||||||
|
services.AddTransient<FormStore>();
|
||||||
|
services.AddTransient<FormStoreReplenishment>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -146,7 +146,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(StoreBindingModel model, bool withParams)
|
private void CheckModel(StoreBindingModel model, bool withParams=true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
|
@ -116,4 +116,3 @@ namespace SushibarListImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -50,4 +50,3 @@ namespace SushibarListImplement.Models
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user