private void ParseRowCommand(GridView view, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[1] { "auction" }; if (commands.Contains(e.CommandName)) { int index = e.GetSelectedRowIndex() % view.PageSize; GridViewRow row = view.Rows[index]; string Id = (row.Cells[0].Text.Trim()); var Auction = new BannerAuction(Convert.ToInt32(Id)); if (e.CommandName == "auction") { AuctionsPanel.Visible = false; BiddingPanel.Visible = true; target = Auction; GenerateBiddingPanel(view); DimensionsPlaceHolder.Controls.Clear(); } } }
private void GenerateBiddingPanel(GridView view) { PlaceBidPanel.Visible = true; BannerAuction target = this.target; //Generate DDL var where = TableHelper.MakeDictionary("CreatorUsername", Member.CurrentName); where.Add("Status", (int)AdvertStatus.Active); where.Add("BannerAdvertDimensionId", (int)target.BannerType.Id); availableOptions = TableHelper.SelectRows <BannerAdvert>(where); //if 0, redirect if (availableOptions.Count == 0) { Response.Redirect(String.Format("~/user/advert/bannersb.aspx?red=new&view={0}", CurrentSelectedDimemsions.Id)); } //Generate Button BidButton.Text = U4000.PLACEBID + ": " + target.NextMinBidValue.ToString(); BindDataToDDL(); //Generate fields GenerateBidFields(target); //Check if we have the best bid if (target.HighestBid != null && target.HighestBid.Username == Member.CurrentName) { PlaceBidPanel.Visible = false; } }
protected void AuctionGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { BannerAuction Auction = new BannerAuction(Convert.ToInt32(e.Row.Cells[0].Text)); // 1 - Display Time // 2 - Highest Bid // 3 - Auction closes // 4 - Button e.Row.Cells[1].Text = Auction.DisplayTime; e.Row.Cells[2].Text = Auction.HighestBidString; e.Row.Cells[3].Text = Auction.Closes; if (Auction.Status != BannerAuctionStatus.Opened) { e.Row.Cells[4].Controls[1].Visible = false; } else { ((LiteralControl)e.Row.Cells[4].Controls[2]).Text = " " + U4000.AUCTION; } } }
protected void BidButton_Click(object sender, EventArgs e) { BannerAuction target = this.target; ErrPanel.Visible = false; SucPanel.Visible = false; try { BannerAdvert advert = new BannerAdvert(Convert.ToInt32(ddlOptions.SelectedValue)); Member User = Member.Current; Money bidValue = target.NextMinBidValue; //Status check if (target.Status != BannerAuctionStatus.Opened) { throw new MsgException(U4000.AUCTIONCLOSED); } //Balance check if (bidValue > User.PurchaseBalance) { throw new MsgException(L1.NOTENOUGHFUNDS); } //Take money User.SubtractFromPurchaseBalance(bidValue, "Banner bid"); User.SaveBalances(); //Add bid BannerBid bid = new BannerBid(); bid.BidValue = bidValue; bid.BannerAdvertId = advert.Id; bid.BannerAuctionId = target.Id; bid.Username = User.Name; BannerAuctionManager.AddBid(bid, target, User); //Refresh bids field GenerateBidFields(target); PlaceBidPanel.Visible = false; SucPanel.Visible = true; SucMess.Text = U4000.BIDPLACED; AuctionGrid.DataBind(); } catch (MsgException ex) { ErrPanel.Visible = true; ErrMess.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); } }
private void GenerateBidFields(BannerAuction target) { var bids = target.GetBids(); for (int i = 0; i < bids.Count; i++) { bool IsPaid = i == 0 ? false : true; if (i < BannerAuctionManager.DisplayedNormalBannerNumber) { IsPaid = false; } BidsLiteral.Text += bids[i].ToString(i + 1, IsPaid); } }