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);
    }
    // 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);
    }
示例#4
0
    public static List <MessageDispute> getMsgforDispute(string disputeID)
    {
        List <MessageDispute> msgDisList = new List <MessageDispute>();

        try
        {
            SqlCommand command = new SqlCommand("SELECT * FROM MessageDispute WHERE disputeID = @disputeID");
            command.Parameters.AddWithValue("@disputeID", disputeID);
            command.Connection = connection;
            connection.Open();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                MessageDispute msgDis = new MessageDispute();

                msgDis.Date  = Convert.ToDateTime(reader["date"]);
                msgDis.Reply = reader["reply"].ToString();

                if (reader["memberID"] != DBNull.Value)
                {
                    msgDis.Member = MemberDB.getMemberbyID(reader["memberID"].ToString());
                }
                else
                {
                    msgDis.Member = new Member(null, null, null, 0, null, null, 0, null, null, new DateTime(), new DateTime(), null, new DateTime(), null, null);
                }

                if (reader["staffID"] != DBNull.Value)
                {
                    msgDis.Staff = StaffDB.getStaffbyID(reader["staffID"].ToString());
                }
                else
                {
                    msgDis.Staff = new Staff(null, null, null, null, 0, null, new DateTime());
                }

                msgDis.Dispute = DisputeDB.getDisputeybyID(reader["disputeID"].ToString());

                msgDisList.Add(msgDis);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(msgDisList);
    }
示例#5
0
    public static int addMsgDispute(MessageDispute msgDis)
    {
        try
        {
            SqlCommand command = new SqlCommand("INSERT INTO MessageDispute (date, reply, memberID, staffID, disputeID) values (@date, @reply, @memberID, @staffID, @disputeID)");
            command.Parameters.AddWithValue("@date", msgDis.Date);
            command.Parameters.AddWithValue("@reply", msgDis.Reply);

            if (msgDis.Member.MemberID != null)
            {
                command.Parameters.AddWithValue("@memberID", msgDis.Member.MemberID);
            }
            else
            {
                command.Parameters.AddWithValue("@memberID", DBNull.Value);
            }

            if (msgDis.Staff.StaffID != null)
            {
                command.Parameters.AddWithValue("@staffID", msgDis.Staff.StaffID);
            }
            else
            {
                command.Parameters.AddWithValue("@staffID", DBNull.Value);
            }

            command.Parameters.AddWithValue("@disputeID", msgDis.Dispute.DisputeID);
            command.Connection = connection;
            connection.Open();

            if (command.ExecuteNonQuery() > 0)
            {
                int msgdisputeID = 1;
                return(msgdisputeID);
            }
        }
        finally
        {
            connection.Close();
        }
        return(-1);
    }