// ========================================================================
// 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
{
    /// 
    ///	ItemAnnotation Generated by MyGeneration using the CSLA Object Mapping template
    /// 
    [Serializable()]
    [TypeConverter(typeof(ItemAnnotationConverter))]
    public partial class ItemAnnotation : 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 _AnnotationID;
        [System.ComponentModel.DataObjectField(true, true)]
        public int AnnotationID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
                return _AnnotationID;
            }
        }
        private Annotation _MyAnnotation;
        [System.ComponentModel.DataObjectField(true, true)]
        public Annotation MyAnnotation
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
                return _MyAnnotation;
            }
        }
        private int _TypeID;
        public int TypeID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
                return _TypeID;
            }
        }
        private AnnotationType _MyAnnotationType;
        public AnnotationType MyAnnotationType
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
                return _MyAnnotationType;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (_MyAnnotationType != value)
                {
                    _MyAnnotationType = value;
                    _TypeID = value.TypeID;// Update underlying data field
                    PropertyHasChanged();
                }
            }
        }
        private string _RtfText = string.Empty;
        public string RtfText
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _RtfText;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (value == null) value = string.Empty;
                if (_RtfText != value)
                {
                    _RtfText = value;
                    PropertyHasChanged();
                }
            }
        }
        private string _SearchText = string.Empty;
        public string SearchText
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _SearchText;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (value == null) value = string.Empty;
                if (_SearchText != value)
                {
                    _SearchText = value;
                    PropertyHasChanged();
                }
            }
        }
        private string _Config = string.Empty;
        public string Config
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _Config;
            }
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            set
            {
                if (value == null) value = string.Empty;
                if (_Config != value)
                {
                    _Config = 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 _AnnotationType_Name = string.Empty;
        public string AnnotationType_Name
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _AnnotationType_Name;
            }
        }
        private string _AnnotationType_Config = string.Empty;
        public string AnnotationType_Config
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _AnnotationType_Config;
            }
        }
        private DateTime _AnnotationType_DTS = new DateTime();
        public DateTime AnnotationType_DTS
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _AnnotationType_DTS;
            }
        }
        private string _AnnotationType_UserID = string.Empty;
        public string AnnotationType_UserID
        {
            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
            get
            {
                return _AnnotationType_UserID;
            }
        }
        // CSLATODO: Check ItemAnnotation.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 ItemAnnotation
        protected override object GetIdValue()
        {
            return MyItemAnnotationUnique; // Absolutely Unique ID
        }
        // CSLATODO: Replace base ItemAnnotation.ToString function as necessary
        /// 
        /// Overrides Base ToString
        /// 
        /// A string representation of current ItemAnnotation
        //public override string ToString()
        //{
        //  return base.ToString();
        //}
        public override bool IsDirty
        {
            get
            {
                if (base.IsDirty)
                    return true;
                return IsDirtyList(new List