Ejemplo n.º 1
0
 private void RenderStartPanel(DateTime startDate)
 {
     if (TimeHelper.AuctionHasStarted(startDate))
     {
         StartPanel.Visible = false;
     }
     else
     {
         StartPanel.Visible   = true;
         StartLabelValue.Text = startDate.ToString();
     }
 }
Ejemplo n.º 2
0
        private void UpdateAuctionEndsLabel()
        {
            var list      = SPContext.Current.Web.Lists[Constants.ConfigListName].Items[0];
            var endDate   = DateTime.Parse(list["EndDate"].ToString());
            var startDate = DateTime.Parse(list["StartDate"].ToString());
            var timeLeft  = TimeHelper.GetTimeLeft(endDate);

            AuctionEnds.Text = "<div class=\"auction-time\">";

            if (!TimeHelper.AuctionHasStarted(startDate) && !TimeHelper.AuctionHasEnded(endDate))
            {
                AuctionEnds.Text += string.Format("Auction Starts: <strong>{0}</strong>", startDate);
            }
            else if (TimeHelper.AuctionHasEnded(endDate))
            {
                AuctionEnds.Text += string.Format("Auction Ended: <strong>{0}</strong>", endDate);
            }
            else
            {
                AuctionEnds.Text += string.Format("Auction Ends: <strong>{0}</strong>", endDate);
            }

            AuctionEnds.Text += "</div>";
        }
Ejemplo n.º 3
0
        private void RenderBidValues(SPListItem item, DateTime startDate, DateTime endDate)
        {
            YouWonPanel.Visible        = false;
            HighestBidderPanel.Visible = false;

            if (TimeHelper.AuctionHasEnded(endDate))
            {
                StartPanel.Visible                   = false;
                StartingBidPanel.Visible             = false;
                EndLabelText.Text                    = "Ended:";
                EndLabelValue.Text                   = endDate.ToString();
                CurrentBidPanel.Visible              = false;
                PlaceBidPanel.Visible                = false;
                SPSecurityTrimmedControlName.Visible = false;

                if (item["Bidder"] != null)
                {
                    var bidderColumn     = (SPFieldUser)item.Fields.GetField("Bidder");
                    var bidderFieldValue = (SPFieldUserValue)bidderColumn.GetFieldValue(item["Bidder"].ToString());

                    if (bidderFieldValue.User.LoginName.Equals(SPContext.Current.Web.CurrentUser.LoginName))
                    {
                        YouWonPanel.Visible = true;
                    }

                    StartingBidPanel.Visible = true;
                    BidSellLabel.Text        = "Selling Price:";
                    BidSellValue.Text        = string.Format("{0:c}", item["Bid"]);
                }
            }
            else
            {
                if (TimeHelper.AuctionHasStarted(startDate))
                {
                    PlaceBidPanel.Visible = true;
                }
                else
                {
                    PlaceBidPanel.Visible = false;
                }

                StartPanel.Visible = true;

                StartingBidPanel.Visible = true;
                BidSellLabel.Text        = "Starting Bid:";
                BidSellValue.Text        = string.Format("{0:c}", item["StartingBid"]);

                var bidCountField = item["NumberOfBids"];
                if (bidCountField != null)
                {
                    var bids = Convert.ToInt32(bidCountField.ToString());
                    if (bids > 0)
                    {
                        StartingBidPanel.Visible = false;
                    }
                }

                EndLabelText.Text  = "Ends:";
                EndLabelValue.Text = endDate.ToString();

                if (item["Bidder"] != null)
                {
                    var bidderColumn     = (SPFieldUser)item.Fields.GetField("Bidder");
                    var bidderFieldValue = (SPFieldUserValue)bidderColumn.GetFieldValue(item["Bidder"].ToString());

                    // Is the current user the current bidder?
                    if (bidderFieldValue.User.LoginName.Equals(SPContext.Current.Web.CurrentUser.LoginName))
                    {
                        HighestBidderPanel.Visible = true;
                        PlaceBidPanel.Visible      = false;
                    }
                    else
                    {
                        HighestBidderPanel.Visible = false;
                        PlaceBidPanel.Visible      = true;
                    }
                }

                if (item["Bid"] != null)
                {
                    _currentBid = Convert.ToDouble(item["Bid"].ToString());
                    var bidIncrement = Convert.ToDouble(item["MinimumBidIncrement"].ToString());
                    MinimumBidLabel.Text    = string.Format("(Enter {0:c} or More to Bid)", _currentBid + bidIncrement);
                    CurrentBidPanel.Visible = true;
                    CurrentBidValue.Text    = string.Format("{0:c}", _currentBid);
                }
                else
                {
                    CurrentBidPanel.Visible = false;
                    var minBid       = Convert.ToDouble(item["StartingBid"].ToString());
                    var bidIncrement = Convert.ToDouble(item["MinimumBidIncrement"].ToString());
                    MinimumBidLabel.Text = string.Format("(Enter {0:c} or More to Bid)", minBid + bidIncrement);
                }
            }
        }