Example #1
0
 public void Insert(SQLiteDatabase db)
 {
     if (Id != 0)
     {
         throw new Exception("Already inserted");
     }
     String sql = "INSERT INTO ProjectUser (ProjectID, Login, Notified) VALUES ('" + ProjectId + "', '" + Login + "', 0); SELECT last_insert_rowid()";
     Id = Int16.Parse(db.ExecuteScalar(sql));
 }
Example #2
0
        /// <summary>
        /// Stores the Project into database. Returns true if the project is new.
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool Store(SQLiteDatabase db)
        {
            // make the texts safe
            String t = Title.Replace("'", "''");
            String m = Message.Replace("'", "''");
            String a = Attachment == null ? "" : Attachment.Replace("'", "''");

            if (id == 0)
            {
                // insert
                String sql = "INSERT INTO Project (Title, Message, Attachment) VALUES ('" + t + "', '" + m + "', '" + a + "'); SELECT last_insert_rowid()";
                Id = Int16.Parse(db.ExecuteScalar(sql));
                return true;
            }
            else
            {
                // update
                String sql = "UPDATE Project SET Title='" + t + "', Message='" + m + "', Attachment='" + a + "' WHERE ID=" + Id;
                db.ExecuteNonQuery(sql);
                return false;
            }
        }