예제 #1
0
        // Remove document from selected list
        //
        private void RemoveDocument()
        {
            TreeNode tn = new TreeNode();

            tn = tvLinkedDocuments.SelectedNode;

            var nodeType = tn.Tag.GetType().Name;

            if (nodeType == "Document")
            {
                Document doc = new Document();
                doc = (Document)tn.Tag;

                ClientDocumentLink dl = new ClientDocumentLink();

                // Logically delete the record if the record is commited.
                if (dl.Read(ParentID: parentDocument.UID,
                            ChildID: doc.UID,
                            LinkType: cbxLinkType.Text,
                            clientUID: Utils.ClientID,
                            clientDocumentSetUID: Utils.ClientSetID))
                {
                    dl.Delete(dl.UID);
                }

                tn.Remove();
            }

            if (nodeType == "ClientDocumentLink")
            {
                ClientDocumentLink clientDocLink = new ClientDocumentLink();
                clientDocLink = (ClientDocumentLink)tn.Tag;

                ClientDocumentLink dl = new ClientDocumentLink();

                // Logically delete the record if the record is commited.
                if (dl.Read(parentDocument.UID,
                            clientDocLink.FKChildDocumentUID,
                            cbxLinkType.Text,
                            Utils.ClientID,
                            Utils.ClientSetID))
                {
                    dl.Delete(dl.UID);
                }

                tn.Remove();
            }
        }
예제 #2
0
        // ---------------------------------------------------------------------------------
        //                      Save
        // ---------------------------------------------------------------------------------
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (parentDocument.UID <= 0)
            {
                MessageBox.Show("Main document is not selected.");
                return;
            }

            foreach (TreeNode tn in tvLinkedDocuments.Nodes[0].Nodes)
            {
                var nodeType = tn.Tag.GetType().Name;
                if (nodeType == "scClientDocSetDocLink")
                {
                    var doc = new scClientDocSetDocLink();
                    doc = (scClientDocSetDocLink)tn.Tag;

                    // Add parentClientDocument and childClientDocument... Daniel 17/08/2010
                    //
                    ClientDocumentLink.LinkDocuments(
                        clientUID: selectedClient.UID,
                        clientDocumentSetUID: selectedClientDocumentSet.UID,
                        parentDocumentUID: parentDocument.UID,
                        childDocumentUID: doc.document.UID,
                        LinkType: cbxLinkType.Text);
                }

                if (nodeType == "Document")
                {
                    Document doc = new Document();
                    doc = (Document)tn.Tag;

                    ClientDocumentLink.LinkDocuments(
                        clientUID: selectedClient.UID,
                        clientDocumentSetUID:  selectedClientDocumentSet.UID,
                        parentDocumentUID: parentDocument.UID,
                        childDocumentUID: doc.UID,
                        LinkType: cbxLinkType.Text);
                }
            }
            MessageBox.Show("Saved successfully.");
        }
예제 #3
0
        /// <summary>
        /// Associate documents from selected document set to selected client
        /// </summary>
        /// <param name="clientUID"></param>
        /// <param name="clientDocumentSetUID"></param>
        /// <param name="documentSetUID"></param>
        public static void AssociateDocumentsToClient(
            ClientDocumentSet clientDocumentSet,
            int documentSetUID,
            HeaderInfo headerInfo)
        {
            // It is a new client document set
            // It maybe a new client, the client document set MUST be new or empty
            // 1) Instantiate a TREE for the Client Document Set document
            // 2) Instantiate a second tree for the documents related to that document set
            // 3) Now the old copy all starts, all the nodes from the second tree are moved to the new tree
            //    following current process
            // 4) Save happens as per usual
            //

            TreeView tvFileList           = new TreeView();               // This is the list of documents for a client, it should be EMPTY
            TreeView tvDocumentsAvailable = new TreeView();               // This is the list of documents for a client, it should be EMPTY
            string   folderOnly           = clientDocumentSet.FolderOnly; // Contains the folder location of the file

            // Add root folder
            //
            ClientDocument clientDocument = new ClientDocument();

            clientDocument.AddRootFolder(clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID, clientDocumentSet.FolderOnly);

            // List client document list !!!!!!! Important because the ROOT folder is loaded ;-)

            var documentSetList = new ClientDocument();

            documentSetList.List(clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID);

            tvFileList.Nodes.Clear();
            documentSetList.ListInTree(tvFileList, "CLIENT");
            if (tvFileList.Nodes.Count > 0)
            {
                tvFileList.Nodes[0].Expand();
            }

            // Load available documents
            //
            tvDocumentsAvailable.Nodes.Clear();

            // Get document list for a given document set
            //
            DocumentSet documentSet = new DocumentSet();

            documentSet.UID = documentSetUID;
            documentSet.Read(IncludeDocuments: 'Y');

            // Load document in the treeview
            //
            Document.Document root = new Document.Document();
            root.GetRoot(headerInfo);

            DocumentList.ListInTree(tvDocumentsAvailable, documentSet.documentList, root);

            while (tvDocumentsAvailable.Nodes[0].Nodes.Count > 0)
            {
                TreeNode tn = tvDocumentsAvailable.Nodes[0].Nodes[0];
                tn.Remove();

                tvFileList.Nodes[0].Nodes.Add(tn);
            }

            tvFileList.SelectedNode = tvFileList.Nodes[0];

            // -------------------------------------------------------------------
            // The documents have been moved from the available to client's tree
            // Now it is time to save the documents
            // -------------------------------------------------------------------
            Save(clientDocumentSet, documentSetUID, tvFileList);

            ClientDocumentLink cloneLinks = new ClientDocumentLink();

            cloneLinks.ReplicateDocSetDocLinkToClient(clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID, documentSetUID);
        }