public IEnumerable <Product> GetProducts() { try { Db.OpenConnection(); using (SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM Product", Db.Connection)) { using (SQLiteDataReader reader = cmd.ExecuteReader()) { List <Product> products = new List <Product>(); while (reader.Read()) { Product product = new Product(); product.Id = reader["Id"].ToString(); product.Description = reader["Description"].ToString(); product.Price = Decimal.Parse(reader["Price"].ToString()); products.Add(product); } return(products); } } } catch (Exception ex) { //this.Logger.log(ex); throw; } finally { Db.CloseConnection(); } }
public IEnumerable <Purchase> Purchases() { try { Db.OpenConnection(); using (SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM Purchase", Db.Connection)) { using (SQLiteDataReader reader = cmd.ExecuteReader()) { List <Purchase> purshases = new List <Purchase>(); while (reader.Read()) { int id = Int32.Parse(reader["Id"].ToString()); string date = reader["Date"].ToString(); string content = reader["Content"].ToString(); purshases.Add(new Purchase { Id = id, Date = DateTime.Parse(date), Content = content }); } return(purshases); } } } catch (Exception ex) { //this.Logger.log(ex); throw; } finally { Db.CloseConnection(); } }
private void QuitOnClick() { //UnityEditor.EditorApplication.isPlaying = false; // quit editor SQLiteDatabase.CloseConnection(); // close database connection Application.Quit(); // quit app }