private bool AddOrder(OrderTracker tracker, double price) { bool matched = false; Order order = tracker.Order; if (order.IsBuy) { matched = MatchBidOrder(tracker, price, Asks); } else { matched = MatchAskOrder(tracker, price, Bids); } if (tracker.Open != 0 && !tracker.IsImmediate) { if (order.IsBuy) { Bids.Add(price, tracker); } else { Asks.Add(price, tracker); } } return(matched); }
public bool AddBid(Player player, decimal amount, out decimal currentBid) { if (!IsValidBid(amount, out currentBid)) { return(false); } GetBidPrice(player, amount); var bid = Bids.FirstOrDefault(c => c.Player.Id == player.channel.owner.playerID.steamID.m_SteamID); if (bid == null) { bid = new AuctionBid() { Player = new CachedPlayer(player), Amount = amount }; Bids.Add(bid); } else { bid.Amount = amount; } BestBid = bid; return(true); }
public IList <Quote> ToQuotes() { var quotes = new List <Quote>(); if (Asks != null) { quotes.AddRange(Asks.Take(100).Select(x => new Quote { Broker = Broker.Bitflyer, Side = QuoteSide.Ask, Price = x.Price, Volume = x.Size })); } if (Bids != null) { quotes.AddRange(Bids.Take(100).Select(x => new Quote { Broker = Broker.Bitflyer, Side = QuoteSide.Bid, Price = x.Price, Volume = x.Size })); } return(quotes); }
public List <Entry> GetEntries() { var bids = Bids .Select(pl => new Entry { Price = decimal.Parse(pl[0], CultureInfo.InvariantCulture), QtyProfile = new List <decimal> { decimal.Parse(pl[1], CultureInfo.InvariantCulture) }, Side = Side.Buy, TransactionId = FinalUpdateId }); var asks = Asks .Select(pl => new Entry { Price = decimal.Parse(pl[0], CultureInfo.InvariantCulture), QtyProfile = new List <decimal> { decimal.Parse(pl[1], CultureInfo.InvariantCulture) }, Side = Side.Sell, TransactionId = FinalUpdateId }); return(bids .Concat(asks) .ToList()); }
public async Task <IActionResult> AddBid(AuktionValues item) { var value = 0; var itemValue = item.Summa; var checkList = GetBid(item.AuktionID, "Öppen"); foreach (var values in checkList) { value = HighestValue(value, values.Summa); } if (itemValue > value) { var model = new Bids() { Summa = item.Summa, AuktionID = item.AuktionID, Budgivare = User.Identity.Name }; var json = JsonConvert.SerializeObject(model); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); var accept = await client.PostAsync("/api/Bud/1180", stringContent); } return(RedirectToAction("Auctions", "Auctions", new { id = item.AuktionID })); }
private void Dispatch(OrderBookModel orderBookModel) { Asks.Clear(); Bids.Clear(); int count = orderBookModel.Asks.Count; int takeCount = 100; orderBookModel.Asks.Skip(count - takeCount).Take(takeCount).ToList().ForEach(x => Asks.Add(new OrderBookEntry { Amount = x.Amount, DateTime = x.DateTime, Price = x.Price, GroupedPrice = x.GroupedPrice, GroupedVolume = x.GroupedVolume })); orderBookModel.Bids.Take(100).ToList().ForEach(x => Bids.Add(new OrderBookEntry { Amount = x.Amount, DateTime = x.DateTime, Price = x.Price, GroupedPrice = x.GroupedPrice, GroupedVolume = x.GroupedVolume })); }
// This return the user that can pay for an auction public User UserWhoCanPay() { // Initialize payee User payee = null; // Make sure you can deduct the money from the Top bidder Bid topbid = GetTopBid(); // Only process if there is a current top bid if (topbid != null) { float remainder = topbid.User.Money - topbid.UserBid; if (remainder >= 0) { payee = topbid.User; } else { // Loop through the bids until one can cover the cost foreach (var bid in Bids.Reverse()) { remainder = bid.User.Money - bid.UserBid; if (remainder >= 0) { payee = topbid.User; break; } } } } // Return the payee return(payee); }
public Bids GetMinimumBid() { string sql = "SELECT Bids.*, MIN(Price) FROM Bids WHERE listingid = " + Id; Bids Bid = new Bids(); DataRow row = Db.getOne(sql); if (!row.IsNull(0)) { var _listingId = row["listingid"].ToString(); int listingId; int.TryParse(_listingId, out listingId); Bid.Listing = new Listings(); Bid.Listing.Id = listingId; var _userId = row["userid"].ToString(); int userId; int.TryParse(_userId, out userId); Bid.User = new Users(); Bid.User.Id = userId; var _price = row["price"].ToString(); int price; int.TryParse(_price, out price); Bid.Price = price; var dateTime = row["datetime"].ToString(); Bid.DateTime = Convert.ToDateTime(dateTime); } return(Bid); }
/// <summary> /// Reserved for internal use. /// </summary> protected override void ReconstructSubTargets() { GenderTarget = new GenderTarget() { Bids = Bids.Select(t => t.GenderTargetBid).ToList() }; }
public void ProcessTransfers() { foreach (var playerBidList in Bids.Values) { var highestBid = playerBidList. Where(b => b.PurchasingTeam.Players.Count < Configuration.MaxSquadSize). OrderByDescending(b => b.BidAmount). FirstOrDefault(); if (highestBid == null) { continue; } var player = highestBid.Player; if (highestBid.BidAmount < player.ReleaseValue) { continue; // Winning bid isn't high enough } // TODO: purchased players still existing in other team's match days. highestBid.PurchasingTeam.Balance -= highestBid.BidAmount; highestBid.SellingTeam.Balance += highestBid.BidAmount; highestBid.SellingTeam.Players.Remove(player); highestBid.PurchasingTeam.Players.Add(player); player.TeamName = highestBid.PurchasingTeam.TeamName; player.Number = highestBid.PlayerNumber; player.ResetPlayerIndex(); } Bids.Clear(); }
/// <summary> /// Reserved for internal use. /// </summary> protected override void ReconstructSubTargets() { AgeTarget = new AgeTarget { Bids = Bids.Select(t => t.AgeTargetBid).ToList() }; }
public void SortBidsAndAsks() { // descending Bids.Sort((x1, x2) => { if (x1.Price > x2.Price) { return(-1); } else if (x1.Price < x2.Price) { return(1); } return(0); }); // ascending Asks.Sort((x1, x2) => { if (x1.Price > x2.Price) { return(1); } else if (x1.Price < x2.Price) { return(-1); } return(0); }); }
public void SubmitBid(Bid bid) { if (bid.BidAmount > bid.PurchasingTeam.Balance - TeamBids[bid.PurchasingTeam].Sum(b => b.BidAmount)) { return; // Team can't afford it (including existing potentially successful bids) } if (bid.PurchasingTeam.Players.Any(p => p.Number == bid.PlayerNumber)) { return; // That number is already taken } if (TeamBids[bid.PurchasingTeam].Any(b => b.PlayerNumber == bid.PlayerNumber)) { return; // One team putting in two bids for the same team number } if (!Bids.ContainsKey(bid.Player.Index)) { Bids[bid.Player.Index] = new List <Bid>(); } if (Bids[bid.Player.Index].Any(b => b.PurchasingTeam == bid.PurchasingTeam)) { return; // Already put in one bid, ignore subsequent bids for this week } Bids[bid.Player.Index].Add(bid); }
protected void SubmitBid_Click(object sender, EventArgs e) { jobId = (int)Session["theJob"]; currentWorker = (Workers)Session["user"]; int giveBid = Convert.ToInt32(Bidtxtbox.Text); int lowestBid = DataFactory.GetLowestBid(jobId); if (giveBid <= lowestBid || giveBid <= 0 || lowestBid == 0) { Bids bid = new Bids() { Bid = Convert.ToInt32(Bidtxtbox.Text), Id_Job = theJob.Id_Job, Id_Worker = currentWorker.Id_Worker }; DataFactory.AddBid(bid); DataFactory.UpdateCurrentbid(jobId, giveBid); Response.Redirect("ViewJob.aspx"); } if (giveBid >= lowestBid) { ErrorInBidLbl.Text = "Ditt bud är för högt, det ligger redan ett lägre bud på detta jobb!"; } }
public OrderBook Convert(TradingPair pair) { var convertedBids = Bids .Select( x => new OrderBookEntry( Conversion.ToDecimalInvariant(x[1]), Conversion.ToDecimalInvariant(x[0]), (long)Timestamp, ExchangeType.BitStamp)) .ToList(); var convertedAsks = Asks .Select( x => new OrderBookEntry( Conversion.ToDecimalInvariant(x[1]), Conversion.ToDecimalInvariant(x[0]), (long)Timestamp, ExchangeType.BitStamp)) .ToList(); return(new OrderBook( convertedBids, convertedAsks, Timestamp.ToDateTimeUTC(), ExchangeType.BitStamp, pair)); }
public void StartAuction(int auctionTime) { Bids.Clear(); AuctionTime = auctionTime; Running = true; StartTime = DateTime.Now; }
public void AddOrUpdateOrders(IEnumerable <OrderBookItem> newOrders) { foreach (var order in newOrders) { if (order.IsBuy) { if (Bids.TryGetValue(order.Id, out var storedOrder) && order.Price == 0) // Updates from some exchanges don't have price { order.Price = storedOrder.Price; } InvertSize(order); Bids[order.Id] = order; } else { if (Asks.TryGetValue(order.Id, out var storedOrder) && order.Price == 0) // Updates from some exchanges don't have price { order.Price = storedOrder.Price; } InvertSize(order); Asks[order.Id] = order; } } }
public override string ToString() { string res = "\n"; res += string.Format("\n{0,-27} {1, -27}\n", "===BIDS===", "===ASKS==="); res += string.Format("\n{0,-8} {1,-7} {2, -10} || {0,-8} {1,-7} {2,-10}\n", "Exchange", "Price", "Amount", ""); using (var bidEnumerator = Bids.GetEnumerator()) using (var askEnumerator = Asks.GetEnumerator()) { var nextBid = bidEnumerator.MoveNext(); var nextAsk = askEnumerator.MoveNext(); while (nextBid || nextAsk) { string nextBidExchange = (nextBid) ? bidEnumerator.Current.ExchangeID.ToString() : ""; string nextBidPrice = (nextBid) ? bidEnumerator.Current.Price.ToString() : ""; string nextBidAmount = (nextBid) ? bidEnumerator.Current.RemainingVolume.ToString("N4") : ""; string nextAskExchange = (nextAsk) ? askEnumerator.Current.ExchangeID.ToString() : ""; string nextAskPrice = (nextAsk) ? askEnumerator.Current.Price.ToString() : ""; string nextAskAmount = (nextAsk) ? askEnumerator.Current.RemainingVolume.ToString("N4") : ""; res += string.Format("\n{0,-8} {1,-7} {2,-10} || {3,-8} {4,-7} {5,-10}\n", nextBidExchange, nextBidPrice, nextBidAmount, nextAskExchange, nextAskPrice, nextAskAmount); nextBid = bidEnumerator.MoveNext(); nextAsk = askEnumerator.MoveNext(); } } return(res); }
public SynthOrderBook(AssetPair assetPair, IReadOnlyList <OrderBook> originalOrderBooks) { AssetPair = assetPair; OriginalOrderBooks = originalOrderBooks; BestBid = Bids.FirstOrDefault(); BestAsk = Asks.FirstOrDefault(); }
internal void AddExec(Exec exec) { int execQty = exec.qty; if (exec.side == Side.Bid) { for (int i = Bids.Count - 1; i >= 0; i--) { if (Bids[i].Qty <= execQty) { execQty -= Bids[i].Qty; Bids.RemoveAt(i); } } } if (exec.side == Side.Ask) { for (int i = Asks.Count - 1; i >= 0; i--) { if (Asks[i].Qty <= execQty) { execQty -= Asks[i].Qty; Asks.RemoveAt(i); } } } }
public List <AuctionControlData> GetSelling(Guid userId) { var auctions = (from a in db.Auctions where (!a.Finalized && a.EndDate > DateTime.Now) && a.OwnerId == userId join u in db.aspnet_Users on a.OwnerId equals u.UserId join t in db.Bidders on a.Id equals t.AuctionId into Bids join s in db.Shipments on a.ShipmentId equals s.Id //join i in db.Images on a.Id equals i.AuctionId select new AuctionControlData() { Title = a.Title, AuctionId = a.Id, //Image = i.ImageData, BuyItNowPrice = a.BuyItNowPrice, BestPrice = Bids.Max(p => p.Price).ToString().Length == 0 ? 0 : Bids.Max(p => p.Price), BestPriceUsername = (from o in db.aspnet_Users where o.UserId == Bids.OrderByDescending(p => p.Price).FirstOrDefault().BidderId select o).FirstOrDefault().UserName,//o.UserName, MinimumPrice = a.MinimumPrice, SellerName = u.UserName, SellerId = a.OwnerId, ShipmentName = s.Name, ShipmentId = a.ShipmentId, ShipmentPrice = s.Price, EndDate = a.EndDate, OffersNum = Bids.Count(), Views = a.Views }).ToList(); return(auctions); }
public override Bid GetWinnerBid() { if (Bids.Count == 0) { return(null); } else { //Steps //1 : I only send push requests that are valid //2 : Find all containers migration costs average var avgCost = Bids.Select(x => x.ContainerId).Select(x => Containers[x].MigrationCost).Average(); var NewBids = Bids.Where(x => Containers[x.ContainerId].MigrationCost >= avgCost).ToList(); ForsmanBid winner = NewBids.First(); var lds = ToBeHostLoadInfos(NewBids[0].BiddingHost, NewBids[0].NewLoadInfo); var bentropy = AccountingHelpers.CalculateEntropy(lds); //3: Find the new entropy after migration for (int i = 1; i < NewBids.Count; i++) { lds = ToBeHostLoadInfos(NewBids[i].BiddingHost, NewBids[i].NewLoadInfo); var entropy = AccountingHelpers.CalculateEntropy(lds); if (entropy > bentropy) { bentropy = entropy; winner = NewBids[i]; } } return(winner); } }
/// <summary> /// Reserved for internal use. /// </summary> protected override void ReconstructSubTargets() { DeviceOsTarget = new DeviceOSTarget() { Bids = Bids.Select(t => t.DeviceOsTargetBid).ToList() }; }
public OrderBook UpdateOrder(Order mmsOrder) { if (mmsOrder.MarketSide == MarketSide.Ask) { if (Asks.All(askOrder => askOrder.MMSId != mmsOrder.MMSId)) { throw new ApplicationException("Ask Order changed received, but no existing order found: {0}".FormatAs(mmsOrder)); } // remove var newAsks = Asks.Where(o => o.MMSId != mmsOrder.MMSId).ToList(); // add newAsks.Add(mmsOrder); return(new OrderBook(Bids, newAsks, Exchange, Pair, Time)); } else { if (Bids.All(bidOrder => bidOrder.MMSId != mmsOrder.MMSId)) { throw new ApplicationException("Bid Order changed received, but no existing order found: {0}".FormatAs(mmsOrder)); } // remove var newBids = Bids.Where(o => o.MMSId != mmsOrder.MMSId).ToList(); // add newBids.Add(mmsOrder); return(new OrderBook(newBids, Asks, Exchange, Pair, Time)); } }
public OrderBook UpdatePair(Pair pair) { var bids = Bids.Select(o => o.UpdatePair(pair)); var asks = Asks.Select(o => o.UpdatePair(pair)); return(new OrderBook(bids, asks, Exchange, pair, Time)); }
/// <summary> /// Reserved for internal use. /// </summary> protected override void ReconstructSubTargets() { DayTimeTarget = new DayTimeTarget() { Bids = Bids.Select(t => t.DayTimeTargetBid).ToList() }; }
public OrderBook AddOrder(Order mmsOrder) { if (mmsOrder.MarketSide == MarketSide.Ask) { if (Asks.Any(askOrder => askOrder.MMSId == mmsOrder.MMSId)) { throw new ApplicationException("Ask Order added received, but existing order found: {0}".FormatAs(mmsOrder)); } List <Order> newAsks = Asks.ToList(); newAsks.Add(mmsOrder); return(new OrderBook(Bids, newAsks, Exchange, Pair, Time)); } else { if (Bids.Any(bidOrder => bidOrder.MMSId == mmsOrder.MMSId)) { throw new ApplicationException("Bid Order added received, but existing order found: {0}".FormatAs(mmsOrder)); } List <Order> newBids = Bids.ToList(); newBids.Add(mmsOrder); return(new OrderBook(newBids, Asks, Exchange, Pair, Time)); } }
public OrderBook Convert(TradingPair pair) { var convertedBids = Bids.Select( x => new OrderBookEntry( Conversion.ToDecimalInvariant(x.Amount), Conversion.ToDecimalInvariant(x.Price), (long)x.Timestamp, ExchangeType.Bitfinex)) .ToList(); var convertedAsks = Asks.Select( x => new OrderBookEntry( Conversion.ToDecimalInvariant(x.Amount), Conversion.ToDecimalInvariant(x.Price), (long)x.Timestamp, ExchangeType.Bitfinex)) .ToList(); return(new OrderBook( convertedBids, convertedAsks, DateTime.UtcNow, ExchangeType.Bitfinex, pair)); }
public List <Bids> ChanceToWin() { string sql = @"SELECT * FROM LISTINGS WHERE LastDate >= '" + DateTime.Today.ToString("yyyy-MM-dd") + "'"; DataTable ListingTable = Db.getAll(sql); List <Bids> chanceToWin = new List <Bids>(); foreach (DataRow row in ListingTable.Rows) { var listingId = row["id"].ToString(); sql = "SELECT MIN(Price) as min FROM BIDS WHERE listingid = " + listingId; DataRow MinimumPrice = Db.getOne(sql); var _minimumPrice = MinimumPrice["min"].ToString(); if (_minimumPrice == "") { _minimumPrice = "0"; } sql = "SELECT * FROM Bids WHERE listingid = " + listingId + " and UserId = " + Id + " and Price = " + _minimumPrice; DataRow chanceToWinRow = Db.getOne(sql); if (chanceToWinRow.ItemArray.Count() > 0) { sql = "SELECT * FROM Bids Where listingId = " + listingId + " and UserId = " + Id; DataRow bidrow = Db.getOne(sql); var _bidId = bidrow["id"].ToString(); int bidId = Convert.ToInt32(_bidId); Bids bid = new Bids(); bid.Id = bidId; bid.Get(); chanceToWin.Add(bid); } } return(chanceToWin); }
public AuktionBudViewModel([NotNull] AuktionModel auktion, [NotNull, ItemNotNull] List <BudModel> bud) { AuktionID = auktion.AuktionID; Titel = auktion.Titel; Beskrivning = auktion.Beskrivning; StartDatum = auktion.StartDatum; SlutDatum = auktion.SlutDatum; Utropspris = auktion.Utropspris ?? 0; SkapadAv = auktion.SkapadAv; Gruppkod = auktion.Gruppkod; Bids = bud.Select(b => new BudViewModel(b)).ToList(); MaxedPrice = Bids.Count == 0 ? Utropspris : Bids.Max(b => b.Summa); HighestBid = Bids.FirstOrDefault(); DateTime now = DateTime.Now; TimeUntilEnd = SlutDatum - now; TimeUntilEndFormatted = DateTimeHelpers.FormatRemainingTime(SlutDatum); TimeSinceStart = now - StartDatum; TimeSinceStartFormatted = DateTimeHelpers.FormatRemainingTime(StartDatum); IsClosed = SlutDatum < now; }
private void ValidateNewBid(Bid bid) { string errorMessage = ""; DateTime biddingStartTime = GetNearestBidStatTime(bid.CreatedDate); DateTime biddingEndTime = biddingStartTime.AddSeconds(BidTimeDurationSeconds); if (bid.CreatedDate < biddingStartTime || bid.CreatedDate > biddingEndTime) { errorMessage += "Invalid time for bidding."; } if (bid.Amount < 1 || bid.Amount > MaxBidAmount) { errorMessage += "\nInvalid bid amount."; } if (bid.User == null) { errorMessage += "\nCurrent user doesn't participate in specified loan."; } if (Bids.Any(x => x.User.Id == bid.User.Id && x.CreatedDate.Date == biddingStartTime.Date)) { errorMessage += "\nCurrent user already has made a bid."; } if (!string.IsNullOrEmpty(errorMessage)) { throw new BusinessLogicException(errorMessage); } }
protected void btnmodify_Click(object sender, EventArgs e) { Bids bid = new Bids(); bid._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); bid._clientid = new Guid(Session["id"].ToString()); bid._amount = modifyamount.Text; bid.ModifyBid(); }
public static void AddBid(Bids bid) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { db.Bids.Add(bid); db.SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { divSuccess.Visible = false; divError.Visible = false; Bids bid = new Bids(); bid._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); Repeater1.DataSource = bid.RetrieveBids(); Repeater1.DataBind(); }
public ActionResult Create(Bids.Models.Member member) { if (ModelState.IsValid) { //db.Members.Add(member); //db.SaveChanges(); unitOfWork.MemberRepository.Insert(member); unitOfWork.Save(); return RedirectToAction("Index"); } return View(member); }
protected void btnBid_Click(object sender, EventArgs e) { //Validate the session if (Session["id"] == null || Session["id"].Equals("")) { Server.Transfer("/Login.aspx"); } string productid = Request.QueryString.Get("ProductID").ToString(); Bids bid = new Bids(); bid._bidid = Guid.NewGuid(); bid._productid = new Guid(productid); bid._clientid = new Guid(Session["id"].ToString()); bid._amount = amounttxt.Text; bid._status = "Pending"; bid.SaveBid(); btnBid.Enabled = false; btnBid.Text = "Thank You!"; }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { hfbidid.Value = e.CommandArgument.ToString(); //Get the status and bidId string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' }); string bidId = commandArgs[0]; string bidStatus = commandArgs[1]; if (e.CommandName == "accept") { //Validate the current status if (bidStatus == "Accepted") { divError.Visible = true; divSuccess.Visible = false; lblError.Text = "This bid was already accepted before"; } //If there is another bid accepted. It cannot be accepted. Bids bid = new Bids(); bid._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); if(this.bidStatusExist("Accepted", bid)){ divError.Visible = true; divSuccess.Visible = false; lblError.Text = "There is another bid currently accepted for this product."; } else { bid._bidid = new Guid(bidId); bid.UpdateStatus(); //Refresh the data Repeater1.DataSource = bid.RetrieveBids(); Repeater1.DataBind(); divSuccess.Visible = true; divError.Visible = false; lblSuccess.Text = "The bid was accepted correctly"; } } else if (e.CommandName == "reject") { //Validate the status if (bidStatus == "Rejected") { divError.Visible = true; divSuccess.Visible = false; lblError.Text = "This bid was already rejected before"; } else { Bids bid = new Bids(); bid._bidid = new Guid(bidId); bid._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); bid.RejectBid(); //Refresh the data Repeater1.DataSource = bid.RetrieveBids(); Repeater1.DataBind(); divSuccess.Visible = true; divError.Visible = false; lblSuccess.Text = "The bid was rejected correctly"; } } }
/// <summary> /// Initializes a new instance of the <see cref="Bids.Enumerator"/> class. /// </summary> /// <param name='bids'> /// Bids. /// </param> public Enumerator(Bids bids) { this.bids = bids; i = -1; }
protected void Page_Load(object sender, EventArgs e) { divSuccess.Visible = false; divError.Visible = false; if (!Page.IsPostBack) { Products product = new Products(); product._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); productInfoDt = product.RetrieveProductInfo(); lblProductName.Text = productInfoDt.Rows[0]["name"].ToString(); lblPrice.Text = productInfoDt.Rows[0]["price"].ToString(); lblDescription.Text = productInfoDt.Rows[0]["description"].ToString(); imgMainPicture.ImageUrl = productInfoDt.Rows[0]["photo1"].ToString(); imgPictureOne.ImageUrl = productInfoDt.Rows[0]["photo1"].ToString(); imgPictureTwo.ImageUrl = productInfoDt.Rows[0]["photo2"].ToString(); imgPictureThree.ImageUrl = productInfoDt.Rows[0]["photo3"].ToString(); imgPictureFour.ImageUrl = productInfoDt.Rows[0]["photo4"].ToString(); Bids bid = new Bids(); bid._productid = new Guid(Request.QueryString.Get("ProductID").ToString()); bid._clientid = new Guid(Session["id"].ToString()); BidsStatusDt = bid.RetrieveBidsStatus(); if (BidsStatusDt.Rows.Count == 0) { newbid.Visible = true; modify.Visible = false; changebid.Visible = false; checkout.Visible = false; Remove.Visible = false; } else if (BidsStatusDt.Rows[0]["status"].ToString() == "Pending") { newbid.Visible = false; modify.Visible = true; modifyamount.Text = BidsStatusDt.Rows[0]["amount"].ToString(); changebid.Visible = false; checkout.Visible = false; Remove.Visible = false; } else if (BidsStatusDt.Rows[0]["status"].ToString() == "Rejected") { newbid.Visible = false; modify.Visible = false; changebid.Visible = true; checkout.Visible = false; Remove.Visible = false; } else if (BidsStatusDt.Rows[0]["status"].ToString() == "Accepted") { newbid.Visible = false; modify.Visible = false; changebid.Visible = false; checkout.Visible = true; Remove.Visible = false; } else if (BidsStatusDt.Rows[0]["status"].ToString() == "Sold") { newbid.Visible = false; modify.Visible = false; changebid.Visible = false; checkout.Visible = false; Remove.Visible = true; } } }
private bool bidStatusExist(string status, Bids bid) { bool exists = false; DataTable bids = bid.RetrieveBids(); foreach (DataRow row in bids.Rows) { string bidStatus = row["status"].ToString(); if (bidStatus == status) { exists = true; break; } } return exists; }