public static string FormatDivisionLink(this OccupiedPositionInfo op, IModuleControl module)
        {
            // don't display division title/link for single-entity divisions
            if (!op.Division.IsSingleEntity)
            {
                var strDivision = FormatHelper.FormatShortTitle(op.Division.ShortTitle, op.Division.Title);
                if (!string.IsNullOrWhiteSpace(op.Division.HomePage))
                {
                    strDivision = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>",
                                                UniversityUrlHelper.FormatURL(module, op.Division.HomePage, false), strDivision);
                }

                return(strDivision);
            }

            return(string.Empty);
        }
Esempio n. 2
0
        protected void gridDivisions_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var now = HttpContext.Current.Timestamp;

            // show / hide edit column
            e.Row.Cells [0].Visible = IsEditable;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var division = (DivisionInfo)e.Row.DataItem;

                if (IsEditable)
                {
                    // get edit link controls
                    var linkEdit = (HyperLink)e.Row.FindControl("linkEdit");
                    var iconEdit = (Image)e.Row.FindControl("iconEdit");

                    // fill edit link controls
                    linkEdit.NavigateUrl = EditUrl("division_id", division.DivisionID.ToString(), "EditDivision");
                    iconEdit.ImageUrl    = UniversityIcons.Edit;
                }

                if (!division.IsPublished(now))
                {
                    e.Row.AddCssClass("u8y-not-published");
                }

                if (division.IsInformal && IsEditable)
                {
                    e.Row.AddCssClass("u8y-informal-division");
                }

                if (division.IsGoverning)
                {
                    e.Row.AddCssClass("u8y-governing-division");
                }

                var labelTitle          = (Label)e.Row.FindControl("labelTitle");
                var linkTitle           = (HyperLink)e.Row.FindControl("linkTitle");
                var literalPhone        = (Literal)e.Row.FindControl("literalPhone");
                var linkEmail           = (HyperLink)e.Row.FindControl("linkEmail");
                var literalLocation     = (Literal)e.Row.FindControl("literalLocation");
                var linkDocument        = (HyperLink)e.Row.FindControl("linkDocument");
                var literalHeadEmployee = (Literal)e.Row.FindControl("literalHeadEmployee");

                // division label / link
                var divisionTitle = division.Title + ((UniversityModelHelper.HasUniqueShortTitle(division.ShortTitle, division.Title)) ? string.Format(
                                                          " ({0})",
                                                          division.ShortTitle) : string.Empty);
                if (!string.IsNullOrWhiteSpace(division.HomePage))
                {
                    linkTitle.NavigateUrl = UniversityUrlHelper.FormatURL(this, division.HomePage, false);
                    linkTitle.Text        = divisionTitle;
                    labelTitle.Visible    = false;
                }
                else
                {
                    labelTitle.Text   = divisionTitle;
                    linkTitle.Visible = false;
                }

                literalPhone.Text    = division.Phone;
                literalLocation.Text = division.Location;

                // email
                if (!string.IsNullOrWhiteSpace(division.Email))
                {
                    linkEmail.Text        = division.Email;
                    linkEmail.NavigateUrl = "mailto:" + division.Email;
                }
                else
                {
                    linkEmail.Visible = false;
                }

                // (main) document
                if (!string.IsNullOrWhiteSpace(division.DocumentUrl))
                {
                    linkDocument.Text        = LocalizeString("Regulations.Text");
                    linkDocument.NavigateUrl = Globals.LinkClick(division.DocumentUrl, TabId, ModuleId);
                }
                else
                {
                    linkDocument.Visible = false;
                }

                // get head employee
                var headEmployee = new HeadEmployeesQuery(ModelContext)
                                   .ListHeadEmployees(division.DivisionID, division.HeadPositionID)
                                   .FirstOrDefault(he => he.IsPublished(now));

                if (headEmployee != null)
                {
                    literalHeadEmployee.Text = "<a href=\""
                                               + EditUrl("employee_id", headEmployee.EmployeeID.ToString(), "EmployeeDetails")
                                               + "\" title=\"" + headEmployee.FullName + "\">" + headEmployee.AbbrName + "</a>";
                }
                else if (division.HeadPositionID != null)
                {
                    literalHeadEmployee.Text = LocalizeString("HeadPosition_IsVacant.Text");
                }
                else
                {
                    literalHeadEmployee.Text = LocalizeString("HeadPosition_NotApplicable.Text");
                }
            }
        }