Esempio n. 1
0
 // check if member logged in is giving or recieving feedback
 public string isGiveorReceiveFeedback(string rentalID, string renteeID, string rentStatus)
 {
     if (rentStatus != "On-going")
     {
         Feedback feed = FeedbackDB.getFeedbackforRental(rentalID);
         if (feed.FeedbackID != null)
         {
             if (renteeID == MemberDB.getMemberbyEmail(Session["user"].ToString()).MemberID)
             {
                 return("Review Feedback");
             }
             else
             {
                 return("Feedback Given");
             }
         }
         else
         {
             if (renteeID == MemberDB.getMemberbyEmail(Session["user"].ToString()).MemberID)
             {
                 return("Give Feedback");
             }
             else
             {
                 return("No Feedback Yet");
             }
         }
     }
     else
     {
         return("");
     }
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //submit feedback for rental selected
        if (txtArea.InnerText == "" || (!rbtnNegative.Checked && !rbtnNeutral.Checked && !rbtnPositive.Checked))
        {
            return;
        }

        if (txtArea.InnerText.Length > 255)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your message cannot exceed 255 characters!')", true);
            return;
        }

        Feedback feed = FeedbackDB.getFeedbackforRental(Request["rentid"].ToString());

        if (feed.FeedbackID != null)
        {
            if (feed.ReplyFeedback != null || feed.Rental.Rentee.Email == Session["user"].ToString())
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Form resubmission is not allowed')", true);
                setFeedbackControls(true);
                txtArea.Visible   = false;
                btnSubmit.Visible = false;
            }
            else
            {
                feed.ReplyFeedback = txtArea.InnerText;
                FeedbackDB.setReplyforFeedback(feed);

                btnSubmit.Visible = false;
                txtArea.InnerText = "";
                txtArea.Visible   = false;
            }
        }
        else
        {
            feed.Comments = txtArea.InnerText;
            feed.Date     = DateTime.Now;

            if (rbtnPositive.Checked)
            {
                feed.Rating = "Positive";
            }
            else if (rbtnNeutral.Checked)
            {
                feed.Rating = "Neutral";
            }
            else if (rbtnNegative.Checked)
            {
                feed.Rating = "Negative";
            }

            feed.Rental        = RentalDB.getRentalbyID(Request["rentid"].ToString());
            feed.SubmittedBy   = feed.Rental.Rentee;
            feed.FeedbackTo    = feed.Rental.Item.Renter;
            feed.ReplyFeedback = null;

            FeedbackDB.addFeedback(feed);

            txtArea.InnerText = "";
            txtArea.Visible   = false;


            btnSubmit.Visible = false;

            setFeedbackControls(true);
        }

        Response.Redirect(Request.RawUrl);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // check if user logged in
        if (Session["user"] == null)
        {
            Session["pageRedirectAfterLogin"] = Request.RawUrl;
            Response.Redirect("Login.aspx"); // not logged in, go to login page
            return;
        }

        if (Request["rentid"] == null)               // check if rental is selected
        {
            Response.Redirect("RentalHistory.aspx"); // go to rental history page if no rental selected
            return;
        }

        // display rental and feedback information

        if (RentalDB.isRentalOfMemberPresent(Request["rentid"].ToString(), MemberDB.getMemberbyEmail(Session["user"].ToString()).MemberID))
        {
            List <Rental> rentalInfoDetails = new List <Rental>();
            Rental        rentalInfo        = RentalDB.getRentalbyID((Request["rentid"].ToString()));

            rentalInfoDetails.Add(rentalInfo);

            rptInfo.DataSource = rentalInfoDetails;
            rptInfo.DataBind();


            List <Feedback> feedbackInfo = new List <Feedback>();
            feedbackInfo.Add(FeedbackDB.getFeedbackforRental(Request["rentid"].ToString()));

            rptFeedbackInfo.DataSource = feedbackInfo;
            rptFeedbackInfo.DataBind();


            Feedback feed = FeedbackDB.getFeedbackforRental(Request["rentid"].ToString());
            // control display based on rating in feedback
            if (feed.FeedbackID != null)
            {
                if (feed.Rating == "Positive")
                {
                    rbtnPositive.Checked = true;
                }
                else if (feed.Rating == "Neutral")
                {
                    rbtnNeutral.Checked = true;
                }
                else if (feed.Rating == "Negative")
                {
                    rbtnNegative.Checked = true;
                }

                if (feed.ReplyFeedback != null)
                {
                    txtArea.Visible   = false;
                    btnSubmit.Visible = false;
                    setFeedbackControls(false);
                }
                else if (feed.Rental.Rentee.Email == Session["user"].ToString())
                {
                    txtArea.Visible   = false;
                    btnSubmit.Visible = false;
                }
            }
            else
            {
                setFeedbackControls(true);
                btnSubmit.Enabled = true;
            }
        }
        else
        {
            setFeedbackControls(false);
            btnSubmit.Visible = false;
            txtArea.Visible   = false;
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Inaccessible Page!')", true);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Session["pageRedirectAfterLogin"] = Request.RawUrl;
            Response.Redirect("Login.aspx");
            return;
        }

        if (Request["rentid"] == null)
        {
            Response.Redirect("RentalHistory.aspx");
            return;
        }



        List <Rental> rentalInfoDetails = new List <Rental>();
        Rental        rentalInfo        = RentalDB.getRentalbyID((Request["rentid"].ToString()));

        rentalInfoDetails.Add(rentalInfo);

        rptInfo.DataSource = rentalInfoDetails;
        rptInfo.DataBind();


        List <Feedback> feedbackInfo = new List <Feedback>();

        feedbackInfo.Add(FeedbackDB.getFeedbackforRental(Request["rentid"].ToString()));

        rptFeedbackInfo.DataSource = feedbackInfo;
        rptFeedbackInfo.DataBind();


        Feedback feed = FeedbackDB.getFeedbackforRental(Request["rentid"].ToString());

        if (feed.FeedbackID != null)
        {
            if (feed.Rating == "Positive")
            {
                rbtnPositive.Checked = true;
            }
            else if (feed.Rating == "Neutral")
            {
                rbtnNeutral.Checked = true;
            }
            else if (feed.Rating == "Negative")
            {
                rbtnNegative.Checked = true;
            }

            if (feed.ReplyFeedback != null)
            {
                txtArea.Visible   = false;
                btnSubmit.Visible = false;
                setFeedbackControls(false);
            }
            else if (feed.Rental.Rentee.Email == Session["user"].ToString())
            {
                txtArea.Visible   = false;
                btnSubmit.Visible = false;
            }
        }
        else
        {
            setFeedbackControls(true);
            btnSubmit.Enabled = true;
        }
    }