Пример #1
0
        /// <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
            }
        }
Пример #2
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        public void LoadData()
        {
            StageBitz.Data.Project project = DataContext.Projects.Where(p => p.ProjectId == ProjectID).FirstOrDefault();
            bool paymentsSpecified         = (FinanceSupport.GetCreditCardToken("Company", project.CompanyId) != null);

            ProjectStatusHandler.ProjectWarningInfo warningInfo = ProjectStatusHandler.GetProjectWarningStatus(project.ProjectStatusCodeId, project.ProjectTypeCodeId == Support.GetCodeByValue("ProjectType", "FREETRIALOPTIN").CodeId, project.ExpirationDate);
            StageBitz.Data.User companyAdmin = this.GetBL <CompanyBL>().GetCompanyPrimaryAdministrator(project.CompanyId);

            ProjectName       = Support.TruncateString(project.ProjectName, 30);
            RemainingDays     = string.Format("{0} day{1}", warningInfo.DaysToExpiration < 0 ? 0 : warningInfo.DaysToExpiration, warningInfo.DaysToExpiration == 1 ? string.Empty : "s");
            CompanyAdminName  = Support.TruncateString((companyAdmin.FirstName + " " + companyAdmin.LastName).Trim(), 30);
            CompanyAdminEmail = companyAdmin.Email1;
            PaymentFailedDate = null;

            CompanyFinancialUrl = ResolveUrl(string.Format("~/Company/CompanyFinancialDetails.aspx?companyid={0}", project.CompanyId));

            if (warningInfo.WarningStatus == ProjectStatusHandler.ProjectWarningStatus.NoWarning)
            {
                noticesMultiView.Visible = false;
                return;
            }
            else
            {
                noticesMultiView.Visible = true;
            }

            #region Determine User Permission Type

            ProjectPermission userType = ProjectPermission.Staff;
            if (Support.IsCompanyAdministrator(project.CompanyId))
            {
                userType = ProjectPermission.CompanyAdministrator;
            }
            else if (Support.IsProjectAdministrator(ProjectID))
            {
                userType = ProjectPermission.ProjectAdministrator;
            }
            else
            {
                userType = ProjectPermission.Staff;
            }

            #endregion Determine User Permission Type

            switch (warningInfo.WarningStatus)
            {
            case ProjectStatusHandler.ProjectWarningStatus.FreeTrialGrace:
                if (userType == ProjectPermission.CompanyAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.FreeTrialGraceCompanyAdmin;
                }
                break;

            case ProjectStatusHandler.ProjectWarningStatus.GracePeriod:
                if (userType == ProjectPermission.CompanyAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.GracePeriodCompanyAdmin;
                    ucCompanyPaymentFailedWarningGracePeriodCompanyAdmin.CompanyID = project.CompanyId;
                    ucCompanyPaymentFailedWarningGracePeriodCompanyAdmin.LoadData(CompanyPaymentFailedWarning.PermissionLevel.CompanyAdministrator,
                                                                                  CompanyPaymentFailedWarning.DisplayMode.PaymentFailedGracePeriod);
                }
                else if (userType == ProjectPermission.ProjectAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.GracePeriodProjectAdmin;
                    ucCompanyPaymentFailedWarningGracePeriodNonCompanyAdmin.CompanyID = project.CompanyId;
                    ucCompanyPaymentFailedWarningGracePeriodNonCompanyAdmin.LoadData(CompanyPaymentFailedWarning.PermissionLevel.NonCompanyAdministrator,
                                                                                     CompanyPaymentFailedWarning.DisplayMode.PaymentFailedGracePeriod);
                }
                PaymentFailedDate = project.ExpirationDate.Value.AddDays(-7);
                break;

            case ProjectStatusHandler.ProjectWarningStatus.PaymentFailed:
                if (userType == ProjectPermission.CompanyAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.PaymentFailedCompanyAdmin;
                    ucCompanyPaymentFailedWarningPaymentFailedCompanyAdmin.CompanyID = project.CompanyId;
                    ucCompanyPaymentFailedWarningPaymentFailedCompanyAdmin.LoadData(CompanyPaymentFailedWarning.PermissionLevel.CompanyAdministrator,
                                                                                    CompanyPaymentFailedWarning.DisplayMode.PaymentFailed);
                }
                else if (userType == ProjectPermission.ProjectAdministrator || userType == ProjectPermission.Staff)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.PaymentFailedProjectStaff;
                    ucCompanyPaymentFailedWarningPaymentFailedNonCompanyAdmin.CompanyID = project.CompanyId;
                    ucCompanyPaymentFailedWarningPaymentFailedNonCompanyAdmin.LoadData(CompanyPaymentFailedWarning.PermissionLevel.NonCompanyAdministrator,
                                                                                       CompanyPaymentFailedWarning.DisplayMode.PaymentFailed);
                }

                break;

            case ProjectStatusHandler.ProjectWarningStatus.Suspended:
                if (userType == ProjectPermission.CompanyAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.SuspendedCompanyAdmin;
                }
                else if (userType == ProjectPermission.ProjectAdministrator || userType == ProjectPermission.Staff)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.SuspendedProjectStaff;
                }
                break;

            case ProjectStatusHandler.ProjectWarningStatus.Closed:
                if (userType == ProjectPermission.CompanyAdministrator)
                {
                    noticesMultiView.ActiveViewIndex = (int)NoticeType.ClosedProjectCompanyAdmin;
                }
                break;
            }

            //If the project's payment has failed, calculate the number of days the payment is due.
            if (PaymentFailedDate != null)
            {
                int paymentOverdueDays = (int)(Today - PaymentFailedDate.Value).TotalDays;
                PaymentOverdueDays = string.Format("{0} day{1}", paymentOverdueDays, paymentOverdueDays == 1 ? string.Empty : "s");
            }

            upnlProjectWarningDisplay.Update();
        }
Пример #3
0
        /// <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
                    }
                }
            }
        }