// <fileinfo name="OrderSubtotalsRow_Base.cs">
//      <copyright>
//          All rights reserved.
//      </copyright>
//      <remarks>
//          Do not change this source code manually. Changes to this file may 
//          cause incorrect behavior and will be lost if the code is regenerated.
//      </remarks>
//      <generator rewritefile="True" infourl="http://www.SharpPower.com">RapTier</generator>
// </fileinfo>

using System;

namespace MyCompany.MyProject.Db
{
    /// <summary>
    /// The base class for <see cref="OrderSubtotalsRow"/> that 
    /// represents a record in the <c>Order Subtotals</c> view.
    /// </summary>
    /// <remarks>
    /// Do not change this source code manually. Update the <see cref="OrderSubtotalsRow"/>
    /// class if you need to add or change some functionality.
    /// </remarks>
    public abstract class OrderSubtotalsRow_Base
    {
        private int _orderID;
        private decimal _subtotal;
        private bool _subtotalNull = true;

        /// <summary>
        /// Initializes a new instance of the <see cref="OrderSubtotalsRow_Base"/> class.
        /// </summary>
        public OrderSubtotalsRow_Base()
        {
            // EMPTY
        }

        /// <summary>
        /// Gets or sets the <c>OrderID</c> column value.
        /// </summary>
        /// <value>The <c>OrderID</c> column value.</value>
        public int OrderID
        {
            get { return _orderID; }
            set { _orderID = value; }
        }

        /// <summary>
        /// Gets or sets the <c>Subtotal</c> column value.
        /// This column is nullable.
        /// </summary>
        /// <value>The <c>Subtotal</c> column value.</value>
        public decimal Subtotal
        {
            get
            {
                if(IsSubtotalNull)
                    throw new InvalidOperationException("Cannot get value because it is DBNull.");
                return _subtotal;
            }
            set
            {
                _subtotalNull = false;
                _subtotal = value;
            }
        }

        /// <summary>
        /// Indicates whether the <see cref="Subtotal"/>
        /// property value is null.
        /// </summary>
        /// <value>true if the property value is null, otherwise false.</value>
        public bool IsSubtotalNull
        {
            get { return _subtotalNull; }
            set { _subtotalNull = value; }
        }

        /// <summary>
        /// Returns the string representation of this instance.
        /// </summary>
        /// <returns>The string representation of this instance.</returns>
        public override string ToString()
        {
            System.Text.StringBuilder dynStr = new System.Text.StringBuilder(GetType().Name);
            dynStr.Append(':');
            dynStr.Append("  OrderID=");
            dynStr.Append(OrderID);
            dynStr.Append("  Subtotal=");
            dynStr.Append(IsSubtotalNull ? (object)"<NULL>" : Subtotal);
            return dynStr.ToString();
        }
    } // End of OrderSubtotalsRow_Base class
} // End of namespace