예제 #1
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoSeminar dojoSeminar, IDataReader r, int idOffset, int dataOffset)
        {
            dojoSeminar.iD            = r.GetInt32(idOffset);
            dojoSeminar.isSynced      = true;
            dojoSeminar.isPlaceHolder = false;

            dojoSeminar.name        = r.GetString(0 + dataOffset);
            dojoSeminar.startDate   = r.GetDateTime(1 + dataOffset);
            dojoSeminar.endDate     = r.GetDateTime(2 + dataOffset);
            dojoSeminar.description = r.GetString(3 + dataOffset);
            dojoSeminar.isLocal     = r.GetBoolean(4 + dataOffset);
            if (!r.IsDBNull(5 + dataOffset) && r.GetInt32(5 + dataOffset) > 0)
            {
                dojoSeminar.location = GreyFoxContact.NewPlaceHolder("kitTessen_Locations", r.GetInt32(5 + dataOffset));
            }
            dojoSeminar.classUnitFee             = r.GetDecimal(6 + dataOffset);
            dojoSeminar.classUnitType            = (DojoSeminarClassUnitType)r.GetByte(7 + dataOffset);
            dojoSeminar.baseRegistrationFee      = r.GetDecimal(8 + dataOffset);
            dojoSeminar.registrationEnabled      = r.GetBoolean(9 + dataOffset);
            dojoSeminar.registrationStart        = r.GetDateTime(10 + dataOffset);
            dojoSeminar.fullEarlyRegistrationFee = r.GetDecimal(11 + dataOffset);
            dojoSeminar.earlyEndDate             = r.GetDateTime(12 + dataOffset);
            dojoSeminar.fullRegistrationFee      = r.GetDecimal(13 + dataOffset);
            dojoSeminar.lateStartDate            = r.GetDateTime(14 + dataOffset);
            dojoSeminar.fullLateRegistrationFee  = r.GetDecimal(15 + dataOffset);
            dojoSeminar.registrationEnd          = r.GetDateTime(16 + dataOffset);
            dojoSeminar.details            = r.GetString(17 + dataOffset);
            dojoSeminar.detailsOverrideUrl = r.GetString(18 + dataOffset);
            dojoSeminar.pdfUrl             = r.GetString(19 + dataOffset);
            if (!r.IsDBNull(20 + dataOffset) && r.GetInt32(20 + dataOffset) > 0)
            {
                dojoSeminar.item = RHItem.NewPlaceHolder(r.GetInt32(20 + dataOffset));
            }
        }
예제 #2
0
        /// <summary>
        /// Makes a deep copy of the current DojoSeminar.
        /// </summary>
        /// <returns> A new DojoSeminar object reflecting the cloned DojoSeminar object.</returns>
        public DojoSeminar Copy()
        {
            DojoSeminar dojoSeminar = new DojoSeminar();

            CopyTo(dojoSeminar);
            return(dojoSeminar);
        }
예제 #3
0
        /// <summary>
        /// Makes a deep copy of the current DojoSeminar.
        /// </summary>
        /// <returns> A new DojoSeminar object reflecting the cloned DojoSeminar object.</returns>
        /// <param name="isolation">Placeholders are used to isolate the DojoSeminar from its children.</param>
        public DojoSeminar Copy(bool isolation)
        {
            DojoSeminar dojoSeminar = new DojoSeminar();

            CopyTo(dojoSeminar, isolation);
            return(dojoSeminar);
        }
예제 #4
0
        public static DojoSeminar ParseFromReader(IDataReader r, int idOffset, int dataOffset)
        {
            DojoSeminar dojoSeminar = new DojoSeminar();

            FillFromReader(dojoSeminar, r, idOffset, dataOffset);
            return(dojoSeminar);
        }
예제 #5
0
 /// <summary>
 /// Deep copies the current DojoSeminar to another instance of DojoSeminar.
 /// </summary>
 /// <param name="DojoSeminar">The DojoSeminar to copy to.</param>
 /// <param name="isolation">Placeholders are used to isolate the DojoSeminar from its children.</param>
 public void CopyTo(DojoSeminar dojoSeminar, bool isolation)
 {
     dojoSeminar.iD            = iD;
     dojoSeminar.isPlaceHolder = isPlaceHolder;
     dojoSeminar.isSynced      = isSynced;
     dojoSeminar.name          = name;
     dojoSeminar.startDate     = startDate;
     dojoSeminar.endDate       = endDate;
     dojoSeminar.description   = description;
     dojoSeminar.isLocal       = isLocal;
     if (location != null)
     {
         if (isolation)
         {
             dojoSeminar.location = location.NewPlaceHolder();
         }
         else
         {
             dojoSeminar.location = location.Copy(false);
         }
     }
     dojoSeminar.classUnitFee             = classUnitFee;
     dojoSeminar.classUnitType            = classUnitType;
     dojoSeminar.baseRegistrationFee      = baseRegistrationFee;
     dojoSeminar.registrationEnabled      = registrationEnabled;
     dojoSeminar.registrationStart        = registrationStart;
     dojoSeminar.fullEarlyRegistrationFee = fullEarlyRegistrationFee;
     dojoSeminar.earlyEndDate             = earlyEndDate;
     dojoSeminar.fullRegistrationFee      = fullRegistrationFee;
     dojoSeminar.lateStartDate            = lateStartDate;
     dojoSeminar.fullLateRegistrationFee  = fullLateRegistrationFee;
     dojoSeminar.registrationEnd          = registrationEnd;
     if (options != null)
     {
         if (isolation)
         {
             dojoSeminar.options = options.Copy(true);
         }
         else
         {
             dojoSeminar.options = options.Copy(false);
         }
     }
     dojoSeminar.details            = details;
     dojoSeminar.detailsOverrideUrl = detailsOverrideUrl;
     dojoSeminar.pdfUrl             = pdfUrl;
     if (item != null)
     {
         if (isolation)
         {
             dojoSeminar.item = item.NewPlaceHolder();
         }
         else
         {
             dojoSeminar.item = item.Copy(false);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Duplicates DojoSeminar object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoSeminar object reflecting the replicated DojoSeminar object.</returns>
        public DojoSeminar Duplicate()
        {
            DojoSeminar clonedDojoSeminar = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoSeminar.iD       = DojoSeminarManager._insert(clonedDojoSeminar);
            clonedDojoSeminar.isSynced = true;
            return(clonedDojoSeminar);
        }
예제 #7
0
        private static void fillParameters(Database database, DbCommand dbCommand, DojoSeminar dojoSeminar)
        {
            #region General

            addParameter(database, dbCommand, "@Name", DbType.String, dojoSeminar.name);
            addParameter(database, dbCommand, "@StartDate", DbType.Date, dojoSeminar.startDate);
            addParameter(database, dbCommand, "@EndDate", DbType.Date, dojoSeminar.endDate);
            addParameter(database, dbCommand, "@Description", DbType.String, dojoSeminar.description);
            addParameter(database, dbCommand, "@IsLocal", DbType.Boolean, dojoSeminar.isLocal);
            if (dojoSeminar.location == null)
            {
                addParameter(database, dbCommand, "@LocationID", DbType.Int32, DBNull.Value);
            }
            else
            {
                addParameter(database, dbCommand, "@LocationID", DbType.Int32, dojoSeminar.location.ID);
            }

            #endregion

            #region Registration

            addParameter(database, dbCommand, "@ClassUnitFee", DbType.Currency, dojoSeminar.classUnitFee);
            addParameter(database, dbCommand, "@ClassUnitType", DbType.Byte, (Byte)dojoSeminar.classUnitType);
            addParameter(database, dbCommand, "@BaseRegistrationFee", DbType.Currency, dojoSeminar.baseRegistrationFee);
            addParameter(database, dbCommand, "@RegistrationEnabled", DbType.Boolean, dojoSeminar.registrationEnabled);
            addParameter(database, dbCommand, "@RegistrationStart", DbType.Date, dojoSeminar.registrationStart);
            addParameter(database, dbCommand, "@FullEarlyRegistrationFee", DbType.Currency, dojoSeminar.fullEarlyRegistrationFee);
            addParameter(database, dbCommand, "@EarlyEndDate", DbType.Date, dojoSeminar.earlyEndDate);
            addParameter(database, dbCommand, "@FullRegistrationFee", DbType.Currency, dojoSeminar.fullRegistrationFee);
            addParameter(database, dbCommand, "@LateStartDate", DbType.Date, dojoSeminar.lateStartDate);
            addParameter(database, dbCommand, "@FullLateRegistrationFee", DbType.Currency, dojoSeminar.fullLateRegistrationFee);
            addParameter(database, dbCommand, "@RegistrationEnd", DbType.Date, dojoSeminar.registrationEnd);

            #endregion

            #region Details

            addParameter(database, dbCommand, "@Details", DbType.String, dojoSeminar.details);
            addParameter(database, dbCommand, "@DetailsOverrideUrl", DbType.String, dojoSeminar.detailsOverrideUrl);
            addParameter(database, dbCommand, "@PdfUrl", DbType.String, dojoSeminar.pdfUrl);

            #endregion

            #region Rappahanock

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

            #endregion
        }
예제 #8
0
        public static DojoSeminar NewPlaceHolder(int iD)
        {
            DojoSeminar dojoSeminar = new DojoSeminar();

            dojoSeminar.iD            = iD;
            dojoSeminar.isPlaceHolder = true;
            dojoSeminar.isSynced      = true;
            return(dojoSeminar);
        }
예제 #9
0
        public void Remove(DojoSeminar value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("DojoSeminar not found in collection."));
            }
            RemoveAt(index);
        }
예제 #10
0
 public void Add(DojoSeminar dojoSeminar, TimeSpan slidingExpiration)
 {
     lock (this)
     {
         count++;
         ensureArrays();
         dojoSeminarArray[count - 1]    = dojoSeminar;
         timeStamps[count - 1]          = DateTime.Now;
         absoluteExpirations[count - 1] = DateTime.Now.Add(slidingExpiration); // Never Expires
         slidingExpirations[count - 1]  = slidingExpiration;                   // Never slides
         quickSort(0, count - 1);
     }
 }
예제 #11
0
 public int IndexOf(DojoSeminar value)
 {
     lock (this)
     {
         for (int x = 0; x < count; x++)
         {
             if (DojoSeminarArray[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
예제 #12
0
        internal static bool _fill(DojoSeminar dojoSeminar)
        {
            // Clone item from cache.
            if (cacheEnabled)
            {
                object cachedObject = cacheFind(dojoSeminar.iD);
                if (cachedObject != null)
                {
                    ((DojoSeminar)cachedObject).CopyTo(dojoSeminar, true);
                    return(dojoSeminar.isSynced);
                }
            }

            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;

            query = new StringBuilder("SELECT ");
            query.Append(string.Join(",", InnerJoinFields));
            query.Append(" FROM kitTessen_Seminars WHERE DojoSeminarID=");
            query.Append(dojoSeminar.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 DojoSeminarID '{0}'.",
                                                  dojoSeminar.iD)));
            }

            FillFromReader(dojoSeminar, r, 0, 1);

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

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

            return(true);
        }
예제 #13
0
 public int Add(DojoSeminar value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoSeminarArray.GetUpperBound(0) + 1)
         {
             DojoSeminar[] tempDojoSeminarArray = new DojoSeminar[count * 2];
             Array.Copy(DojoSeminarArray, tempDojoSeminarArray, count - 1);
             DojoSeminarArray = tempDojoSeminarArray;
         }
         DojoSeminarArray[count - 1] = value;
     }
     return(count - 1);
 }
예제 #14
0
 /// <summary>
 /// Ensures that the index and object array are sized correctly
 /// for additions. This method should be protected by locks
 /// issued by calling methods.
 /// </summary>
 private void ensureArrays()
 {
     if (count > dojoSeminarArray.GetUpperBound(0) + 1)
     {
         DojoSeminar[] tempDojoSeminarArray    = new DojoSeminar[count * 2];
         DateTime[]    tempTimeStamps          = new DateTime[count * 2];
         DateTime[]    tempAbsoluteExpirations = new DateTime[count * 2];
         TimeSpan[]    tempSlidingExpirations  = new TimeSpan[count * 2];
         Array.Copy(dojoSeminarArray, tempDojoSeminarArray, count - 1);
         Array.Copy(timeStamps, tempTimeStamps, count - 1);
         Array.Copy(absoluteExpirations, tempAbsoluteExpirations, count - 1);
         Array.Copy(slidingExpirations, tempSlidingExpirations, count - 1);
         dojoSeminarArray    = tempDojoSeminarArray;
         timeStamps          = tempTimeStamps;
         absoluteExpirations = tempAbsoluteExpirations;
         slidingExpirations  = tempSlidingExpirations;
     }
 }
예제 #15
0
        /// <summary>
        /// Clones DojoSeminar object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoSeminar object reflecting the replicated DojoSeminar object.</returns>
        public DojoSeminar Clone()
        {
            DojoSeminar clonedDojoSeminar = new DojoSeminar();

            clonedDojoSeminar.iD                       = iD;
            clonedDojoSeminar.isSynced                 = isSynced;
            clonedDojoSeminar.name                     = name;
            clonedDojoSeminar.startDate                = startDate;
            clonedDojoSeminar.endDate                  = endDate;
            clonedDojoSeminar.description              = description;
            clonedDojoSeminar.isLocal                  = isLocal;
            clonedDojoSeminar.classUnitFee             = classUnitFee;
            clonedDojoSeminar.baseRegistrationFee      = baseRegistrationFee;
            clonedDojoSeminar.registrationEnabled      = registrationEnabled;
            clonedDojoSeminar.registrationStart        = registrationStart;
            clonedDojoSeminar.fullEarlyRegistrationFee = fullEarlyRegistrationFee;
            clonedDojoSeminar.earlyEndDate             = earlyEndDate;
            clonedDojoSeminar.fullRegistrationFee      = fullRegistrationFee;
            clonedDojoSeminar.lateStartDate            = lateStartDate;
            clonedDojoSeminar.fullLateRegistrationFee  = fullLateRegistrationFee;
            clonedDojoSeminar.registrationEnd          = registrationEnd;
            clonedDojoSeminar.details                  = details;
            clonedDojoSeminar.detailsOverrideUrl       = detailsOverrideUrl;
            clonedDojoSeminar.pdfUrl                   = pdfUrl;

            clonedDojoSeminar.classUnitType = classUnitType;

            if (location != null)
            {
                clonedDojoSeminar.location = location;
            }

            if (options != null)
            {
                clonedDojoSeminar.options = options.Clone();
            }

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

            return(clonedDojoSeminar);
        }
예제 #16
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);
            }
        }
예제 #17
0
 public void CheckedAdd(DojoSeminar dojoSeminar, TimeSpan slidingExpiration)
 {
     lock (this)
     {
         int i = binarySearch(dojoSeminar.iD);
         if (i != -1)
         {
             dojoSeminarArray[i]    = dojoSeminar;
             absoluteExpirations[i] = DateTime.Now.Add(slidingExpiration);  // Expires
             slidingExpirations[i]  = slidingExpiration;                    // Never slides
             return;
         }
         count++;
         ensureArrays();
         dojoSeminarArray[count - 1]    = dojoSeminar;
         timeStamps[count - 1]          = DateTime.Now;
         absoluteExpirations[count - 1] = DateTime.Now.Add(slidingExpiration); // Expires
         slidingExpirations[count - 1]  = slidingExpiration;                   // Never slides
         quickSort(0, count - 1);
     }
 }
예제 #18
0
 public void Insert(int index, DojoSeminar value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoSeminarArray.GetUpperBound(0) + 1)
         {
             DojoSeminar[] tempDojoSeminarArray = new DojoSeminar[count * 2];
             Array.Copy(DojoSeminarArray, tempDojoSeminarArray, count - 1);
             DojoSeminarArray = tempDojoSeminarArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             DojoSeminarArray[x] = DojoSeminarArray[x - 1];
         }
         DojoSeminarArray[index] = value;
     }
 }
예제 #19
0
        private static void cacheStore(DojoSeminar dojoSeminar)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add("kitTessen_Seminars_" + dojoSeminar.iD.ToString(), dojoSeminar);
        }
예제 #20
0
        internal static int _update(DojoSeminar dojoSeminar)
        {
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            dbCommand = database.GetSqlStringCommand("UPDATE kitTessen_Seminars SET Name=@Name," +
                                                     "StartDate=@StartDate," +
                                                     "EndDate=@EndDate," +
                                                     "Description=@Description," +
                                                     "IsLocal=@IsLocal," +
                                                     "LocationID=@LocationID," +
                                                     "ClassUnitFee=@ClassUnitFee," +
                                                     "ClassUnitType=@ClassUnitType," +
                                                     "BaseRegistrationFee=@BaseRegistrationFee," +
                                                     "RegistrationEnabled=@RegistrationEnabled," +
                                                     "RegistrationStart=@RegistrationStart," +
                                                     "FullEarlyRegistrationFee=@FullEarlyRegistrationFee," +
                                                     "EarlyEndDate=@EarlyEndDate," +
                                                     "FullRegistrationFee=@FullRegistrationFee," +
                                                     "LateStartDate=@LateStartDate," +
                                                     "FullLateRegistrationFee=@FullLateRegistrationFee," +
                                                     "RegistrationEnd=@RegistrationEnd," +
                                                     "Details=@Details," +
                                                     "DetailsOverrideUrl=@DetailsOverrideUrl," +
                                                     "PdfUrl=@PdfUrl," +
                                                     "ItemID=@ItemID WHERE DojoSeminarID=@DojoSeminarID;");

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

            if (dojoSeminar.options != null)
            {
                // Delete child relationships for Options.
                dbCommand = database.GetSqlStringCommand("DELETE  FROM kitTessen_SeminarsChildren_Options WHERE DojoSeminarID=@DojoSeminarID;");
                database.AddInParameter(dbCommand, "@DojoSeminarID", DbType.Int32, dojoSeminar.iD);
                database.ExecuteNonQuery(dbCommand);

                // Save child relationships for Options.
                dbCommand = database.GetSqlStringCommand("INSERT INTO kitTessen_SeminarsChildren_Options (DojoSeminarID, DojoSeminarOptionID) VALUES (@DojoSeminarID, @DojoSeminarOptionID);");
                database.AddInParameter(dbCommand, "@DojoSeminarID", DbType.Int32, dojoSeminar.iD);
                database.AddInParameter(dbCommand, "@DojoSeminarOptionID", DbType.Int32);
                foreach (DojoSeminarOption dojoSeminarOption in dojoSeminar.options)
                {
                    dbCommand.Parameters["@DojoSeminarOptionID"].Value = dojoSeminarOption.ID;
                    database.ExecuteNonQuery(dbCommand);
                }
            }

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

            return(dojoSeminar.iD);
        }
예제 #21
0
        public DojoSeminarCollection GetCollection(int topCount, string whereClause, string sortClause, params DojoSeminarFlags[] optionFlags)
        {
            StringBuilder         query;
            Database              database;
            DbCommand             dbCommand;
            IDataReader           r;
            DojoSeminarCollection dojoSeminarCollection;

            int innerJoinOffset;

            query = new StringBuilder("SELECT ");

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

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

            innerJoinOffset = InnerJoinFields.GetUpperBound(0) + 1;
            int locationOffset               = -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 DojoSeminarFlags.Location:
                        for (int i = 0; i <= GreyFoxContactManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("Location.");
                            query.Append(GreyFoxContactManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        locationOffset  = innerJoinOffset;
                        innerJoinOffset = locationOffset + GreyFoxContactManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoSeminarFlags.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 DojoSeminarFlags.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 DojoSeminarFlags.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 DojoSeminarFlags.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 DojoSeminarFlags.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 DojoSeminarFlags.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 DojoSeminarFlags.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_Seminars AS DojoSeminar");
            }
            else
            {
                query.Append(" FROM kitTessen_Seminars AS DojoSeminar");
            }
            //
            // Finish INNER JOIN expressions
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoSeminarFlags.Location:
                        query.Append(" LEFT JOIN kitTessen_Locations AS Location ON DojoSeminar.LocationID = Location.GreyFoxContactID)");
                        break;

                    case DojoSeminarFlags.Item:
                        query.Append(" LEFT JOIN RH_Items AS Item ON DojoSeminar.ItemID = Item.RHItemID)");
                        break;

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

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

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

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

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

                    case DojoSeminarFlags.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

            dojoSeminarCollection = new DojoSeminarCollection();

            while (r.Read())
            {
                DojoSeminar dojoSeminar = ParseFromReader(r, 0, 1);

                // Fill Location
                if (locationOffset != -1 && !r.IsDBNull(locationOffset))
                {
                    GreyFoxContactManager.FillFromReader(dojoSeminar.location, "kitTessen_Locations", r, locationOffset, locationOffset + 1);
                }

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

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

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

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

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

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

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

                dojoSeminarCollection.Add(dojoSeminar);
            }

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

            return(dojoSeminarCollection);
        }
예제 #22
0
        /// <summary>
        /// Calculates the calcSeminarFee for the registration and sets the TotalFee to the amount due.
        /// </summary>
        /// <param name="ignore">Optionally ignores setting the TotalFee property.</param>
        /// <returns>The amount of the TotalFee.</returns>
        public decimal CalculateFee(DojoSeminarRegistrationOptionCollection options, bool ignore)
        {
            decimal     fullFee        = decimal.Zero;
            decimal     calcSeminarFee = decimal.Zero;
            decimal     calcTotalFee   = decimal.Zero;
            DojoSeminar seminar        = ParentSeminar;

            // Detect Early Bird
            if (registrationDate < seminar.EarlyEndDate)
            {
                fullFee = seminar.FullEarlyRegistrationFee;
            }
            else if (registrationDate < seminar.LateStartDate)
            {
                fullFee = seminar.FullRegistrationFee;
            }
            else
            {
                fullFee = seminar.FullLateRegistrationFee;
            }

            switch (seminar.ClassUnitType)
            {
            case DojoSeminarClassUnitType.Day:
                TimeSpan span = seminar.EndDate.Subtract(seminar.StartDate);
                if (ClassUnits == span.Days)
                {
                    calcSeminarFee = fullFee;
                }
                else
                {
                    calcSeminarFee = seminar.BaseRegistrationFee + (seminar.ClassUnitFee * ClassUnits);
                }
                break;

            case DojoSeminarClassUnitType.Class:
                if (ClassUnits == seminar.ClassCount)
                {
                    calcSeminarFee = fullFee;
                }
                else
                {
                    calcSeminarFee = seminar.BaseRegistrationFee + (seminar.ClassUnitFee * ClassUnits);
                }
                break;

            case DojoSeminarClassUnitType.None:
                calcSeminarFee = fullFee;
                break;

            default:
                throw (new Exception(string.Format("Illegal ClassUnitType '{0}'.", seminar.ClassUnitType)));
            }

            // Calculate Option Fees
            calcTotalFee = calcSeminarFee;
            foreach (DojoSeminarRegistrationOption option in options)
            {
                calcTotalFee += option.TotalFee;
            }

            if (!ignore)
            {
                SeminarFee = calcSeminarFee;
                TotalFee   = calcTotalFee;
            }

            return(calcSeminarFee);
        }
예제 #23
0
        /// <summary>
        /// Inserts a DojoSeminar 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="_DojoSeminar">The DojoSeminar to insert into the database.</param>
        internal static int _insert(DojoSeminar dojoSeminar)
        {
            int       id;
            string    query;
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            query = "INSERT INTO kitTessen_Seminars " +
                    "(" +
                    "Name," +
                    "StartDate," +
                    "EndDate," +
                    "Description," +
                    "IsLocal," +
                    "LocationID," +
                    "ClassUnitFee," +
                    "ClassUnitType," +
                    "BaseRegistrationFee," +
                    "RegistrationEnabled," +
                    "RegistrationStart," +
                    "FullEarlyRegistrationFee," +
                    "EarlyEndDate," +
                    "FullRegistrationFee," +
                    "LateStartDate," +
                    "FullLateRegistrationFee," +
                    "RegistrationEnd," +
                    "Details," +
                    "DetailsOverrideUrl," +
                    "PdfUrl," +
                    "ItemID) VALUES (" +
                    "@Name," +
                    "@StartDate," +
                    "@EndDate," +
                    "@Description," +
                    "@IsLocal," +
                    "@LocationID," +
                    "@ClassUnitFee," +
                    "@ClassUnitType," +
                    "@BaseRegistrationFee," +
                    "@RegistrationEnabled," +
                    "@RegistrationStart," +
                    "@FullEarlyRegistrationFee," +
                    "@EarlyEndDate," +
                    "@FullRegistrationFee," +
                    "@LateStartDate," +
                    "@FullLateRegistrationFee," +
                    "@RegistrationEnd," +
                    "@Details," +
                    "@DetailsOverrideUrl," +
                    "@PdfUrl," +
                    "@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, dojoSeminar);
                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, dojoSeminar);
                database.AddOutParameter(dbCommand, "@LastID", DbType.Int32, 10);
                database.ExecuteNonQuery(dbCommand);
                id = (int)dbCommand.Parameters["@LastID"].Value;
            }

            // Save child relationships for Options.
            if (dojoSeminar.options != null)
            {
                dbCommand = database.GetSqlStringCommand("INSERT INTO kitTessen_SeminarsChildren_Options " +
                                                         "(DojoSeminarID, DojoSeminarOptionID)" +
                                                         " VALUES (@DojoSeminarID, @DojoSeminarOptionID);");
                addParameter(database, dbCommand, "@DojoSeminarID", DbType.Int32);
                addParameter(database, dbCommand, "@DojoSeminarOptionID", DbType.Int32);
                foreach (DojoSeminarOption item in dojoSeminar.options)
                {
                    dbCommand.Parameters["@DojoSeminarID"].Value       = id;
                    dbCommand.Parameters["@DojoSeminarOptionID"].Value = item.ID;
                    database.ExecuteNonQuery(dbCommand);
                }
            }
            // Store dojoSeminar in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoSeminar);
            }
            return(id);
        }
예제 #24
0
 /// <summary>
 /// Deep copies the current DojoSeminar to another instance of DojoSeminar.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="DojoSeminar">The DojoSeminar to copy to.</param>
 public void CopyTo(DojoSeminar dojoSeminar)
 {
     CopyTo(dojoSeminar, false);
 }
예제 #25
0
 public bool Contains(DojoSeminar value)
 {
     return(IndexOf(value) != -1);
 }
예제 #26
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(DojoSeminar dojoSeminar)
 {
     return(this.iD - dojoSeminar.iD);
 }
예제 #27
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            DojoSeminar dojoSeminar = (DojoSeminar)obj;

            return(this.iD - dojoSeminar.iD);
        }