コード例 #1
0
ファイル: Documents.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Add a new Document to the database (or possibly update an existing item)
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            DocumentsDAO lwDataAccess = new DocumentsDAO();

            if (DocumentID == 0)
            {
                DocumentID = lwDataAccess.DocumentAdd(this);
            }
            else
            {
                lwDataAccess.DocumentUpdate(this);
            }
            return(0);
        }
コード例 #2
0
ファイル: Documents.cs プロジェクト: windygu/AW-master
        public int Populate(SCOPE scope, int parentID)
        {
            // Ensure that the list is empty initially
            this.Clear();

            DocumentsDAO lwDataAccess = new DocumentsDAO();
            DataTable    table        = lwDataAccess.EnumerateDocuments(scope, parentID);

            // Iterate through the returned rows in the table and create AssetType objects for each
            foreach (DataRow row in table.Rows)
            {
                AddDocument(row);
            }
            return(this.Count);
        }
コード例 #3
0
ファイル: Documents.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete this Document from the database
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            // First remove the reference to the document from the database
            DocumentsDAO lwDataAccess = new DocumentsDAO();

            lwDataAccess.DocumentDelete(this);

            // ...then delete the file itself if it is located in the \documents folder
            string documentsFolder = System.IO.Path.Combine(Application.StartupPath, "Documents");

            if (Path.StartsWith(documentsFolder))
            {
                try
                {
                    File.Delete(Path);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Failed to delete document " + Path + " \nThe error was " + e.Message);
                }
            }

            return(0);
        }