Advertisement
Garth0

Untitled

Jan 16th, 2020
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. if(serialPort1.BytesToRead > 0)
  2. {
  3. string color = serialPort1.ReadLine().Trim();
  4. if(color.StartsWith("WHITE"))
  5. {
  6. double wprice = 5;
  7. Balance[names.IndexOf(tbBuyer.Text)] -= wprice;
  8. lbx1.Items.Clear();
  9. foreach (string mate in names)
  10. {
  11. lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
  12. }
  13. }
  14. else if (color.StartsWith("BLACK"))
  15. {
  16. double bprice = 2;
  17. Balance[names.IndexOf(tbBuyer.Text)] -= bprice;
  18. lbx1.Items.Clear();
  19. foreach (string mate in names)
  20. {
  21. lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
  22. }
  23. }
  24. else if (color.StartsWith("RED"))
  25. {
  26. double rprice = 3;
  27. Balance[names.IndexOf(tbBuyer.Text)] -= rprice;
  28. lbx1.Items.Clear();
  29. foreach (string mate in names)
  30. {
  31. lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
  32. }
  33. }
  34. else if (color.StartsWith("BLUE"))
  35. {
  36. double blprice = 4;
  37. Balance[names.IndexOf(tbBuyer.Text)] -= blprice;
  38. lbx1.Items.Clear();
  39. foreach (string mate in names)
  40. {
  41. lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
  42. }
  43. }
  44. else if (color.StartsWith("GREEN"))
  45. {
  46. double gprice = 1;
  47. Balance[names.IndexOf(tbBuyer.Text)] -= gprice;
  48. lbx1.Items.Clear();
  49. foreach (string mate in names)
  50. {
  51. lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement