コード例 #1
0
    protected void OrganizationsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
        {
            return;
        }

        LinkButton buttonDelete = (LinkButton)e.Item.FindControl("DeleteOrganization");

        if (buttonDelete != null)
        {
            buttonDelete.OnClientClick = String.Format("return confirm('{0}')", Resources.Organization.MessageConfirmDelete);
        }

        Organization item = (Organization)e.Item.DataItem;

        if (item == null)
        {
            return;
        }

        //Show the delete button if is Owner
        HiddenField theHFOwner = (HiddenField)e.Item.FindControl("IsOwnerHiddenField");

        if (theHFOwner != null)
        {
            if (!Convert.ToBoolean(theHFOwner.Value))
            {
                Panel panelDelete = (Panel)e.Item.FindControl("pnlDelete");
                if (panelDelete != null)
                {
                    panelDelete.CssClass = "col-md-1 col-sm-1 col-xs-3 disabled";
                }

                Panel panelShare = (Panel)e.Item.FindControl("pnlShare");
                if (panelShare != null)
                {
                    panelShare.CssClass = "col-md-1 col-sm-1 col-xs-3 disabled";
                }
            }
        }

        Quantity theQuantity = null;

        try
        {
            theQuantity = OrganizationBLL.GetQuantityByOrganization(item.OrganizationID);
        }
        catch {}

        if (theQuantity == null)
        {
            return;
        }

        if (theQuantity.Areas == 0 && theQuantity.Projects == 0 && theQuantity.Activities == 0 && theQuantity.Kpis == 0 && theQuantity.People == 0)
        {
            Panel element = (Panel)e.Item.FindControl("emptyMessage");
            element.Visible = true;
            return;
        }

        Panel detailsPanel = (Panel)e.Item.FindControl("detailsContainer");

        detailsPanel.Visible = true;

        Panel kpiImagePanel = (Panel)e.Item.FindControl("KpiImageContainer");

        kpiImagePanel.Visible = true;

        Label      areasLabel       = (Label)e.Item.FindControl("AreasLabel");
        LinkButton projectButton    = (LinkButton)e.Item.FindControl("ProjectsButton");
        LinkButton activitiesButton = (LinkButton)e.Item.FindControl("ActivitiesButton");
        LinkButton kpisButton       = (LinkButton)e.Item.FindControl("KpisButton");
        LinkButton PersonButton     = (LinkButton)e.Item.FindControl("PersonLinkButton");

        Literal and1 = (Literal)e.Item.FindControl("AndLiteral1");
        Literal and2 = (Literal)e.Item.FindControl("AndLiteral2");
        Literal and3 = (Literal)e.Item.FindControl("AndLiteral3");
        Literal and4 = (Literal)e.Item.FindControl("AndLiteral4");

        areasLabel.Visible = theQuantity.Areas > 0;
        areasLabel.Text    = areasLabel.Visible ? theQuantity.Areas + " Area" + (theQuantity.Areas == 1 ? "" : "s") : "";

        projectButton.Visible = theQuantity.Projects > 0;
        projectButton.Text    = projectButton.Visible ? theQuantity.Projects + " " + Resources.Organization.LabelProjects : "";

        activitiesButton.Visible = theQuantity.Activities > 0;
        activitiesButton.Text    = activitiesButton.Visible ? theQuantity.Activities + (theQuantity.Activities == 1 ? " " + Resources.Organization.LabelActivity : " " + Resources.Organization.LabelActivities) : "";

        if (ShowPeopleCheckbox.Checked)
        {
            PersonButton.Visible = theQuantity.People > 0;
            PersonButton.Text    = PersonButton.Visible ? theQuantity.People + (theQuantity.People == 1 ? " " + Resources.Organization.LabelPeople : " " + Resources.Organization.LabelPerson) : "";
        }

        kpisButton.Visible = theQuantity.Kpis > 0;
        kpisButton.Text    = kpisButton.Visible ? theQuantity.Kpis + " KPI" + (theQuantity.Kpis == 1 ? "" : "s") : "";

        and1.Visible = areasLabel.Visible && projectButton.Visible;
        if (and1.Visible)
        {
            if (activitiesButton.Visible || kpisButton.Visible)
            {
                and1.Text = ",";
            }
            else
            {
                and1.Text = " " + Resources.Organization.LabelAnd + " ";
            }
        }

        and2.Visible = projectButton.Visible && activitiesButton.Visible;
        if (and2.Visible)
        {
            if (kpisButton.Visible)
            {
                and2.Text = ",";
            }
            else
            {
                and2.Text = " " + Resources.Organization.LabelAnd + " ";
            }
        }

        and3.Visible = activitiesButton.Visible && PersonButton.Visible;
        if (and3.Visible)
        {
            if (PersonButton.Visible)
            {
                and3.Text = ",";
            }
            else
            {
                and3.Text = " " + Resources.Organization.LabelAnd + " ";
            }
        }

        and4.Visible = kpisButton.Visible;
        if (and4.Visible && kpisButton.Visible)
        {
            and4.Text = " " + Resources.Organization.LabelAnd + " ";
        }
    }