public static ArrayList GetDonationGiftList(string username)
        {
            //get a list of item from redeemable_gift table
            ArrayList redeemableGifts = new ArrayList();

            IDbConnection connection = null;
            IDbCommand    command    = null;
            IDataReader   reader     = null;

            try
            {
                connection = new OdbcConnection(ConnectionString);

                connection.Open( );


                command = connection.CreateCommand( );

                command.CommandText = String.Format("SELECT redeemable_gift.id AS id, redeemable_gift.type_id AS type, gift_type.type_name AS name FROM redeemable_gift INNER JOIN gift_type ON redeemable_gift.type_id=gift_type.type_id WHERE redeemable_gift.account_name='{0}' ORDER BY redeemable_gift.id ASC", username);
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int          giftId     = System.Convert.ToInt32(reader["id"]);
                    int          giftTypeId = System.Convert.ToInt32(reader["type"]);
                    string       giftName   = (string)reader["name"];
                    DonationGift gift       = new DonationGift(giftId, giftTypeId, giftName);
                    redeemableGifts.Add(gift);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Retrieve Donation Gift List] Error...");
                Console.WriteLine(e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
                if (command != null && connection != null)
                {
                    command.Dispose();
                    connection.Close();
                    connection.Dispose();
                }
            }

            return(redeemableGifts);
        }
Ejemplo n.º 2
0
		public static ArrayList GetDonationGiftList(string username)
		{
			//get a list of item from redeemable_gift table
			ArrayList redeemableGifts = new ArrayList();
			
			IDbConnection connection = null;
			IDbCommand command = null;
			IDataReader reader = null;
			try
			{
				connection = new OdbcConnection( ConnectionString );

				connection.Open( );
				
				
				command = connection.CreateCommand( );
				
				command.CommandText = String.Format("SELECT redeemable_gift.id AS id, redeemable_gift.type_id AS type, gift_type.type_name AS name FROM redeemable_gift INNER JOIN gift_type ON redeemable_gift.type_id=gift_type.type_id WHERE redeemable_gift.account_name='{0}' ORDER BY redeemable_gift.id ASC", username);
				reader = command.ExecuteReader();
				
				while (reader.Read())
				{
					int giftId = System.Convert.ToInt32(reader["id"]);
					int giftTypeId = System.Convert.ToInt32(reader["type"]);
					string giftName = (string)reader["name"];
					DonationGift gift = new DonationGift(giftId, giftTypeId, giftName);
					redeemableGifts.Add(gift);
				}
				reader.Close();
			}
			catch( Exception e )
			{
				Console.WriteLine( "[Retrieve Donation Gift List] Error..." );
				Console.WriteLine( e );
			}
			finally
			{
				if (reader != null && !reader.IsClosed)
					reader.Close();
				if (command != null && connection != null)
				{
					command.Dispose();
					connection.Close();
				}
			}
			
			return redeemableGifts;
		}
        public static void ClaimAllDonationItems_OnCommand(CommandEventArgs e)
        {
            PlayerMobile pm       = (PlayerMobile)e.Mobile;
            BankBox      box      = pm.FindBankNoCreate();
            ArrayList    itemList = GetDonationGiftList(pm.Account.Username);

            for (int i = 0; i < itemList.Count; i++)
            {
                DonationGift giftInfo = (DonationGift)itemList[i];
                Item         gift     = RedeemGift(giftInfo.Id, pm.Account.Username) as Item;
                if (!box.TryDropItem(pm, gift, false))
                {
                    pm.AddToBackpack(gift);
                }
            }

            pm.SendMessage("{0} items has been placed in your bank box. Thank you for your donation!", itemList.Count);
        }