Пример #1
0
        // -----------------------------------------------------
        //    List Documents
        // -----------------------------------------------------
        private void List(string Condition)
        {
            this.documentList = new List <Document>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    Document.SQLDocumentConcat("DOC") +
                    "   FROM     [Document] DOC " +
                    "  WHERE DOC.[SourceCode] = 'FCM' " +
                    "    AND DOC.[IsVoid] = 'N' " +
                    Condition +
                    "  ORDER BY PARENTUID ASC, SequenceNumber ASC "
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Document _Document = new Document();
                            Document.LoadDocumentFromReader(_Document, "DOC", reader);
                            this.documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Пример #2
0
        // -----------------------------------------------------
        //    List Documents for a client
        // -----------------------------------------------------
        public void ListClient(int clientUID)
        {
            this.documentList = new List <Document>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    Document.SQLDocumentConcat("DOC") +
                    "   FROM [Document] DOC " +
                    "  WHERE [SourceCode] = 'CLIENT' " +
                    "    AND [FKClientUID] = {0} " +
                    "    AND [IsVoid] <> 'Y' " +
                    "  ORDER BY PARENTUID ASC, SequenceNumber ASC ",
                    clientUID);

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Document _Document = new Document();
                            Document.LoadDocumentFromReader(_Document, "DOC", reader);

                            this.documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Пример #3
0
        // -----------------------------------------------------
        //        List Documents for a Document Set
        // -----------------------------------------------------
        public void ListDocSet(int documentSetUID)
        {
            this.documentList = new List <Document>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    "  SELECT " +
                    Document.SQLDocumentConcat("DOC") +
                    " ,[LNK].[FKParentDocumentUID] " +
                    " ,[LNK].[FKParentDocumentSetUID] " +
                    " ,[LNK].[SequenceNumber] " +
                    "   FROM [Document] DOC " +
                    "       ,[DocumentSetDocument] LNK" +
                    "  WHERE " +
                    "        [LNK].[FKDocumentUID] = [DOC].[UID] " +
                    "    AND [DOC].[SourceCode] = 'FCM' " +
                    "    AND [LNK].[IsVoid]     = 'N' " +
                    "    AND [DOC].[IsVoid]     = 'N' " +
                    "    AND [LNK].[FKDocumentSetUID] = {0}  " +
                    "  ORDER BY [LNK].FKParentDocumentUID ASC, [LNK].SequenceNumber ",
                    documentSetUID
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Document _Document = new Document();
                            Document.LoadDocumentFromReader(_Document, "DOC", reader);

                            // This is necessary because when the list comes from DocumentSet, the parent may change
                            //
                            _Document.ParentUID = Convert.ToInt32(reader["FKParentDocumentUID"].ToString());

                            this.documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Пример #4
0
        // -----------------------------------------------------
        //    Get Document Details
        // -----------------------------------------------------
        public static scDocoSetDocumentLink FindDocumentInSet(int documentSetUID, int documentUID)
        {
            //
            // EA SQL database
            //
            scDocoSetDocumentLink ret = new scDocoSetDocumentLink();

            ret.document            = new Document();
            ret.documentSet         = new DocumentSet();
            ret.DocumentSetDocument = new DocumentSetDocument();

            string commandString = "";

            commandString = string.Format(
                " SELECT " +
                "       [Document].[UID] DocumentUID" +
                "      ,[Document].[CUID] DocumentCUID " +
                "      ,[Document].[Name] DocumentName " +
                "      ,[Document].[SequenceNumber] DocumentSequenceNumber " +
                "      ,[Document].[IssueNumber] DocumentIssueNumber " +
                "      ,[Document].[Location] DocumentLocation " +
                "      ,[Document].[Comments] DocumentComments" +
                "      ,[Document].[UID] DocumentUID" +
                "      ,[Document].[FileName] DocumentFileName" +
                "      ,[Document].[SourceCode] DocumentSourceCode" +
                "      ,[Document].[FKClientUID] DocumentFKClientUID" +
                "      ,[Document].[ParentUID] DocumentParentUID" +
                "      ,[Document].[RecordType] DocumentRecordType" +
                "      ,[Document].[IsProjectPlan] DocumentIsProjectPlan" +
                "      ,[Document].[DocumentType] DocumentDocumentType" +
                "      ,[DocSetDoc].[UID] DocSetDocUID" +
                "      ,[DocSetDoc].[FKDocumentUID] DocSetDocFKDocumentUID" +
                "      ,[DocSetDoc].[FKDocumentSetUID] DocSetDocFKDocumentSetUID" +
                "      ,[DocSetDoc].[Location] DocSetDocLocation" +
                "      ,[DocSetDoc].[IsVoid] DocSetDocIsVoid" +
                "      ,[DocSetDoc].[StartDate] DocSetDocStartDate" +
                "      ,[DocSetDoc].[EndDate] DocSetDocEndDate" +
                "      ,[DocSetDoc].[FKParentDocumentUID] DocSetDocFKParentDocumentUID" +
                "      ,[DocSetDoc].[FKParentDocumentSetUID] DocSetDocFKParentDocumentSetUID" +
                "      ,[DocSet].[UID] SetUID" +
                "      ,[DocSet].[TemplateType] SetTemplateType" +
                "      ,[DocSet].[TemplateFolder] SetTemplateFolder" +
                "  FROM  [Document] Document" +
                "       ,[DocumentSetDocument] DocSetDoc " +
                "       ,[DocumentSet] DocSet " +
                " WHERE " +
                "        [Document].[UID] = [DocSetDoc].[FKDocumentUID] " +
                "    AND [DocSetDoc].[FKDocumentSetUID] = [DocSet].[UID] " +
                "    AND [Document].[UID] = {0} " +
                "    AND [DocSetDoc].[FKDocumentSetUID] = {1}",
                documentUID,
                documentSetUID);

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        try
                        {
                            // Document
                            //
                            Document.LoadDocumentFromReader(ret.document, "", reader);
                            //ret.document.UID = Convert.ToInt32(reader["DocumentUID"].ToString());
                            //ret.document.CUID = reader["DocumentCUID"].ToString();
                            //ret.document.Name = reader["DocumentName"].ToString();
                            //ret.document.SequenceNumber = Convert.ToInt32(reader["DocumentSequenceNumber"].ToString());
                            //ret.document.IssueNumber = Convert.ToInt32(reader["DocumentIssueNumber"].ToString());
                            //ret.document.Location = reader["DocumentLocation"].ToString();
                            //ret.document.Comments = reader["DocumentComments"].ToString();
                            //ret.document.FileName = reader["DocumentFileName"].ToString();
                            //ret.document.SourceCode = reader["DocumentSourceCode"].ToString();
                            //ret.document.FKClientUID = Convert.ToInt32(reader["DocumentFKClientUID"].ToString());
                            //ret.document.ParentUID = Convert.ToInt32(reader["DocumentParentUID"].ToString());
                            //ret.document.RecordType = reader["DocumentRecordType"].ToString();
                            //ret.document.IsProjectPlan = Convert.ToChar(reader["DocumentIsProjectPlan"]);
                            //ret.document.DocumentType = reader["DocumentDocumentType"].ToString();

                            // Document Set
                            //
                            ret.documentSet.UID            = Convert.ToInt32(reader["SetUID"].ToString());
                            ret.documentSet.TemplateType   = reader["SetTemplateType"].ToString();
                            ret.documentSet.TemplateFolder = reader["SetTemplateFolder"].ToString();
                            ret.documentSet.UIDNameDisplay = ret.documentSet.UID.ToString() +
                                                             "; " + ret.documentSet.TemplateType;

                            // DocumentSetDocument
                            //
                            ret.DocumentSetDocument.UID                    = Convert.ToInt32(reader["DocSetDocUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentUID          = Convert.ToInt32(reader["DocSetDocFKDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentSetUID       = Convert.ToInt32(reader["DocSetDocFKDocumentSetUID"].ToString());
                            ret.DocumentSetDocument.Location               = reader["DocSetDocLocation"].ToString();
                            ret.DocumentSetDocument.IsVoid                 = Convert.ToChar(reader["DocSetDocIsVoid"].ToString());
                            ret.DocumentSetDocument.StartDate              = Convert.ToDateTime(reader["DocSetDocStartDate"].ToString());
                            ret.DocumentSetDocument.EndDate                = Convert.ToDateTime(reader["DocSetDocEndDate"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentUID    = Convert.ToInt32(reader["DocSetDocFKParentDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentSetUID = Convert.ToInt32(reader["DocSetDocFKParentDocumentSetUID"].ToString());
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return(ret);
        }