public int UpdateActiveCountryNotes(ActiveCountryItem newItem) { string queryString = "update " + tableActiveCountry + " set note=@note where id=@id"; using (SQLiteConnection connection = new SQLiteConnection(strConnection)) using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection)) { // Set command parameters. dbCommand.Parameters.AddWithValue("@id", newItem.Id); dbCommand.Parameters.AddWithValue("@note", newItem.Note); // Update active ocuntry in table. connection.Open(); int result = dbCommand.ExecuteNonQuery(); // Notify changes. if (this.CountryModified != null) { this.CountryModified(this, null); } // Return the result. return(result); } }
public int AddActiveCountry(ActiveCountryItem newItem) { string queryString = "insert into " + tableActiveCountry + " values(null, @iso2, @note)"; using (SQLiteConnection connection = new SQLiteConnection(strConnection)) using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection)) { // Set command parameters. dbCommand.Parameters.AddWithValue("@iso2", newItem.Iso2Code); dbCommand.Parameters.AddWithValue("@note", newItem.Note); // Add new active country to table. connection.Open(); int result = dbCommand.ExecuteNonQuery(); // Notify changes. if (this.CountryModified != null) { this.CountryModified(this, null); } // Return the result. return(result); } }
public int DeleteActiveCountry(ActiveCountryItem newItem) { string queryString = "delete from " + tableActiveCountry + " where id=@id"; using (SQLiteConnection connection = new SQLiteConnection(strConnection)) using (SQLiteCommand dbCommand = new SQLiteCommand(queryString, connection)) { // Set command parameters. dbCommand.Parameters.AddWithValue("@id", newItem.Id); // Delete active country from table. connection.Open(); int result = dbCommand.ExecuteNonQuery(); // Notify changes. if (this.CountryModified != null) { this.CountryModified(this, null); } // Return the result. return(result); } }