Ejemplo n.º 1
0
        private void ParentHasChanged()
        {
            var x = cbxDocument.Text;

            if (string.IsNullOrEmpty(x))
            {
                return;
            }

            string[] doco = x.Split(';');
            parentDocument.UID = Convert.ToInt32(doco[0]);
            // parentDocument.Read();

            //parentDocument = RepDocument.Read(false, parentDocument.UID);

            // Using Business Layer
            var documentReadRequest = new DocumentReadRequest();

            documentReadRequest.UID  = parentDocument.UID;
            documentReadRequest.CUID = "";
            documentReadRequest.retrieveVoidedDocuments = false;

            var docreadresp = BUSDocument.DocumentRead(documentReadRequest);

            if (docreadresp.response.ReturnCode == 0001)
            {
                // all good
            }
            else
            {
                MessageBox.Show(docreadresp.response.Message);
                return;
            }

            parentDocument = docreadresp.document;
            //

            // Get document set
            if (string.IsNullOrEmpty(cbxDocumentSet.Text))
            {
                documentSetUID = 1;
            }
            else
            {
                var docSetUID = cbxDocumentSet.Text;

                string[] docoSet = docSetUID.Split(';');
                // The first is the client id, the second is the document set id
                //
                documentSetUID = Convert.ToInt32(docoSet[1]);
            }

            ClientDocumentLinkList list = ClientDocumentLinkList.ListRelatedDocuments(
                selectedClient.UID,
                documentSetUID,
                parentDocument.UID,
                cbxLinkType.Text);

            loadLinkedDocuments(parentDocument);
        }
Ejemplo n.º 2
0
        // ------------------------------------------
        //            List Documents
        // ------------------------------------------
        public void loadDocumentList()
        {
            // Image list
            //
            ImageList imageList = ControllerUtils.GetImageList();

            // Binding
            tvProjectPlanDoco.ImageList = imageList;

            // Clear nodes
            tvProjectPlanDoco.Nodes.Clear();

            var docoList = new DocumentList();

            docoList.List();

            // Load document in the treeview
            //
            //docoList.ListInTree(tvProjectPlanDoco);
            Document root = new Document();

            root.CUID       = "ROOT";
            root.RecordType = FCMConstant.RecordType.FOLDER;
            root.UID        = 0;
            // root.Read();

            // root = RepDocument.Read(false, 0, "ROOT");

            // Using Business Layer

            root = BUSDocument.GetRootDocument();

            DocumentList.ListInTree(tvProjectPlanDoco, docoList, root);
            tvProjectPlanDoco.ExpandAll();
        }
Ejemplo n.º 3
0
        public void loadDocumentList(int documentSetUID = 0)
        {
            // Image list
            //
            ImageList imageList = ControllerUtils.GetImageList();

            // Binding
            tvFileList.ImageList = imageList;

            // Clear nodes
            tvFileList.Nodes.Clear();

            var docoList = new DocumentList();

            docoList.ListDocSet(documentSetUID);

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

            root.CUID       = "ROOT";
            root.RecordType = FCMConstant.RecordType.FOLDER;
            root.UID        = 0;
            // root.Read();

            //root = RepDocument.Read(false, 0, "ROOT");
            root = BUSDocument.GetRootDocument();

            DocumentList.ListInTree(tvFileList, docoList, root);
            tvFileList.Nodes[0].Expand();
        }
Ejemplo n.º 4
0
        // ------------------------------------------
        //            List Documents
        // ------------------------------------------
        public void loadLinkedDocuments(Document document)
        {
            // Image list
            //
            ImageList imageList = ControllerUtils.GetImageList();

            // Binding
            tvLinkedDocuments.ImageList = imageList;

            // Clear nodes
            tvLinkedDocuments.Nodes.Clear();

            var docoList = ClientDocumentLinkList.ListRelatedDocuments(
                selectedClient.UID,
                documentSetUID,
                document.UID,
                cbxLinkType.Text);

            // Load document in the treeview
            //
            // docoList.ListInTree(tvLinkedDocuments);
            Document root = new Document();

            root.CUID       = document.CUID;
            root.RecordType = FCMConstant.RecordType.FOLDER;
            root.UID        = document.UID;
            // root.Read();

            // root = RepDocument.Read(false, document.UID);

            // Using Business Layer
            var documentReadRequest = new DocumentReadRequest();

            documentReadRequest.UID  = document.UID;
            documentReadRequest.CUID = "";
            documentReadRequest.retrieveVoidedDocuments = false;

            var docreadresp = BUSDocument.DocumentRead(documentReadRequest);

            if (docreadresp.response.ReturnCode == 0001)
            {
                // all good
            }
            else
            {
                MessageBox.Show(docreadresp.response.Message);
                return;
            }

            root = docreadresp.document;
            //



            ControllerUtils.ListInTree(tvLinkedDocuments, docoList, root);
            tvLinkedDocuments.ExpandAll();
        }
Ejemplo n.º 5
0
        // -----------------------------------------------------------
        //  Delete Document (Logical delete)
        // -----------------------------------------------------------
        private void deleteDocument(HeaderInfo headerInfo)
        {
            Document rm = new Document();

            // rm.SetToVoid(rm.UID);

            // RepDocument.SetToVoid(rm.UID);
            BUSDocument.SetToVoid(rm.UID);

            loadDocumentList(headerInfo);
        }
Ejemplo n.º 6
0
        // ---------------------------------------
        // Save sequence number and parent
        // ---------------------------------------
        private void SaveSequenceParent(HeaderInfo headerInfo, Document document)
        {
            // document.Save(headerInfo, FCMConstant.SaveType.UPDATE);

            //RepDocument.Save(headerInfo, document, FCMConstant.SaveType.UPDATE);

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument = document;
            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            document.UID = resp.document.UID;
        }
Ejemplo n.º 7
0
        // ------------------------------------------
        //            List Documents
        // ------------------------------------------
        public void loadDocumentList(HeaderInfo headerInfo)
        {
            // Image list
            //
            imageList16           = ControllerUtils.GetImageList();
            imageList16.ImageSize = new Size(16, 16);

            imageList32           = ControllerUtils.GetImageList();
            imageList32.ImageSize = new Size(32, 32);

            // Binding
            tvFileList.ImageList = imageList16;

            // Clear nodes
            tvFileList.Nodes.Clear();

            var docoList = new DocumentList();

            if (cbxType.Text == "FCM")
            {
                docoList.List();
            }
            else
            {
                docoList.ListClient(Utils.ClientID);
            }

            // Load document in the treeview
            //
            // docoList.ListInTree(tvFileList);
            Document root = new Document();

            // root.GetRoot(headerInfo);

            //root = RepDocument.GetRoot(HeaderInfo.Instance);

            root = BUSDocument.GetRootDocument();

            DocumentList.ListInTree(tvFileList, docoList, root);
            tvFileList.Nodes[0].Expand();

            GetValuesFromCache();

            tvFileList.Refresh();
        }
Ejemplo n.º 8
0
        // -------------------------------------------------------
        //  Load Event
        // -------------------------------------------------------
        private void UIClientDocumentLink_Load(object sender, EventArgs e)
        {
            // Get client list from background and load into the list
            // -------------------------------------------------------
            foreach (Client c in Utils.ClientList)
            {
                cbxClient.Items.Add(c.UID + "; " + c.Name);
            }

            // Get selected client from the background
            // -------------------------------------------------------
            // cbxClient.SelectedIndex = Utils.ClientIndex;

            // Load document in the treeview
            // -------------------------------------------------------
            Document root = new Document();

            root.CUID       = "ROOT";
            root.Name       = "FCM Documents";
            root.RecordType = FCMConstant.RecordType.FOLDER;
            root.UID        = 0;
            // root.Read();

            // root = RepDocument.Read(false, 0, "ROOT");

            // Using Business Layer

            root = BUSDocument.GetRootDocument();


            // Populate document list
            // -------------------------------------------------------
            PopulateDocumentCombo('N');

            // List Available Documents
            // -------------------------------------------------------
            loadDocumentList();

            // List Documents Linked to selected document
            // -------------------------------------------------------
            loadLinkedDocuments(parentDocument);
        }
Ejemplo n.º 9
0
        // ----------------------------------------------------------------------
        // List documents available for selection in list box tvListOfDocuments
        // ----------------------------------------------------------------------
        public void loadDocumentList()
        {
            // Image list
            //
            ImageList imageList = ControllerUtils.GetImageList();

            // Binding
            tvListOfDocuments.ImageList = imageList;

            // Clear nodes
            tvListOfDocuments.Nodes.Clear();

            var docoList = new ClientDocument();

            // docoList.List(Utils.ClientID, Utils.ClientSetID);

            var cdlr = new BUSClientDocument.ClientDocumentListRequest();

            cdlr.clientUID            = Utils.ClientID;
            cdlr.clientDocumentSetUID = Utils.ClientSetID;

            var response = BUSClientDocument.List(cdlr);

            // Load document in the treeview
            //
            // docoList.ListInTree(tvListOfDocuments);
            Document root = new Document();

            root.CUID       = "ROOT";
            root.RecordType = FCMConstant.RecordType.FOLDER;
            root.UID        = 0;
            // root.Read();

            // root = RepDocument.Read(false, 0, "ROOT");
            root = BUSDocument.GetRootDocument();

            // docoList.ListInTree(tvListOfDocuments, "CLIENT");

            BUSClientDocument.ListInTree(docoList, tvListOfDocuments, "CLIENT");

            tvListOfDocuments.ExpandAll();
        }
Ejemplo n.º 10
0
        private void fixDocumentLocation(TreeNode tn)
        {
            if (tn.Tag == null)
            {
                return;
            }

            Document document = (Document)tn.Tag;

            if (document.RecordType == "FOLDER")
            {
                foreach (TreeNode node in tn.Nodes)
                {
                    fixDocumentLocation(node);
                }
            }

            var drr = new DocumentReadRequest();

            drr.UID = document.UID;

            var docread = BUSDocument.DocumentRead(drr);

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument = docread.document;

            documentSaveRequest.inDocument.Name =
                UIHelper.ClientDocumentUIHelper.SetDocumentName(
                    documentSaveRequest.inDocument.SimpleFileName,
                    documentSaveRequest.inDocument.IssueNumber.ToString(),
                    documentSaveRequest.inDocument.CUID,
                    documentSaveRequest.inDocument.RecordType,
                    documentSaveRequest.inDocument.FileName);

            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            tn.Tag = resp.document;
        }
Ejemplo n.º 11
0
        private void btnFixLocation_Click(object sender, EventArgs e)
        {
            int documentUID = Convert.ToInt32(txtUID.Text);
            var drr         = new DocumentReadRequest();

            drr.UID = documentUID;

            var docread = BUSDocument.DocumentRead(drr);

            if (docread.document.RecordType == "FOLDER")
            {
                return;
            }

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument      = docread.document;
            documentSaveRequest.inDocument.Name =
                UIHelper.ClientDocumentUIHelper.SetDocumentName(
                    documentSaveRequest.inDocument.SimpleFileName,
                    documentSaveRequest.inDocument.IssueNumber.ToString(),
                    documentSaveRequest.inDocument.CUID,
                    documentSaveRequest.inDocument.RecordType,
                    documentSaveRequest.inDocument.FileName);
            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            txtLocation.Text = resp.document.Location;
            txtName.Text     = resp.document.Name;

            TreeNode tndocSelected = tvFileList.SelectedNode;

            if (tndocSelected != null)
            {
                if (tndocSelected.Tag.GetType().Name == "Document")
                {
                    tndocSelected.Tag = resp.document;
                }
            }
        }
Ejemplo n.º 12
0
        private void btnNewIssue_Click(object sender, EventArgs e)
        {
            Document document = new Document();

            document.UID            = Convert.ToInt32(txtUID.Text);
            document.CUID           = txtCUID.Text;
            document.Location       = txtLocation.Text;
            document.IssueNumber    = Convert.ToInt32(txtIssueNumber.Text);
            document.Name           = txtName.Text;
            document.SequenceNumber = Convert.ToInt32(txtSeqNum.Text);
            document.FileName       = txtFileName.Text;
            document.ParentUID      = Convert.ToInt32(txtParentUID.Text);

            // var response = document.NewVersion(HeaderInfo.Instance);

            // var response = RepDocument.NewVersion(HeaderInfo.Instance, document);

            //
            var documentNewVersionRequest = new DocumentNewVersionRequest();

            documentNewVersionRequest.headerInfo = HeaderInfo.Instance;
            documentNewVersionRequest.inDocument = document;
            var respNewVersion = BUSDocument.DocumentNewVersion(documentNewVersionRequest);

            if (respNewVersion.response.ReturnCode != 0001)
            {
                ControllerUtils.ShowFCMMessage(respNewVersion.response.UniqueCode, Utils.UserID);
                return;
            }

            var i = respNewVersion.response.Contents.ToString();

            MessageBox.Show("New issue #" + i + " created successfully.");

            txtFileName.Text    = document.FileName;
            txtName.Text        = document.Name;
            txtIssueNumber.Text = document.IssueNumber.ToString();
        }
Ejemplo n.º 13
0
        // ----------------------------------------------
        //  Removing an element from the tree
        // ----------------------------------------------
        private void btnDelete_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode tndocSelected = tvFileList.SelectedNode;
            TreeNode parent        = tndocSelected.Parent;

            tndocSelected.Remove();

            // Update database with new sequence numbers
            //
            UpdateSequence(parent);

            // Delete element
            Document document = new Document();

            document = (Document)tndocSelected.Tag;
            // document.SetToVoid(document.UID);

            // RepDocument.SetToVoid(document.UID);

            BUSDocument.SetToVoid(document.UID);

            tvFileList.SelectedNode = parent;
        }
Ejemplo n.º 14
0
        // -----------------------------------------------------
        //           Load documents in a tree
        // -----------------------------------------------------
        public static void ListInTree(
            TreeView fileList,
            ClientDocumentLinkList documentList,
            Document root)
        {
            // Find root folder
            //
            Document rootDocument = new Document();

            rootDocument.CUID       = root.CUID;
            rootDocument.RecordType = root.RecordType;
            rootDocument.UID        = root.UID;
            // rootDocument.Read();

            // rootDocument = RepDocument.Read(false, root.UID);

            // Using Business Layer
            var documentReadRequest = new DocumentReadRequest();

            documentReadRequest.UID  = root.UID;
            documentReadRequest.CUID = root.CUID;
            documentReadRequest.retrieveVoidedDocuments = false;

            var docreadresp = BUSDocument.DocumentRead(documentReadRequest);

            if (docreadresp.response.ReturnCode == 0001)
            {
                // all good
            }
            else
            {
                MessageBox.Show(docreadresp.response.Message);
                return;
            }

            rootDocument = docreadresp.document;
            //


            // Create root
            //
            var rootNode = new TreeNode(rootDocument.Name, FCMConstant.Image.Folder, FCMConstant.Image.Folder);

            // Add root node to tree
            //
            fileList.Nodes.Add(rootNode);
            rootNode.Tag  = rootDocument;
            rootNode.Name = rootDocument.Name;

            foreach (var document in documentList.clientDocumentLinkList)
            {
                // Ignore root folder
                if (document.childDocument.CUID == "ROOT")
                {
                    continue;
                }

                // Check if folder has a parent
                string cdocumentUID = document.UID.ToString();
                string cparentIUID  = document.childDocument.ParentUID.ToString();

                int image = 0;

                if (document.childDocument.RecordType != null)
                {
                    document.childDocument.RecordType = document.childDocument.RecordType.Trim();
                }

                image = Utils.ImageSelect(document.childDocument.RecordType);

                if (document.childDocument.ParentUID == 0)
                {
                    var treeNode = new TreeNode(document.childDocument.Name, image, image);
                    treeNode.Tag  = document;
                    treeNode.Name = cdocumentUID;

                    rootNode.Nodes.Add(treeNode);
                }
                else
                {
                    // Find the parent node
                    //
                    var node = fileList.Nodes.Find(cparentIUID, true);

                    if (node.Count() > 0)
                    {
                        var treeNode = new TreeNode(document.childDocument.Name, image, image);
                        treeNode.Tag  = document;
                        treeNode.Name = cdocumentUID;

                        node[0].Nodes.Add(treeNode);
                    }
                    else
                    {
                        // Add Element to the root
                        //
                        var treeNode = new TreeNode(document.childDocument.Name, image, image);
                        treeNode.Tag  = document;
                        treeNode.Name = cdocumentUID;

                        rootNode.Nodes.Add(treeNode);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Document docSave = new Document();

            if (string.IsNullOrEmpty(cbxSourceCode.Text))
            {
                MessageBox.Show("Source code must be set.");
                return;
            }

            if (string.IsNullOrEmpty(cbxDocumentType.Text))
            {
                MessageBox.Show("Document Type must be set.");
                return;
            }



            if (string.IsNullOrEmpty(txtUID.Text))
            {
                docSave.UID = 0;
            }
            else
            {
                docSave.UID = Convert.ToInt32(txtUID.Text);
            }

            if (checkProjectPlan.Checked)
            {
                docSave.IsProjectPlan = "N";
            }
            else
            {
                docSave.IsProjectPlan = "N";
            }

            docSave.CUID     = txtCUID.Text;
            docSave.Comments = txtComments.Text;
            docSave.Location = txtLocation.Text;
            docSave.Status   = "ACTIVE";

            if (string.IsNullOrEmpty(txtIssueNumber.Text))
            {
                docSave.IssueNumber = 0;
            }
            else
            {
                docSave.IssueNumber = Convert.ToInt32(txtIssueNumber.Text);
            }
            docSave.Name           = txtName.Text;
            docSave.DisplayName    = txtDisplayName.Text;
            docSave.RecordType     = cbxRecordType.Text;
            docSave.SimpleFileName = txtSimpleFileName.Text;

            if (cbxRecordType.Text == FCMConstant.RecordType.FOLDER)
            {
                cbxDocumentType.Text = MackkadoITFramework.Helper.Utils.DocumentType.FOLDER;
            }

            docSave.DocumentType = cbxDocumentType.Text;

            if (string.IsNullOrEmpty(cbxRecordType.Text))
            {
                MessageBox.Show("Record Type is mandatory.");
                return;
            }
            if (string.IsNullOrEmpty(cbxDocumentType.Text))
            {
                MessageBox.Show("Document Type is mandatory.");
                return;
            }


            // Parent UID is sourced from document tree
            //
            if (string.IsNullOrEmpty(txtParentUID.Text))
            {
                docSave.ParentUID = 0;
            }
            else
            {
                docSave.ParentUID = Convert.ToInt32(txtParentUID.Text);
            }

            if (string.IsNullOrEmpty(txtSeqNum.Text))
            {
                docSave.SequenceNumber = 0;
            }
            else
            {
                docSave.SequenceNumber = Convert.ToInt32(txtSeqNum.Text);
            }

            docSave.Comments = txtComments.Text;
            docSave.FileName = txtFileName.Text;

            docSave.FileExtension = MKITHelper.Utils.GetFileExtensionString(txtFileName.Text);

            docSave.SourceCode = cbxSourceCode.Text;

            if (string.IsNullOrEmpty(txtClientUID.Text))
            {
                docSave.FKClientUID = 0;
            }
            else
            {
                docSave.FKClientUID = Convert.ToInt32(txtClientUID.Text);
            }

            if (docSave.SourceCode == "CLIENT" && docSave.FKClientUID == 0)
            {
                MessageBox.Show("Client ID is mandatory if source type is CLIENT");
                return;
            }

            // docSave.Save(HeaderInfo.Instance, FCMConstant.SaveType.UPDATE);

            // RepDocument.Save(HeaderInfo.Instance, docSave, FCMConstant.SaveType.UPDATE);

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument = docSave;
            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            docSave.UID = resp.document.UID;

            if (uidl != null)
            {
                uidl.Refresh();
            }

            txtLocation.Text = resp.document.Location;


            MessageBox.Show(resp.response.Message);

            txtCUID.Enabled  = false;
            txtCUID.ReadOnly = true;
            //txtDirectory.Focus();

            documentSavedSuccessfully = true;

            if (treeNode == null)
            {
                // There is no need to set the treenode unless it is passed in.
            }
            else
            {
                treeNode.Tag  = docSave;
                treeNode.Name = docSave.FileName;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Delete document selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteDocument_Click(object sender, EventArgs e)
        {
            var resp =
                MessageBox.Show("Are you sure?", "Delete Document", MessageBoxButtons.YesNo);

            if (resp != DialogResult.Yes)
            {
                return;
            }

            //
            // Get selected document from tree
            //
            TreeNode docSelected = tvFileList.SelectedNode;

            if (docSelected == null)
            {
                return;
            }

            if (docSelected.Tag.GetType().Name == "scClientDocSetDocLink")
            {
                var rm = new scClientDocSetDocLink();
                rm = (scClientDocSetDocLink)docSelected.Tag; // Cast

                try
                {
                    // rm.document.Delete( rm.document.UID );

                    // RepDocument.Delete(rm.document.UID);
                    BUSDocument.DeleteDocument(rm.document.UID);
                }
                catch
                {
                    // Using Logical Deletion
                    // rm.document.SetToVoid( rm.document.UID );

                    // RepDocument.SetToVoid(rm.document.UID);
                    BUSDocument.SetToVoid(rm.document.UID);
                }
            }

            if (docSelected.Tag.GetType().Name == "Document")
            {
                var rm = new Document();
                rm = (Document)docSelected.Tag; // Cast

                try
                {
                    // rm.Delete( rm.UID );

                    // RepDocument.Delete(rm.UID);
                    BUSDocument.DeleteDocument(rm.UID);
                }
                catch
                {
                    // rm.SetToVoid( rm.UID );
                    // RepDocument.SetToVoid(rm.UID);
                    BUSDocument.SetToVoid(rm.UID);
                }
            }

            // Physically delete items

            // Remove item
            docSelected.Remove();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Add FCM document to Client Set
        /// </summary>
        /// <param name="headerInfo"></param>
        /// <param name="clientUID"></param>
        /// <param name="clientDocumentSetUID"></param>
        /// <param name="documentUID"></param>
        /// <returns></returns>
        public static ResponseStatus AddDocumentToSet(HeaderInfo headerInfo, int clientUID, int clientDocumentSetUID, int documentUID)
        {
            string sourceFolder      = "";
            string destinationFolder = "";


            if (clientUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client UID was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0001
                }
            }
            ;

            if (clientDocumentSetUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client Document Set UID  was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0002
                }
            }
            ;

            if (documentUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Document UID  was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0003
                }
            }
            ;

            // Find Document
            //
            DocumentReadRequest documentReadRequest = new DocumentReadRequest();

            documentReadRequest.headerInfo = headerInfo;
            documentReadRequest.retrieveVoidedDocuments = false;
            documentReadRequest.UID = documentUID;

            var documentReadResponse = BUSDocument.DocumentRead(documentReadRequest);
            var documentSelected     = new Document();

            documentSelected = documentReadResponse.document;

            // Find parent of the document
            //
            var folderReadRequestParent = new DocumentReadRequest();

            folderReadRequestParent.headerInfo = headerInfo;
            folderReadRequestParent.retrieveVoidedDocuments = false;
            folderReadRequestParent.UID = documentSelected.ParentUID; // Reading parent

            var folderParentResponse = BUSDocument.DocumentRead(folderReadRequestParent);
            var folderParent         = new Document();

            folderParent = folderParentResponse.document;

            // Find the equivalent parent in ClientDocumentSetDocument
            //
            var foundParent = RepClientDocument.Find(folderParent.UID, clientDocumentSetUID, 'N', clientUID);

            if (foundParent.UID <= 0)
            {
                return new ResponseStatus {
                           Message = "Parent folder not found.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0006
                }
            }
            ;

            // Find ClientDocumentSet
            //
            var clientDocumentSet = new ClientDocumentSet();

            clientDocumentSet.UID         = clientDocumentSetUID;
            clientDocumentSet.FKClientUID = clientUID;
            clientDocumentSet.Read();

            if (clientDocumentSet.UID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client Document Set not found.", XMessageType = MessageType.Error, ReturnCode = -0030, ReasonCode = 0004
                }
            }
            ;

            // Create link
            //
            var documentLink = new scClientDocSetDocLink();

            if (documentSelected.RecordType == "DOCUMENT")
            #region Document
            {
                documentLink.document = new Document();

                documentLink.document = documentSelected;

                documentLink.clientDocument    = new ClientDocument();
                documentLink.clientDocumentSet = new ClientDocumentSet();

                // Fill in the extra details...
                //

                documentLink.clientDocument.EndDate = System.DateTime.MaxValue;
                documentLink.clientDocument.FKClientDocumentSetUID = clientDocumentSet.UID;
                documentLink.clientDocument.FKClientUID            = clientDocumentSet.FKClientUID;
                documentLink.clientDocument.FKDocumentUID          = documentLink.document.UID;
                documentLink.clientDocument.Generated         = 'N';
                documentLink.clientDocument.SourceIssueNumber = documentLink.document.IssueNumber;
                documentLink.clientDocument.ClientIssueNumber = 00;

                if (documentLink.document.RecordType == FCMConstant.RecordType.FOLDER)
                {
                    documentLink.clientDocument.ComboIssueNumber = documentLink.document.CUID;
                    documentLink.clientDocument.FileName         = documentLink.document.SimpleFileName;
                }
                else
                {
                    documentLink.clientDocument.ComboIssueNumber =
                        BUSClientDocument.GetComboIssueNumber(documentLink.document.CUID,
                                                              documentLink.document.IssueNumber,
                                                              clientDocumentSet.FKClientUID);


                    documentLink.clientDocument.FileName = documentLink.clientDocument.ComboIssueNumber + " " +
                                                           documentLink.document.SimpleFileName;
                }
                documentLink.clientDocument.IsProjectPlan = documentLink.document.IsProjectPlan;
                documentLink.clientDocument.DocumentCUID  = documentLink.document.CUID;
                documentLink.clientDocument.DocumentType  = documentLink.document.DocumentType;
                // The client document location includes the client path (%CLIENTFOLDER%) plus the client document set id
                // %CLIENTFOLDER%\CLIENTSET201000001R0001\


                // How to identify the parent folder
                //
                documentLink.clientDocument.ParentUID = foundParent.UID;

                // Daniel
                // 01-Jul-2013
                // Retrieving the clientdocument parent using the UID for the parent clientdocument
                //
//                documentLink.clientDocument.Location = BUSClientDocument.GetClientDocumentLocation(folderReadRequestParent.UID);
                documentLink.clientDocument.Location = BUSClientDocument.GetClientDocumentLocation(foundParent.UID);

                documentLink.clientDocument.RecordType     = documentLink.document.RecordType;
                documentLink.clientDocument.SequenceNumber = 1;
                documentLink.clientDocument.SourceFileName = documentLink.document.FileName;
                documentLink.clientDocument.SourceLocation = documentLink.document.Location;

                documentLink.clientDocument.StartDate = System.DateTime.Today;
                documentLink.clientDocument.UID       = 0;

                documentLink.clientDocumentSet.UID          = clientDocumentSetUID;
                documentLink.clientDocumentSet.SourceFolder = sourceFolder;
                documentLink.clientDocumentSet.ClientSetID  = clientDocumentSet.UID;
                documentLink.clientDocumentSet.FKClientUID  = clientDocumentSet.FKClientUID;
                documentLink.clientDocumentSet.Folder       = destinationFolder;
            }
            #endregion Document

            // Save link to database
            //
            // documentLink.clientDocument.UID = cdsl.LinkDocumentToClientSet(documentLink);

            documentLink.clientDocument.UID = LinkDocumentToClientSet(documentLink);

            return(new ResponseStatus());
        }