Exemple #1
0
        // -----------------------------------------------------
        //          Delete Link
        // -----------------------------------------------------
        public static void Delete(int DocumentSetUID, int DocumentUID)
        {
            // Links have to be deleted first
            //

            DocumentSetDocument dsd = new DocumentSetDocument();

            dsd.Find(documentUID: DocumentUID, docSetUID: DocumentSetUID, voidRead: 'N');

            if (dsd.UID <= 0)
            {
                return;
            }

            DocumentSetDocumentLink.DeleteAllRelated(dsd.UID);

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString =
                    (
                        "DELETE FROM [DocumentSetDocument] " +
                        " WHERE [FKDocumentUID] = @FKDocumentUID " +
                        "   AND [FKDocumentSetUID] = @FKDocumentSetUID "
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    command.Parameters.Add("@FKDocumentUID", SqlDbType.BigInt).Value    = DocumentUID;
                    command.Parameters.Add("@FKDocumentSetUID", SqlDbType.BigInt).Value = DocumentSetUID;
                    command.Parameters.Add("@IsVoid", SqlDbType.Char).Value             = 'Y';

                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            return;
        }