Example #1
0
    //Bindings
    private void ButtonVisibilityAll()
    {
        DataSet dsApp = client.GetWishlist(Session["Email"].ToString().Trim());
        int     i     = 0;
        bool    found = false;

        foreach (GridViewRow dr2 in GridViewAllFlats.Rows)
        {
            found = false;
            foreach (DataRow row in dsApp.Tables[0].Rows)
            {
                if (row["FlatId"].ToString().Trim().Equals(dr2.Cells[0].Text.Trim()))
                {
                    found = true;
                }
            }

            if (found)
            {
                GridViewAllFlats.Rows[i].Cells[5].FindControl("ButtonAdd").Visible    = false;
                GridViewAllFlats.Rows[i].Cells[5].FindControl("ButtonRemove").Visible = true;
            }
            else
            {
                GridViewAllFlats.Rows[i].Cells[5].FindControl("ButtonRemove").Visible = false;
                GridViewAllFlats.Rows[i].Cells[5].FindControl("ButtonAdd").Visible    = true;
            }

            i++;
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["New"] != null)
        {
            if (Session["Type"].ToString() == "Student")
            {
                if (!IsPostBack)
                {
                    WelcomeLabel.Text += Session["Email"].ToString();
                    DataSet ds1 = client.GetWishlist(Session["Email"].ToString());
                    GridView1.DataSource = ds1.Tables[0];
                    GridView1.DataBind();
                }

                DataSet ds2 = client.GetAllFlats();

                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    if (Convert.ToInt32(GridView1.Rows[i].Cells[2].Text) == 1)
                    {
                        int    rowCount = 0;
                        int    finalRow = 0;
                        string status;
                        foreach (DataRow row in ds2.Tables[0].Rows)
                        {
                            if ((row["Id"].ToString().Trim()).Equals(GridView1.Rows[i].Cells[0].Text.Trim()))
                            {
                                finalRow = rowCount;
                            }
                            rowCount++;
                            status = ds2.Tables[0].Rows[finalRow]["Status"].ToString().Trim();
                            if (status.Equals("Pending"))
                            {
                                GridView1.Rows[i].Cells[4].FindControl("ButtonAccept").Visible = true;
                                GridView1.Rows[i].Cells[4].FindControl("ButtonDeny").Visible   = true;
                            }
                            else
                            {
                                GridView1.Rows[i].Cells[4].FindControl("ButtonAccept").Visible = false;
                                GridView1.Rows[i].Cells[4].FindControl("ButtonDeny").Visible   = false;
                            }
                        }
                    }
                }
            }
            else if (Session["Type"].ToString() == "Landlord")
            {
                Response.Redirect("MainPageLandlord.aspx");
            }
        }
        else
        {
            Response.Redirect("Register.aspx");
        }
    }