protected void Button2_Click(object sender, EventArgs e) { String brand = TextBox1.Text; String modelName = TextBox2.Text; String modelNum = TextBox3.Text; String possessionType = RadioButtonList1.Text; String yearOfPurchase = DropDownList2.Text; String carPrice = TextBox4.Text; String carEngine = TextBox5.Text; String carStock = TextBox8.Text; String fuelType = DropDownList1.Text; String frontImg = FileUpload1.PostedFile.FileName; String sideImg = FileUpload2.PostedFile.FileName; String rearImg = FileUpload3.PostedFile.FileName; String frontImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Front"); String frontImgTarget = Path.Combine(frontImgFolder, frontImg); FileUpload1.SaveAs(frontImgTarget); String sideImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Side"); String sideImgTarget = Path.Combine(sideImgFolder, sideImg); FileUpload2.SaveAs(sideImgTarget); String rearImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Rear"); String rearImgTarget = Path.Combine(rearImgFolder, rearImg); FileUpload3.SaveAs(rearImgTarget); DatabaseHandler obj = new DatabaseHandler(); String carId = "CAR_" + DateTime.Now.Ticks.ToString(); obj.InsertCar(carId, brand, modelName, modelNum, possessionType, yearOfPurchase, carPrice, carEngine, fuelType, frontImgTarget, sideImgTarget, rearImgTarget); String sellerUsername = Request.Cookies["Car-Trading"]["Username"]; DataSet ds = obj.GetSellerId(sellerUsername); String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString(); ds = obj.GetSellerName(sellerId); String sellerName = ds.Tables[0].Rows[0]["SELLER_NAME"].ToString(); obj.InsertSellerCar(sellerId, carId, carStock); Response.Write("Car Added"); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox8.Text = ""; RadioButtonList1.ClearSelection(); }
protected void Button2_Click(object sender, EventArgs e) { String brandName = TextBox1.Text; String modelName = TextBox2.Text; String modelNum=TextBox3.Text; String carYear = DropDownList2.Text; String carPrice = TextBox4.Text; String carEngine = TextBox5.Text; String carFuel = DropDownList1.Text; String frontImg = FileUpload1.PostedFile.FileName; String sideImg = FileUpload2.PostedFile.FileName; String rearImg = FileUpload3.PostedFile.FileName; String auctionStartTime=TextBox6.Text; String auctionEndTime=TextBox7.Text; String frontImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Front"); String frontImgTarget = Path.Combine(frontImgFolder, frontImg); FileUpload1.SaveAs(frontImgTarget); String sideImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Side"); String sideImgTarget = Path.Combine(sideImgFolder, sideImg); FileUpload2.SaveAs(sideImgTarget); String rearImgFolder = HttpContext.Current.Server.MapPath("~\\Car\\Rear"); String rearImgTarget = Path.Combine(rearImgFolder, rearImg); FileUpload3.SaveAs(rearImgTarget); DatabaseHandler obj = new DatabaseHandler(); DataSet ds = obj.GetSellerId(Request.Cookies["Car-Trading"]["Username"].ToString()); String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString(); String carId = "CAR_" + DateTime.Now.Ticks.ToString(); String auctionId = "AUCTION_" + DateTime.Now.Ticks.ToString(); obj.InsertCar(carId, brandName, modelName, modelNum, "Old", carYear, carPrice, carEngine, carFuel, frontImgTarget, sideImgTarget, rearImgTarget); obj.InsertAuctionInfo(auctionId, sellerId, carId, auctionStartTime, auctionEndTime, "0"); Label1.Text = "Car added for auction"; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; DropDownList1.ClearSelection(); DropDownList2.ClearSelection(); }