protected void Page_Load(object sender, EventArgs e) { if (!checkCookie()) Response.Redirect("Login.aspx"); String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString(); DatabaseHandler obj=new DatabaseHandler(); DataSet ds = obj.GetSellerId(sellerUsername); String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString(); ds = obj.GetSellerAuctionInfo(sellerId); if (ds == null) Label8.Text = "You have no auction currently in progress"; else { Table1.Visible = true; Table2.Visible = true; Label1.Text = ds.Tables[0].Rows[0]["CAR_BRAND"].ToString(); Label2.Text = ds.Tables[0].Rows[0]["CAR_MODEL_NAME"].ToString(); Label3.Text = ds.Tables[0].Rows[0]["CAR_MODEL_NUMBER"].ToString(); Label4.Text = ds.Tables[0].Rows[0]["CAR_PRICE"].ToString(); Label5.Text = ds.Tables[0].Rows[0]["AUCTION_START_TIME"].ToString(); Label6.Text = ds.Tables[0].Rows[0]["AUCTION_END_TIME"].ToString(); Label7.Text = ds.Tables[0].Rows[0]["AUCTION_BIDS"].ToString(); String auctionId = ds.Tables[0].Rows[0]["AUCTION_ID"].ToString(); if(Label7.Text!="0") { ds = obj.GetAuctionBids(auctionId); GridView1.DataSource = ds; GridView1.DataBind(); } } }
protected void Button2_Click(object sender, EventArgs e) { String bidAmount = TextBox1.Text; DatabaseHandler obj = new DatabaseHandler(); String auctionId = Session["auctionId"].ToString(); DataSet ds = obj.GetAuctionCarInfo(auctionId); int basePrice = Convert.ToInt32(ds.Tables[0].Rows[0]["CAR_BASE_PRICE"].ToString()); if (Convert.ToInt32(bidAmount) < basePrice) { Label9.Text = "Bid amount must be more than base price"; Label9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000"); } else { obj.PlaceAuctionBid(Request.Cookies["Car-Trading"]["Username"].ToString(), bidAmount); DataSet ds1 = new DataSet(); DatabaseHandler obj1 = new DatabaseHandler(); ds1 = obj.GetAuctionBids(auctionId); GridView1.DataSource = ds1; GridView1.DataBind(); Panel1.Visible = false; Label9.Text = "Bid placed !"; Label9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00FF00"); } }
protected void LinkButton2_Click(object sender, EventArgs e) { DatabaseHandler obj=new DatabaseHandler(); DataSet ds = obj.GetAuctionBids(Session["auctionId"].ToString()); long winnerBid = 0; String winnerUsername = null; foreach (DataRow dr in ds.Tables[0].Rows) { long bid = Convert.ToInt64(dr["CUSTOMER_BID_AMOUNT"].ToString()); if (winnerBid < bid) { winnerBid = bid; winnerUsername = dr["CUSTOMER_USERNAME"].ToString(); } } obj.InsertAuctionWinner(Session["auctionId"].ToString(), winnerUsername); Response.Redirect("AuctionResult.aspx?auctionId=" + Session["auctionId"].ToString()); }
protected void Page_Load(object sender, EventArgs e) { this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None; if (!checkCookie()) Response.Redirect("Login.aspx"); String auctionId = Session["auctionId"].ToString(); DatabaseHandler obj = new DatabaseHandler(); DataSet ds = obj.GetAuctionCarInfo(auctionId); Label1.Text = ds.Tables[0].Rows[0]["CAR_BRAND"].ToString(); Label2.Text = ds.Tables[0].Rows[0]["CAR_MODEL_NAME"].ToString(); Label3.Text = ds.Tables[0].Rows[0]["CAR_MODEL_NUMBER"].ToString(); Label4.Text = ds.Tables[0].Rows[0]["CAR_PRODUCTION_YEAR"].ToString(); Label5.Text = ds.Tables[0].Rows[0]["CAR_BASE_PRICE"].ToString(); Label7.Text = ds.Tables[0].Rows[0]["CAR_ENGINE"].ToString(); Label8.Text = ds.Tables[0].Rows[0]["CAR_FUEL"].ToString(); ImageButton1.ImageUrl = "~\\Car\\Front\\" + Path.GetFileName(ds.Tables[0].Rows[0]["CAR_FRONT_IMAGE"].ToString()); ImageButton2.ImageUrl = "~\\Car\\Side\\" + Path.GetFileName(ds.Tables[0].Rows[0]["CAR_SIDE_IMAGE"].ToString()); ImageButton3.ImageUrl = "~\\Car\\Rear\\" + Path.GetFileName(ds.Tables[0].Rows[0]["CAR_REAR_IMAGE"].ToString()); DataSet ds1 = new DataSet(); ds1 = obj.GetAuctionBids(auctionId); if (ds1 == null) Label9.Text = "No bids have been placed for this car yet"; else { Label9.Text = ds1.Tables[0].Rows.Count + " bid(s) placed on this car"; GridView1.DataSource = ds1; GridView1.DataBind(); } }