// Update an existing sub currency void UpdateSubcurrency(CurrencyData subCurrency) { NewResult ("Updating..."); // Setup the update query string query = "UPDATE " + tableName; query += " SET "; query += subCurrency.UpdateList (); query += " WHERE id=?id"; // Setup the register data List<Register> update = new List<Register> (); foreach (string field in subCurrency.fields.Keys) { update.Add (subCurrency.fieldToRegister (field)); } update.Add (new Register ("id", "?id", MySqlDbType.Int32, subCurrency.id.ToString (), Register.TypesOfField.Int)); }
/// <summary> /// Inserts a new entry in the currencies database for the sub currency. /// </summary> /// <returns>The sub currency.</returns> /// <param name="subCurrency">Sub currency.</param> /// <param name="parent">Parent.</param> int InsertSubCurrency(CurrencyData subCurrency) { // Setup the update query string query = "INSERT INTO " + tableName; query += " (" + subCurrency.FieldList ("", ", ") + ") "; query += "VALUES "; query += " (" + subCurrency.FieldList ("?", ", ") + ") "; int itemID = -1; // Setup the register data List<Register> update = new List<Register> (); foreach (string field in subCurrency.fields.Keys) { update.Add (subCurrency.fieldToRegister (field)); } // Update the database itemID = DatabasePack.Insert (DatabasePack.contentDatabasePrefix, query, update); return itemID; }