Advertisement
Guest User

Untitled

a guest
Jun 28th, 2011
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Runtime.Serialization.Formatters.Binary;
  11.  
  12. namespace test
  13. {
  14.  
  15. public partial class Form1 : Form
  16. {
  17. [Serializable]
  18. public class ore
  19. {
  20. public float Cost;
  21.  
  22. }
  23. [Serializable]
  24. public class comodity
  25. {
  26.  
  27. public float comodityCost;
  28.  
  29. }
  30. public float helioptris;
  31. public float noralgis;
  32. public float triandulis;
  33. public float eperton;
  34. public float imentium;
  35. public float stermonit;
  36. public float titan;
  37. public float HDT;
  38. public float liquizit;
  39.  
  40.  
  41.  
  42.  
  43.  
  44. private List<ore> oreData = new List<ore>();
  45. private ore b1 = null;
  46. private ore b2 = null;
  47. private ore b3 = null;
  48. private ore b4 = null;
  49. private ore b5 = null;
  50. private ore b6 = null;
  51. private ore b7 = null;
  52. private ore b8 = null;
  53. private ore b9 = null;
  54.  
  55.  
  56. private List<comodity> comodityData = new List<comodity>();
  57. private comodity o1 = null;
  58. private comodity o2 = null;
  59. private comodity o3 = null;
  60. private comodity o4 = null;
  61. private comodity o5 = null;
  62. private comodity o6 = null;
  63. private comodity o7 = null;
  64. private comodity o8 = null;
  65. private comodity o9 = null;
  66. private comodity o10 = null;
  67. private comodity o11 = null;
  68. private comodity o12 = null;
  69. private comodity o13 = null;
  70. private comodity o14 = null;
  71. private comodity o15 = null;
  72.  
  73.  
  74. public Form1()
  75. {
  76. InitializeComponent();
  77. b1 = new ore();
  78. b2 = new ore();
  79. b3 = new ore();
  80. b4 = new ore();
  81. b5 = new ore();
  82. b6 = new ore();
  83. b7 = new ore();
  84. b8 = new ore();
  85. b9 = new ore();
  86. oreData.Add(b1);
  87. oreData.Add(b2);
  88. oreData.Add(b3);
  89. oreData.Add(b4);
  90. oreData.Add(b5);
  91. oreData.Add(b6);
  92. oreData.Add(b7);
  93. oreData.Add(b8);
  94. oreData.Add(b9);
  95.  
  96. FileStream fs = new FileStream("ore.dat", FileMode.Open);
  97. BinaryFormatter bf = new BinaryFormatter();
  98. oreData = (List<ore>)bf.Deserialize(fs);
  99. fs.Close();
  100.  
  101. if (oreData != null)
  102. {
  103. if (oreData.Count > 0)
  104. textBox1.Text = oreData[0].Cost.ToString();//update the text box helioptris
  105. if (oreData.Count > 1)
  106. textBox2.Text = oreData[1].Cost.ToString();//update the text box noralgis
  107. if (oreData.Count > 2)
  108. textBox5.Text = oreData[2].Cost.ToString();//update the text box triandulis
  109. if (oreData.Count > 3)
  110. textBox6.Text = oreData[3].Cost.ToString();//update the text box eperton
  111. if (oreData.Count > 4)
  112. textBox7.Text = oreData[4].Cost.ToString();//update the text box imentium
  113. if (oreData.Count > 5)
  114. textBox8.Text = oreData[5].Cost.ToString();//update the text box stermoit
  115. if (oreData.Count > 6)
  116. textBox9.Text = oreData[6].Cost.ToString();//update the text box titan
  117. if (oreData.Count > 7)
  118. textBox10.Text = oreData[7].Cost.ToString();//update the text box HDT
  119. if (oreData.Count > 8)
  120. textBox11.Text = oreData[8].Cost.ToString();//update the text box liquizit
  121. }
  122.  
  123.  
  124.  
  125. o1 = new comodity(); // alligor
  126. o1.comodityCost = (titan * 315) + (eperton * 180) + (imentium * 135);
  127. o2 = new comodity(); // briochit
  128. o2.comodityCost = eperton * 27 + noralgis * 45 + imentium * 67;
  129. o3 = new comodity();// chollonin
  130. o3.comodityCost = imentium * 135;
  131. o4 = new comodity();// espitium
  132. o4.comodityCost = liquizit * 90 + eperton * 135 + stermonit * 90;
  133. o5 = new comodity();// hydrobenol
  134. o5.comodityCost = HDT * 90 + liquizit * 315 + triandulis * 225 + stermonit * 135;
  135. o6 = new comodity();// isopropenitol
  136. o6.comodityCost = HDT * 45;
  137. o7 = new comodity();// metchropin
  138. o7.comodityCost = stermonit * 36;
  139. o8 = new comodity();// phlobotil
  140. o8.comodityCost = HDT * 90 + helioptris * 54;
  141. o9 = new comodity();// plasteosine
  142. o9.comodityCost = titan * 18 + helioptris * 9;
  143. o10 = new comodity();// polynitrocol
  144. o10.comodityCost = helioptris * 180 + imentium * 180;
  145. o11 = new comodity();// polynucleit
  146. o11.comodityCost = HDT * 180 + triandulis * 180;
  147. o12 = new comodity();// prilumium
  148. o12.comodityCost = stermonit * 72;
  149. o13 = new comodity();// statchanol
  150. o13.comodityCost = imentium * 108;
  151. o14 = new comodity();// titanium
  152. o14.comodityCost = titan * 27;
  153. o15 = new comodity();// vitricyl
  154. o15.comodityCost = HDT * 90 + liquizit * 90;
  155.  
  156. comodityData.Add(o1);
  157. comodityData.Add(o2);
  158. comodityData.Add(o3);
  159. comodityData.Add(o4);
  160. comodityData.Add(o5);
  161. comodityData.Add(o6);
  162. comodityData.Add(o7);
  163. comodityData.Add(o8);
  164. comodityData.Add(o9);
  165. comodityData.Add(o11);
  166. comodityData.Add(o12);
  167. comodityData.Add(o13);
  168. comodityData.Add(o14);
  169. comodityData.Add(o15);
  170.  
  171.  
  172. }
  173.  
  174. private void textBox1_TextChanged(object sender, EventArgs e) //helioptris
  175. {
  176. // 1st text box input is float
  177. float tempFloat;
  178.  
  179.  
  180.  
  181. if (float.TryParse(textBox1.Text, out tempFloat))
  182. {
  183. oreData[0].Cost = tempFloat;
  184. helioptris = tempFloat;
  185.  
  186. }
  187. else
  188. MessageBox.Show("uh oh");
  189.  
  190.  
  191.  
  192. }
  193.  
  194.  
  195. private void textBox2_TextChanged(object sender, EventArgs e) // noralgis
  196. {
  197. // 2nd text box input is float
  198. float tempFloat;
  199. if (float.TryParse(textBox2.Text, out tempFloat))
  200. {
  201. oreData[1].Cost = tempFloat;
  202. noralgis = tempFloat;
  203.  
  204. }
  205. else
  206. MessageBox.Show("uh oh");
  207.  
  208.  
  209. }
  210.  
  211.  
  212. private void button1_Click(object sender, EventArgs e) // the save button
  213. {
  214.  
  215.  
  216.  
  217. FileStream fs = new FileStream("ore.dat", FileMode.Create);
  218. BinaryFormatter bf = new BinaryFormatter();
  219. bf.Serialize(fs, oreData);
  220. fs.Close();
  221.  
  222. FileStream nfs = new FileStream("comoditys.dat", FileMode.Create);
  223. BinaryFormatter nbf = new BinaryFormatter();
  224. nbf.Serialize(nfs, comodityData);
  225. nfs.Close();
  226.  
  227.  
  228. }
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. private void textBox3_TextChanged(object sender, EventArgs e)
  241. {
  242. // 3rd text box
  243. }
  244.  
  245. private void textBox4_TextChanged(object sender, EventArgs e)
  246. {
  247. //4th text box
  248. }
  249.  
  250.  
  251. private void button2_Click(object sender, EventArgs e)
  252. {
  253. FileStream fs = new FileStream("ore.dat", FileMode.Open);
  254. BinaryFormatter bf = new BinaryFormatter();
  255. oreData = (List<ore>)bf.Deserialize(fs);
  256. fs.Close();
  257.  
  258. if (oreData != null)
  259. {
  260. if (oreData.Count > 0)
  261. textBox3.Text = oreData[0].Cost.ToString();//update the text box helioptris
  262. if (oreData.Count > 1)
  263. textBox4.Text = oreData[1].Cost.ToString();//update the text box noralgis
  264. if (oreData.Count > 2)
  265. textBox12.Text = oreData[2].Cost.ToString();//update the text box triandulis
  266. if (oreData.Count > 3)
  267. textBox13.Text = oreData[3].Cost.ToString();//update the text box eperton
  268. if (oreData.Count > 4)
  269. textBox14.Text = oreData[4].Cost.ToString();//update the text box imentium
  270. if (oreData.Count > 5)
  271. textBox15.Text = oreData[5].Cost.ToString();//update the text box stermoit
  272. if (oreData.Count > 6)
  273. textBox16.Text = oreData[6].Cost.ToString();//update the text box titan
  274. if (oreData.Count > 7)
  275. textBox17.Text = oreData[7].Cost.ToString();//update the text box HDT
  276. if (oreData.Count > 8)
  277. textBox18.Text = oreData[8].Cost.ToString();//update the text box liquizit
  278. }
  279. }
  280.  
  281. private void textBox5_TextChanged(object sender, EventArgs e) // triandulis
  282. {
  283.  
  284. float tempFloat;
  285.  
  286.  
  287. if (float.TryParse(textBox5.Text, out tempFloat))
  288. {
  289. oreData[2].Cost = tempFloat;
  290. triandulis = tempFloat;
  291. }
  292. else
  293. MessageBox.Show("uh oh");
  294. }
  295.  
  296. private void textBox6_TextChanged(object sender, EventArgs e) // eperton
  297. {
  298.  
  299. float tempFloat;
  300.  
  301.  
  302. if (float.TryParse(textBox6.Text, out tempFloat))
  303. {
  304. oreData[3].Cost = tempFloat;
  305. eperton = tempFloat;
  306. }
  307. else
  308. MessageBox.Show("uh oh");
  309. }
  310.  
  311. private void textBox7_TextChanged(object sender, EventArgs e) // imentium
  312. {
  313.  
  314. float tempFloat;
  315.  
  316.  
  317. if (float.TryParse(textBox7.Text, out tempFloat))
  318. {
  319. oreData[4].Cost = tempFloat;
  320. imentium = tempFloat;
  321. }
  322. else
  323. MessageBox.Show("uh oh");
  324. }
  325.  
  326. private void textBox8_TextChanged(object sender, EventArgs e) // stermonit
  327. {
  328.  
  329. float tempFloat;
  330.  
  331.  
  332. if (float.TryParse(textBox8.Text, out tempFloat))
  333. {
  334. oreData[5].Cost = tempFloat;
  335. stermonit = tempFloat;
  336. }
  337. else
  338. MessageBox.Show("uh oh");
  339. }
  340.  
  341. private void textBox9_TextChanged(object sender, EventArgs e) // titan
  342. {
  343.  
  344. float tempFloat;
  345.  
  346.  
  347. if (float.TryParse(textBox9.Text, out tempFloat))
  348. {
  349. oreData[6].Cost = tempFloat;
  350. titan = tempFloat;
  351. }
  352. else
  353. MessageBox.Show("uh oh");
  354. }
  355.  
  356. private void textBox10_TextChanged(object sender, EventArgs e) // HDT
  357. {
  358.  
  359. float tempFloat;
  360.  
  361.  
  362. if (float.TryParse(textBox10.Text, out tempFloat))
  363. {
  364. oreData[7].Cost = tempFloat;
  365. HDT = tempFloat;
  366. }
  367. else
  368. MessageBox.Show("uh oh");
  369. }
  370.  
  371. private void textBox11_TextChanged(object sender, EventArgs e) // liquizite
  372. {
  373.  
  374. float tempFloat;
  375.  
  376.  
  377. if (float.TryParse(textBox11.Text, out tempFloat))
  378. {
  379. oreData[8].Cost = tempFloat;
  380. liquizit = tempFloat;
  381. }
  382. else
  383. MessageBox.Show("uh oh");
  384. }
  385.  
  386. private void textBox12_TextChanged(object sender, EventArgs e)
  387. {
  388. // display
  389. }
  390.  
  391. private void textBox13_TextChanged(object sender, EventArgs e)
  392. {
  393. // display
  394. }
  395.  
  396. private void textBox14_TextChanged(object sender, EventArgs e)
  397. {
  398. // display
  399. }
  400.  
  401. private void textBox15_TextChanged(object sender, EventArgs e)
  402. {
  403. // display
  404. }
  405.  
  406. private void textBox16_TextChanged(object sender, EventArgs e)
  407. {
  408. // display
  409. }
  410.  
  411. private void textBox17_TextChanged(object sender, EventArgs e)
  412. {
  413. // display
  414. }
  415.  
  416. private void textBox18_TextChanged(object sender, EventArgs e)
  417. {
  418. // display
  419. }
  420. // start comodity display
  421. private void textBox19_TextChanged(object sender, EventArgs e)
  422. {
  423.  
  424. }
  425.  
  426. private void textBox20_TextChanged(object sender, EventArgs e)
  427. {
  428.  
  429. }
  430.  
  431. private void textBox21_TextChanged(object sender, EventArgs e)
  432. {
  433.  
  434. }
  435.  
  436. private void textBox22_TextChanged(object sender, EventArgs e)
  437. {
  438.  
  439. }
  440.  
  441. private void textBox23_TextChanged(object sender, EventArgs e)
  442. {
  443.  
  444. }
  445.  
  446. private void textBox24_TextChanged(object sender, EventArgs e)
  447. {
  448.  
  449. }
  450.  
  451. private void textBox25_TextChanged(object sender, EventArgs e)
  452. {
  453.  
  454. }
  455.  
  456. private void textBox26_TextChanged(object sender, EventArgs e)
  457. {
  458.  
  459. }
  460.  
  461. private void textBox27_TextChanged(object sender, EventArgs e)
  462. {
  463.  
  464. }
  465.  
  466. private void textBox28_TextChanged(object sender, EventArgs e)
  467. {
  468.  
  469. }
  470.  
  471. private void textBox29_TextChanged(object sender, EventArgs e)
  472. {
  473.  
  474. }
  475.  
  476. private void textBox30_TextChanged(object sender, EventArgs e)
  477. {
  478.  
  479. }
  480.  
  481. private void textBox31_TextChanged(object sender, EventArgs e)
  482. {
  483.  
  484. }
  485.  
  486. private void textBox32_TextChanged(object sender, EventArgs e)
  487. {
  488.  
  489. }
  490.  
  491. private void textBox33_TextChanged(object sender, EventArgs e)
  492. {
  493.  
  494. }
  495.  
  496. private void button3_Click(object sender, EventArgs e)
  497. {
  498. FileStream df = new FileStream("comoditys.dat", FileMode.Open);
  499. BinaryFormatter abf = new BinaryFormatter();
  500. comodityData = (List<comodity>)abf.Deserialize(df);
  501. df.Close();
  502.  
  503. if (comodityData != null)
  504. {
  505. if (comodityData.Count > 0)
  506. textBox19.Text = comodityData[0].comodityCost.ToString();//update the text box Alligor
  507. if (comodityData.Count > 1)
  508. textBox20.Text = comodityData[1].comodityCost.ToString();//update the text box Briochit
  509. if (comodityData.Count > 2)
  510. textBox21.Text = comodityData[2].comodityCost.ToString();//update the text box Chollonin
  511. if (comodityData.Count > 3)
  512. textBox22.Text = comodityData[3].comodityCost.ToString();//update the text box Espitium
  513. if (comodityData.Count > 4)
  514. textBox23.Text = comodityData[4].comodityCost.ToString();//update the text box Hydrobenol
  515. if (comodityData.Count > 5)
  516. textBox24.Text = comodityData[5].comodityCost.ToString();//update the text box Isopropenitol
  517. if (comodityData.Count > 6)
  518. textBox25.Text = comodityData[6].comodityCost.ToString();//update the text box Metachropin
  519. if (comodityData.Count > 7)
  520. textBox26.Text = comodityData[7].comodityCost.ToString();//update the text box Phlobotil
  521. if (comodityData.Count > 8)
  522. textBox27.Text = comodityData[8].comodityCost.ToString();//update the text box Plasteosine
  523. if (comodityData.Count > 9)
  524. textBox28.Text = comodityData[9].comodityCost.ToString();//update the text box Polynitrocol
  525. if (comodityData.Count > 10)
  526. textBox29.Text = comodityData[10].comodityCost.ToString();//update the text box Polynucliet
  527. if (comodityData.Count > 11)
  528. textBox30.Text = comodityData[11].comodityCost.ToString();//update the text box Prilumium
  529. if (comodityData.Count > 12)
  530. textBox31.Text = comodityData[12].comodityCost.ToString();//update the text box Statchanol
  531. if (comodityData.Count > 13)
  532. textBox32.Text = comodityData[13].comodityCost.ToString();//update the text box Titanium
  533. if (comodityData.Count > 14)
  534. textBox33.Text = comodityData[14].comodityCost.ToString();//update the text box Vitricyl
  535. }
  536.  
  537. }
  538.  
  539. private void button4_Click(object sender, EventArgs e)
  540. {
  541. Form2 form2 = new Form2();
  542. form2.Show();
  543. }
  544. }
  545. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement