Exemple #1
0
        public List <Operation> SelectOpList(TestSQLiteDB databaseObject)
        {
            List <Operation> opList    = new List <Operation>();
            string           query     = "SELECT * FROM Operations";
            SQLiteCommand    myCommand = new SQLiteCommand(query, databaseObject.myConnection);

            databaseObject.OpenConnection();
            using (SQLiteDataReader queryResult = myCommand.ExecuteReader())
            {
                if (queryResult.HasRows)
                {
                    while (queryResult.Read())
                    {
                        Operation opNew = new Operation
                        {
                            Id           = int.Parse(queryResult["ID"].ToString()),
                            Firstnumber  = int.Parse(queryResult["FIRSTNUMBER"].ToString()),
                            Op           = queryResult["OP"].ToString(),
                            Secondnumber = Convert.ToInt32(queryResult["SECONDNUMBER"]),
                            Result       = Convert.ToInt32(queryResult["RESULT"]),
                            Timestamp    = queryResult["TIMESTAMP"].ToString()
                        };
                        opList.Add(opNew);
                    }
                }
            }

            databaseObject.CloseConnection();
            return(opList);
        }
Exemple #2
0
        public void DeleteAllOp(TestSQLiteDB databaseObject)
        {
            string        query     = "DELETE FROM Operations";
            SQLiteCommand myCommand = new SQLiteCommand(query, databaseObject.myConnection);

            databaseObject.OpenConnection();
            myCommand.ExecuteNonQuery();
            databaseObject.CloseConnection();
        }
Exemple #3
0
        public void InsertNewOp(TestSQLiteDB databaseObject, Operation operation)
        {
            string        query     = "INSERT INTO Operations('ID', 'FIRSTNUMBER', 'OP', 'SECONDNUMBER', 'RESULT', 'TIMESTAMP') VALUES(@ID, @FIRSTNUMBER, @OP, @SECONDNUMBER, @RESULT, @TIMESTAMP)";
            SQLiteCommand myCommand = new SQLiteCommand(query, databaseObject.myConnection);

            databaseObject.OpenConnection();
            myCommand.Parameters.AddWithValue("ID", operation.Id);
            myCommand.Parameters.AddWithValue("FIRSTNUMBER", operation.Firstnumber);
            myCommand.Parameters.AddWithValue("OP", operation.Op);
            myCommand.Parameters.AddWithValue("SECONDNUMBER", operation.Secondnumber);
            myCommand.Parameters.AddWithValue("RESULT", operation.Result);
            myCommand.Parameters.AddWithValue("TIMESTAMP", operation.Timestamp);
            myCommand.ExecuteNonQuery();
            databaseObject.CloseConnection();
        }