Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. private void btnLoadBusSetting_Click(object sender, EventArgs e)
  2. {
  3. if (txtLoadPathBus.Text == "")
  4. {
  5. MessageBox.Show("Please select a path before loading.");
  6. }
  7. else
  8. {
  9. StreamReader SR = new StreamReader(txtLoadPathBus.Text);
  10. string [] BusRecord;
  11. string recordno, buscode, destination, cost, driver;
  12.  
  13. //Read and Display the lines by lines until everything is read.
  14. string lineRecord = SR.ReadLine();
  15. while (lineRecord != null)
  16. {
  17. BusRecord = lineRecord.Split('%');
  18. recordno = BusRecord[0];
  19. buscode = BusRecord[1];
  20. destination = BusRecord[2];
  21. cost = BusRecord[3];
  22. driver = BusRecord[4];
  23.  
  24. for (int i=0; i < RecordNum.Length; i++)
  25. {
  26. RecordNum[i] = int.Parse(recordno);
  27. BusCode[i] = buscode;
  28. Destination[i] = destination;
  29. Cost[i] = decimal.Parse(cost);
  30. DriverID[i] = driver;
  31. }
  32. lineRecord = SR.ReadLine();
  33. }
  34. MessageBox.Show("Updated Sucessfully");
  35. txtLoadPathBus.Clear();
  36. RefreshBus();
  37. }
  38. }
  39.  
  40. //This is what text file saved.
  41. 1%Bob192%Malacca%550.30%Bob
  42. 2%John193%Albania%1050%John
  43. 3%Saber130%Algeria%2340%Toma
  44. 4%Alpha140%Andorra%2121%John
  45. 5%Benji150%Angola%3412%Benji
  46. 6%Toma160%Anguilla%8741%Toma
  47. 7%Jerry170%Antarctica%2981%John
  48. 8%Kit180%Azerbaijan%2412%Kit
  49. 9%Tom190%Bahamas%9821%Tom
  50. 10%Josh200%Bfasrain%2182%Jonathan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement