Guest User

Untitled

a guest
Jan 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. ...
  2. public ArrayList GetFly(int tip, string country)
  3. {
  4. ...
  5. var list = new ArrayList();
  6. var reader = command.ExecuteReader();
  7. if (reader.HasRows)
  8. {
  9. ...
  10. while (reader.Read())
  11. {
  12. decimal nr_zbor = reader.GetDecimal(cod_zbor);
  13. string aeroport = reader.GetString(nume_aeroport);
  14. string companie = reader.GetString(nume_companie);
  15. list.Add(nr_zbor);
  16. list.Add(companie);
  17. list.Add(aeroport);
  18. }
  19. }
  20. ...
  21.  
  22. private SearchFlyClass searchFly = new SearchFlyClass();
  23. private ArrayList fly = new ArrayList();
  24. ...
  25. private void ShowResultFlySearch(int direction, string country)
  26. {
  27. fly = searchFly.GetFly(direction, country);
  28. for (int count = 0; count < fly.Count; count++)
  29. {
  30. string zbor = fly[0].ToString();
  31. string companie = fly[1].ToString();
  32. string aeroport = fly[2].ToString();
  33. ListViewItem searchlist = new ListViewItem();
  34. searchlist.Items.Add(new ListViewItem(elem));
  35.  
  36. }
  37. }
  38.  
  39. ListView listView = new ListView();
  40. listView.View = View.Details;
  41.  
  42. listView.Columns.Add("zbor");
  43. listView.Columns.Add("airport");
  44. listView.Columns.Add("company");
  45.  
  46. private void ShowResultFlySearch(int direction, string country)
  47. {
  48. fly = searchFly.GetFly(direction, country);
  49.  
  50. for (int count = 0; count < fly.Count; count++)
  51. {
  52. string zbor = fly[0].ToString();
  53. string companie = fly[1].ToString();
  54. string aeroport = fly[2].ToString();
  55.  
  56. ListViewItem listViewItem = new ListViewItem(zbor);
  57. listViewItem.SubItems.Add(airport);
  58. listViewItem.SubItems.Add(companie);
  59.  
  60. listView.Items.Add (listViewItem);
  61. }
  62. }
  63.  
  64. public class Flight
  65. {
  66. public decimal Code { get; set; }
  67. public string Company { get; set; }
  68. public string Airport { get; set; }
  69. }
  70.  
  71. public Flight GetFlight(int tip, string country)
  72.  
  73. var flight = new Flight();
  74. flight.Code = reader.GetDecimal(cod_zbor);
  75. flight.Airport = reader.GetString(nume_aeroport);
  76. flight.Company = reader.GetString(nume_companie);
  77. return flight;
  78.  
  79. var flight = searchFly.GetFlight(...);
  80. // access flight properties here
Add Comment
Please, Sign In to add comment