-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66520a6
commit ed2b3a9
Showing
39 changed files
with
982 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.10.35013.160 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inventory", "Inventory\Inventory.csproj", "{4577FB12-6D99-4CAF-863A-38C6CE029D6E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4577FB12-6D99-4CAF-863A-38C6CE029D6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4577FB12-6D99-4CAF-863A-38C6CE029D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4577FB12-6D99-4CAF-863A-38C6CE029D6E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4577FB12-6D99-4CAF-863A-38C6CE029D6E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {73B855CE-4A89-4E67-8CDB-40178284917B} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Inventory | ||
{ | ||
public class CurrencyFormatException : Exception | ||
{ | ||
public CurrencyFormatException(string currency) : base(currency) { } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System.Text.RegularExpressions; | ||
using System.Xml.Linq; | ||
|
||
namespace Inventory | ||
{ | ||
public partial class frmAddProduct : Form | ||
{ | ||
BindingSource showProductList; | ||
private int _Quantity; | ||
private double _SellPrice; | ||
private string _ProductName, _Category, _MfgDate, _ExpDate, _Description; | ||
|
||
public frmAddProduct() | ||
{ | ||
InitializeComponent(); | ||
showProductList = new BindingSource(); | ||
} | ||
|
||
private void label4_Click(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private void frmAddProduct_Load(object sender, EventArgs e) | ||
{ | ||
string[] ListOfProductCategory = new string[] { | ||
"Beverages", | ||
"Bread/Bakery", | ||
"Canned/Jarred Goods", | ||
"Dairy", | ||
"Frozen Goods", | ||
"Meat", | ||
"Personal Care", | ||
"Other" | ||
}; | ||
|
||
foreach (string items in ListOfProductCategory) | ||
{ | ||
cbCategory.Items.Add(items); | ||
|
||
} | ||
} | ||
|
||
public string Product_Name(string name) | ||
{ | ||
if (!Regex.IsMatch(name, @"^[a-zA-Z]+$")) | ||
{ | ||
throw new StringFormatException(""); | ||
} | ||
|
||
return name; | ||
} | ||
public int Quantity(string qty) | ||
{ | ||
if (!Regex.IsMatch(qty, @"^[0-9]")) | ||
{ | ||
throw new NumberFormatException(""); | ||
} | ||
|
||
return Convert.ToInt32(qty); | ||
} | ||
public double SellingPrice(string price) | ||
{ | ||
if (!Regex.IsMatch(price.ToString(), @"^(\d*\.)?\d+$")) | ||
{ | ||
throw new CurrencyFormatException(""); | ||
} | ||
return Convert.ToDouble(price); | ||
} | ||
|
||
private void btnAddProduct_Click(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
_ProductName = Product_Name(txtProductName.Text); | ||
_Category = cbCategory.Text; | ||
_MfgDate = dtPickerMfgDate.Value.ToString("yyyy-MM-dd"); | ||
_ExpDate = dtPickerExpDate.Value.ToString("yyyy-MM-dd"); | ||
_Description = richTxtDescription.Text; | ||
_Quantity = Quantity(txtQuantity.Text); | ||
_SellPrice = SellingPrice(txtSellPrice.Text); | ||
showProductList.Add(new ProductClass(_ProductName, _Category, _MfgDate, _ExpDate, _SellPrice, _Quantity, _Description)); | ||
gridViewProductList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; | ||
gridViewProductList.DataSource = showProductList; | ||
} | ||
catch (StringFormatException err) | ||
{ | ||
MessageBox.Show(err.Message); | ||
} | ||
catch (CurrencyFormatException err1) | ||
{ | ||
MessageBox.Show(err1.Message); | ||
} | ||
catch (NumberFormatException err2) | ||
{ | ||
MessageBox.Show(err2.Message); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.