Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLoadBusSetting_Click(object sender, EventArgs e)
- {
- if (txtLoadPathBus.Text == "")
- {
- MessageBox.Show("Please select a path before loading.");
- }
- else
- {
- StreamReader SR = new StreamReader(txtLoadPathBus.Text);
- string [] BusRecord;
- string recordno, buscode, destination, cost, driver;
- //Read and Display the lines by lines until everything is read.
- string lineRecord = SR.ReadLine();
- while (lineRecord != null)
- {
- BusRecord = lineRecord.Split('%');
- recordno = BusRecord[0];
- buscode = BusRecord[1];
- destination = BusRecord[2];
- cost = BusRecord[3];
- driver = BusRecord[4];
- for (int i=0; i < RecordNum.Length; i++)
- {
- RecordNum[i] = int.Parse(recordno);
- BusCode[i] = buscode;
- Destination[i] = destination;
- Cost[i] = decimal.Parse(cost);
- DriverID[i] = driver;
- }
- lineRecord = SR.ReadLine();
- }
- MessageBox.Show("Updated Sucessfully");
- txtLoadPathBus.Clear();
- RefreshBus();
- }
- }
- //This is what text file saved.
- 1%Bob192%Malacca%550.30%Bob
- 2%John193%Albania%1050%John
- 3%Saber130%Algeria%2340%Toma
- 4%Alpha140%Andorra%2121%John
- 5%Benji150%Angola%3412%Benji
- 6%Toma160%Anguilla%8741%Toma
- 7%Jerry170%Antarctica%2981%John
- 8%Kit180%Azerbaijan%2412%Kit
- 9%Tom190%Bahamas%9821%Tom
- 10%Josh200%Bfasrain%2182%Jonathan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement