public void UpdateCityList(Carrier inCarrier) { inCarrier.CityList.Clear(); string query = "SELECT * FROM CarrierDepot where CarrierID = " + inCarrier.CarrierID.ToString() + ";"; //Create a list to store the result List <string>[] list = new List <string> [7]; list[0] = new List <string>(); list[1] = new List <string>(); list[2] = new List <string>(); list[3] = new List <string>(); list[4] = new List <string>(); list[5] = new List <string>(); list[6] = new List <string>(); //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { list[0].Add(dataReader["CityName"] + ""); list[1].Add(dataReader["CarrierID"] + ""); list[2].Add(dataReader["FTL_Availibility"] + ""); list[3].Add(dataReader["LTL_Availibility"] + ""); list[4].Add(dataReader["FTL_Rate"] + ""); list[5].Add(dataReader["LTL_Rate"] + ""); list[6].Add(dataReader["Reefer_Charge"] + ""); } //close Data Reader dataReader.Close(); for (int i = 0; i < list[0].Count; i++) { CarrierDepot current = new CarrierDepot(); current.CityName = list[0][i]; current.CarrierID = int.Parse(list[1][i]); current.FTL_Availibility = int.Parse(list[2][i]); current.LTL_Availibility = int.Parse(list[3][i]); current.FTL_Rate = double.Parse(list[4][i]); current.LTL_Rate = double.Parse(list[5][i]); current.reeferCharge = double.Parse(list[6][i]); inCarrier.CityList.Add(current); } }
public void AddCity(string inCity, int inFTLA, int inLTLA, double inFTLRate, double inLTLRate, double inReeferCharge) { CarrierDepot temp = new CarrierDepot(CarrierID, inCity, inFTLA, inLTLA, inFTLRate, inLTLRate, inReeferCharge); CityList.Add(temp); }