Ejemplo n.º 1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Remove")
        {
            int    flatId       = Convert.ToInt32(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].Text);
            string studentEmail = Session["Email"].ToString();
            client.RemoveFromWishlist(studentEmail.Trim(), flatId);
            Response.Redirect("WishList.aspx");
        }
        if (e.CommandName == "Accept")
        {
            if (MessageBox.Show("If you click yes the flat will be removed from wishlist and you will pay a fee. Do you wish to continue?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                int flatId = Convert.ToInt32(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].Text);
                if (client.ConfirmTenants(flatId, Session["Email"].ToString().Trim()))
                {
                    client.UpdateFlatStatus(flatId, "Closed", "", "Not available");

                    string studentEmail = Session["Email"].ToString();
                    client.RemoveFromWishlist(studentEmail.Trim(), flatId);
                    Response.Redirect("WishList.aspx");
                }
                else
                {
                    Response.Redirect("ErrorPage.aspx");
                }
            }
            else
            {
                int    flatId       = Convert.ToInt32(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].Text);
                string studentEmail = Session["Email"].ToString();
                client.RemoveFromWishlist(studentEmail.Trim(), flatId);
                Response.Redirect("WishList.aspx");
            }
        }
        if (e.CommandName == "Deny")
        {
            if (MessageBox.Show("If you click yes the flat will be removed from wishlist. Do you wish to continue?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                int    flatId       = Convert.ToInt32(GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].Text);
                string studentEmail = Session["Email"].ToString();
                client.RemoveFromWishlist(studentEmail.Trim(), flatId);
                Response.Redirect("WishList.aspx");
            }
        }
    }