/// <summary> /// Handles the ItemDataBound event of the gvClosedProjects control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridItemEventArgs"/> instance containing the event data.</param> protected void gvClosedProjects_ItemDataBound(object sender, GridItemEventArgs e) { //Set company name, set project name, and set those links if (e.Item is GridDataItem) { ProjectListInfo project = e.Item.DataItem as ProjectListInfo; HtmlAnchor lnkProject = (HtmlAnchor)e.Item.FindControl("lnkProject"); HtmlAnchor lnkCompany = (HtmlAnchor)e.Item.FindControl("lnkCompany"); Literal litCompany = (Literal)e.Item.FindControl("litCompany"); Label lblProject = (Label)e.Item.FindControl("lblProject"); //INITIALIZATION string projectName = (project.ProjectName != null) ? Support.TruncateString(project.ProjectName, 20) : string.Empty; string companyName = (project.CompanyName != null) ? Support.TruncateString(project.CompanyName, 20) : string.Empty; if (lnkProject != null) { lnkProject.HRef = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); lnkProject.InnerText = lblProject.Text = projectName; if (project.IsCompanyAdmin || Support.CanAccessProject(project.ProjectId)) { lblProject.Visible = false; lnkProject.Visible = true; } else { lblProject.Visible = true; lnkProject.Visible = false; } } if (lnkCompany != null && litCompany != null) { lnkCompany.HRef = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); lnkCompany.InnerText = companyName; litCompany.Text = companyName; } if (!project.IsCompanyAdmin) { lnkCompany.Visible = false; litCompany.Visible = true; } } }
/// <summary> /// Handles the ItemDataBound event of the gvProjectInvitations control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridItemEventArgs"/> instance containing the event data.</param> protected void gvProjectInvitations_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { ProjectListInfo project = e.Item.DataItem as ProjectListInfo; HtmlAnchor lnkProject = (HtmlAnchor)e.Item.FindControl("lnkProject"); HtmlAnchor lnkCompany = (HtmlAnchor)e.Item.FindControl("lnkCompany"); LinkButton lnkbtnViewInvite = (LinkButton)e.Item.FindControl("lnkbtnViewInvite"); Literal litCompany = (Literal)e.Item.FindControl("litCompany"); Literal litProject = (Literal)e.Item.FindControl("litProject"); //INITIALIZATION string projectName = (project.ProjectName != null) ? Support.TruncateString(project.ProjectName, 20) : string.Empty; string companyName = (project.CompanyName != null) ? Support.TruncateString(project.CompanyName, 20) : string.Empty; lnkbtnViewInvite.CommandArgument = project.InvitationId.ToString(); if (lnkProject != null) { lnkProject.HRef = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); lnkProject.InnerText = projectName; litProject.Text = projectName; } if (lnkCompany != null) { lnkCompany.HRef = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); lnkCompany.InnerText = companyName; litCompany.Text = companyName; } if (!Support.IsCompanyAdministrator(project.CompanyId)) { lnkCompany.Visible = false; litCompany.Visible = true; lnkProject.Visible = false; litProject.Visible = true; } } }
/// <summary> /// Handles the ItemDataBound event of the gvProjects control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridItemEventArgs"/> instance containing the event data.</param> protected void gvProjects_ItemDataBound(object sender, GridItemEventArgs e) { //Set company name, set project name, and set those links if (e.Item is GridDataItem) { ProjectListInfo project = e.Item.DataItem as ProjectListInfo; HtmlAnchor lnkProject = (HtmlAnchor)e.Item.FindControl("lnkProject"); HtmlAnchor lnkCompany = (HtmlAnchor)e.Item.FindControl("lnkCompany"); Literal litCompany = (Literal)e.Item.FindControl("litCompany"); Label lblProject = (Label)e.Item.FindControl("lblProject"); //INITIALIZATION string projectName = (project.ProjectName != null) ? Support.TruncateString(project.ProjectName, 20) : string.Empty; string companyName = (project.CompanyName != null) ? Support.TruncateString(project.CompanyName, 20) : string.Empty; if (lnkProject != null) { lnkProject.HRef = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); lnkProject.InnerText = lblProject.Text = projectName; if (project.IsCompanyAdmin || Support.CanAccessProject(project.ProjectId)) { lblProject.Visible = false; lnkProject.Visible = true; } else { lblProject.Visible = true; lnkProject.Visible = false; } } if (lnkCompany != null && litCompany != null) { lnkCompany.HRef = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); lnkCompany.InnerText = companyName; litCompany.Text = companyName; } if (!project.IsCompanyAdmin) { lnkCompany.Visible = false; litCompany.Visible = true; } #region Notifications HtmlAnchor lnkNotificationCount = (HtmlAnchor)e.Item.FindControl("lnkNotificationCount"); if (project.NotificationCount > 0 && DisplayMode == ViewMode.UserDashboard) { lnkNotificationCount.Visible = true; lnkNotificationCount.InnerText = project.NotificationCount.ToString(); lnkNotificationCount.HRef = string.Format("~/Project/ProjectNotifications.aspx?projectid={0}", project.ProjectId); } else { lnkNotificationCount.Visible = false; } #endregion Notifications #region Warning Icon if (DisplayMode == ViewMode.CompanyDashboard && project.IsCompanyAdmin) { HtmlGenericControl divProjectWarning = (HtmlGenericControl)e.Item.FindControl("divProjectWarning"); ProjectStatusHandler.ProjectWarningInfo warningInfo = ProjectStatusHandler.GetProjectWarningStatus(project.ProjectStatusCodeId, project.ProjectTypeCodeId == Support.GetCodeByValue("ProjectType", "FREETRIALOPTIN").CodeId, project.ExpirationDate); if (warningInfo.WarningStatus == ProjectStatusHandler.ProjectWarningStatus.NoWarning) { divProjectWarning.Visible = false; } else { divProjectWarning.Visible = true; } } #endregion Warning Icon #region Project Suspention Icon HtmlGenericControl divProjectSuspended = (HtmlGenericControl)e.Item.FindControl("divProjectSuspended"); divProjectSuspended.Visible = (project.ProjectStatusCodeId == Support.GetCodeByValue("ProjectStatus", "SUSPENDED").CodeId); #endregion Project Suspention Icon } }
/// <summary> /// Handles the ItemDataBound event of the lvProjects control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ListViewItemEventArgs"/> instance containing the event data.</param> protected void lvProjects_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ProjectListInfo project = e.Item.DataItem as ProjectListInfo; ProjectBL projectBL = GetBL <ProjectBL>(); //INITIALIZATION string projectName = (project.ProjectName != null) ? Support.TruncateString(project.ProjectName, 20) : string.Empty; string companyName = (project.CompanyName != null) ? Support.TruncateString(project.CompanyName, 20) : string.Empty; PlaceHolder plcProjectMemberView = (PlaceHolder)e.Item.FindControl("plcProjectMemberView"); PlaceHolder plcInvitationView = (PlaceHolder)e.Item.FindControl("plcInvitationView"); PlaceHolder plcClosedProjectsView = (PlaceHolder)e.Item.FindControl("plcClosedProjectsView"); if (projectBL.IsProjectClosed(project.ProjectId)) { plcProjectMemberView.Visible = false; plcInvitationView.Visible = false; plcClosedProjectsView.Visible = true; HyperLink lnkProjectClosed = (HyperLink)e.Item.FindControl("lnkProjectClosed"); Label lblProjectClosed = (Label)e.Item.FindControl("lblProjectClosed"); Label lblClosedDate = (Label)e.Item.FindControl("lblClosedDate"); Label lblClosedBy = (Label)e.Item.FindControl("lblClosedBy"); if (lnkProjectClosed != null && lblProjectClosed != null) { lnkProjectClosed.Text = lblProjectClosed.Text = projectName; int projectId = project.ProjectId; if (project.IsCompanyAdmin || Support.CanAccessProject(projectId)) { lnkProjectClosed.NavigateUrl = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); lblProjectClosed.Visible = false; lnkProjectClosed.Visible = true; } else { lblProjectClosed.Visible = true; lnkProjectClosed.Visible = false; } } if (lblClosedDate != null) { lblClosedDate.Text = project.ClosedOn.HasValue ? Utils.FormatDatetime(project.ClosedOn.Value, false) : string.Empty; } if (lblClosedBy != null) { lblClosedBy.Text = Support.TruncateString(project.ClosedByName, 10); lblClosedBy.ToolTip = project.ClosedByName; } } else { plcClosedProjectsView.Visible = false; if (project.InvitationId == 0) { #region Project that this user is a member of plcProjectMemberView.Visible = true; plcInvitationView.Visible = false; HyperLink lnkProject = (HyperLink)e.Item.FindControl("lnkBtnProject"); HyperLink lnkCompany = (HyperLink)e.Item.FindControl("lnkBtnCompany"); Label lblProject = (Label)e.Item.FindControl("lblProject"); //Set Links if (lnkProject != null && lblProject != null) { lnkProject.Text = lblProject.Text = projectName; int projectId = project.ProjectId; if (project.IsCompanyAdmin || Support.CanAccessProject(projectId)) { lnkProject.NavigateUrl = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); lblProject.Visible = false; lnkProject.Visible = true; } else { lblProject.Visible = true; lnkProject.Visible = false; } } #region Company link if (lnkCompany != null) { //If it is in Userdashboard and if not a Company Admin, show the Literal. if (DisplayMode == ViewMode.UserDashboard) { HtmlGenericControl spnCompany = (HtmlGenericControl)e.Item.FindControl("spnCompany"); //check if it is a company admin. if (project.IsCompanyAdmin) { lnkCompany.Text = string.Format("({0})", companyName); lnkCompany.NavigateUrl = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); spnCompany.Visible = false; } else { spnCompany.InnerText = string.Format("({0})", companyName); lnkCompany.Visible = false; } } else if (DisplayMode == ViewMode.CompanyDashboard) { lnkCompany.Text = string.Format("({0})", companyName); lnkCompany.NavigateUrl = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); } } #endregion Company link #region Item counts Literal litItems = (Literal)e.Item.FindControl("litItems"); Literal litCompleted = (Literal)e.Item.FindControl("litCompleted"); Literal litInProgress = (Literal)e.Item.FindControl("litInProgress"); Literal litNotstarted = (Literal)e.Item.FindControl("litNotstarted"); //Validate data before assigning int itemCount = (project.ItemCount != null) ? project.ItemCount : 0; int completeItemCount = (project.CompletedItemCount != null) ? project.CompletedItemCount : 0; int inProgressItemCount = (project.InProgressItemCount != null) ? project.InProgressItemCount : 0; int notStartedItemCount = (project.NotStartedItemCount != null) ? project.NotStartedItemCount : 0; //Set literals if (itemCount == 1) { litItems.Text = string.Format("{0} Item Brief", itemCount); } else { litItems.Text = string.Format("{0} Item Briefs", itemCount); } litCompleted.Text = (litCompleted != null) ? string.Format("{0} Completed", completeItemCount) : string.Empty; litInProgress.Text = (litInProgress != null) ? string.Format("{0} In Progress", inProgressItemCount) : string.Empty; litNotstarted.Text = (litNotstarted != null) ? string.Format("{0} Not Started", notStartedItemCount) : string.Empty; #endregion Item counts #region Notifications HtmlGenericControl divNotificationArea = (HtmlGenericControl)e.Item.FindControl("divNotificationArea"); HtmlAnchor lnkNotificationCount = (HtmlAnchor)e.Item.FindControl("lnkNotificationCount"); if (project.NotificationCount > 0 && DisplayMode == ViewMode.UserDashboard) { lnkNotificationCount.Visible = true; lnkNotificationCount.InnerText = project.NotificationCount.ToString(); lnkNotificationCount.HRef = string.Format("~/Project/ProjectNotifications.aspx?projectid={0}", project.ProjectId); } else { lnkNotificationCount.Visible = false; } #endregion Notifications #region Warning Icon if (project.IsCompanyAdmin) { HtmlGenericControl divProjectWarning = (HtmlGenericControl)e.Item.FindControl("divProjectWarning"); ProjectStatusHandler.ProjectWarningInfo warningInfo = ProjectStatusHandler.GetProjectWarningStatus(project.ProjectStatusCodeId, project.ProjectTypeCodeId == Support.GetCodeByValue("ProjectType", "FREETRIALOPTIN").CodeId, project.ExpirationDate); if (warningInfo.WarningStatus == ProjectStatusHandler.ProjectWarningStatus.NoWarning) { divProjectWarning.Visible = false; } else { divProjectWarning.Visible = true; } } #endregion Warning Icon #region Project Suspention Icon HtmlGenericControl divProjectSuspended = (HtmlGenericControl)e.Item.FindControl("divProjectSuspended"); divProjectSuspended.Visible = (project.ProjectStatusCodeId == Support.GetCodeByValue("ProjectStatus", "SUSPENDED").CodeId); #endregion Project Suspention Icon #endregion Project that this user is a member of } else { //This only occurs in user dashboard for invited projects #region Invited project plcProjectMemberView.Visible = false; plcInvitationView.Visible = true; HyperLink lnkProject = (HyperLink)e.Item.FindControl("lnkBtnProjectInvt"); HyperLink lnkCompany = (HyperLink)e.Item.FindControl("lnkBtnCompanyInvt"); Literal litProjectName = (Literal)e.Item.FindControl("litProjectName"); Literal litCompanyName = (Literal)e.Item.FindControl("litCompanyName"); #region Project/Company links //check if it is a company admin. if (project.IsCompanyAdmin) { lnkProject.Text = string.Format("({0})", projectName); lnkProject.NavigateUrl = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", project.ProjectId); litProjectName.Visible = false; } else //If not a Company Admin, show the Literal. { litProjectName.Visible = true; litProjectName.Text = projectName; lnkProject.Visible = false; } if (project.IsCompanyAdmin) { lnkCompany.Text = string.Format("({0})", companyName); lnkCompany.NavigateUrl = string.Format("~/Company/CompanyDashboard.aspx?companyid={0}", project.CompanyId); litCompanyName.Visible = false; } else { litCompanyName.Visible = true; litCompanyName.Text = companyName; lnkCompany.Visible = false; } #endregion Project/Company links LinkButton lnkbtnViewInvite = (LinkButton)e.Item.FindControl("lnkbtnViewInvite"); lnkbtnViewInvite.CommandArgument = project.InvitationId.ToString(); #endregion Invited project } } } }