protected void GridViewAllFlats_RowCommand(object sender, GridViewCommandEventArgs e) { int rowindex = Convert.ToInt32(e.CommandArgument) % GridViewAllFlats.PageSize; if (e.CommandName == "Add") { int flatId = Convert.ToInt32(GridViewAllFlats.Rows[rowindex].Cells[0].Text); string studentEmail = Session["Email"].ToString(); int score = Convert.ToInt32(Session["Score"]); client.AddToWishlist(studentEmail, flatId, score); Response.Redirect("MainPageStudent.aspx"); } else if (e.CommandName == "Remove") { int flatId = Convert.ToInt32(GridViewAllFlats.Rows[rowindex].Cells[0].Text); string studentEmail = Session["Email"].ToString(); client.RemoveFromWishlist(studentEmail.Trim(), flatId); Response.Redirect("MainPageStudent.aspx"); } if (e.CommandName == "View") { Session["Flat"] = Convert.ToInt32(GridViewAllFlats.Rows[rowindex].Cells[0].Text); Response.Redirect("FlatsDetailsStudent.aspx"); } }
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"); } } }
protected void ButtonRemoveFlat_Click(object sender, EventArgs e) { int flatId = Convert.ToInt32(Session["Flat"]); string studentEmail = Session["Email"].ToString(); client.RemoveFromWishlist(studentEmail.Trim(), flatId); LabelAddRemove.Text = "Flat has been removed from your wishlist."; }