/// <summary> /// Creates a BTBlock item int the database /// </summary> /// <param name="MemberID">The owner of the block item</param> /// <param name="BTBlockItem">The BTBlock object</param> public static void CreateBTBlockItems(int MemberID, MemberBlock[] BTBlockItems) { for (int i = 0; i < BTBlockItems.Length; i++) { BTBlockItems[i].MemberID = MemberID; BTBlockItems[i].Save(); } }
/// <summary> ///// obselete??????? ///// </summary> ///// <param name="MemberID"></param> ///// <returns></returns> //public static MemberBlockItem[] GetMemberBTBlockList(string MemberID) //{ // Database db = DatabaseFactory.CreateDatabase(); // DbCommand dbCommand = db.GetStoredProcCommand("HG_GetMemberBTBlockList"); // db.AddInParameter(dbCommand, "MemberID", DbType.Int32, MemberID); // List<MemberBlock> BTBlockList = new List<MemberBlock>(); // List<MemberBlockItem> BTBlockItems = new List<MemberBlockItem>(); // using (IDataReader dr = db.ExecuteReader(dbCommand)) // { // BTBlockList = MemberBlock.PopulateObject(dr); // dr.Close(); // } // for (int i = 0; i < BTBlockList.Count; i++) // { // //BTBlockItems. // MemberBlockItem blockItem = new MemberBlockItem(); // blockItem.MemberID = BTBlockList[i].MemberID; // blockItem.BlockMemberID = BTBlockList[i].BlockMemberID; // blockItem.DTCreated = BTBlockList[i].DTCreated.Ticks.ToString(); // BTBlockItems.Add(blockItem); // } // return BTBlockItems.ToArray(); //} /// <summary> /// Deletes a BTBlock item from the database /// </summary> /// <param name="MemberID">The owner of the block item</param> /// <param name="BTBlockItem">The BTBlock object</param> public static void DeleteBTBlockItems(string MemberID, MemberBlock[] BTBlockItems) { Database db = DatabaseFactory.CreateDatabase(); for (int i = 0; i < BTBlockItems.Length; i++) { DbCommand dbCommand = db.GetStoredProcCommand("HG_DeleteBTBlockItem"); db.AddInParameter(dbCommand, "MemberID", DbType.Int32, MemberID); db.AddInParameter(dbCommand, "BTBlockID", DbType.Int32, BTBlockItems[i].MemberBlockID); db.ExecuteNonQuery(dbCommand); } }
/// <summary> /// Takes an prepopulated IDataReader and creates an array of MemberBlocks /// </summary> public static List<MemberBlock> PopulateObject(IDataReader dr) { ColumnFieldList list = new ColumnFieldList(dr); List<MemberBlock> arr = new List<MemberBlock>(); MemberBlock obj; while (dr.Read()) { obj = new MemberBlock(); if (list.IsColumnPresent("MemberBlockID")) { obj._memberBlockID = (int)dr["MemberBlockID"]; } if (list.IsColumnPresent("MemberID")) { obj._memberID = (int)dr["MemberID"]; } if (list.IsColumnPresent("BlockMemberID")) { obj._blockMemberID = (int)dr["BlockMemberID"]; } if (list.IsColumnPresent("DTCreated")) { obj._dTCreated = (DateTime)dr["DTCreated"]; } arr.Add(obj); } dr.Close(); return arr; }