Esempio n. 1
0
        public static DojoSeminarOption ParseFromReader(IDataReader r, int idOffset, int dataOffset)
        {
            DojoSeminarOption dojoSeminarOption = new DojoSeminarOption();

            FillFromReader(dojoSeminarOption, r, idOffset, dataOffset);
            return(dojoSeminarOption);
        }
Esempio n. 2
0
        public static void FillOptions(DojoSeminarCollection dojoSeminarCollection)
        {
            StringBuilder s;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;

            if (dojoSeminarCollection.Count > 0)
            {
                s = new StringBuilder("SELECT DojoSeminarID, DojoSeminarOptionID FROM kitTessen_SeminarsChildren_Options ORDER BY DojoSeminarID; ");

                // Clone and sort collection by ID first to fill children in one pass
                DojoSeminarCollection clonedCollection = dojoSeminarCollection.Clone();
                clonedCollection.Sort();

                database  = DatabaseFactory.CreateDatabase();
                dbCommand = database.GetSqlStringCommand(s.ToString());
                r         = database.ExecuteReader(dbCommand);

                bool more = r.Read();

                foreach (DojoSeminar dojoSeminar in clonedCollection)
                {
                    DojoSeminarOptionCollection options;
                    if (dojoSeminar.options != null)
                    {
                        options = dojoSeminar.options;
                        options.Clear();
                    }
                    else
                    {
                        options             = new DojoSeminarOptionCollection();
                        dojoSeminar.options = options;
                    }

                    while (more)
                    {
                        if (r.GetInt32(0) < dojoSeminar.iD)
                        {
                            more = r.Read();
                        }
                        else if (r.GetInt32(0) == dojoSeminar.iD)
                        {
                            options.Add(DojoSeminarOption.NewPlaceHolder(r.GetInt32(1)));
                            more = r.Read();
                        }
                        else
                        {
                            break;
                        }
                    }

                    // No need to continue if there are no more records
                    if (!more)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Makes a deep copy of the current DojoSeminarOption.
        /// </summary>
        /// <returns> A new DojoSeminarOption object reflecting the cloned DojoSeminarOption object.</returns>
        public DojoSeminarOption Copy()
        {
            DojoSeminarOption dojoSeminarOption = new DojoSeminarOption();

            CopyTo(dojoSeminarOption);
            return(dojoSeminarOption);
        }
Esempio n. 4
0
        /// <summary>
        /// Makes a deep copy of the current DojoSeminarOption.
        /// </summary>
        /// <returns> A new DojoSeminarOption object reflecting the cloned DojoSeminarOption object.</returns>
        /// <param name="isolation">Placeholders are used to isolate the DojoSeminarOption from its children.</param>
        public DojoSeminarOption Copy(bool isolation)
        {
            DojoSeminarOption dojoSeminarOption = new DojoSeminarOption();

            CopyTo(dojoSeminarOption, isolation);
            return(dojoSeminarOption);
        }
Esempio n. 5
0
        /// <summary>
        /// Duplicates DojoSeminarOption object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoSeminarOption object reflecting the replicated DojoSeminarOption object.</returns>
        public DojoSeminarOption Duplicate()
        {
            DojoSeminarOption clonedDojoSeminarOption = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoSeminarOption.iD       = DojoSeminarOptionManager._insert(clonedDojoSeminarOption);
            clonedDojoSeminarOption.isSynced = true;
            return(clonedDojoSeminarOption);
        }
Esempio n. 6
0
        public static DojoSeminarOption NewPlaceHolder(int iD)
        {
            DojoSeminarOption dojoSeminarOption = new DojoSeminarOption();

            dojoSeminarOption.iD            = iD;
            dojoSeminarOption.isPlaceHolder = true;
            dojoSeminarOption.isSynced      = true;
            return(dojoSeminarOption);
        }
        public void Remove(DojoSeminarOption value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("DojoSeminarOption not found in collection."));
            }
            RemoveAt(index);
        }
 public int IndexOf(DojoSeminarOption value)
 {
     lock (this)
     {
         for (int x = 0; x < count; x++)
         {
             if (DojoSeminarOptionArray[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoSeminarOption dojoSeminarOption, IDataReader r, int idOffset, int dataOffset)
        {
            dojoSeminarOption.iD            = r.GetInt32(idOffset);
            dojoSeminarOption.isSynced      = true;
            dojoSeminarOption.isPlaceHolder = false;

            dojoSeminarOption.name        = r.GetString(0 + dataOffset);
            dojoSeminarOption.description = r.GetString(1 + dataOffset);
            dojoSeminarOption.fee         = r.GetDecimal(2 + dataOffset);
            dojoSeminarOption.maxQuantity = r.GetInt32(3 + dataOffset);
            if (!r.IsDBNull(4 + dataOffset) && r.GetInt32(4 + dataOffset) > 0)
            {
                dojoSeminarOption.item = RHItem.NewPlaceHolder(r.GetInt32(4 + dataOffset));
            }
        }
Esempio n. 10
0
        internal static bool _fill(DojoSeminarOption dojoSeminarOption)
        {
            // Clone item from cache.
            if (cacheEnabled)
            {
                object cachedObject = cacheFind(dojoSeminarOption.iD);
                if (cachedObject != null)
                {
                    ((DojoSeminarOption)cachedObject).CopyTo(dojoSeminarOption, true);
                    return(dojoSeminarOption.isSynced);
                }
            }

            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;

            query = new StringBuilder("SELECT ");
            query.Append(string.Join(",", InnerJoinFields));
            query.Append(" FROM kitTessen_SeminarOptions WHERE DojoSeminarOptionID=");
            query.Append(dojoSeminarOption.iD);
            query.Append(";");

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
            IDataReader r = database.ExecuteReader(dbCommand);

            if (!r.Read())
            {
                throw(new Exception(string.Format("Cannot find DojoSeminarOptionID '{0}'.",
                                                  dojoSeminarOption.iD)));
            }

            FillFromReader(dojoSeminarOption, r, 0, 1);

            // Microsoft DAAB still needs to have the reader closed.
            r.Close();

            // Store dojoSeminarOption in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoSeminarOption);
            }

            return(true);
        }
 public int Add(DojoSeminarOption value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoSeminarOptionArray.GetUpperBound(0) + 1)
         {
             DojoSeminarOption[] tempDojoSeminarOptionArray = new DojoSeminarOption[count * 2];
             Array.Copy(DojoSeminarOptionArray, tempDojoSeminarOptionArray, count - 1);
             DojoSeminarOptionArray = tempDojoSeminarOptionArray;
         }
         DojoSeminarOptionArray[count - 1] = value;
     }
     return(count - 1);
 }
Esempio n. 12
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoSeminarRegistrationOption dojoSeminarRegistrationOption, IDataReader r, int idOffset, int dataOffset)
        {
            dojoSeminarRegistrationOption.iD            = r.GetInt32(idOffset);
            dojoSeminarRegistrationOption.isSynced      = true;
            dojoSeminarRegistrationOption.isPlaceHolder = false;

            dojoSeminarRegistrationOption.quantity    = r.GetDecimal(0 + dataOffset);
            dojoSeminarRegistrationOption.totalFee    = r.GetDecimal(1 + dataOffset);
            dojoSeminarRegistrationOption.costPerItem = r.GetDecimal(2 + dataOffset);
            if (!r.IsDBNull(3 + dataOffset) && r.GetInt32(3 + dataOffset) > 0)
            {
                dojoSeminarRegistrationOption.parentOption = DojoSeminarOption.NewPlaceHolder(r.GetInt32(3 + dataOffset));
            }
            if (!r.IsDBNull(4 + dataOffset) && r.GetInt32(4 + dataOffset) > 0)
            {
                dojoSeminarRegistrationOption.parentRegistration = DojoSeminarRegistration.NewPlaceHolder(r.GetInt32(4 + dataOffset));
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Clones DojoSeminarOption object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoSeminarOption object reflecting the replicated DojoSeminarOption object.</returns>
        public DojoSeminarOption Clone()
        {
            DojoSeminarOption clonedDojoSeminarOption = new DojoSeminarOption();

            clonedDojoSeminarOption.iD          = iD;
            clonedDojoSeminarOption.isSynced    = isSynced;
            clonedDojoSeminarOption.name        = name;
            clonedDojoSeminarOption.description = description;
            clonedDojoSeminarOption.fee         = fee;
            clonedDojoSeminarOption.maxQuantity = maxQuantity;


            if (item != null)
            {
                clonedDojoSeminarOption.item = item;
            }

            return(clonedDojoSeminarOption);
        }
Esempio n. 14
0
        public static void FillOptions(DojoSeminar dojoSeminar)
        {
            StringBuilder s;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;

            s = new StringBuilder("SELECT DojoSeminarOptionID FROM kitTessen_SeminarsChildren_Options ");
            s.Append("WHERE DojoSeminarID=");
            s.Append(dojoSeminar.iD);
            s.Append(";");

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(s.ToString());
            r         = database.ExecuteReader(dbCommand);

            DojoSeminarOptionCollection options;

            if (dojoSeminar.options != null)
            {
                options = dojoSeminar.options;
                options.Clear();
            }
            else
            {
                options             = new DojoSeminarOptionCollection();
                dojoSeminar.options = options;
            }

            while (r.Read())
            {
                options.Add(DojoSeminarOption.NewPlaceHolder(r.GetInt32(0)));
            }

            dojoSeminar.Options = options;
            // Store DojoSeminar in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoSeminar);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// Deep copies the current DojoSeminarOption to another instance of DojoSeminarOption.
 /// </summary>
 /// <param name="DojoSeminarOption">The DojoSeminarOption to copy to.</param>
 /// <param name="isolation">Placeholders are used to isolate the DojoSeminarOption from its children.</param>
 public void CopyTo(DojoSeminarOption dojoSeminarOption, bool isolation)
 {
     dojoSeminarOption.iD            = iD;
     dojoSeminarOption.isPlaceHolder = isPlaceHolder;
     dojoSeminarOption.isSynced      = isSynced;
     dojoSeminarOption.name          = name;
     dojoSeminarOption.description   = description;
     dojoSeminarOption.fee           = fee;
     dojoSeminarOption.maxQuantity   = maxQuantity;
     if (item != null)
     {
         if (isolation)
         {
             dojoSeminarOption.item = item.NewPlaceHolder();
         }
         else
         {
             dojoSeminarOption.item = item.Copy(false);
         }
     }
 }
 public void Insert(int index, DojoSeminarOption value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoSeminarOptionArray.GetUpperBound(0) + 1)
         {
             DojoSeminarOption[] tempDojoSeminarOptionArray = new DojoSeminarOption[count * 2];
             Array.Copy(DojoSeminarOptionArray, tempDojoSeminarOptionArray, count - 1);
             DojoSeminarOptionArray = tempDojoSeminarOptionArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             DojoSeminarOptionArray[x] = DojoSeminarOptionArray[x - 1];
         }
         DojoSeminarOptionArray[index] = value;
     }
 }
Esempio n. 17
0
        internal static int _update(DojoSeminarOption dojoSeminarOption)
        {
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            dbCommand = database.GetSqlStringCommand("UPDATE kitTessen_SeminarOptions SET Name=@Name," +
                                                     "Description=@Description," +
                                                     "Fee=@Fee," +
                                                     "MaxQuantity=@MaxQuantity," +
                                                     "ItemID=@ItemID WHERE DojoSeminarOptionID=@DojoSeminarOptionID;");

            fillParameters(database, dbCommand, dojoSeminarOption);
            database.AddInParameter(dbCommand, "DojoSeminarOptionID", DbType.Int32, dojoSeminarOption.iD);
            // Abandon remaining updates if no rows have been updated by returning false immediately.
            if (database.ExecuteNonQuery(dbCommand) == 0)
            {
                return(-1);
            }

            // Store dojoSeminarOption in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoSeminarOption);
            }
            // ************************* WARNING ****************************
            // Update operations must invalidate the cached collections.
            // Invalidation MUST invalidate any foreign cached collections that
            // with children objects this manager provides or else the foreign
            // caches retain invalidated and potentially corrupt data!
            // NOTE:
            // NitroCast only allows collection caching on objects that do not
            // have any children objects to minimize potential corruption.
            // ************************* WARNING ****************************

            invalidateCachedCollections();

            return(dojoSeminarOption.iD);
        }
Esempio n. 18
0
        private static void fillParameters(Database database, DbCommand dbCommand, DojoSeminarOption dojoSeminarOption)
        {
            #region Default

            addParameter(database, dbCommand, "@Name", DbType.String, dojoSeminarOption.name);
            addParameter(database, dbCommand, "@Description", DbType.String, dojoSeminarOption.description);
            addParameter(database, dbCommand, "@Fee", DbType.Currency, dojoSeminarOption.fee);
            addParameter(database, dbCommand, "@MaxQuantity", DbType.Int32, dojoSeminarOption.maxQuantity);

            #endregion

            #region Rappahanock

            if (dojoSeminarOption.item == null)
            {
                addParameter(database, dbCommand, "@ItemID", DbType.Int32, DBNull.Value);
            }
            else
            {
                addParameter(database, dbCommand, "@ItemID", DbType.Int32, dojoSeminarOption.item.ID);
            }

            #endregion
        }
Esempio n. 19
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(DojoSeminarOption dojoSeminarOption)
 {
     return(this.iD - dojoSeminarOption.iD);
 }
Esempio n. 20
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            DojoSeminarOption dojoSeminarOption = (DojoSeminarOption)obj;

            return(this.iD - dojoSeminarOption.iD);
        }
Esempio n. 21
0
        /// <summary>
        /// Inserts a DojoSeminarOption into the database. All children should have been
        /// saved to the database before insertion. New children will not be
        /// related to this object in the database.
        /// </summary>
        /// <param name="_DojoSeminarOption">The DojoSeminarOption to insert into the database.</param>
        internal static int _insert(DojoSeminarOption dojoSeminarOption)
        {
            int       id;
            string    query;
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            query = "INSERT INTO kitTessen_SeminarOptions " +
                    "(" +
                    "Name," +
                    "Description," +
                    "Fee," +
                    "MaxQuantity," +
                    "ItemID) VALUES (" +
                    "@Name," +
                    "@Description," +
                    "@Fee," +
                    "@MaxQuantity," +
                    "@ItemID);";

            if (database.ConnectionStringWithoutCredentials.StartsWith("provider=microsoft.jet.oledb.4.0"))
            {
                // Microsoft Access
                // Connection must remain open for IDENTITY to return correct value,
                // therefore use the dbCommand object's Connection directly to control
                // connection state.
                dbCommand = database.GetSqlStringCommand(query);
                fillParameters(database, dbCommand, dojoSeminarOption);
                dbCommand.Connection = database.CreateConnection();
                dbCommand.Connection.Open();
                dbCommand.ExecuteNonQuery();
                dbCommand.CommandText = "SELECT @@IDENTITY AS LastID";
                id = (int)dbCommand.ExecuteScalar();
                dbCommand.Connection.Close();
            }
            else
            {
                //// Microsoft SQL Server
                dbCommand = database.GetSqlStringCommand(query + " SELECT @LastID = SCOPE_IDENTITY();");
                fillParameters(database, dbCommand, dojoSeminarOption);
                database.AddOutParameter(dbCommand, "@LastID", DbType.Int32, 10);
                database.ExecuteNonQuery(dbCommand);
                id = (int)dbCommand.Parameters["@LastID"].Value;
            }
            // Store dojoSeminarOption in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoSeminarOption);
            }
            // ************************* WARNING ****************************
            // Insert operations must invalidate the cached collections.
            // Invalidation MUST invalidate any foreign cached collections that
            // with children objects this manager provides or else the foreign
            // caches retain invalidated and potentially corrupt data!
            // NOTE:
            // NitroCast only allows collection caching on objects that do not
            // have any children objects to minimize potential corruption.
            invalidateCachedCollections();
            return(id);
        }
Esempio n. 22
0
 /// <summary>
 /// Deep copies the current DojoSeminarOption to another instance of DojoSeminarOption.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="DojoSeminarOption">The DojoSeminarOption to copy to.</param>
 public void CopyTo(DojoSeminarOption dojoSeminarOption)
 {
     CopyTo(dojoSeminarOption, false);
 }
Esempio n. 23
0
        public DojoSeminarOptionCollection GetCollection(int topCount, string whereClause, string sortClause, params DojoSeminarOptionFlags[] optionFlags)
        {
            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;
            DojoSeminarOptionCollection dojoSeminarOptionCollection;
            int hashcode;

            // Cache Handling

            hashcode = 0;

            if (cacheEnabled)
            {
                hashcode = topCount.GetHashCode() +
                           whereClause.GetHashCode() +
                           sortClause.GetHashCode() +
                           tableName.GetHashCode();

                DojoSeminarOptionCollection collection = cacheFindCollection(hashcode);
                if (collection != null)
                {
                    return(collection);
                }
            }

            int innerJoinOffset;

            query = new StringBuilder("SELECT ");

            if (topCount > 0)
            {
                query.Append("TOP ");
                query.Append(topCount);
                query.Append(" ");
            }

            foreach (string columnName in InnerJoinFields)
            {
                query.Append("DojoSeminarOption.");
                query.Append(columnName);
                query.Append(",");
            }

            innerJoinOffset = InnerJoinFields.GetUpperBound(0) + 1;
            int itemOffset                   = -1;
            int itemParentItemOffset         = -1;
            int itemPurchaseVendorOffset     = -1;
            int itemPurchaseAccountOffset    = -1;
            int itemInventoryAccountOffset   = -1;
            int itemTaxOffset                = -1;
            int itemSalesIncomeAccountOffset = -1;

            //
            // Append Option Flag Fields
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoSeminarOptionFlags.Item:
                        for (int i = 0; i <= RHItemManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item.");
                            query.Append(RHItemManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemOffset      = innerJoinOffset;
                        innerJoinOffset = itemOffset + RHItemManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemParentItem:
                        for (int i = 0; i <= RHItemManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_ParentItem.");
                            query.Append(RHItemManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemParentItemOffset = innerJoinOffset;
                        innerJoinOffset      = itemParentItemOffset + RHItemManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemPurchaseVendor:
                        for (int i = 0; i <= RHVendorManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_PurchaseVendor.");
                            query.Append(RHVendorManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemPurchaseVendorOffset = innerJoinOffset;
                        innerJoinOffset          = itemPurchaseVendorOffset + RHVendorManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemPurchaseAccount:
                        for (int i = 0; i <= RHAccountManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_PurchaseAccount.");
                            query.Append(RHAccountManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemPurchaseAccountOffset = innerJoinOffset;
                        innerJoinOffset           = itemPurchaseAccountOffset + RHAccountManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemInventoryAccount:
                        for (int i = 0; i <= RHAccountManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_InventoryAccount.");
                            query.Append(RHAccountManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemInventoryAccountOffset = innerJoinOffset;
                        innerJoinOffset            = itemInventoryAccountOffset + RHAccountManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemTax:
                        for (int i = 0; i <= RHTaxTypeManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_Tax.");
                            query.Append(RHTaxTypeManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemTaxOffset   = innerJoinOffset;
                        innerJoinOffset = itemTaxOffset + RHTaxTypeManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarOptionFlags.ItemSalesIncomeAccount:
                        for (int i = 0; i <= RHAccountManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Item_SalesIncomeAccount.");
                            query.Append(RHAccountManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        itemSalesIncomeAccountOffset = innerJoinOffset;
                        innerJoinOffset = itemSalesIncomeAccountOffset + RHAccountManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;
                    }
                }
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            if (optionFlags != null)
            {
                query.Append(" FROM ");

                //
                // Start INNER JOIN expressions
                //
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    query.Append("(");
                }

                query.Append("kitTessen_SeminarOptions AS DojoSeminarOption");
            }
            else
            {
                query.Append(" FROM kitTessen_SeminarOptions AS DojoSeminarOption");
            }
            //
            // Finish INNER JOIN expressions
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoSeminarOptionFlags.Item:
                        query.Append(" LEFT JOIN RH_Items AS Item ON DojoSeminarOption.ItemID = Item.RHItemID)");
                        break;

                    case DojoSeminarOptionFlags.ItemParentItem:
                        query.Append(" LEFT JOIN RH_Items AS Item_ParentItem ON Item.ParentItemID = Item_ParentItem.RHItemID)");
                        break;

                    case DojoSeminarOptionFlags.ItemPurchaseVendor:
                        query.Append(" LEFT JOIN RH_Vendors AS Item_PurchaseVendor ON Item.PurchaseVendorID = Item_PurchaseVendor.RHVendorID)");
                        break;

                    case DojoSeminarOptionFlags.ItemPurchaseAccount:
                        query.Append(" LEFT JOIN RH_Accounts AS Item_PurchaseAccount ON Item.PurchaseAccountID = Item_PurchaseAccount.RHAccountID)");
                        break;

                    case DojoSeminarOptionFlags.ItemInventoryAccount:
                        query.Append(" LEFT JOIN RH_Accounts AS Item_InventoryAccount ON Item.InventoryAccountID = Item_InventoryAccount.RHAccountID)");
                        break;

                    case DojoSeminarOptionFlags.ItemTax:
                        query.Append(" LEFT JOIN RH_TaxTypes AS Item_Tax ON Item.TaxID = Item_Tax.RHTaxTypeID)");
                        break;

                    case DojoSeminarOptionFlags.ItemSalesIncomeAccount:
                        query.Append(" LEFT JOIN RH_Accounts AS Item_SalesIncomeAccount ON Item.SalesIncomeAccountID = Item_SalesIncomeAccount.RHAccountID)");
                        break;
                    }
                }
            }

            //
            // Render where clause
            //
            if (whereClause != string.Empty)
            {
                query.Append(" WHERE ");
                query.Append(whereClause);
            }

            //
            // Render sort clause
            //
            if (sortClause != string.Empty)
            {
                query.Append(" ORDER BY ");
                query.Append(sortClause);
            }

            //
            // Render final semicolon
            //
            query.Append(";");
            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
                        #if DEBUG
            try
            {
                r = database.ExecuteReader(dbCommand);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                throw(new Exception(msg + " --- Query: " + query.ToString()));
            }
                        #else
            r = database.ExecuteReader(dbCommand);
                        #endif

            dojoSeminarOptionCollection = new DojoSeminarOptionCollection();

            while (r.Read())
            {
                DojoSeminarOption dojoSeminarOption = ParseFromReader(r, 0, 1);

                // Fill Item
                if (itemOffset != -1 && !r.IsDBNull(itemOffset))
                {
                    RHItemManager.FillFromReader(dojoSeminarOption.item, r, itemOffset, itemOffset + 1);

                    // Fill
                    if (itemParentItemOffset != -1 && !r.IsDBNull(itemParentItemOffset))
                    {
                        RHItemManager.FillFromReader(dojoSeminarOption.item.ParentItem, r, itemParentItemOffset, itemParentItemOffset + 1);
                    }

                    // Fill Vendor
                    if (itemPurchaseVendorOffset != -1 && !r.IsDBNull(itemPurchaseVendorOffset))
                    {
                        RHVendorManager.FillFromReader(dojoSeminarOption.item.PurchaseVendor, r, itemPurchaseVendorOffset, itemPurchaseVendorOffset + 1);
                    }

                    // Fill Purchase Account
                    if (itemPurchaseAccountOffset != -1 && !r.IsDBNull(itemPurchaseAccountOffset))
                    {
                        RHAccountManager.FillFromReader(dojoSeminarOption.item.PurchaseAccount, r, itemPurchaseAccountOffset, itemPurchaseAccountOffset + 1);
                    }

                    // Fill Asset Account
                    if (itemInventoryAccountOffset != -1 && !r.IsDBNull(itemInventoryAccountOffset))
                    {
                        RHAccountManager.FillFromReader(dojoSeminarOption.item.InventoryAccount, r, itemInventoryAccountOffset, itemInventoryAccountOffset + 1);
                    }

                    // Fill
                    if (itemTaxOffset != -1 && !r.IsDBNull(itemTaxOffset))
                    {
                        RHTaxTypeManager.FillFromReader(dojoSeminarOption.item.Tax, r, itemTaxOffset, itemTaxOffset + 1);
                    }

                    // Fill
                    if (itemSalesIncomeAccountOffset != -1 && !r.IsDBNull(itemSalesIncomeAccountOffset))
                    {
                        RHAccountManager.FillFromReader(dojoSeminarOption.item.SalesIncomeAccount, r, itemSalesIncomeAccountOffset, itemSalesIncomeAccountOffset + 1);
                    }
                }

                dojoSeminarOptionCollection.Add(dojoSeminarOption);
            }

            // Microsoft DAAB still needs to close readers.
            r.Close();

            if (cacheEnabled)
            {
                cacheStoreCollection(hashcode, dojoSeminarOptionCollection);
            }

            return(dojoSeminarOptionCollection);
        }
Esempio n. 24
0
        private static void cacheStore(DojoSeminarOption dojoSeminarOption)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add("kitTessen_SeminarOptions_" + dojoSeminarOption.iD.ToString(), dojoSeminarOption);
        }
 public bool Contains(DojoSeminarOption value)
 {
     return(IndexOf(value) != -1);
 }