예제 #1
0
 public static bool CanWork(int ObjectTypeId, int ObjectId)
 {
     if (ObjectTypeId == (int)ObjectTypes.Task)
     {
         return(Task.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.CalendarEntry)
     {
         return(CalendarEntry.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Document)
     {
         return(Document.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Issue)
     {
         return(Incident.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.ToDo)
     {
         return(ToDo.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Project)
     {
         return(Project.CanEditFinances(ObjectId));
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
        public static DataTable GetListActualFinancesByToDo(int ToDoId)
        {
            if (!ToDo.CanViewFinances(ToDoId))
            {
                throw new AccessDeniedException();
            }

            return(GetListActualFinancesByObject((int)ObjectTypes.ToDo, ToDoId));
        }
예제 #3
0
        private void BindTabs()
        {
            ctrlTopTab.IsLeftLine = false;

            if (Tab != null && (Tab == "General" || Tab == "FileLibrary" || Tab == "Finance" || Tab == "Discussions" || Tab == "Customization"))
            {
                pc["ToDoView_CurrentTab"] = Tab;
            }
            else if (ViewState["CurrentTab"] != null)
            {
                pc["ToDoView_CurrentTab"] = ViewState["CurrentTab"].ToString();
            }
            else if (pc["ToDoView_CurrentTab"] == null)
            {
                pc["ToDoView_CurrentTab"] = "General";
            }

            ctrlTopTab.AddTab(LocRM.GetString("tabGeneral"), "General");
            ctrlTopTab.AddTab(LocRM.GetString("tabMetaData"), "Customization");
            ctrlTopTab.AddTab(LocRM.GetString("tabLibrary"), "FileLibrary");
            int projectId = Mediachase.UI.Web.Util.CommonHelper.GetProjectIdByObjectIdObjectType(this.ToDoID, (int)ObjectTypes.ToDo);

            if (ToDo.CanViewFinances(ToDoID) && !Security.CurrentUser.IsExternal && Mediachase.IBN.Business.SpreadSheet.ProjectSpreadSheet.IsActive(projectId))
            {
                ctrlTopTab.AddTab(LocRM.GetString("tabFinance"), "Finance");
            }
            else
            {
                if (pc["ToDoView_CurrentTab"] == "Finance")
                {
                    pc["ToDoView_CurrentTab"] = "General";
                }
            }
            ctrlTopTab.AddTab(LocRM.GetString("tabDiscussions"), "Discussions");
            ctrlTopTab.SelectItem(pc["ToDoView_CurrentTab"]);

            string controlName = "";

            try
            {
                using (IDataReader rdr = ToDo.GetToDo(ToDoID))
                {
                    if (rdr.Read())
                    {
                        if (rdr["IncidentId"] != DBNull.Value)
                        {
                            controlName = "ToDoGeneralIncidentLayout.ascx";
                        }
                        else if (rdr["TaskId"] != DBNull.Value)
                        {
                            controlName = "ToDoGeneralTaskLayout.ascx";
                        }
                        else if (rdr["DocumentId"] != DBNull.Value)
                        {
                            controlName = "ToDoGeneralDocumentLayout.ascx";
                        }
                        else
                        {
                            controlName = "ToDoGeneral2.ascx";
                        }
                    }
                    else
                    {
                        Response.Redirect("../Common/NotExistingID.aspx?ToDoID=1");
                    }
                }
            }
            catch (AccessDeniedException)
            {
                Response.Redirect("../Common/NotExistingID.aspx?AD=1");
            }

            switch (pc["ToDoView_CurrentTab"])
            {
            case "FileLibrary":
                controlName = "FileLibrary.ascx";
                break;

            case "Finance":
                controlName = "Finance.ascx";
                break;

            case "Discussions":
                controlName = "Discussions.ascx";
                break;

            case "Customization":
                controlName = "MetaDataView.ascx";
                break;
            }

            System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName);
            phItems.Controls.Add(control);
        }
예제 #4
0
        private void BindToDoData()
        {
            bool IsExternal = Security.CurrentUser.IsExternal;

            lblOverdue.Text = LocRM.GetString("Overdue");
            bool canViewFinances = ToDo.CanViewFinances(ToDoID);

            using (IDataReader rdr = ToDo.GetToDo(ToDoID))
            {
                ///  ToDoId, ProjectId, ProjectTitle, CreatorId, ManagerId,
                ///  Title, Description, CreationDate, StartDate, FinishDate,
                ///  ActualFinishDate, PriorityId, PriorityName, StatusId, StatusName,
                ///  PercentCompleted, IsActual, CompletionTypeId, CompletionTypeName
                if (rdr.Read())
                {
                    lblTitle.Text = (string)rdr["Title"];

                    lblPriority.Text = (string)rdr["PriorityName"];
                    if (rdr["StartDate"] != DBNull.Value)
                    {
                        TargetStartDate   = (DateTime)rdr["StartDate"];
                        lblStartDate.Text = TargetStartDate.ToShortDateString() + " " + TargetStartDate.ToShortTimeString();
                    }
                    if (rdr["FinishDate"] != DBNull.Value)
                    {
                        TargetFinishDate = (DateTime)rdr["FinishDate"];
                        lblDueDate.Text  = TargetFinishDate.ToShortDateString() + " " + TargetFinishDate.ToShortTimeString();
                    }
                    lblOverallStatus.Text = (int)rdr["PercentCompleted"] + "% ";                   // + LocRM.GetString("Completed");

                    if (rdr["IncidentId"] != DBNull.Value)
                    {
                        lblParentTitle.Text = LocRM.GetString("BelongsToIncident");
                        if (!IsExternal)
                        {
                            lblParent.Text = "<a href='../Incidents/IncidentView.aspx?IncidentID=" + (int)rdr["IncidentId"] + "'>" + (string)rdr["IncidentTitle"] + "</a>";
                        }
                        else
                        {
                            lblParent.Text = (string)rdr["IncidentTitle"];
                        }
                    }
                    else if (rdr["ProjectId"] != DBNull.Value)
                    {
                        if (Configuration.ProjectManagementEnabled)
                        {
                            lblParentTitle.Text = LocRM.GetString("BelongsToProject");

                            if (!IsExternal && Project.CanRead((int)rdr["ProjectId"]))
                            {
                                lblParent.Text = "<a href='../Projects/ProjectView.aspx?ProjectID=" + (int)rdr["ProjectId"] + "'>" + (string)rdr["ProjectTitle"] + "</a>";
                            }
                            else
                            {
                                lblParent.Text = (string)rdr["ProjectTitle"];
                            }
                        }
                        else
                        {
                            tdParentTitle.Visible = false;
                            tdParentName.Visible  = false;
                        }
                    }
                    else
                    {
                        tdParentTitle.Visible = false;
                        tdParentName.Visible  = false;
                    }


                    lblDescription.Text = CommonHelper.parsetext(rdr["Description"].ToString(), false);
                    lblManager.Text     = CommonHelper.GetUserStatus((int)rdr["ManagerId"]);
                    lblCreated.Text     = CommonHelper.GetUserStatus((int)rdr["CreatorId"]) + "&nbsp;&nbsp;" + ((DateTime)rdr["CreationDate"]).ToShortDateString() + " " + ((DateTime)rdr["CreationDate"]).ToShortTimeString();
                    if (rdr["FinishDate"] != DBNull.Value && (DateTime)rdr["FinishDate"] < UserDateTime.UserNow && !(bool)rdr["IsCompleted"])
                    {
                        lblOverdue.Visible = true;
                    }
                    else
                    {
                        lblOverdue.Visible = false;
                    }

                    //lblCompleted.Text = rdr["StatusName"].ToString();
                    lblCompletionType.Text = (string)rdr["CompletionTypeName"];
                    if ((bool)rdr["MustBeConfirmed"])
                    {
                        lblCompletionType.Text += "<br>" + LocRM.GetString("MustConfirm");
                    }

                    bool IsCompleted = (bool)rdr["IsCompleted"];
                    if (IsCompleted)
                    {
                        if (rdr["CompletedBy"] != DBNull.Value)
                        {
                            lblCompleted.Text = GetCompletionType((int)rdr["ReasonId"]) + " " + CommonHelper.GetUserStatus((int)rdr["CompletedBy"]);
                        }
                        else
                        {
                            lblCompleted.Text = LocRM.GetString("Yes");
                        }

                        if (rdr["ActualFinishDate"] != DBNull.Value)
                        {
                            lblActualFinishDate.Text = ((DateTime)rdr["ActualFinishDate"]).ToString("g");
                        }
                        trActualFinishDate.Visible = true;
                    }
                    else
                    {
                        lblCompleted.Text          = LocRM.GetString("No");
                        trActualFinishDate.Visible = false;
                    }

                    string categories = "";
                    using (IDataReader rdr1 = ToDo.GetListCategories(ToDoID))
                    {
                        while (rdr1.Read())
                        {
                            if (categories != "")
                            {
                                categories += ", ";
                            }
                            categories += (string)rdr1["CategoryName"];
                        }
                    }
                    lblCategory.Text = categories;

                    lblClient.Text = Util.CommonHelper.GetClientLink(this.Page, rdr["OrgUid"], rdr["ContactUid"], rdr["ClientName"]);

                    lblTaskTime.Text = Util.CommonHelper.GetHours((int)rdr["TaskTime"]);
                    if (canViewFinances)
                    {
                        SpentTimeLabel.Text = String.Format(CultureInfo.InvariantCulture,
                                                            "{0} / {1}:",
                                                            LocRM3.GetString("spentTime"),
                                                            LocRM3.GetString("approvedTime"));

                        lblSpentTime.Text = String.Format(CultureInfo.InvariantCulture,
                                                          "{0} / {1}",
                                                          Util.CommonHelper.GetHours((int)rdr["TotalMinutes"]),
                                                          Util.CommonHelper.GetHours((int)rdr["TotalApproved"]));
                    }
                }
            }

            tdPriority.Visible         = tdPriority2.Visible = PortalConfig.CommonToDoAllowViewPriorityField;
            tdCompletion.Visible       = tdCompletion2.Visible = PortalConfig.ToDoAllowViewCompletionTypeField;
            tdCategories.Visible       = tdCategories2.Visible = PortalConfig.CommonToDoAllowViewGeneralCategoriesField;
            tdClient.Visible           = tdClient2.Visible = PortalConfig.CommonToDoAllowViewClientField;
            trCategoriesClient.Visible = tdCategories.Visible || tdClient.Visible;
            tdTaskTime.Visible         = tdTaskTime2.Visible = PortalConfig.CommonToDoAllowViewTaskTimeField;
        }