// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.          
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $     $Revision: $                                           
// $Author: $   $Date: $                                                   
//                                                                         
// $History: $                                                             
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
    /// 
    ///	RevisionVersion Generated by MyGeneration using the CSLA Object Mapping template
    /// 
    [Serializable()]
    [TypeConverter(typeof(RevisionVersionConverter))]
    public partial class RevisionVersion : BusinessBase, IVEHasBrokenRules, IDisposable
    {
        #region Log4Net
        private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        #endregion
        #region Business Methods
        private string _ErrorMessage = string.Empty;
        public string ErrorMessage
        {
            get { return _ErrorMessage; }
        }
        private int _VersionID;
        [System.ComponentModel.DataObjectField(true, true)]
        public int VersionID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyVersion != null) _VersionID = _MyVersion.VersionID;
                return _VersionID;
            }
        }
        private Version _MyVersion;
        [System.ComponentModel.DataObjectField(true, true)]
        public Version MyVersion
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyVersion == null && _VersionID != 0) _MyVersion = Version.Get(_VersionID);
                return _MyVersion;
            }
        }
        private int _StageID;
        public int StageID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyStage != null) _StageID = _MyStage.StageID;
                return _StageID;
            }
        }
        private Stage _MyStage;
        public Stage MyStage
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyStage == null && _StageID != 0) _MyStage = Stage.GetJustStage(_StageID);
                return _MyStage;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_MyStage != value)
                {
                    _MyStage = value;
                    _StageID = value.StageID;// Update underlying data field
                    PropertyHasChanged();
                }
            }
        }
        private byte[] _PDF;
        public byte[] PDF
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _PDF;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_PDF != value)
                {
                    _PDF = value;
                    PropertyHasChanged();
                }
            }
        }
        private byte[] _SummaryPDF;
        public byte[] SummaryPDF
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _SummaryPDF;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_SummaryPDF != value)
                {
                    _SummaryPDF = value;
                    PropertyHasChanged();
                }
            }
        }
        private string _ApprovedXML;
        public string ApprovedXML
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _ApprovedXML;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_ApprovedXML != value)
                {
                    _ApprovedXML = value;
                    PropertyHasChanged();
                }
            }
        }
        private DateTime _DTS = new DateTime();
        public DateTime DTS
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _DTS;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_DTS != value)
                {
                    _DTS = value;
                    PropertyHasChanged();
                }
            }
        }
        private string _UserID = string.Empty;
        public string UserID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _UserID;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (value == null) value = string.Empty;
                if (_UserID != value)
                {
                    _UserID = value;
                    PropertyHasChanged();
                }
            }
        }
        private byte[] _LastChanged = new byte[8];//timestamp
        private string _Stage_Name = string.Empty;
        public string Stage_Name
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Stage_Name;
            }
        }
        private string _Stage_Description = string.Empty;
        public string Stage_Description
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Stage_Description;
            }
        }
        private int _Stage_IsApproved;
        public int Stage_IsApproved
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Stage_IsApproved;
            }
        }
        private DateTime _Stage_DTS = new DateTime();
        public DateTime Stage_DTS
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Stage_DTS;
            }
        }
        private string _Stage_UserID = string.Empty;
        public string Stage_UserID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Stage_UserID;
            }
        }
        // CSLATODO: Check RevisionVersion.GetIdValue to assure that the ID returned is unique
        /// 
        /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
        /// 
        /// A Unique ID for the current RevisionVersion
        protected override object GetIdValue()
        {
            return MyRevisionVersionUnique; // Absolutely Unique ID
        }
        // CSLATODO: Replace base RevisionVersion.ToString function as necessary
        /// 
        /// Overrides Base ToString
        /// 
        /// A string representation of current RevisionVersion
        //public override string ToString()
        //{
        //  return base.ToString();
        //}
        public override bool IsDirty
        {
            get
            {
                if (base.IsDirty)
                    return true;
                return IsDirtyList(new List