/// <summary>
 /// Insert new Bus instance in database
 /// </summary>
 /// <param name="bus"></param>
 public void Insert(Bus bus)
 {
     if (bus != null)
     {
         string insert_statement = string.Format("INSERT INTO tbl_bus (bus_number, bus_capacity, bus_details, bus_lattitude, bus_longitude, bus_occupied, bus_vacant) VALUES('{0}',{1},'{2}','{3}','{4}',{5},{6})"
             , bus.BusNumber
             , bus.Capacity
             , bus.Details
             , bus.Lattitude
             , bus.Longitude
             , bus.Occupied
             , bus.Vacancy);
         using (MySqlCommand command = new MySqlCommand(insert_statement, this.connection))
         {
             using (MySqlDataReader reader = command.ExecuteReader())
             {
             }
         }
     }
 }
        /// <summary>
        /// Parse data to Bus object
        /// ("bus_number"&"lattitude"&"longitude"&"capacity"&"vacant"&"occupied"&"details)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Bus ParseData(string data)
        {
            string substringdata = data.Substring(data.IndexOf("("));
            string substringremove = substringdata.Substring(substringdata.IndexOf(")"));

            substringdata = substringdata.Replace("(","").Replace(substringremove, "");
            string[] splittedbycomma = substringdata.Split('&');

            Bus bus = new Bus
            {
                Action = ActionType.Transmit,
                BusNumber = splittedbycomma[0],
                Lattitude = splittedbycomma[1],
                Longitude = splittedbycomma[2],
                Capacity = splittedbycomma[3],
                Vacancy = splittedbycomma[4],
                Occupied = splittedbycomma[5],
                Details = splittedbycomma[6],
            };
            return bus;
        }
 /// <summary>
 /// Update record base on Bus Instance
 /// </summary>
 /// <param name="bus"></param>
 public void Update(Bus bus)
 {
     if (bus != null)
     {
         string update_statement = string.Format("UPDATE tbl_bus SET bus_lattitude='{1}', bus_longitude='{2}', bus_vacant={3}, bus_occupied={4} WHERE bus_number='{0}'"
             , bus.BusNumber
             , bus.Lattitude
             , bus.Longitude
             , bus.Vacancy
             , bus.Occupied);
         using (MySqlCommand command = new MySqlCommand(update_statement, this.connection))
         {
             using (MySqlDataReader reader = command.ExecuteReader())
             {
             }
         }
     }
 }