⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customer.cs

📁 微软的行业应用解决方案示例
💻 CS
字号:
using System;

namespace HardwareDistributor.Business
{
    /// <summary>
    /// Customer for an order.
    /// </summary>
    public class Customer : DataObject
    {
        #region Constants
        public const string CITY_COLUMN = "City";
        public const string CONTACTNAME_COLUMN = "ContactName";
        public const string CONTACTPHONE_COLUMN = "ContactPhone";
        public const string CUSTOMERID_COLUMN = "CustomerId";
        public const string NAME_COLUMN = "Name";
        public const string POSTALCODE_COLUMN = "PostalCode";
        public const string ROUTEID_COLUMN = "RouteId";
        public const string STATEPROVINCE_COLUMN = "StateProvince";
        public const string STREETADDRESS_COLUMN = "StreetAddress";
        #endregion


        #region Fields
        private string _city = string.Empty;
        private string _contactName = string.Empty;
        private string _contactPhone = string.Empty;
        private Nullable<int> _customerId = null;
        private string _name = string.Empty;
        private string _postalCode = string.Empty;
        private Nullable<int> _routeId = null;
        private string _stateProvince = string.Empty;
        private string _streetAddress = string.Empty;
        #endregion


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


        /// <summary>
        /// Create an unmodified Customer
        /// </summary>
        /// <param name="customerId">Id of the customer</param>
        /// <param name="customerName">Name of the customer</param>
        /// <param name="streetAddress">Street address of the customer</param>
        /// <param name="city">City of the customer</param>
        /// <param name="stateProvince">
        /// State or Province of the customer
        /// </param>
        /// <param name="postalCode">Postal code of the customer</param>
        /// <param name="contactName">Name of the customer contact</param>
        /// <param name="contactPhone">
        /// Phone number of the customer contact
        /// </param>
        /// <param name="routeId">Route the customer is assigned</param>
        public Customer(Nullable<int> customerId, 
                        string customerName, 
                        string streetAddress, 
                        string city, 
                        string stateProvince, 
                        string postalCode, 
                        string contactName, 
                        string contactPhone, 
                        Nullable<int> routeId)
        {
            _customerId = customerId;
            _name = customerName;
            _streetAddress = streetAddress;
            _city = city;
            _stateProvince = stateProvince;
            _postalCode = postalCode;
            _contactName = contactName;
            _contactPhone = contactPhone;
            _objectState= ObjectState.Unchanged;
        }
        #endregion

        #region Properties
        /// <summary>
        /// City where customer resides
        /// </summary>
        public string City
        {
            get
            {
                return _city;
            }
            set
            {
                // If needed put additional editing before the change value.
                _city = ChangeValue<string>(_city, value.Trim(), CITY_COLUMN);
            }
        }


        /// <summary>
        /// Point of contact at Customer's company
        /// </summary>
        public string ContactName
        {
            get
            {
                return _contactName;
            }
            set
            {
                // If needed put additional editing before the change value.
                _contactName = ChangeValue<string>(_contactName, value, 
                                                   CONTACTNAME_COLUMN);
            }
        }


        /// <summary>
        /// Customer's phone number
        /// </summary>
        public string ContactPhone
        {
            get
            {
                return _contactPhone;
            }
            set
            {
                // If needed put additional editing before the change value.
                _contactPhone = ChangeValue<string>(_contactPhone, value, 
                                                    CONTACTPHONE_COLUMN);
            }
        }


        /// <summary>
        /// Customer's unique Id
        /// </summary>
        /// <remarks>
        /// Since CustomerId is a primary key it is treated differently. The 
        /// only time it can be updated is when it is null. The value starts 
        /// out null until the customer is actually inserted into the database. 
        /// At that time the new key is assigned. And since it is actually 
        /// coming from the database it is not considered a modification to the 
        /// object. This means that the object state is not altered.
        /// </remarks>
        public Nullable<int> CustomerId
        {
            get
            {
                return _customerId;
            }
            set
            {
                _customerId = ChangeKey<Nullable<int>>(_customerId, value, 
                                                              CUSTOMERID_COLUMN);
            }
        }

        
        /// <summary>
        /// Customer's company name
        /// </summary>
        public string CustomerName
        {
            get
            {
                return _name;
            }
            set
            {
                // If needed put additional editing before the change value.
                _name = ChangeValue<string>(_name, value, NAME_COLUMN);
            }
        }


        /// <summary>
        /// Customer's postal/zip code
        /// </summary>
        public string PostalCode
        {
            get
            {
                return _postalCode;
            }
            set
            {
                // If needed put additional editing before the change value.
                _postalCode = ChangeValue<string>(_postalCode, value, 
                                                  POSTALCODE_COLUMN);
            }
        }


        /// <summary>
        /// Id of the route this customer belongs
        /// </summary>
        /// <remarks>
        /// Since RouteId is nullable in the database the type here is a 
        /// nullable integer.
        /// </remarks>
        public Nullable<int> RouteId
        {
            get
            {
                return _routeId;
            }
            set
            {
                // If needed put additional editing before the change value.
                _routeId = ChangeValue<Nullable<int>>(_routeId, value, 
                                                      ROUTEID_COLUMN);
            }
        }


        /// <summary>
        /// State or Province where customer resides
        /// </summary>
        public string StateProvince
        {
            get
            {
                return _stateProvince;
            }
            set
            {
                // If needed put additional editing before the change value.
                _stateProvince = ChangeValue<string>(_stateProvince, value.Trim(), 
                                                     STATEPROVINCE_COLUMN);
            }
        }


        /// <summary>
        /// Address of Customer's place of business
        /// </summary>
        public string StreetAddress
        {
            get
            {
                return _streetAddress;
            }
            set
            {
                // If needed put additional editing before the change value.
                _streetAddress = ChangeValue<string>(_streetAddress, value.Trim(),
                                                     STREETADDRESS_COLUMN);
            }
        }
        #endregion
    }
}

⌨️ 快捷键说明

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