示例#1
0
        internal static void FillReferences(GreyFoxKeyword _GreyFoxKeyword)
        {
            StringBuilder s = new StringBuilder("SELECT GreyFoxKeywordChildID FROM kitCms_KeywordsChildren_References ");

            s.Append("WHERE GreyFoxKeywordID=");
            s.Append(_GreyFoxKeyword.iD);
            s.Append(";");

            OleDbConnection dbConnection = new OleDbConnection(_GreyFoxKeyword.connectionString);
            OleDbCommand    dbCommand    = new OleDbCommand(s.ToString(), dbConnection);

            dbConnection.Open();
            OleDbDataReader r = dbCommand.ExecuteReader();

            GreyFoxKeywordCollection references;

            if (_GreyFoxKeyword.references != null)
            {
                references = _GreyFoxKeyword.references;
                references.Clear();
            }
            else
            {
                references = new GreyFoxKeywordCollection();
                _GreyFoxKeyword.references = references;
            }

            while (r.Read())
            {
                references.Add(GreyFoxKeyword.NewPlaceHolder(_GreyFoxKeyword.connectionString, r.GetInt32(0)));
            }

            dbConnection.Close();
            _GreyFoxKeyword.references = references;
        }
示例#2
0
        internal static bool _fill(GreyFoxKeyword GreyFoxKeyword)
        {
            StringBuilder query = new StringBuilder("SELECT " +
                                                    "Keyword, " +
                                                    "Definition, " +
                                                    "Culture " +
                                                    " FROM kitCms_Keywords WHERE GreyFoxKeywordID=");

            query.Append(greyFoxKeyword.iD);
            query.Append(";");

            OleDbConnection dbConnection = new OleDbConnection(greyFoxKeyword.connectionString);
            OleDbCommand    dbCommand    = new OleDbCommand(query.ToString(), dbConnection);

            dbConnection.Open();
            OleDbDataReader r = dbCommand.ExecuteReader();

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

            greyFoxKeyword.keyword = r.GetString(0);

            greyFoxKeyword.definition = r.GetString(1);

            greyFoxKeyword.culture = r.GetString(2);

            r.Close();
            dbConnection.Close();
            return(true);
        }
示例#3
0
        public GreyFoxKeywordCollection GetCollection(string whereClause, string sortClause)
        {
            StringBuilder query = new StringBuilder("SELECT ");

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

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM kitCms_Keywords ");
            //
            // 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(";");
            OleDbConnection dbConnection = new OleDbConnection(connectionString);
            OleDbCommand    dbCommand    = new OleDbCommand(query.ToString(), dbConnection);

            dbConnection.Open();
            OleDbDataReader          r = dbCommand.ExecuteReader();
            GreyFoxKeywordCollection GreyFoxKeywordCollection = new GreyFoxKeywordCollection();

            while (r.Read())
            {
                GreyFoxKeyword GreyFoxKeyword = ParseFromReader(connectionString, r, 0, 1);

                greyFoxKeywordCollection.Add(greyFoxKeyword);
            }

            r.Close();
            dbConnection.Close();
            return(GreyFoxKeywordCollection);
        }
示例#4
0
        public void Remove(GreyFoxKeyword value)
        {
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("GreyFoxKeyword not found in collection."));
            }
            RemoveAt(index);
        }
示例#5
0
        /// <summary>
        /// Replicates Amns.GreyFoxKeyword object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new Amns.GreyFoxKeyword object reflecting the replicated Amns.GreyFoxKeyword object.</returns>
        public GreyFoxKeyword Replicate(string connectionString)
        {
            GreyFoxKeyword clonedGreyFoxKeyword = this.Clone();

            clonedGreyFoxKeyword.connectionString = connectionString;

            // Insert must be called after children are replicated!
            clonedGreyFoxKeyword.iD       = Amns.GreyFoxKeywordManager._insert(clonedGreyFoxKeyword);
            clonedGreyFoxKeyword.isSynced = true;
            return(clonedGreyFoxKeyword);
        }
示例#6
0
 public int IndexOf(GreyFoxKeyword value)
 {
     for (int x = 0; x < itemCount; x++)
     {
         if (GreyFoxKeywordArray[x].Equals(value))
         {
             return(x);
         }
     }
     return(-1);
 }
示例#7
0
 public void Insert(int index, GreyFoxKeyword value)
 {
     itemCount++;
     if (itemCount > GreyFoxKeywordArray.Length)
     {
         for (int x = index + 1; x == itemCount - 2; x++)
         {
             GreyFoxKeywordArray[x] = GreyFoxKeywordArray[x - 1];
         }
     }
     GreyFoxKeywordArray[index] = value;
 }
示例#8
0
 public int Add(GreyFoxKeyword value)
 {
     itemCount++;
     if (itemCount > GreyFoxKeywordArray.GetUpperBound(0) + 1)
     {
         GreyFoxKeyword[] tempGreyFoxKeywordArray = new GreyFoxKeyword[itemCount * 2];
         for (int x = 0; x <= GreyFoxKeywordArray.GetUpperBound(0); x++)
         {
             tempGreyFoxKeywordArray[x] = GreyFoxKeywordArray[x];
         }
         GreyFoxKeywordArray = tempGreyFoxKeywordArray;
     }
     GreyFoxKeywordArray[itemCount - 1] = value;
     return(itemCount - 1);
 }
示例#9
0
        public static void FillFromReader(GreyFoxKeyword GreyFoxKeyword, string connectionString, OleDbDataReader r, int idOffset, int dataOffset)
        {
            greyFoxKeyword.connectionString = connectionString;
            greyFoxKeyword.iD            = r.GetInt32(idOffset);
            greyFoxKeyword.isSynced      = true;
            greyFoxKeyword.isPlaceHolder = false;

            //
            // Parse Children From Database
            //

            //
            // Parse Fields From Database
            //
            greyFoxKeyword.keyword = r.GetString(0 + dataOffset);

            greyFoxKeyword.definition = r.GetString(1 + dataOffset);

            greyFoxKeyword.culture = r.GetString(2 + dataOffset);
        }
示例#10
0
        /// <summary>
        /// Inserts a GreyFoxKeyword 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="_GreyFoxKeyword">The GreyFoxKeyword to insert into the database.</param>
        internal static int _insert(GreyFoxKeyword greyFoxKeyword)
        {
            OleDbConnection dbConnection = new OleDbConnection(greyFoxKeyword.connectionString);
            OleDbCommand    dbCommand    = new OleDbCommand();

            dbCommand.Connection  = dbConnection;
            dbCommand.CommandText = "INSERT INTO kitCms_Keywords (Keyword,Definition,Culture) VALUES (@Keyword,@Definition,@Culture);";

            dbCommand.Parameters.Add("@Keyword", OleDbType.VarChar);
            dbCommand.Parameters["@Keyword"].Value = greyFoxKeyword.keyword;
            dbCommand.Parameters.Add("@Definition", OleDbType.VarChar);
            dbCommand.Parameters["@Definition"].Value = greyFoxKeyword.definition;
            dbCommand.Parameters.Add("@Culture", OleDbType.VarChar);
            dbCommand.Parameters["@Culture"].Value = greyFoxKeyword.culture;

            dbConnection.Open();
            dbCommand.ExecuteNonQuery();
            dbCommand.CommandText = "SELECT @@IDENTITY AS IDVal";
            int id = (int)dbCommand.ExecuteScalar();

            // Save child relationships for Synonyms.
            if (greyFoxKeyword.synonyms != null)
            {
                foreach (GreyFoxKeyword item in greyFoxKeyword.synonyms)
                {
                    dbCommand.Parameters.Clear();
                    dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_Synonyms " +
                                            "(GreyFoxKeywordID, GreyFoxKeywordID)" +
                                            " VALUES (@GreyFoxKeywordID, @GreyFoxKeywordID);";
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = id;
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = item.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            // Save child relationships for Antonyms.
            if (greyFoxKeyword.antonyms != null)
            {
                foreach (GreyFoxKeyword item in GreyFoxKeyword.antonyms)
                {
                    dbCommand.Parameters.Clear();
                    dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_Antonyms " +
                                            "(GreyFoxKeywordID, GreyFoxKeywordID)" +
                                            " VALUES (@GreyFoxKeywordID, @GreyFoxKeywordID);";
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = id;
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = item.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            // Save child relationships for References.
            if (greyFoxKeyword.references != null)
            {
                foreach (GreyFoxKeyword item in GreyFoxKeyword.references)
                {
                    dbCommand.Parameters.Clear();
                    dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_References " +
                                            "(GreyFoxKeywordID, GreyFoxKeywordID)" +
                                            " VALUES (@GreyFoxKeywordID, @GreyFoxKeywordID);";
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = id;
                    dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
                    dbCommand.Parameters["@GreyFoxKeywordID"].Value = item.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            dbConnection.Close();
            return(id);
        }
示例#11
0
        internal static void _update(GreyFoxKeyword GreyFoxKeyword)
        {
            OleDbConnection dbConnection = new OleDbConnection(greyFoxKeyword.connectionString);
            OleDbCommand    dbCommand    = new OleDbCommand();

            dbCommand.Connection  = dbConnection;
            dbCommand.CommandText = "UPDATE kitCms_Keywords SET Keyword=@Keyword,Definition=@Definition,Culture=@Culture WHERE GreyFoxKeywordID=@GreyFoxKeywordID";

            dbCommand.Parameters.Add("@Keyword", OleDbType.VarChar);
            dbCommand.Parameters["@Keyword"].Value = GreyFoxKeyword.keyword;
            dbCommand.Parameters.Add("@Definition", OleDbType.VarChar);
            dbCommand.Parameters["@Definition"].Value = GreyFoxKeyword.definition;
            dbCommand.Parameters.Add("@Culture", OleDbType.VarChar);
            dbCommand.Parameters["@Culture"].Value = GreyFoxKeyword.culture;
            dbCommand.Parameters.Add("@GreyFoxKeywordID", OleDbType.Integer);
            dbCommand.Parameters["@GreyFoxKeywordID"].Value = GreyFoxKeyword.iD;
            dbConnection.Open();
            dbCommand.ExecuteNonQuery();

            if (greyFoxKeyword.synonyms != null)
            {
                // Delete child relationships for Synonyms.
                dbCommand.CommandText = "DELETE * FROM kitCms_KeywordsChildren_Synonyms WHERE GreyFoxKeywordID_1=@GreyFoxKeywordID_1;";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@GreyFoxKeywordID_1", OleDbType.Integer);
                dbCommand.Parameters["@GreyFoxKeywordID_1"].Value = GreyFoxKeyword.iD;
                dbCommand.ExecuteNonQuery();

                // Save child relationships for Synonyms.
                dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_Synonyms (GreyFoxKeywordID_1, GreyFoxKeywordID_2) VALUES (@GreyFoxKeywordID_1, @GreyFoxKeywordID_2);";
                dbCommand.Parameters.Add("@GreyFoxKeywordID_2", OleDbType.Integer);
                foreach (GreyFoxKeyword childGreyFoxKeyword in GreyFoxKeyword.synonyms)
                {
                    dbCommand.Parameters["@GreyFoxKeywordID_2"].Value = childGreyFoxKeyword.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            if (greyFoxKeyword.antonyms != null)
            {
                // Delete child relationships for Antonyms.
                dbCommand.CommandText = "DELETE * FROM kitCms_KeywordsChildren_Antonyms WHERE GreyFoxKeywordID_1=@GreyFoxKeywordID_1;";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@GreyFoxKeywordID_1", OleDbType.Integer);
                dbCommand.Parameters["@GreyFoxKeywordID_1"].Value = GreyFoxKeyword.iD;
                dbCommand.ExecuteNonQuery();

                // Save child relationships for Antonyms.
                dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_Antonyms (GreyFoxKeywordID_1, GreyFoxKeywordID_2) VALUES (@GreyFoxKeywordID_1, @GreyFoxKeywordID_2);";
                dbCommand.Parameters.Add("@GreyFoxKeywordID_2", OleDbType.Integer);
                foreach (GreyFoxKeyword childGreyFoxKeyword in GreyFoxKeyword.antonyms)
                {
                    dbCommand.Parameters["@GreyFoxKeywordID_2"].Value = childGreyFoxKeyword.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            if (greyFoxKeyword.references != null)
            {
                // Delete child relationships for References.
                dbCommand.CommandText = "DELETE * FROM kitCms_KeywordsChildren_References WHERE GreyFoxKeywordID_1=@GreyFoxKeywordID_1;";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@GreyFoxKeywordID_1", OleDbType.Integer);
                dbCommand.Parameters["@GreyFoxKeywordID_1"].Value = GreyFoxKeyword.iD;
                dbCommand.ExecuteNonQuery();

                // Save child relationships for References.
                dbCommand.CommandText = "INSERT INTO kitCms_KeywordsChildren_References (GreyFoxKeywordID_1, GreyFoxKeywordID_2) VALUES (@GreyFoxKeywordID_1, @GreyFoxKeywordID_2);";
                dbCommand.Parameters.Add("@GreyFoxKeywordID_2", OleDbType.Integer);
                foreach (GreyFoxKeyword childGreyFoxKeyword in GreyFoxKeyword.references)
                {
                    dbCommand.Parameters["@GreyFoxKeywordID_2"].Value = childGreyFoxKeyword.ID;
                    dbCommand.ExecuteNonQuery();
                }
            }

            dbConnection.Close();
        }
示例#12
0
 public bool Contains(GreyFoxKeyword value)
 {
     return(IndexOf(value) != -1);
 }