示例#1
0
        internal static List <Auction> GetItemsBought(User user)
        {
            List <Auction> auctions = new List <Auction>();
            string         query    = $"SELECT * FROM items WHERE bidder_id={user.Id}";

            // Prepare the connection
            MySqlConnection dbConnection = new MySqlConnection(LoadConnectionString());
            MySqlCommand    dbCommand    = new MySqlCommand(query, dbConnection);

            dbCommand.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                dbConnection.Open();
                reader = dbCommand.ExecuteReader();

                while (reader.Read())
                {
                    Auction auctionToAdd = new Auction();

                    auctionToAdd.Id          = int.Parse(reader["id"].ToString());
                    auctionToAdd.Name        = reader["name"].ToString();
                    auctionToAdd.Description = reader["description"].ToString();
                    auctionToAdd.ImgPath     = reader["img_path"].ToString();
                    auctionToAdd.End         = DateTime.Parse(reader["end"].ToString());
                    auctionToAdd.HighestBid  = float.Parse(reader["highest_bid"].ToString());

                    auctions.Add(auctionToAdd);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DB error: " + ex.Message);
            }

            return(auctions);
        }
示例#2
0
        public FullAuctionControl(Auction _auction)
        {
            InitializeComponent();

            auction = _auction;
        }