using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace RDH.Data.Models
{
    [Serializable]
    [DataContract]
    public partial class StorageSpace : BaseSnapshotModel// IModel , INotifyPropertyChanged
    {
        private Guid? _parentkey;
        private Guid _snapshotkey;
        private DateTime? _starttime;
        private DateTime? _endtime;
        private Decimal? _rowindex;
        private Decimal? _columnindex;
        private Decimal? _rowspan;
        private Decimal? _columnspan;
        private Decimal? _childrenrows;
        private Decimal? _childrencolumns;
        private string _typecode;
        private string _name;
        private string _code;
        private string _serialno;
        private Guid? _devicekey;
        private Guid? _createby;
        private Guid? _key;
        private bool? _flag;
        private DateTime? _clienttime;
        private DateTime? _servertime;
        private string _ext01;
        private string _ext02;
        private string _ext03;
        private string _ext04;
        private string _ext05;
        private string _ext06;
        private string _ext07;
        private string _ext08;
        private string _ext09;
        private string _ext10;
        private DispensingDevice _dispensingdevice;
        private Int32? _pocketLowerAddress;

        #region Public Properties

        [DataMember]
        public virtual Guid? ParentKey
        {
            get { return _parentkey; }
            set
            {
                _parentkey = value;
                OnPropertyChanged("ParentKey");
            }
        }
        [DataMember]
        public virtual Guid SnapshotKey
        {
            get { return _snapshotkey; }
            set
            {
                _snapshotkey = value;
                OnPropertyChanged("SnapshotKey");
            }
        }
        [DataMember]
        public virtual DateTime? StartTime
        {
            get { return _starttime; }
            set
            {
                _starttime = value;
                OnPropertyChanged("StartTime");
            }
        }
        [DataMember]
        public virtual DateTime? EndTime
        {
            get { return _endtime; }
            set
            {
                _endtime = value;
                OnPropertyChanged("EndTime");
                EndFlag = value == null ? 0 : 1;
            }
        }
        [DataMember]
        public virtual Decimal? RowIndex
        {
            get { return _rowindex; }
            set
            {
                _rowindex = value;
                OnPropertyChanged("RowIndex");
            }
        }
        [DataMember]
        public virtual Decimal? ColumnIndex
        {
            get { return _columnindex; }
            set
            {
                _columnindex = value;
                OnPropertyChanged("ColumnIndex");
            }
        }
        [DataMember]
        public virtual Decimal? RowSpan
        {
            get { return _rowspan; }
            set
            {
                _rowspan = value;
                OnPropertyChanged("RowSpan");
            }
        }
        [DataMember]
        public virtual Decimal? ColumnSpan
        {
            get { return _columnspan; }
            set
            {
                _columnspan = value;
                OnPropertyChanged("ColumnSpan");
            }
        }
        [DataMember]
        public virtual Decimal? ChildrenRows
        {
            get { return _childrenrows; }
            set
            {
                _childrenrows = value;
                OnPropertyChanged("ChildrenRows");
            }
        }
        [DataMember]
        public virtual Decimal? ChildrenColumns
        {
            get { return _childrencolumns; }
            set
            {
                _childrencolumns = value;
                OnPropertyChanged("ChildrenColumns");
            }
        }
        [DataMember]
        public virtual string TypeCode
        {
            get { return _typecode; }
            set
            {
                _typecode = value;
                OnPropertyChanged("TypeCode");
            }
        }
        [DataMember]
        public virtual string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                OnPropertyChanged("Name");
            }
        }
        [DataMember]
        public virtual string Code
        {
            get { return _code; }
            set
            {
                _code = value;
                OnPropertyChanged("Code");
            }
        }
        [DataMember]
        public virtual string SerialNo
        {
            get { return _serialno; }
            set
            {
                _serialno = value;
                OnPropertyChanged("SerialNo");
            }
        }
        [DataMember]
        public virtual Guid? DeviceKey
        {
            get { return _devicekey; }
            set
            {
                _devicekey = value;
                OnPropertyChanged("DeviceKey");
            }
        }
        [DataMember]
        public virtual Guid? CreateBy
        {
            get { return _createby; }
            set
            {
                _createby = value;
                OnPropertyChanged("CreateBy");
            }
        }
        [DataMember]
        public virtual Guid? Key
        {
            get { return _key; }
            set
            {
                _key = value;
                OnPropertyChanged("Key");
            }
        }
        [DataMember]
        public virtual bool? Flag
        {
            get { return _flag; }
            set
            {
                _flag = value;
                OnPropertyChanged("Flag");
            }
        }
        [DataMember]
        public virtual DateTime? ClientTime
        {
            get { return _clienttime; }
            set
            {
                _clienttime = value;
                OnPropertyChanged("ClientTime");
            }
        }
        [DataMember]
        public virtual DateTime? ServerTime
        {
            get { return _servertime; }
            set
            {
                _servertime = value;
                OnPropertyChanged("ServerTime");
            }
        }
        /// <summary>
        /// 获取或设置对应的下位机地址编码
        /// </summary>
        [DataMember]
        public virtual string Ext01
        {
            get { return _ext01; }
            set
            {
                _ext01 = value;
                OnPropertyChanged("Ext01");
            }
        }
        /// <summary>
        /// 获取或设置单元格编号
        /// </summary>
        [DataMember]
        public virtual string Ext02
        {
            get { return _ext02; }
            set
            {
                _ext02 = value;
                OnPropertyChanged("Ext02");
            }
        }
        /// <summary>
        /// 获取或设置是否为回收单元
        /// </summary>
        [DataMember]
        public virtual string Ext03
        {
            get { return _ext03; }
            set
            {
                _ext03 = value;
                OnPropertyChanged("Ext03");
            }
        }
        /// <summary>
        /// 获取或设置RFID单元关联的天线号
        /// </summary>
        [DataMember]
        public virtual string Ext04
        {
            get { return _ext04; }
            set
            {
                _ext04 = value;
                OnPropertyChanged("Ext04");
            }
        }
        [DataMember]
        public virtual string Ext05
        {
            get { return _ext05; }
            set
            {
                _ext05 = value;
                OnPropertyChanged("Ext05");
            }
        }
        [DataMember]
        public virtual string Ext06
        {
            get { return _ext06; }
            set
            {
                _ext06 = value;
                OnPropertyChanged("Ext06");
            }
        }
        [DataMember]
        public virtual string Ext07
        {
            get { return _ext07; }
            set
            {
                _ext07 = value;
                OnPropertyChanged("Ext07");
            }
        }
        [DataMember]
        public virtual string Ext08
        {
            get { return _ext08; }
            set
            {
                _ext08 = value;
                OnPropertyChanged("Ext08");
            }
        }
        [DataMember]
        public virtual string Ext09
        {
            get { return _ext09; }
            set
            {
                _ext09 = value;
                OnPropertyChanged("Ext09");
            }
        }
        [DataMember]
        public virtual string Ext10
        {
            get { return _ext10; }
            set
            {
                _ext10 = value;
                OnPropertyChanged("Ext10");
            }
        }
        [DataMember]
        public DispensingDevice DispensingDevice
        {
            get { return _dispensingdevice; }
            set
            {
                _dispensingdevice = value;
                OnPropertyChanged("DispensingDevice");
            }
        }
        public Int32 PocketLowerAddress
        {
            get
            {
                if (_pocketLowerAddress.HasValue)
                {
                    return _pocketLowerAddress.Value;
                }
                Int32 temNum;
                Int32.TryParse(Ext02, out temNum);
                _pocketLowerAddress = temNum;
                return temNum;
            }
            set
            {
                _pocketLowerAddress = value;
                Ext02 = value.ToString();
                OnPropertyChanged("PocketLowerAddress");
            }
        }
        public StorageSpace ParentInfo { get; set; }
        #endregion
    }

}
