Пример #1
0
        private bool setUpEditing(int projectID)
        {
            try
            {
                ProjectFunctions.LoggedByList = ProjectFunctions.GetInternalTeam(projectID);
                stageList = ProjectFunctions.GetProjectHistoryStages(projectID);
                stageList.Add(Globals.NoStage);
                ProjectFunctions.OwnerList = ProjectFunctions.CombinedTeamList(projectID);

                foreach (ActionProxy action in ProjectFunctions.ActionList) // Required for the initial values to display when in 'project mode'
                {
                    int?stageID = action.LinkedStage.ID;
                    if (stageID != null)
                    {
                        action.LinkedStage = stageList.Where(sl => sl.ID == stageID).FirstOrDefault();
                    }

                    int loggedByID = action.LoggedBy.ID;
                    action.LoggedBy = ProjectFunctions.LoggedByList.Where(lbl => lbl.ID == loggedByID).FirstOrDefault();

                    bool internalOwner = (action.Owner.InternalTeamMember != null);
                    int  ownerID       = internalOwner ? action.Owner.InternalTeamMember.ID : action.Owner.ClientTeamMember.ID;
                    action.Owner = ProjectFunctions.OwnerList.Where(ol => (internalOwner && ol.InternalTeamMember.ID == ownerID) ||
                                                                    (!internalOwner && ol.ClientTeamMember != null && ol.ClientTeamMember.ID == ownerID))
                                   .FirstOrDefault();
                }

                if (!editing || firstRefresh)
                {
                    editing = true;
                    ProjectButtonText.Text         = "All Projects";
                    ActionDataGrid.IsReadOnly      = false;
                    ActionDataGrid.BorderThickness = new Thickness(3);
                    Instructions.Content           = "Double-click cells in italics to edit (others update automatically). Edit the bottom (blank) row to add.";
                    MessageFunctions.InfoAlert("To add new rows, scroll to the bottom of the table and edit the first empty row. Each action must have an 'owner' from the project team, "
                                               + "and either a linked stage or a target completion date.", "'Direct Edit' Mode");
                    NotesBox.IsReadOnly = false;
                }
                return(true);
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error setting up action editing", generalException);
                return(false);
            }
        }