コード例 #1
0
        /// <summary>
        /// Loads all comments into the list.
        /// </summary>
        private void LoadComments()
        {
            Database db = new Database();
            try
            {
                comments = new List<RemoteFileComment>();
                db.CreateCommand("SELECT * FROM files_comments WHERE files_id = :id");
                db.AddParameter("id", Id);
                db.OpenConnection();
                db.ExecuteCommand();
                OracleDataReader dr = db.DataReader;

                while (dr.Read())
                {
                    User user = ftp_db_poc.User.GetById(dr.GetValueByColumn<int>("users_id"));
                    DateTime dateTime = dr.GetValueByColumn<DateTime>("created");
                    string text = dr.GetValueByColumn<string>("text");
                    RemoteFileComment comment = new RemoteFileComment(dr.GetValueByColumn<int>("id"), text, user, dateTime);
                    comments.Add(comment);
                }
            }
            finally
            {
                db.CloseConnection();
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes the comment from the database and from the list.
        /// </summary>
        /// <param name="comment"></param>
        public void RemoveComment(RemoteFileComment comment)
        {
            Database db = new Database();
            try
            {
                db.CreateCommand("DELETE files_comments WHERE id = :id");
                db.AddParameter("id", comment.Id);
                db.OpenConnection();
                db.ExecuteCommand();

                comments.Remove(comment);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.CloseConnection();
            }
        }