protected void btnSubmit_Click(object sender, EventArgs e) { if (tbxMessage.Text.Length > 255) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your message cannot exceed 255 characters!')", true); return; } Dispute dis = DisputeDB.getDisputeforRental(Request["rentid"].ToString()); if (dis.Status == "Resolved") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your page has expired since your disputer has closed the case')", true); rptMessages.DataBind(); setChatControls(false); tbxMessage.Text = ""; return; } if (tbxMessage.Text != "") { if (dis.DisputeID == null) { if (ddlReason.SelectedValue != "") { dis = new Dispute(); dis.Reason = ddlReason.SelectedItem.Value; dis.Date = DateTime.Now; dis.Rental = RentalDB.getRentalbyID(Request["rentid"].ToString()); dis.Status = "Pending"; dis.SubmittedBy = MemberDB.getMemberbyEmail(Session["user"].ToString()); DisputeDB.addDispute(dis); ddlReason.Enabled = false; } else { return; } } dis = DisputeDB.getDisputeforRental(Request["rentid"].ToString()); MessageDispute msgDis = new MessageDispute(); msgDis.Date = DateTime.Now; msgDis.Dispute = dis; msgDis.Member = MemberDB.getMemberbyEmail(Session["user"].ToString()); msgDis.Staff = new Staff(null, null, null, null, 0, null, new DateTime()); msgDis.Reply = tbxMessage.Text; MessageDisputeDB.addMsgDispute(msgDis); tbxMessage.Text = ""; rptMessages.DataSource = MessageDisputeDB.getMsgforDispute(dis.DisputeID); rptMessages.DataBind(); } }
protected void btnResolve_Click(object sender, EventArgs e) { Dispute dis = DisputeDB.getDisputeforRental(Request["rentid"].ToString()); if (dis.Status == "Resolved") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your page has expired since your disputer has closed the case')", true); rptMessages.DataBind(); setChatControls(false); tbxMessage.Text = ""; return; } //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirmMessage", "confirm('You are about to close the dispute case. As the action is irreversible, are you sure?')", true); DisputeDB.resolveDispute(dis.DisputeID); MessageDispute msgDis = new MessageDispute(); msgDis.Date = DateTime.Now; msgDis.Dispute = dis; msgDis.Member = MemberDB.getMemberbyEmail(Session["user"].ToString()); msgDis.Staff = new Staff(null, null, null, null, 0, null, new DateTime()); msgDis.Reply = "==============The Dispute has been closed================"; MessageDisputeDB.addMsgDispute(msgDis); setChatControls(false); }
protected void Page_Load(object sender, EventArgs e) { // user has selected a dispute to be viewed. this page displays messages pertaining the dispute selected // checks if user is logged in if (Session["admin"] == null) // if not logged in, redirect to login page { Response.Redirect("Login.aspx"); return; } // check if a dispute is selected if (Request.QueryString["disputeID"] == null) // if nothing is selected, redirect back to DisputeList page { Response.Redirect("~/DisputeList.aspx"); } else // if a dispute is selected, display the correct messages for the dispute selected { List <MessageDispute> disputeMsg = MessageDisputeDB.getMsgforDispute(Request.QueryString["disputeID"].ToString()); rptMessages.DataSource = disputeMsg; rptMessages.DataBind(); List <Dispute> disputeMembers = new List <Dispute>(); Dispute dis = DisputeDB.getDisputeybyID(Request.QueryString["disputeID"].ToString()); if (dis.Status == "Resolved") { setChatControls(false); } else { setChatControls(true); } disputeMembers.Add(dis); Member targetMember = new Member(); if (dis.SubmittedBy.MemberID != dis.Rental.Rentee.MemberID) { targetMember = dis.Rental.Rentee; } else { targetMember = dis.Rental.Item.Renter; } btnBanDisputer.Text = "Ban " + dis.SubmittedBy.Name.Substring(0, dis.SubmittedBy.Name.IndexOf(" ")); btnBanDisputed.Text = "Ban " + targetMember.Name.Substring(0, targetMember.Name.IndexOf(" ")); rptMemberInfoRedirect.DataSource = disputeMembers; rptMemberInfoRedirect.DataBind(); } }
// posts message and updates database of the message posted private void submitMessage(string message, Dispute dis) { MessageDispute msgDis = new MessageDispute(); msgDis.Date = DateTime.Now; msgDis.Dispute = dis; msgDis.Member = new Member(null, null, null, 0, null, null, 0, null, null, new DateTime(), new DateTime(), null, new DateTime(), null, null); msgDis.Staff = StaffDB.getStaffbyEmail(Session["admin"].ToString()); msgDis.Reply = message; MessageDisputeDB.addMsgDispute(msgDis); }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Session["pageRedirectAfterLogin"] = Request.RawUrl; Response.Redirect("Login.aspx"); return; } if (Request["rentid"].ToString() == null) { Response.Redirect("Default.aspx"); return; } List <Rental> rentalInfoDetails = new List <Rental>(); Rental rentalInfo = RentalDB.getRentalbyID(Request["rentid"].ToString()); rentalInfoDetails.Add(rentalInfo); rptInfo.DataSource = rentalInfoDetails; rptInfo.DataBind(); Session["user"] = Session["user"]; Dispute dis = DisputeDB.getDisputeforRental(Request["rentid"].ToString()); if (dis.DisputeID != null) { ddlReason.SelectedValue = dis.Reason; ddlReason.Enabled = false; if (MemberDB.getMemberbyID(dis.SubmittedBy.MemberID).Email == Session["user"].ToString()) { btnResolve.Visible = true; } if (dis.Status == "Resolved") { btnResolve.Enabled = false; tbxMessage.Enabled = false; btnSubmit.Enabled = false; } rptMessages.DataSource = MessageDisputeDB.getMsgforDispute(dis.DisputeID); rptMessages.DataBind(); } else { if (RentalDB.getRentalbyID(Request["rentid"].ToString()).Rentee.Email == Session["user"].ToString()) { for (int x = 1; x < 5; x++) { ddlReason.Items[x].Enabled = false; } } else if (RentalDB.getRentalbyID(Request["rentid"].ToString()).Item.Renter.Email == Session["user"].ToString()) { for (int x = 1; x < ddlReason.Items.Count; x++) { ddlReason.Items[x].Enabled = false; } } } }
protected void Page_Load(object sender, EventArgs e) { // checks if user is logged in if (Session["user"] == null) // user is not logged in, redirect to login page { Session["pageRedirectAfterLogin"] = Request.RawUrl; Response.Redirect("Login.aspx"); return; } if (Request["rentid"] == null) { Response.Redirect("Default.aspx"); return; } //display dispute by rentalID if rentalID belongs to appropriate logged on user 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(); Dispute dis = DisputeDB.getDisputeforRental(Request["rentid"].ToString()); if (dis.DisputeID != null) { ddlReason.SelectedValue = dis.Reason; ddlReason.Enabled = false; if (MemberDB.getMemberbyID(dis.SubmittedBy.MemberID).Email == Session["user"].ToString()) { btnResolve.Visible = true; } if (dis.Status == "Resolved") { setChatControls(false); } rptMessages.DataSource = MessageDisputeDB.getMsgforDispute(dis.DisputeID); rptMessages.DataBind(); } else { if (RentalDB.getRentalbyID(Request["rentid"].ToString()).Rentee.Email == Session["user"].ToString()) { for (int x = 1; x < 5; x++) { ddlReason.Items[x].Enabled = false; } } else if (RentalDB.getRentalbyID(Request["rentid"].ToString()).Item.Renter.Email == Session["user"].ToString()) { for (int x = 1; x < ddlReason.Items.Count; x++) { ddlReason.Items[x].Enabled = false; } } } } else { ddlReason.Enabled = false; setChatControls(false); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Inaccessible Page!')", true); } }