Skip to content
6 changes: 2 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static void error(string message = constants.preMadeErrorMsg, Exception
//rest isn't necessary. if you don't provide an exception, it won't display one. If you provide an error, it will default to "hide error".
// WARNING: If you provide a boolean, you can controll if it's hidden. If you provide a boolean but no error, well, it won't work righ

/* internal static string path()
internal static string path()
{
var pathSpliter = '\\'; //part between paths
var loc = AppDomain.CurrentDomain.BaseDirectory; //get the current domain
Expand All @@ -46,8 +46,6 @@ internal static void error(string message = constants.preMadeErrorMsg, Exception
completeLoc = completeLoc + comp + char.ToString(pathSpliter); //add next part to path
}
return completeLoc; //output path
} //derive the path of the base file */

} //derive the path of the base file
} //base commands to aid in everything

}
4 changes: 3 additions & 1 deletion bin/Debug/snacks.csv
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test,0.03,1,H:\Students_Folder\Charlie Hatch\Semesters\Multi-Semester\App Dev\Projects\Advanced Appdev\Snack-Shack-2\presetImages\2fer.jpg
Test,0.05,2,H:\Students_Folder\Charlie Hatch\Semesters\Multi-Semester\App Dev\Projects\Advanced Appdev\Snack-Shack\presetImages\2fer.jpg
test,0.07,1,H:\Students_Folder\Charlie Hatch\Semesters\Multi-Semester\App Dev\Projects\Advanced Appdev\Snack-Shack\presetImages\airheads.jpg
test,0.1,9,H:\Students_Folder\Charlie Hatch\Semesters\Multi-Semester\App Dev\Projects\Advanced Appdev\Snack-Shack\presetImages\2fer.jpg
10 changes: 4 additions & 6 deletions constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ namespace snackShack
{
internal static class constants //pre-defined constants
{
//const char fileSepChar_con = '\\'; //seperater in file paths
internal const char fileSepChar_con = '\\'; //seperater in file paths
internal static string fileSepString = fileSepChar_con.ToString();
//internal const int min = 4; //length of entries
internal const char entrySep = ','; //seperation character
internal const string preMadeErrorMsg = "I'm sorry dave, I'm afraid I can't do that"; //pre-made error message
internal const decimal minPrice = 0.05M;
/*internal static string fileSepString() //give the seperation character as a string
{
char.ToString(fileSepChar_con);
}
*/
internal const string fileName = "snacks";
internal const string fileExtension = "csv";
/* internal static char fileSepChar() //give the seperation character as a char
{
return fileSepChar_con;
Expand Down
10 changes: 6 additions & 4 deletions frm_snackInvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;

namespace snackShack
{
Expand All @@ -13,7 +14,8 @@ public frm_snackInvent()
toolStripStatusLabel1.Text = ""; // Wipe the status strip of all text
nud_snackPrice.Minimum = constants.minPrice; // Set the minimum price to the constant defined in constants.cs
}


string filePath = Path.Combine(coreCommands.path(), constants.fileName + '.' + constants.fileExtension);
private void bttn_snackImage_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.gif;*bmp)|*.jpg;*.jpeg;*.png;*.gif;*.bmp";
Expand Down Expand Up @@ -71,7 +73,7 @@ private void frm_snackInvent_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
using (StreamWriter sw = new StreamWriter("snacks.csv")) {
using (StreamWriter sw = new StreamWriter(filePath)) {
int count = 0;
toolStripStatusLabel1.Text = String.Format("Wrote {0} snacks to file", count); //show current number of entries, which is 0.
//If this is what you see when done, something went wrong
Expand All @@ -94,12 +96,12 @@ private void frm_snackInvent_Load(object sender, EventArgs e)
{
try
{
if(File.Exists("snacks.csv"))
if(File.Exists(filePath))
{
toolStripStatusLabel1.Text =
String.Format("Proceeding to load snacks from file"); //if you see this, something went wrong...
//It means that it failed before it loaded something
using (StreamReader sr = new StreamReader("snacks.csv"))
using (StreamReader sr = new StreamReader(filePath))
{
int count = 0;
while(!sr.EndOfStream)
Expand Down
1 change: 1 addition & 0 deletions snacks.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test,0.09,0,C:\Users\Charlie\Non Puriel\Snack-Shack\presetImages\airheads.jpg