diff --git a/View/Dimensions/DimensionSource/Add.cs b/View/Dimensions/DimensionSource/Add.cs
index 61c3199..866ea16 100644
--- a/View/Dimensions/DimensionSource/Add.cs
+++ b/View/Dimensions/DimensionSource/Add.cs
@@ -80,8 +80,16 @@ private void AttemptAdd()
conversionFailed = false;
return;
}
- string selectedUnitOfDimension = unitOfVolumeListBox.SelectedItem.ToString();
- unitOfDimensionName = new UnitOfDimension(selectedUnitOfDimension);
+ if (unitOfVolumeListBox.SelectedItem != null)
+ {
+ string selectedUnitOfDimension = unitOfVolumeListBox.SelectedItem.ToString();
+ unitOfDimensionName = new UnitOfDimension(selectedUnitOfDimension);
+ }
+ else
+ {
+ MessageBox.Show("Please select Unit of Volume");
+ return;
+ }
add = new WHIO.Model.Dimension(width, length, height, unitOfDimensionName,name);
if (add.Create())
{
@@ -90,6 +98,7 @@ private void AttemptAdd()
Close();
}
else MessageBox.Show(this, "Create Fail");
+ return;
}
private double convertToDouble(string text)
diff --git a/View/MainForm.Designer.cs b/View/MainForm.Designer.cs
index 5f93d9b..6d4e0da 100644
--- a/View/MainForm.Designer.cs
+++ b/View/MainForm.Designer.cs
@@ -119,6 +119,7 @@ private void InitializeComponent()
this.productToolStripMenuItem.Name = "productToolStripMenuItem";
this.productToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.productToolStripMenuItem.Text = "Product";
+ this.productToolStripMenuItem.Click += new System.EventHandler(this.click_Product);
//
// uOMSettingToolStripMenuItem
//
diff --git a/View/MainForm.cs b/View/MainForm.cs
index d08560a..dd720fa 100644
--- a/View/MainForm.cs
+++ b/View/MainForm.cs
@@ -5,6 +5,7 @@
using Warehouse_IO.View;
using Warehouse_IO.View.Dimension.UnitOfVolumeSource;
using Warehouse_IO.View.Dimensions.DimensionSource;
+using Warehouse_IO.View.ProductSource;
using Warehouse_IO.View.SupplierFormSource;
using Warehouse_IO.View.TruckFormSource;
using Warehouse_IO.View.UOMSource;
@@ -25,6 +26,7 @@ public partial class MainForm : Form
PackagingForm pack;
UOMForm uom;
DimensionsForm dimension;
+ ProductForm product;
public MainForm()
{
@@ -176,5 +178,15 @@ private void click_Dimension(object sender, EventArgs e)
DisableMainForm();
dimension.returnMain += EventToActiveAdmin;
}
+
+ private void click_Product(object sender, EventArgs e)
+ {
+ product = new ProductForm();
+ product.MdiParent = this;
+ product.Show();
+
+ DisableMainForm();
+ product.returnMain += EventToActiveAdmin;
+ }
}
}
diff --git a/View/ProductSource/Add.Designer.cs b/View/ProductSource/Add.Designer.cs
new file mode 100644
index 0000000..7759f56
--- /dev/null
+++ b/View/ProductSource/Add.Designer.cs
@@ -0,0 +1,56 @@
+namespace Warehouse_IO.View.ProductSource
+{
+ partial class Add
+ {
+ ///
+ /// 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.SuspendLayout();
+ //
+ // cancelButton
+ //
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // AddButton
+ //
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ this.AddButton.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddButton_KeyPress);
+ //
+ // Add
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(425, 432);
+ this.Name = "Add";
+ this.Text = "Add";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/View/ProductSource/Add.cs b/View/ProductSource/Add.cs
new file mode 100644
index 0000000..45fdac6
--- /dev/null
+++ b/View/ProductSource/Add.cs
@@ -0,0 +1,112 @@
+using Warehouse_IO.WHIO.Model;
+using Warehouse_IO.View.Add_Edit_Remove_Components;
+using System;
+using System.Windows.Forms;
+using System.Collections.Generic;
+
+namespace Warehouse_IO.View.ProductSource
+{
+ public partial class Add : AddEditProductForm
+ {
+ Product add;
+ UOM uom;
+ Warehouse_IO.WHIO.Model.Dimension dimension;
+ List uomList;
+ List dimensionList;
+ private List dimensionId = new List();
+ private List uomId = new List();
+
+ public event EventHandler UpdateGrid;
+
+ public Add()
+ {
+ InitializeComponent();
+ nameTextBox.KeyPress += AddButton_KeyPress;
+ UoMListBox.KeyPress += AddButton_KeyPress;
+ dimensionListBox.KeyPress += AddButton_KeyPress;
+
+ dimensionList = new List();
+ uomList = new List();
+ updateList();
+ }
+
+ private void updateList()
+ {
+ dimensionList = Warehouse_IO.WHIO.Model.Dimension.GetDimensionList();
+ uomList = UOM.GetUOMList();
+ dimensionList.Sort((x, y) => x.Name.CompareTo(y.Name));
+ uomList.Sort((x, y) => x.Name.CompareTo(y.Name));
+
+ UoMListBox.Items.Clear();
+ dimensionListBox.Items.Clear();
+
+ foreach (Warehouse_IO.WHIO.Model.Dimension dimension in dimensionList)
+ {
+ string formattedDimension = $"{dimension.Width} x {dimension.Length} x {dimension.Height} {dimension.Unit.Name} {dimension.Name}";
+ dimensionListBox.Items.Add(formattedDimension);
+ dimensionId.Add(dimension.ID);
+ }
+ foreach (UOM uom in uomList)
+ {
+ string formattedDimension = $"{uom.Quantity}{uom.Unit.Name}/{uom.Package.Name} {uom.Name}";
+ UoMListBox.Items.Add(formattedDimension);
+ uomId.Add(uom.ID);
+ }
+ }
+
+ private void AttemptAdd()
+ {
+ if (string.IsNullOrEmpty(nameTextBox.Text))
+ {
+ MessageBox.Show(this, "Please enter a product name.");
+ return;
+ }
+ int selectedUOMIndex = UoMListBox.SelectedIndex;
+ if (selectedUOMIndex >= 0 && selectedUOMIndex < uomId.Count)
+ {
+ int selectedUOMID = uomId[selectedUOMIndex];
+ uom = new UOM(selectedUOMID);
+ }
+ else
+ {
+ MessageBox.Show(this, "Please select UOM");
+ return;
+ }
+ int selectedDimensionIndex = dimensionListBox.SelectedIndex;
+ if (selectedDimensionIndex >= 0 && selectedDimensionIndex < dimensionId.Count)
+ {
+ int selectedDimensionID = dimensionId[selectedDimensionIndex];
+ dimension = new Warehouse_IO.WHIO.Model.Dimension(selectedDimensionID);
+ }
+ else
+ {
+ MessageBox.Show(this, "Please select Dimension");
+ return;
+ }
+ add = new Product(nameTextBox.Text,uom,dimension);
+ if (add.Create())
+ {
+ MessageBox.Show(this, "Product Create");
+ UpdateGrid?.Invoke(this, EventArgs.Empty);
+ Close();
+ }
+ else MessageBox.Show(this, "Create Fail");
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ AttemptAdd();
+ }
+ private void AddButton_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == (char)Keys.Enter)
+ {
+ AttemptAdd();
+ }
+ }
+ private void cancelButton_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+ }
+}
diff --git a/View/ProductSource/Add.resx b/View/ProductSource/Add.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/View/ProductSource/Add.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/View/ProductSource/Edit.Designer.cs b/View/ProductSource/Edit.Designer.cs
new file mode 100644
index 0000000..58c4d68
--- /dev/null
+++ b/View/ProductSource/Edit.Designer.cs
@@ -0,0 +1,57 @@
+namespace Warehouse_IO.View.ProductSource
+{
+ partial class Edit
+ {
+ ///
+ /// 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.SuspendLayout();
+ //
+ // cancelButton
+ //
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // AddButton
+ //
+ this.AddButton.Text = "Edit";
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ this.AddButton.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddButton_KeyPress);
+ //
+ // Edit
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(425, 432);
+ this.Name = "Edit";
+ this.Text = "Edit";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/View/ProductSource/Edit.cs b/View/ProductSource/Edit.cs
new file mode 100644
index 0000000..0a7aceb
--- /dev/null
+++ b/View/ProductSource/Edit.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Warehouse_IO.WHIO.Model;
+using Warehouse_IO.Common;
+using Warehouse_IO.View.Add_Edit_Remove_Components;
+
+namespace Warehouse_IO.View.ProductSource
+{
+ public partial class Edit : AddEditProductForm
+ {
+ Product edit;
+ UOM uom;
+ Warehouse_IO.WHIO.Model.Dimension dimension;
+ List uomList;
+ List dimensionList;
+ private List dimensionId = new List();
+ private List uomId = new List();
+
+ public event EventHandler UpdateGrid;
+
+ public Edit()
+ {
+ InitializeComponent();
+ updateList();
+ edit = new Product(Global.tempPkey);
+ nameTextBox.Text = edit.Name.ToString();
+
+ //Selected data in listbox referred by ID in private list
+ int uomIndex = uomId.IndexOf(edit.UOM.ID);
+ if (uomIndex >= 0)
+ {
+ UoMListBox.SelectedIndex = uomIndex;
+ }
+ int dimensionIndex = dimensionId.IndexOf(edit.Dimension.ID);
+ if (dimensionIndex >= 0)
+ {
+ dimensionListBox.SelectedIndex = dimensionIndex;
+ }
+
+ nameTextBox.KeyPress += AddButton_KeyPress;
+ UoMListBox.KeyPress += AddButton_KeyPress;
+ dimensionListBox.KeyPress += AddButton_KeyPress;
+
+ dimensionList = new List();
+ uomList = new List();
+ }
+ private void updateList()
+ {
+ dimensionList = Warehouse_IO.WHIO.Model.Dimension.GetDimensionList();
+ uomList = UOM.GetUOMList();
+ dimensionList.Sort((x, y) => x.Name.CompareTo(y.Name));
+ uomList.Sort((x, y) => x.Name.CompareTo(y.Name));
+
+ UoMListBox.Items.Clear();
+ dimensionListBox.Items.Clear();
+
+ foreach (Warehouse_IO.WHIO.Model.Dimension dimension in dimensionList)
+ {
+ string formattedDimension = $"{dimension.Width} x {dimension.Length} x {dimension.Height} {dimension.Unit.Name} {dimension.Name}";
+ dimensionListBox.Items.Add(formattedDimension);
+ dimensionId.Add(dimension.ID);
+ }
+ foreach (UOM uom in uomList)
+ {
+ string formattedDimension = $"{uom.Quantity}{uom.Unit.Name}/{uom.Package.Name} {uom.Name}";
+ UoMListBox.Items.Add(formattedDimension);
+ uomId.Add(uom.ID);
+ }
+ }
+ private void AttemptEdit()
+ {
+ edit.Name = nameTextBox.Text;
+ if (string.IsNullOrEmpty(nameTextBox.Text))
+ {
+ MessageBox.Show(this, "Please enter a product name.");
+ return;
+ }
+ int selectedUOMIndex = UoMListBox.SelectedIndex;
+ if (selectedUOMIndex >= 0 && selectedUOMIndex < uomId.Count)
+ {
+ int selectedUOMID = uomId[selectedUOMIndex];
+ uom = new UOM(selectedUOMID);
+ edit.UOM = uom;
+ }
+ else
+ {
+ MessageBox.Show(this, "Please select UOM");
+ return;
+ }
+ int selectedDimensionIndex = dimensionListBox.SelectedIndex;
+ if (selectedDimensionIndex >= 0 && selectedDimensionIndex < dimensionId.Count)
+ {
+ int selectedDimensionID = dimensionId[selectedDimensionIndex];
+ dimension = new Warehouse_IO.WHIO.Model.Dimension(selectedDimensionID);
+ edit.Dimension = dimension;
+ }
+ else
+ {
+ MessageBox.Show(this, "Please select Dimension");
+ return;
+ }
+ if (edit.Change())
+ {
+ MessageBox.Show(this, "Product has edited");
+ UpdateGrid?.Invoke(this, EventArgs.Empty);
+ Close();
+ }
+ else MessageBox.Show(this, "Edited Fail");
+
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ AttemptEdit();
+ }
+ private void AddButton_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == (char)Keys.Enter)
+ {
+ AttemptEdit();
+ }
+ }
+ private void cancelButton_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+ }
+}
diff --git a/View/ProductSource/Edit.resx b/View/ProductSource/Edit.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/View/ProductSource/Edit.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/View/ProductSource/ProductForm.Designer.cs b/View/ProductSource/ProductForm.Designer.cs
new file mode 100644
index 0000000..b85741e
--- /dev/null
+++ b/View/ProductSource/ProductForm.Designer.cs
@@ -0,0 +1,64 @@
+namespace Warehouse_IO.View.ProductSource
+{
+ partial class ProductForm
+ {
+ ///
+ /// 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.SuspendLayout();
+ //
+ // x
+ //
+ this.x.Click += new System.EventHandler(this.x_Click);
+ //
+ // r
+ //
+ this.r.Click += new System.EventHandler(this.r_Click);
+ //
+ // e
+ //
+ this.e.Click += new System.EventHandler(this.e_Click);
+ //
+ // a
+ //
+ this.a.Click += new System.EventHandler(this.a_Click);
+ //
+ // ProductForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(617, 535);
+ this.Location = new System.Drawing.Point(0, 0);
+ this.Name = "ProductForm";
+ this.Text = "ProductForm";
+ this.Load += new System.EventHandler(this.ProductForm_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/View/ProductSource/ProductForm.cs b/View/ProductSource/ProductForm.cs
new file mode 100644
index 0000000..3517021
--- /dev/null
+++ b/View/ProductSource/ProductForm.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Warehouse_IO.WHIO.Model;
+using Warehouse_IO.Common;
+using Warehouse_IO.View.ParentFormComponents;
+
+namespace Warehouse_IO.View.ProductSource
+{
+ public partial class ProductForm : ParentForm
+ {
+ private Add add;
+ private Edit edit;
+ private Remove remove;
+ MainForm main;
+
+ List productList;
+ UOM uom;
+ Warehouse_IO.WHIO.Model.Dimension dimension;
+ BindingSource bind = new BindingSource();
+ public event EventHandler returnMain;
+
+ public ProductForm()
+ {
+ InitializeComponent();
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
+ productList = new List();
+ UpdateDatagridView();
+ main = new MainForm();
+ }
+
+ private void ProductForm_Load(object sender, EventArgs e)
+ {
+ WindowState = FormWindowState.Maximized;
+ }
+ public void UpdateDatagridView()
+ {
+ productList = Product.GetProductList();
+ bind.DataSource = productList;
+ productList.Sort((x, y) => x.ID.CompareTo(y.ID));
+ dataGridView.DataSource = bind;
+
+ dataGridView.CellFormatting += DataGridView_CellFormatting;
+ }
+ private void DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
+ {
+
+ if (e.ColumnIndex == 2 || e.ColumnIndex == 3)
+ {
+ if (dataGridView.Rows[e.RowIndex].DataBoundItem != null)
+ {
+ Product data = (Product)dataGridView.Rows[e.RowIndex].DataBoundItem;
+ uom = new UOM(data.UOM.ID);
+ dimension = new WHIO.Model.Dimension(data.Dimension.ID);
+ if (e.ColumnIndex == 2)
+ {
+ string formattedValue = $"{uom.Quantity}{uom.Unit.Name}/{uom.Package.Name} {uom.Name}";
+ e.Value = formattedValue;
+ }
+ else if (e.ColumnIndex == 3)
+ {
+ string formattedValue = $"{dimension.Width} x {dimension.Length} x {dimension.Height} {dimension.Unit.Name} {dimension.Name}";
+ e.Value = formattedValue;
+ }
+ }
+ }
+ }
+
+ private void a_Click(object sender, EventArgs e)
+ {
+ add = new Add();
+ add.Owner = main;
+
+ add.UpdateGrid += OnUpdate;
+ add.ShowDialog();
+ }
+ private void e_Click(object sender, EventArgs e)
+ {
+ DataGridViewRow selectedRow = dataGridView.CurrentRow;
+ Global.tempPkey = -1;
+ int value = (int)selectedRow.Cells[0].Value;
+ Global.tempPkey = value;
+
+ edit = new Edit();
+ edit.Owner = main;
+
+ edit.UpdateGrid += OnUpdate;
+ edit.ShowDialog();
+ }
+ private void r_Click(object sender, EventArgs e)
+ {
+ DataGridViewRow selectedRow = dataGridView.CurrentRow;
+ Global.tempPkey = -1;
+ int value = (int)selectedRow.Cells[0].Value;
+ Global.tempPkey = value;
+
+ remove = new Remove();
+ remove.Owner = main;
+
+ remove.UpdateGrid += OnUpdate;
+ remove.ShowDialog();
+ }
+ private void x_Click(object sender, EventArgs e)
+ {
+ returnMain?.Invoke(this, EventArgs.Empty);
+ Close();
+ }
+ private void OnUpdate(object sender, EventArgs e)
+ {
+ UpdateDatagridView();
+ }
+ }
+}
diff --git a/View/ProductSource/ProductForm.resx b/View/ProductSource/ProductForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/View/ProductSource/ProductForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/View/ProductSource/Remove.Designer.cs b/View/ProductSource/Remove.Designer.cs
new file mode 100644
index 0000000..9776a0a
--- /dev/null
+++ b/View/ProductSource/Remove.Designer.cs
@@ -0,0 +1,38 @@
+namespace Warehouse_IO.View.ProductSource
+{
+ partial class Remove
+ {
+ ///
+ /// 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.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Text = "Remove";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/View/ProductSource/Remove.cs b/View/ProductSource/Remove.cs
new file mode 100644
index 0000000..c1e7068
--- /dev/null
+++ b/View/ProductSource/Remove.cs
@@ -0,0 +1,31 @@
+using System;
+using Warehouse_IO.WHIO.Model;
+using System.Windows.Forms;
+using Warehouse_IO.Common;
+using Warehouse_IO.View.Add_Edit_Remove_Components;
+
+namespace Warehouse_IO.View.ProductSource
+{
+ public partial class Remove : RemoveForm
+ {
+ Product remove;
+
+ public event EventHandler UpdateGrid;
+
+ public Remove()
+ {
+ InitializeComponent();
+ }
+ protected override void AttemptRemove()
+ {
+ remove = new Product(Global.tempPkey);
+ if (remove.Remove())
+ {
+ MessageBox.Show(this, "Removed Success");
+ UpdateGrid?.Invoke(this, EventArgs.Empty);
+ Close();
+ }
+ else MessageBox.Show(this, "It's foreign key");
+ }
+ }
+}
diff --git a/View/UOMSource/AddUOM.cs b/View/UOMSource/AddUOM.cs
index 40fd4ba..e3f0d63 100644
--- a/View/UOMSource/AddUOM.cs
+++ b/View/UOMSource/AddUOM.cs
@@ -62,10 +62,26 @@ private void AttemptAdd()
{
MessageBox.Show("Invalid Quantity Format");
}
- string selectedUnitOfWeight = unitOfWeightListBox.SelectedItem.ToString();
- string selectedPerPackage = perPackageListBox.SelectedItem.ToString();
- unitofUom = new UnitOfUOM(selectedUnitOfWeight);
- package = new Package(selectedPerPackage);
+ if (unitOfWeightListBox.SelectedItem != null)
+ {
+ string selectedUnitOfWeight = unitOfWeightListBox.SelectedItem.ToString();
+ unitofUom = new UnitOfUOM(selectedUnitOfWeight);
+ }
+ else
+ {
+ MessageBox.Show("Please select Unit of Weight");
+ return;
+ }
+ if (perPackageListBox.SelectedItem != null)
+ {
+ string selectedPerPackage = perPackageListBox.SelectedItem.ToString();
+ package = new Package(selectedPerPackage);
+ }
+ else
+ {
+ MessageBox.Show("Please select Package");
+ return;
+ }
add = new UOM(value, unitofUom, package, nameTextBox.Text);
if (add.Create())
{
@@ -74,6 +90,7 @@ private void AttemptAdd()
UpdateGrid?.Invoke(this, EventArgs.Empty);
}
else MessageBox.Show(this, "Create Fail");
+ return;
}
private double convertToDouble(string text)
{
diff --git a/Warehouse IO.csproj b/Warehouse IO.csproj
index d39977a..66d80e9 100644
--- a/Warehouse IO.csproj
+++ b/Warehouse IO.csproj
@@ -127,6 +127,12 @@
AddEditDimensionFrom.cs
+
+ Form
+
+
+ AddEditProductForm.cs
+
Form
@@ -247,6 +253,30 @@
ParentForm.cs
+
+ Form
+
+
+ Add.cs
+
+
+ Form
+
+
+ Edit.cs
+
+
+ Form
+
+
+ ProductForm.cs
+
+
+ Form
+
+
+ Remove.cs
+
Form
@@ -408,6 +438,9 @@
AddEditDimensionFrom.cs
+
+ AddEditProductForm.cs
+
AddEditUOMForm.cs
@@ -447,6 +480,15 @@
ParentForm.cs
+
+ Add.cs
+
+
+ Edit.cs
+
+
+ ProductForm.cs
+
StorageLocationForm.cs