public List<ProtectionLevel> ReadProtection(CreatureIdentification creature) { throw new NotImplementedException(); }
public List<OrderClass> ReadOrder(CreatureIdentification creature) { throw new NotImplementedException(); }
public PictureList ReadPicture(CreatureIdentification creature) { throw new NotImplementedException(); }
private void setValues(MySqlCommand cmd, CreatureIdentification item) { if (item is CreatureIdentification) setValuesFromCreatureIdentification(cmd, item); if (item is Creatures) setValuesFromCreature(cmd, (Creatures)item); if (item is Animal) setValuesFromAnimal(cmd, (Animal)item); if (item is ReptileClass) setValuesFromReptile(cmd, (ReptileClass)item); if (item is GastropodaClass) setValuesFromGastropoda(cmd, (GastropodaClass)item); if (item is CrustaceanClass) setValuesFromCrustacean(cmd, (CrustaceanClass)item); if (item is PlantClass) setValuesFromPlant(cmd, (PlantClass)item); }
public List<LatinNameClass> ReadLatinName(CreatureIdentification creature) { throw new NotImplementedException(); }
private int createCreature(CreatureIdentification item) { int insertId = 0; using (MySqlConnection conn = getAConnection()) { if (conn.State != System.Data.ConnectionState.Open) { using (MySqlCommand cmd = new MySqlCommand(INSERT_CREATURE, conn)) { setValues(cmd, item); try { insertId = (int)cmd.ExecuteScalar(); } catch (SqlException ex) { handleDBError(new Delegates.DatabaseArgs(ex)); } } } else { handleDBError(new Delegates.DatabaseArgs("Connection not open")); } } return insertId; }
/// <summary> /// Constructor /// </summary> /// <param name="versionNumber">The version number</param> /// <param name="creatureIdentification">the CreatureIdentification</param> public VersionInfo(decimal versionNumber, CreatureIdentification creatureIdentification) : base() { Version = versionNumber; CreatureIdentification = creatureIdentification; }
public DecorationList ReadDecoration(CreatureIdentification creature) { throw new NotImplementedException(); }
public FamilyListClass ReadFamily(CreatureIdentification creature) { throw new NotImplementedException(); }
public BookList ReadBook(CreatureIdentification creature, BookListType listType) { throw new NotImplementedException(); }
public BottomList ReadBottom(CreatureIdentification creature) { throw new NotImplementedException(); }
public BehaviorList ReadBehavior(CreatureIdentification creature) { throw new NotImplementedException(); }
private bool updateCreature(CreatureIdentification item) { using (MySqlConnection conn = getAConnection()) { if (conn.State != System.Data.ConnectionState.Open) { doVersionControl(item); using (MySqlCommand cmd = new MySqlCommand(UPDATE_CREATURE, conn)) { setValues(cmd, item); try { cmd.ExecuteScalar(); return true; } catch (SqlException ex) { handleDBError(new Delegates.DatabaseArgs(ex)); return false; } } } else { handleDBError(new Delegates.DatabaseArgs("Connection not open")); } } return false; }
private void setValuesFromCreatureIdentification(MySqlCommand cmd, CreatureIdentification item) { cmd.Parameters.AddWithValue("creatuteType", (int)item.CreatureType); cmd.Parameters.AddWithValue("danishTradenames", item.Tradenames.Danish); cmd.Parameters.AddWithValue("englishTradenames", item.Tradenames.English); cmd.Parameters.AddWithValue("germanTradenames", item.Tradenames.German); cmd.Parameters.AddWithValue("danishDescription", item.Description.Danish); cmd.Parameters.AddWithValue("englishDescription", item.Description.English); cmd.Parameters.AddWithValue("germanDescription", item.Description.German); if (item.ScientificName.ID == 0) { item.ScientificName = this.CreateLatinName(item.ScientificName); } cmd.Parameters.AddWithValue("scientificNameId", item.ScientificName.ID); //TODO: Handle foreign keys }
public List<RegionClass> ReadRegion(CreatureIdentification creature) { throw new NotImplementedException(); }
public FoodTypeList ReadFoodType(CreatureIdentification creature) { throw new NotImplementedException(); }
public SwimmingPositionList ReadSwimmingPosition(CreatureIdentification creature) { throw new NotImplementedException(); }
public List<GroupClass> ReadGroup(CreatureIdentification creature) { throw new NotImplementedException(); }
private bool deleteCreature(CreatureIdentification item) { using (MySqlConnection conn = getAConnection()) { if (conn.State != System.Data.ConnectionState.Open) { using (MySqlCommand cmd = new MySqlCommand(DELETE_CREATURE, conn)) { cmd.Parameters.AddWithValue("id", item.ID); try { cmd.ExecuteScalar(); return true; } catch (SqlException ex) { handleDBError(new Delegates.DatabaseArgs(ex)); return false; } } } else { handleDBError(new Delegates.DatabaseArgs("Connection not open")); } } return false; }
public GrowthSpeedList ReadGrowthSpeed(CreatureIdentification creature) { throw new NotImplementedException(); }
private void doVersionControl(CreatureIdentification newItem) { CreatureIdentification oldItem = selectCreature(newItem.ID, newItem.CreatureType); if (oldItem != null) { using (MySqlConnection conn = getAConnection()) { if (conn.State != System.Data.ConnectionState.Open) { using (MySqlCommand cmdInsert = new MySqlCommand(INSERT_VERSION_CREATURE, conn)) { setValues(cmdInsert, oldItem); cmdInsert.Parameters.AddWithValue("orgId", newItem.ID); try { cmdInsert.ExecuteScalar(); } catch (SqlException ex) { handleDBError(new Delegates.DatabaseArgs(ex)); } } } else { handleDBError(new Delegates.DatabaseArgs("Connection not open")); } } } }