protected void Page_Load(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     String sellerId = null;
     try
     {
         sellerId = Request.QueryString["sellerId"].ToString();
         EncryptDecrypt obj = new EncryptDecrypt();
         sellerId = obj.Decrypt(HttpUtility.UrlDecode(sellerId));
     }
     catch(System.NullReferenceException exc)
     {
         String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString();
         DatabaseHandler x = new DatabaseHandler();
         DataSet ds1 = x.GetSellerId(sellerUsername);
         sellerId = ds1.Tables[0].Rows[0]["SELLER_ID"].ToString();
     }
     DatabaseHandler obj1 = new DatabaseHandler();
     DataSet ds = new DataSet();
     ds = obj1.GetSellerHomeInfo(sellerId);
     Label1.Text = ds.Tables[0].Rows[0]["SELLER_NAME"].ToString();
     Label2.Text = ds.Tables[0].Rows[0]["SELLER_COUNTRY"].ToString();
     Label3.Text = ds.Tables[0].Rows[0]["SELLER_CITY"].ToString();
     Label4.Text = ds.Tables[0].Rows[0]["SELLER_STREET"].ToString();
     Label5.Text = ds.Tables[0].Rows[0]["SELLER_PHONE_NUMBER"].ToString();
     Label6.Text = ds.Tables[0].Rows[0]["SELLER_EMAIL_ID"].ToString();
     Label7.Text = ds.Tables[0].Rows[0]["SELLER_BANK"].ToString();
     Label8.Text = ds.Tables[0].Rows[0]["SELLER_BANK_ACCOUNT_NUMBER"].ToString();
     Image1.ImageUrl = "~\\Seller ID\\" + Path.GetFileName(ds.Tables[0].Rows[0]["SELLER_ID_PROOF"].ToString());
     Image1.Width = 100;
     Image1.Height = 100;
 }
 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 Button1_Click(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     String orderId = Request.QueryString["orderId"].ToString();
     EncryptDecrypt obj = new EncryptDecrypt();
     orderId = obj.Decrypt(HttpUtility.UrlDecode(orderId));
     DatabaseHandler obj1 = new DatabaseHandler();
     String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString();
     DataSet ds = obj1.GetSellerId(sellerUsername);
     String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString();
     ds = obj1.GetSellerPendingOrderInfo(orderId);
     String customerId = ds.Tables[0].Rows[0]["CUSTOMER_ID"].ToString();
     String carId = ds.Tables[0].Rows[0]["CAR_ID"].ToString();
     String oldStock = Label5.Text;
     int oldStock1 = Convert.ToInt32(oldStock);
     int newStock = oldStock1-1;
     String newStock1 = newStock.ToString();
     obj1.DecrementCarStock(carId, newStock1);
     String paymentMode = Label10.Text;
     String customerAddr = Label9.Text;
     String orderDate = Label11.Text;
     obj1.InsertCompletedOrder(orderId, customerId, carId, sellerId, paymentMode, customerAddr, orderDate);
     Label13.Visible = true;
     Label13.Text = "Order Completed";
     Button1.Enabled = false;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString();
     DataSet ds = new DataSet();
     DatabaseHandler obj=new DatabaseHandler();
     ds = obj.GetSellerId(sellerUsername);
     String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString();
     ds = obj.GetSellerCarStock(sellerId);
     GridView1.DataSource = ds;
     GridView1.DataBind();
 }
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString();
     DataSet ds = new DataSet();
     DatabaseHandler obj=new DatabaseHandler();
     ds = obj.GetSellerId(sellerUsername);
     String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString();
     EncryptDecrypt obj1=new EncryptDecrypt();
     sellerId=HttpUtility.UrlEncode(obj1.Encrypt(sellerId));
     String carId=GridView1.SelectedRow.Cells[0].Text;
     carId=HttpUtility.UrlEncode(obj1.Encrypt(carId));
     Response.Redirect("SellerDisplayCarStockInfo.aspx?sellerId=" + sellerId + "&carId=" + carId);
 }
    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();
    }
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     String sellerId = null;
     try
     {
         Response.Redirect("SellerEditInfo.aspx?sellerId=" + Request.QueryString["sellerId"].ToString());
     }
     catch (System.NullReferenceException exc)
     {
         String sellerUsername = Request.Cookies["Car-Trading"]["Username"].ToString();
         DatabaseHandler x = new DatabaseHandler();
         DataSet ds1 = x.GetSellerId(sellerUsername);
         sellerId = ds1.Tables[0].Rows[0]["SELLER_ID"].ToString();
         EncryptDecrypt obj = new EncryptDecrypt();
         sellerId = HttpUtility.UrlEncode(obj.Encrypt(sellerId));
         Response.Redirect("SellerEditInfo.aspx?sellerId=" + sellerId);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!checkCookie())
         Response.Redirect("Login.aspx");
     this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
     DatabaseHandler obj = new DatabaseHandler();
     DataSet ds = obj.GetSellerId(Request.Cookies["Car-Trading"]["Username"].ToString());
     String sellerId = ds.Tables[0].Rows[0]["SELLER_ID"].ToString();
     ds = obj.GetSellerAuctionInfo(sellerId);
     if (ds != null)
     {
         Label1.Text = "You already have an active auction. Please remove it before adding a new one";
         Button2.Enabled = false;
     }
 }