using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace test
{
public partial class Form1 : Form
{
[Serializable]
public class ore
{
public float Cost;
}
[Serializable]
public class comodity
{
public float comodityCost;
}
public float helioptris;
public float noralgis;
public float triandulis;
public float eperton;
public float imentium;
public float stermonit;
public float titan;
public float HDT;
public float liquizit;
private List<ore> oreData = new List<ore>();
private ore b1 = null;
private ore b2 = null;
private ore b3 = null;
private ore b4 = null;
private ore b5 = null;
private ore b6 = null;
private ore b7 = null;
private ore b8 = null;
private ore b9 = null;
private List<comodity> comodityData = new List<comodity>();
private comodity o1 = null;
private comodity o2 = null;
private comodity o3 = null;
private comodity o4 = null;
private comodity o5 = null;
private comodity o6 = null;
private comodity o7 = null;
private comodity o8 = null;
private comodity o9 = null;
private comodity o10 = null;
private comodity o11 = null;
private comodity o12 = null;
private comodity o13 = null;
private comodity o14 = null;
private comodity o15 = null;
public Form1()
{
InitializeComponent();
b1 = new ore();
b2 = new ore();
b3 = new ore();
b4 = new ore();
b5 = new ore();
b6 = new ore();
b7 = new ore();
b8 = new ore();
b9 = new ore();
oreData.Add(b1);
oreData.Add(b2);
oreData.Add(b3);
oreData.Add(b4);
oreData.Add(b5);
oreData.Add(b6);
oreData.Add(b7);
oreData.Add(b8);
oreData.Add(b9);
FileStream fs = new FileStream("ore.dat", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
oreData = (List<ore>)bf.Deserialize(fs);
fs.Close();
if (oreData != null)
{
if (oreData.Count > 0)
textBox1.Text = oreData[0].Cost.ToString();//update the text box helioptris
if (oreData.Count > 1)
textBox2.Text = oreData[1].Cost.ToString();//update the text box noralgis
if (oreData.Count > 2)
textBox5.Text = oreData[2].Cost.ToString();//update the text box triandulis
if (oreData.Count > 3)
textBox6.Text = oreData[3].Cost.ToString();//update the text box eperton
if (oreData.Count > 4)
textBox7.Text = oreData[4].Cost.ToString();//update the text box imentium
if (oreData.Count > 5)
textBox8.Text = oreData[5].Cost.ToString();//update the text box stermoit
if (oreData.Count > 6)
textBox9.Text = oreData[6].Cost.ToString();//update the text box titan
if (oreData.Count > 7)
textBox10.Text = oreData[7].Cost.ToString();//update the text box HDT
if (oreData.Count > 8)
textBox11.Text = oreData[8].Cost.ToString();//update the text box liquizit
}
o1 = new comodity(); // alligor
o1.comodityCost = (titan * 315) + (eperton * 180) + (imentium * 135);
o2 = new comodity(); // briochit
o2.comodityCost = eperton * 27 + noralgis * 45 + imentium * 67;
o3 = new comodity();// chollonin
o3.comodityCost = imentium * 135;
o4 = new comodity();// espitium
o4.comodityCost = liquizit * 90 + eperton * 135 + stermonit * 90;
o5 = new comodity();// hydrobenol
o5.comodityCost = HDT * 90 + liquizit * 315 + triandulis * 225 + stermonit * 135;
o6 = new comodity();// isopropenitol
o6.comodityCost = HDT * 45;
o7 = new comodity();// metchropin
o7.comodityCost = stermonit * 36;
o8 = new comodity();// phlobotil
o8.comodityCost = HDT * 90 + helioptris * 54;
o9 = new comodity();// plasteosine
o9.comodityCost = titan * 18 + helioptris * 9;
o10 = new comodity();// polynitrocol
o10.comodityCost = helioptris * 180 + imentium * 180;
o11 = new comodity();// polynucleit
o11.comodityCost = HDT * 180 + triandulis * 180;
o12 = new comodity();// prilumium
o12.comodityCost = stermonit * 72;
o13 = new comodity();// statchanol
o13.comodityCost = imentium * 108;
o14 = new comodity();// titanium
o14.comodityCost = titan * 27;
o15 = new comodity();// vitricyl
o15.comodityCost = HDT * 90 + liquizit * 90;
comodityData.Add(o1);
comodityData.Add(o2);
comodityData.Add(o3);
comodityData.Add(o4);
comodityData.Add(o5);
comodityData.Add(o6);
comodityData.Add(o7);
comodityData.Add(o8);
comodityData.Add(o9);
comodityData.Add(o11);
comodityData.Add(o12);
comodityData.Add(o13);
comodityData.Add(o14);
comodityData.Add(o15);
}
private void textBox1_TextChanged(object sender, EventArgs e) //helioptris
{
// 1st text box input is float
float tempFloat;
if (float.TryParse(textBox1.Text, out tempFloat))
{
oreData[0].Cost = tempFloat;
helioptris = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox2_TextChanged(object sender, EventArgs e) // noralgis
{
// 2nd text box input is float
float tempFloat;
if (float.TryParse(textBox2.Text, out tempFloat))
{
oreData[1].Cost = tempFloat;
noralgis = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void button1_Click(object sender, EventArgs e) // the save button
{
FileStream fs = new FileStream("ore.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, oreData);
fs.Close();
FileStream nfs = new FileStream("comoditys.dat", FileMode.Create);
BinaryFormatter nbf = new BinaryFormatter();
nbf.Serialize(nfs, comodityData);
nfs.Close();
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
// 3rd text box
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
//4th text box
}
private void button2_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("ore.dat", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
oreData = (List<ore>)bf.Deserialize(fs);
fs.Close();
if (oreData != null)
{
if (oreData.Count > 0)
textBox3.Text = oreData[0].Cost.ToString();//update the text box helioptris
if (oreData.Count > 1)
textBox4.Text = oreData[1].Cost.ToString();//update the text box noralgis
if (oreData.Count > 2)
textBox12.Text = oreData[2].Cost.ToString();//update the text box triandulis
if (oreData.Count > 3)
textBox13.Text = oreData[3].Cost.ToString();//update the text box eperton
if (oreData.Count > 4)
textBox14.Text = oreData[4].Cost.ToString();//update the text box imentium
if (oreData.Count > 5)
textBox15.Text = oreData[5].Cost.ToString();//update the text box stermoit
if (oreData.Count > 6)
textBox16.Text = oreData[6].Cost.ToString();//update the text box titan
if (oreData.Count > 7)
textBox17.Text = oreData[7].Cost.ToString();//update the text box HDT
if (oreData.Count > 8)
textBox18.Text = oreData[8].Cost.ToString();//update the text box liquizit
}
}
private void textBox5_TextChanged(object sender, EventArgs e) // triandulis
{
float tempFloat;
if (float.TryParse(textBox5.Text, out tempFloat))
{
oreData[2].Cost = tempFloat;
triandulis = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox6_TextChanged(object sender, EventArgs e) // eperton
{
float tempFloat;
if (float.TryParse(textBox6.Text, out tempFloat))
{
oreData[3].Cost = tempFloat;
eperton = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox7_TextChanged(object sender, EventArgs e) // imentium
{
float tempFloat;
if (float.TryParse(textBox7.Text, out tempFloat))
{
oreData[4].Cost = tempFloat;
imentium = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox8_TextChanged(object sender, EventArgs e) // stermonit
{
float tempFloat;
if (float.TryParse(textBox8.Text, out tempFloat))
{
oreData[5].Cost = tempFloat;
stermonit = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox9_TextChanged(object sender, EventArgs e) // titan
{
float tempFloat;
if (float.TryParse(textBox9.Text, out tempFloat))
{
oreData[6].Cost = tempFloat;
titan = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox10_TextChanged(object sender, EventArgs e) // HDT
{
float tempFloat;
if (float.TryParse(textBox10.Text, out tempFloat))
{
oreData[7].Cost = tempFloat;
HDT = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox11_TextChanged(object sender, EventArgs e) // liquizite
{
float tempFloat;
if (float.TryParse(textBox11.Text, out tempFloat))
{
oreData[8].Cost = tempFloat;
liquizit = tempFloat;
}
else
MessageBox.Show("uh oh");
}
private void textBox12_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox13_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox14_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox15_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox16_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox17_TextChanged(object sender, EventArgs e)
{
// display
}
private void textBox18_TextChanged(object sender, EventArgs e)
{
// display
}
// start comodity display
private void textBox19_TextChanged(object sender, EventArgs e)
{
}
private void textBox20_TextChanged(object sender, EventArgs e)
{
}
private void textBox21_TextChanged(object sender, EventArgs e)
{
}
private void textBox22_TextChanged(object sender, EventArgs e)
{
}
private void textBox23_TextChanged(object sender, EventArgs e)
{
}
private void textBox24_TextChanged(object sender, EventArgs e)
{
}
private void textBox25_TextChanged(object sender, EventArgs e)
{
}
private void textBox26_TextChanged(object sender, EventArgs e)
{
}
private void textBox27_TextChanged(object sender, EventArgs e)
{
}
private void textBox28_TextChanged(object sender, EventArgs e)
{
}
private void textBox29_TextChanged(object sender, EventArgs e)
{
}
private void textBox30_TextChanged(object sender, EventArgs e)
{
}
private void textBox31_TextChanged(object sender, EventArgs e)
{
}
private void textBox32_TextChanged(object sender, EventArgs e)
{
}
private void textBox33_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
FileStream df = new FileStream("comoditys.dat", FileMode.Open);
BinaryFormatter abf = new BinaryFormatter();
comodityData = (List<comodity>)abf.Deserialize(df);
df.Close();
if (comodityData != null)
{
if (comodityData.Count > 0)
textBox19.Text = comodityData[0].comodityCost.ToString();//update the text box Alligor
if (comodityData.Count > 1)
textBox20.Text = comodityData[1].comodityCost.ToString();//update the text box Briochit
if (comodityData.Count > 2)
textBox21.Text = comodityData[2].comodityCost.ToString();//update the text box Chollonin
if (comodityData.Count > 3)
textBox22.Text = comodityData[3].comodityCost.ToString();//update the text box Espitium
if (comodityData.Count > 4)
textBox23.Text = comodityData[4].comodityCost.ToString();//update the text box Hydrobenol
if (comodityData.Count > 5)
textBox24.Text = comodityData[5].comodityCost.ToString();//update the text box Isopropenitol
if (comodityData.Count > 6)
textBox25.Text = comodityData[6].comodityCost.ToString();//update the text box Metachropin
if (comodityData.Count > 7)
textBox26.Text = comodityData[7].comodityCost.ToString();//update the text box Phlobotil
if (comodityData.Count > 8)
textBox27.Text = comodityData[8].comodityCost.ToString();//update the text box Plasteosine
if (comodityData.Count > 9)
textBox28.Text = comodityData[9].comodityCost.ToString();//update the text box Polynitrocol
if (comodityData.Count > 10)
textBox29.Text = comodityData[10].comodityCost.ToString();//update the text box Polynucliet
if (comodityData.Count > 11)
textBox30.Text = comodityData[11].comodityCost.ToString();//update the text box Prilumium
if (comodityData.Count > 12)
textBox31.Text = comodityData[12].comodityCost.ToString();//update the text box Statchanol
if (comodityData.Count > 13)
textBox32.Text = comodityData[13].comodityCost.ToString();//update the text box Titanium
if (comodityData.Count > 14)
textBox33.Text = comodityData[14].comodityCost.ToString();//update the text box Vitricyl
}
}
private void button4_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
}
}