/// <summary> /// Gets what resources a planet has. By giving it the Planet id. /// </summary> /// <param name="planetId"></param> /// <returns></returns> public List <Resourcedata> PlanetResources(int planetId) { List <Resourcedata> result = new List <Resourcedata>(); if (Check()) { string Query = string.Format("SELECT resources.Resources_id, resources.Name, resources.Initial_Price, resources.Description, planetresources.Price FROM resource, planetresources WHERE resources.Resources_id == planetresources.Resources_id AND planetresources.Planet_id = {0};", planetId); using (SQLiteCommand command = new SQLiteCommand(Query, dbc)) { try { using (SQLiteDataReader rdq = command.ExecuteReader()) { while (rdq.Read()) { Resourcedata record = new Resourcedata(rdq.GetInt32(0), rdq.GetString(1), rdq.GetInt32(2), rdq.GetString(3), planetId, 0, 0, 0, rdq.GetInt32(4), 0, "null"); result.Add(record); } } } catch (Exception ex) { Console.WriteLine("Error " + ex); } } } return(result); }
/// <summary> /// This gets the resource information if you give it the resource_id. /// </summary> /// <param name="resource_id"></param> /// <returns></returns> public List <Resourcedata> getResource(int resources_id) { List <Resourcedata> result = new List <Resourcedata>(); if (Check()) { string Query = string.Format("SELECT resources.Resources_id, resources.Name, resources.Initial_Price, resources.Description, media.Media_id, media.file_Loc FROM resources, resourcesmedia, media WHERE (resources.Resources_id == resourcesmedia.Resources_id AND resourcesmedia.Media_id == media.Media_id) AND resources.Resources_id == {0};", resources_id); using (SQLiteCommand command = new SQLiteCommand(Query, dbc)) { try { using (SQLiteDataReader rdq = command.ExecuteReader()) { while (rdq.Read()) { Resourcedata record = new Resourcedata(rdq.GetInt32(0), rdq.GetString(1), rdq.GetInt32(2), rdq.GetString(3), 0, 0, 0, 0, 0, rdq.GetInt32(4), rdq.GetString(5)); result.Add(record); } } } catch (Exception ex) { Console.WriteLine("Error " + ex); } } } return(result); }
/// <summary> /// Gets all the resources what the ship selected has. /// </summary> /// <param name="shipId"></param> /// <returns></returns> public List <Resourcedata> ShipResources(int shipId) { List <Resourcedata> result = new List <Resourcedata>(); if (Check()) { string Query = string.Format("SELECT resources.Resources_id, resources.Name, resources.Initial_Price, resources.Description, shipresource.Amount, shipresource.Bought_Price FROM resource, shipresource WHERE resources.Resources_id == shipresource.Resources_id AND shipresource.Ship_id = '{0}';", shipId); using (SQLiteCommand command = new SQLiteCommand(Query, dbc)) { try { using (SQLiteDataReader rdq = command.ExecuteReader()) { while (rdq.Read()) { Resourcedata record = new Resourcedata(rdq.GetInt32(0), rdq.GetString(1), rdq.GetInt32(2), rdq.GetString(3), 0, 0, shipId, rdq.GetInt32(4), rdq.GetInt32(5), 0, "null"); result.Add(record); } } } catch (Exception ex) { Console.WriteLine("Error " + ex); } } } return(result); }
public List <Resourcedata> getResource(int resource_id) { List <Resourcedata> result = new List <Resourcedata>(); Resourcedata record = new Resourcedata(1, "resour", 2, "descrp", 1, 2, 3, 4, 5, 6, "loc"); result.Add(record); return(result); }
public List <Resourcedata> ShipResources(int shipId) { List <Resourcedata> result = new List <Resourcedata>(); Resourcedata record = new Resourcedata(shipId, "resour", 2, "descrp", 1, 2, 3, 4, 5, 6, "loc"); result.Add(record); return(result); }