protected void btnUpload_Click(object sender, EventArgs e)
        {
            string imageName = "";

            //Creates a unique name for and image so there is no clash
            if (fileUploadImage.HasFile)
            {
                imageName = Guid.NewGuid().ToString() + "." + fileUploadImage.FileName.Split('.')[1].ToString();
                string imgPath = Server.MapPath("~/CarImages/" + imageName.ToString());
                fileUploadImage.SaveAs(imgPath);
            }

            //Creates new instance of the webservice
            var service = new BiddingService.BiddingDataService();
            //Calls method and executes query
            var x = service.SellCar(txtBoxDesc.Text, txtBoxBrand.Text, txtBoxModel.Text,
                                    txtBoxYear.Text, Int32.Parse(txtBoxStartBid.Text), Int32.Parse(txtBoxKilometer.Text),
                                    txtBoxClosingDate.Text, Int32.Parse(txtBoxValue.Text), imageName);

            if (x == "Success!")
            {
                //Redirects to page
                Response.Redirect("~/CarsAvailable.aspx");
            }
            else
            {
                //Reports erro to the user
                lblError.Text = "Error uploading your car!";
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //Creates a new instance of the webservice
            var service = new BiddingService.BiddingDataService();
            //Calls method and executes query
            var result = service.ChangeDetails(txtBoxName.Text, txtBoxSurname.Text, txtBoxEmail.Text,
                                               txtBoxQuestion.Text, txtBoxAnswer.Text, txtBoxPass.Text);

            if (result == true)
            {
                //Redirects you to the Home page
                Response.Redirect("~/Default.aspx");
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            //Creates a new instance of the webservice
            var service = new BiddingService.BiddingDataService();

            //Calls method and executes query
            var x = service.ForgottenPassword(txtBoxRegisterNewPass.Text, txtBoxRegisterQuestion.Text,
                                              txtBoxRegisterAnswer.Text, txtBxRegisterEmail.Text);

            if (x == "Success!")
            {
                //Redirects to page
                Response.Redirect("~/Default.aspx");
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            //Creates a new instance of the webservice
            var service = new BiddingService.BiddingDataService();

            //Calls method and executes query
            var result = service.AddUser(txtBoxName.Text, txtBoxSurname.Text, txtBoxEmail.Text, txtBoxPass.Text,
                                         txtBoxQuestion.Text, txtDate.Text, txtBoxAnswer.Text);

            if (result == "Successful")
            {
                Response.Redirect("~/CarsAvailable.aspx");
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Example #5
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            var service = new BiddingService.BiddingDataService();
            var result  = service.Login(txtBoxLoginEmail.Text, txtBoxLoginPassword.Text);

            if (result == "Success!")
            {
                //Creates a session cookie
                FormsAuthentication.SetAuthCookie(txtBoxLoginEmail.Text, false);

                //Declares a session to greet user
                Session["Username"] = service.UserName(txtBoxLoginEmail.Text, txtBoxLoginPassword.Text);
                //Declares a session so the user may bid
                Session["UserId"] = service.GetUserID(txtBoxLoginEmail.Text, txtBoxLoginPassword.Text);
                //Redirects you to the Home page
                Response.Redirect("~/CarsBidded.aspx");
            }
            else
            {
                //Reports an error
                lblError.Text = "Your creditials are incorrect!";
            }
        }
        protected void btnBid_Click(object sender, EventArgs e)
        {
            //Parsing all inputs as intergers
            int User = Int32.Parse(txtBoxUserID.Text);
            int Car  = Int32.Parse(txtBoxCarID.Text);
            int Bid  = Int32.Parse(txtBoxBid.Text);
            //Calling the current user logged in
            string Name = Session["Username"] == null ? string.Empty : Session["Username"].ToString();

            //Establishing a connection.
            var service = new BiddingService.BiddingDataService();

            //Executes query
            var result = service.BidCar(User, Car, Bid);

            if (result == 1)
            {
                //Writes to the log file located in /LogFiles/Bidding Values.text
                Log logger = new Log();
                logger.WriteToFile(User, Car, Bid, Name);
                Response.Redirect("~/CarsBidded.aspx");
            }
        }
 protected void btnSignIn_Click(object sender, EventArgs e)
 {
     var service = new BiddingService.BiddingDataService();
     //var result = service.login(txtBoxEmail.Text,txtBoxLoginPassword.Text);
 }