truck.cs

来自「微软的行业应用解决方案示例」· CS 代码 · 共 126 行

CS
126
字号
using System;

namespace HardwareDistributor.Business
{
    public class Truck : DataObject
    {
        #region Constants
        public const string LICENSEPLATENUMBER_COLUMN = "LicensePlateNumber";
        public const string LICENSEPLATESTATEPROVINCE_COLUMN = "LicensePlateStateProvince";
        public const string ROUTEID_COLUMN = "RouteId";
        public const string TRUCKID_COLUMN = "TruckId";
        #endregion


        #region Fields
        private string _licensePlateNumber = string.Empty;
        private string _licensePlateState = string.Empty;
        private Nullable<int> _routeId = null;
        private Nullable<int> _truckId = null;
        #endregion


        #region Constructor(s) & Dispose
        /// <summary>
        /// Create a new Truck
        /// </summary>
        public Truck() : base()
        {
        }


        /// <summary>
        /// Create an unmodified Truck
        /// </summary>
        /// <param name="truckId">Id of the Truck</param>
        /// <param name="truckLicenseStateProvince">
        /// State of the license plate of the Truck
        /// </param>
        /// <param name="truckLicenseNumber">License plate of the Truck</param>
        /// <param name="routeId">Route assigned to the Truck</param>
        public Truck(Nullable<int> truckId, 
                     string truckLicenseStateProvince, 
                     string truckLicenseNumber, 
                     Nullable<int> routeId)
        {
            _truckId = truckId;
            _licensePlateNumber = truckLicenseNumber;
            _licensePlateState = truckLicenseStateProvince;
            _routeId = routeId;
            _objectState = ObjectState.Unchanged;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Truck's license plate number
        /// </summary>
        public string LicenseNumber
        {
            get
            {
                return _licensePlateNumber;
            }
            set
            {
                _licensePlateNumber = ChangeValue<string>(_licensePlateNumber, 
                                                          value,
                                                          LICENSEPLATENUMBER_COLUMN);
            }
        }


        /// <summary>
        /// State or Province found on Truck's license plate
        /// </summary>
        public string LicenseStateProvince
        {
            get
            {
                return _licensePlateState;
            }
            set
            {
                _licensePlateState = ChangeValue<string>(_licensePlateState,
                                                         value,
                                                         LICENSEPLATESTATEPROVINCE_COLUMN);
            }
        }


        /// <summary>
        /// Unique Route Id that this truck belongs to
        /// </summary>
        public Nullable<int> RouteId
        {
            get
            {
                return _routeId;
            }
            set
            {
                _routeId = ChangeValue<Nullable<int>>(_routeId, value,
                                                      ROUTEID_COLUMN);
            }
        }


        /// <summary>
        /// Unique Truck Id
        /// </summary>
        public Nullable<int> TruckId
        {
            get
            {
                return _truckId;
            }
            set
            {
                _truckId = ChangeKey<Nullable<int>>(_truckId, value,
                                                    TRUCKID_COLUMN);
            }
        }
        #endregion
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?