Exemplo n.º 1
0
        /// <summary>
        /// Clones DojoTestListStatus object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoTestListStatus object reflecting the replicated DojoTestListStatus object.</returns>
        public DojoTestListStatus Clone()
        {
            DojoTestListStatus clonedDojoTestListStatus = new DojoTestListStatus();

            clonedDojoTestListStatus.iD                    = iD;
            clonedDojoTestListStatus.isSynced              = isSynced;
            clonedDojoTestListStatus.name                  = name;
            clonedDojoTestListStatus.description           = description;
            clonedDojoTestListStatus.orderNum              = orderNum;
            clonedDojoTestListStatus.isDraft               = isDraft;
            clonedDojoTestListStatus.isFinal               = isFinal;
            clonedDojoTestListStatus.isComplete            = isComplete;
            clonedDojoTestListStatus.teacherEditingEnabled = teacherEditingEnabled;


            if (onFinalized != null)
            {
                clonedDojoTestListStatus.onFinalized = onFinalized;
            }

            if (onCompleted != null)
            {
                clonedDojoTestListStatus.onCompleted = onCompleted;
            }

            return(clonedDojoTestListStatus);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deep copies the current DojoTestListStatus to another instance of DojoTestListStatus.
 /// </summary>
 /// <param name="DojoTestListStatus">The DojoTestListStatus to copy to.</param>
 /// <param name="isolation">Placeholders are used to isolate the DojoTestListStatus from its children.</param>
 public void CopyTo(DojoTestListStatus dojoTestListStatus, bool isolation)
 {
     dojoTestListStatus.iD                    = iD;
     dojoTestListStatus.isPlaceHolder         = isPlaceHolder;
     dojoTestListStatus.isSynced              = isSynced;
     dojoTestListStatus.name                  = name;
     dojoTestListStatus.description           = description;
     dojoTestListStatus.orderNum              = orderNum;
     dojoTestListStatus.isDraft               = isDraft;
     dojoTestListStatus.isFinal               = isFinal;
     dojoTestListStatus.isComplete            = isComplete;
     dojoTestListStatus.teacherEditingEnabled = teacherEditingEnabled;
     if (onFinalized != null)
     {
         if (isolation)
         {
             dojoTestListStatus.onFinalized = onFinalized.NewPlaceHolder();
         }
         else
         {
             dojoTestListStatus.onFinalized = onFinalized.Copy(false);
         }
     }
     if (onCompleted != null)
     {
         if (isolation)
         {
             dojoTestListStatus.onCompleted = onCompleted.NewPlaceHolder();
         }
         else
         {
             dojoTestListStatus.onCompleted = onCompleted.Copy(false);
         }
     }
 }
Exemplo n.º 3
0
        internal static int _update(DojoTestListStatus dojoTestListStatus)
        {
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            dbCommand = database.GetSqlStringCommand("UPDATE kitTessen_DojoTestListStatuses SET Name=@Name," +
                                                     "Description=@Description," +
                                                     "OrderNum=@OrderNum," +
                                                     "IsDraft=@IsDraft," +
                                                     "IsFinal=@IsFinal," +
                                                     "IsComplete=@IsComplete," +
                                                     "TeacherEditingEnabled=@TeacherEditingEnabled," +
                                                     "OnFinalizedID=@OnFinalizedID," +
                                                     "OnCompletedID=@OnCompletedID WHERE DojoTestListStatusID=@DojoTestListStatusID;");

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

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

            return(dojoTestListStatus.iD);
        }
Exemplo n.º 4
0
        public static DojoTestListStatus ParseFromReader(IDataReader r, int idOffset, int dataOffset)
        {
            DojoTestListStatus dojoTestListStatus = new DojoTestListStatus();

            FillFromReader(dojoTestListStatus, r, idOffset, dataOffset);
            return(dojoTestListStatus);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Makes a deep copy of the current DojoTestListStatus.
        /// </summary>
        /// <returns> A new DojoTestListStatus object reflecting the cloned DojoTestListStatus object.</returns>
        /// <param name="isolation">Placeholders are used to isolate the DojoTestListStatus from its children.</param>
        public DojoTestListStatus Copy(bool isolation)
        {
            DojoTestListStatus dojoTestListStatus = new DojoTestListStatus();

            CopyTo(dojoTestListStatus, isolation);
            return(dojoTestListStatus);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Makes a deep copy of the current DojoTestListStatus.
        /// </summary>
        /// <returns> A new DojoTestListStatus object reflecting the cloned DojoTestListStatus object.</returns>
        public DojoTestListStatus Copy()
        {
            DojoTestListStatus dojoTestListStatus = new DojoTestListStatus();

            CopyTo(dojoTestListStatus);
            return(dojoTestListStatus);
        }
Exemplo n.º 7
0
        public static DojoTestListStatus NewPlaceHolder(int iD)
        {
            DojoTestListStatus dojoTestListStatus = new DojoTestListStatus();

            dojoTestListStatus.iD            = iD;
            dojoTestListStatus.isPlaceHolder = true;
            dojoTestListStatus.isSynced      = true;
            return(dojoTestListStatus);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Duplicates DojoTestListStatus object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoTestListStatus object reflecting the replicated DojoTestListStatus object.</returns>
        public DojoTestListStatus Duplicate()
        {
            DojoTestListStatus clonedDojoTestListStatus = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoTestListStatus.iD       = DojoTestListStatusManager._insert(clonedDojoTestListStatus);
            clonedDojoTestListStatus.isSynced = true;
            return(clonedDojoTestListStatus);
        }
Exemplo n.º 9
0
        public void Remove(DojoTestListStatus value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("DojoTestListStatus not found in collection."));
            }
            RemoveAt(index);
        }
Exemplo n.º 10
0
 public int IndexOf(DojoTestListStatus value)
 {
     lock (this)
     {
         for (int x = 0; x < count; x++)
         {
             if (DojoTestListStatusArray[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
Exemplo n.º 11
0
        internal static bool _fill(DojoTestListStatus dojoTestListStatus)
        {
            // Clone item from cache.
            if (cacheEnabled)
            {
                object cachedObject = cacheFind(dojoTestListStatus.iD);
                if (cachedObject != null)
                {
                    ((DojoTestListStatus)cachedObject).CopyTo(dojoTestListStatus, true);
                    return(dojoTestListStatus.isSynced);
                }
            }

            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;

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

            FillFromReader(dojoTestListStatus, r, 0, 1);

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

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

            return(true);
        }
Exemplo n.º 12
0
 public int Add(DojoTestListStatus value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoTestListStatusArray.GetUpperBound(0) + 1)
         {
             DojoTestListStatus[] tempDojoTestListStatusArray = new DojoTestListStatus[count * 2];
             Array.Copy(DojoTestListStatusArray, tempDojoTestListStatusArray, count - 1);
             DojoTestListStatusArray = tempDojoTestListStatusArray;
         }
         DojoTestListStatusArray[count - 1] = value;
     }
     return(count - 1);
 }
Exemplo n.º 13
0
 public void Insert(int index, DojoTestListStatus value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoTestListStatusArray.GetUpperBound(0) + 1)
         {
             DojoTestListStatus[] tempDojoTestListStatusArray = new DojoTestListStatus[count * 2];
             Array.Copy(DojoTestListStatusArray, tempDojoTestListStatusArray, count - 1);
             DojoTestListStatusArray = tempDojoTestListStatusArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             DojoTestListStatusArray[x] = DojoTestListStatusArray[x - 1];
         }
         DojoTestListStatusArray[index] = value;
     }
 }
Exemplo n.º 14
0
        private static void fillParameters(Database database, DbCommand dbCommand, DojoTestListStatus dojoTestListStatus)
        {
            #region General

            addParameter(database, dbCommand, "@Name", DbType.String, dojoTestListStatus.name);
            addParameter(database, dbCommand, "@Description", DbType.String, dojoTestListStatus.description);
            addParameter(database, dbCommand, "@OrderNum", DbType.Int32, dojoTestListStatus.orderNum);

            #endregion

            #region Flags

            addParameter(database, dbCommand, "@IsDraft", DbType.Boolean, dojoTestListStatus.isDraft);
            addParameter(database, dbCommand, "@IsFinal", DbType.Boolean, dojoTestListStatus.isFinal);
            addParameter(database, dbCommand, "@IsComplete", DbType.Boolean, dojoTestListStatus.isComplete);
            addParameter(database, dbCommand, "@TeacherEditingEnabled", DbType.Boolean, dojoTestListStatus.teacherEditingEnabled);

            #endregion

            #region Status Changes

            if (dojoTestListStatus.onFinalized == null)
            {
                addParameter(database, dbCommand, "@OnFinalizedID", DbType.Int32, DBNull.Value);
            }
            else
            {
                addParameter(database, dbCommand, "@OnFinalizedID", DbType.Int32, dojoTestListStatus.onFinalized.ID);
            }
            if (dojoTestListStatus.onCompleted == null)
            {
                addParameter(database, dbCommand, "@OnCompletedID", DbType.Int32, DBNull.Value);
            }
            else
            {
                addParameter(database, dbCommand, "@OnCompletedID", DbType.Int32, dojoTestListStatus.onCompleted.ID);
            }

            #endregion
        }
Exemplo n.º 15
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoTestListStatus dojoTestListStatus, IDataReader r, int idOffset, int dataOffset)
        {
            dojoTestListStatus.iD            = r.GetInt32(idOffset);
            dojoTestListStatus.isSynced      = true;
            dojoTestListStatus.isPlaceHolder = false;

            dojoTestListStatus.name                  = r.GetString(0 + dataOffset);
            dojoTestListStatus.description           = r.GetString(1 + dataOffset);
            dojoTestListStatus.orderNum              = r.GetInt32(2 + dataOffset);
            dojoTestListStatus.isDraft               = r.GetBoolean(3 + dataOffset);
            dojoTestListStatus.isFinal               = r.GetBoolean(4 + dataOffset);
            dojoTestListStatus.isComplete            = r.GetBoolean(5 + dataOffset);
            dojoTestListStatus.teacherEditingEnabled = r.GetBoolean(6 + dataOffset);
            if (!r.IsDBNull(7 + dataOffset) && r.GetInt32(7 + dataOffset) > 0)
            {
                dojoTestListStatus.onFinalized = DojoTestListStatus.NewPlaceHolder(r.GetInt32(7 + dataOffset));
            }
            if (!r.IsDBNull(8 + dataOffset) && r.GetInt32(8 + dataOffset) > 0)
            {
                dojoTestListStatus.onCompleted = DojoTestListStatus.NewPlaceHolder(r.GetInt32(8 + dataOffset));
            }
        }
Exemplo n.º 16
0
        private static void cacheStore(DojoTestListStatus dojoTestListStatus)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add("kitTessen_DojoTestListStatuses_" + dojoTestListStatus.iD.ToString(), dojoTestListStatus);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Deep copies the current DojoTestListStatus to another instance of DojoTestListStatus.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="DojoTestListStatus">The DojoTestListStatus to copy to.</param>
 public void CopyTo(DojoTestListStatus dojoTestListStatus)
 {
     CopyTo(dojoTestListStatus, false);
 }
Exemplo n.º 18
0
        public DojoTestListStatusCollection GetCollection(int topCount, string whereClause, string sortClause, params DojoTestListStatusFlags[] optionFlags)
        {
            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;
            DojoTestListStatusCollection dojoTestListStatusCollection;

            int innerJoinOffset;

            query = new StringBuilder("SELECT ");

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

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

            innerJoinOffset = InnerJoinFields.GetUpperBound(0) + 1;
            int onFinalizedOffset            = -1;
            int onFinalizedOnFinalizedOffset = -1;
            int onFinalizedOnCompletedOffset = -1;
            int onCompletedOffset            = -1;
            int onCompletedOnFinalizedOffset = -1;
            int onCompletedOnCompletedOffset = -1;

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

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOffset = innerJoinOffset;
                        innerJoinOffset   = onCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnCompletedOffset + DojoTestListStatusManager.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_DojoTestListStatuses AS DojoTestListStatus");
            }
            else
            {
                query.Append(" FROM kitTessen_DojoTestListStatuses AS DojoTestListStatus");
            }
            //
            // Finish INNER JOIN expressions
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoTestListStatusFlags.OnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized ON DojoTestListStatus.OnFinalizedID = OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnFinalized ON OnFinalized.OnFinalizedID = OnFinalized_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnCompleted ON OnFinalized.OnCompletedID = OnFinalized_OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted ON DojoTestListStatus.OnCompletedID = OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnFinalized ON OnCompleted.OnFinalizedID = OnCompleted_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnCompleted ON OnCompleted.OnCompletedID = OnCompleted_OnCompleted.DojoTestListStatusID)");
                        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

            dojoTestListStatusCollection = new DojoTestListStatusCollection();

            while (r.Read())
            {
                DojoTestListStatus dojoTestListStatus = ParseFromReader(r, 0, 1);

                // Fill OnFinalized
                if (onFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized, r, onFinalizedOffset, onFinalizedOffset + 1);

                    // Fill
                    if (onFinalizedOnFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnFinalized, r, onFinalizedOnFinalizedOffset, onFinalizedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onFinalizedOnCompletedOffset != -1 && !r.IsDBNull(onFinalizedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnCompleted, r, onFinalizedOnCompletedOffset, onFinalizedOnCompletedOffset + 1);
                    }
                }

                // Fill OnCompleted
                if (onCompletedOffset != -1 && !r.IsDBNull(onCompletedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted, r, onCompletedOffset, onCompletedOffset + 1);

                    // Fill
                    if (onCompletedOnFinalizedOffset != -1 && !r.IsDBNull(onCompletedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnFinalized, r, onCompletedOnFinalizedOffset, onCompletedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onCompletedOnCompletedOffset != -1 && !r.IsDBNull(onCompletedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnCompleted, r, onCompletedOnCompletedOffset, onCompletedOnCompletedOffset + 1);
                    }
                }

                dojoTestListStatusCollection.Add(dojoTestListStatus);
            }

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

            return(dojoTestListStatusCollection);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            DojoTestListStatus dojoTestListStatus = (DojoTestListStatus)obj;

            return(this.iD - dojoTestListStatus.iD);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(DojoTestListStatus dojoTestListStatus)
 {
     return(this.iD - dojoTestListStatus.iD);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Inserts a DojoTestListStatus 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="_DojoTestListStatus">The DojoTestListStatus to insert into the database.</param>
        internal static int _insert(DojoTestListStatus dojoTestListStatus)
        {
            int       id;
            string    query;
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            query = "INSERT INTO kitTessen_DojoTestListStatuses " +
                    "(" +
                    "Name," +
                    "Description," +
                    "OrderNum," +
                    "IsDraft," +
                    "IsFinal," +
                    "IsComplete," +
                    "TeacherEditingEnabled," +
                    "OnFinalizedID," +
                    "OnCompletedID) VALUES (" +
                    "@Name," +
                    "@Description," +
                    "@OrderNum," +
                    "@IsDraft," +
                    "@IsFinal," +
                    "@IsComplete," +
                    "@TeacherEditingEnabled," +
                    "@OnFinalizedID," +
                    "@OnCompletedID);";

            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, dojoTestListStatus);
                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, dojoTestListStatus);
                database.AddOutParameter(dbCommand, "@LastID", DbType.Int32, 10);
                database.ExecuteNonQuery(dbCommand);
                id = (int)dbCommand.Parameters["@LastID"].Value;
            }
            // Store dojoTestListStatus in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoTestListStatus);
            }
            return(id);
        }
Exemplo n.º 22
0
 public bool Contains(DojoTestListStatus value)
 {
     return(IndexOf(value) != -1);
 }