Esempio n. 1
0
        // V2Generator: Section End :ExecuteCreate Row

        #endregion

        #region Create

        /// <summary>
        /// Creates a new ShippingInfo object based on the given row obtained from the database. The row is from the table ShippingInfo.
        /// </summary>
        /// <param name="row"></param>
        /// <returns>null or a ShippingInfo object</returns>
        // V2Generator: Section Start : Create section
        private static ShippingInfo Create(DataRow row)
        {
            // V2Generator: Body Start
            ShippingInfo result = null;

            int     ID      = -1;
            int     OrderID = -1;
            int     Type    = -1;
            decimal Cost    = -1;
            string  Address = null;

            #region get the values
            ID = (int)row[Field_ID];
            if (row[Field_order_id] != System.DBNull.Value)
            {
                OrderID = (int)row[Field_order_id];
            }
            if (row[Field_type] != System.DBNull.Value)
            {
                Type = (int)row[Field_type];
            }
            if (row[Field_cost] != System.DBNull.Value)
            {
                Cost = (decimal)row[Field_cost];
            }
            if (row[Field_address] != System.DBNull.Value)
            {
                Address = (string)row[Field_address];
            }
            #endregion
            result = new ShippingInfo(ID, OrderID, Type, Cost, Address);

            return(result);
            // V2Generator: Body End
        }
Esempio n. 2
0
        // V2Generator: Section End :Insert

        #endregion

        #region Compare

        /// <summary>
        /// Compares the current ShippingInfo object with the given ShippingInfo object
        /// </summary>
        /// <param name="row">The ShippingInfo object to compare with</param>
        /// <returns>The compared difference between the ShippingInfo objects</returns>
        // V2Generator: Section Start : CompareTo
        public int CompareTo(object row)
        {
            // V2Generator: Body Start
            if (row is ShippingInfo)
            {
                ShippingInfo temp = (ShippingInfo)row;
                return(ID.CompareTo(temp.ID));
            }
            else
            {
                throw new System.ArgumentException("object is not a ShippingInfo");
            }
            // V2Generator: Body End
        }
Esempio n. 3
0
        // V2Generator: Section End :Constructor for insert

        #endregion

        #region Execute Create

        /// <summary>
        /// Creates a new ShippingInfo object based on the given record id from the database
        /// </summary>
        /// <param name="ID">No information available for ID</param>
        /// <returns>null or a new ShippingInfo object</returns>
        // V2Generator: Section Start : ExecuteCreate By ID
        public static ShippingInfo ExecuteCreate(int ID)
        {
            // V2Generator: Body Start
            ShippingInfo result = null;

            DataTable dt = ASPEx_sql.ShippingInfo.ShippingInfoGetByID(ID);

            if (dt.Rows.Count > 0)
            {
                result = Create(dt.Rows[0]);
            }

            return(result);
            // V2Generator: Body End
        }
Esempio n. 4
0
        // V2Generator: Section End :Relations

        #endregion

        #region List Methods

        /// <summary>
        /// Lists all the records from the database
        /// </summary>
        /// <returns></returns>
        // V2Generator: Section Start : List all
        public static List <ShippingInfo> List()
        {
            // V2Generator: Body Start
            List <ShippingInfo> list = new List <ShippingInfo>();
            DataTable           dt   = ASPEx_sql.ShippingInfo.ShippingInfoList();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ShippingInfo result = Create(dt.Rows[i]);
                if (result != null)
                {
                    list.Add(result);
                }
            }

            list.Sort();

            return(list);
            // V2Generator: Body End
        }
Esempio n. 5
0
        // V2Generator: Section End :ExecuteCreate By ID

        /// <summary>
        /// Creates a new ShippingInfo object for inserting a new record into the database
        /// </summary>
        /// <param name="OrderID">No information available for OrderID</param>
        /// <param name="Type">No information available for Type</param>
        /// <param name="Cost">No information available for Cost</param>
        /// <param name="Address">No information available for Address</param>
        /// <returns>null or a new ShippingInfo object</returns>
        /// <Exception cref="System.Exception">
        /// Throws an exception if Address is null.
        /// </Exception>
        // V2Generator: Section Start : ExecuteCreate Insert
        public static ShippingInfo ExecuteCreate(
            int OrderID,
            int Type,
            decimal Cost,
            string Address)
        {
            // V2Generator: Body Start
            ShippingInfo result = null;

            #region Validate the input parameter(s)

            if (Address == null)
            {
                throw new System.Exception("ShippingInfo ExecuteCreate :: Address cannot be null (Database Constraint)");
            }
            #endregion

            result = new ShippingInfo(OrderID, Type, Cost, Address);
            return(result);
            // V2Generator: Body End
        }