private void refreshTeamDataGrid()
        {
            try
            {
                TeamProxy    currentRecord               = selectedTeamRecord ?? null;
                ProjectProxy currentProjectProxy         = (ProjectCombo.SelectedItem != null) ? (ProjectProxy)ProjectCombo.SelectedItem : Globals.AllProjects;
                Globals.ProjectStatusFilter statusFilter = Globals.SelectedStatusFilter;
                string projectRoleCode            = Globals.SelectedProjectRole.RoleCode;
                Globals.TeamTimeFilter timeFilter = Globals.SelectedTeamTimeFilter;

                bool success = ProjectFunctions.SetTeamsGridList(statusFilter, projectRoleCode, timeFilter, currentProjectProxy.ProjectID, nameLike, exactName);
                if (success)
                {
                    TeamDataGrid.ItemsSource = ProjectFunctions.TeamsGridList;
                    if (currentRecord != null && ProjectFunctions.TeamsGridList.Exists(tgl => tgl.ID == currentRecord.ID))
                    {
                        TeamDataGrid.SelectedItem = ProjectFunctions.TeamsGridList.First(tgl => tgl.ID == currentRecord.ID);
                    }
                    else if (ProjectFunctions.TeamsGridList.Count == 1)
                    {
                        TeamDataGrid.SelectedItem = ProjectFunctions.TeamsGridList.ElementAt(0);
                    }
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error populating project team grid data", generalException); }
        }
        // ---------------------- //
        // -- Data Management --- //
        // ---------------------- //

        // Data updates //

        // Data retrieval //

        // Other/shared functions //
        private void refreshClientGrid()
        {
            try
            {
                int selectedID = 0;
                if (Globals.SelectedClient != null)
                {
                    selectedID = Globals.SelectedClient.ID;
                }
                if (selectedID == 0 && selectedClientGridRecord != null)
                {
                    selectedID = selectedClientGridRecord.ID;
                }                                                                                                      // Just in case

                clientGridList             = ClientFunctions.ClientGridListByContact(clientActiveOnly, clientContains, contactContains, Globals.CurrentEntityID);
                ClientDataGrid.ItemsSource = clientGridList;
                ClientDataGrid.Items.SortDescriptions.Clear();
                ClientDataGrid.Items.SortDescriptions.Add(new SortDescription("ClientCode", ListSortDirection.Ascending));

                try
                {
                    if (selectedID != 0 && clientGridList.Exists(c => c.ID == selectedID))
                    {
                        ClientDataGrid.SelectedItem = clientGridList.First(c => c.ID == selectedID);
                        ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem);
                    }
                }
                catch (Exception generalException) { MessageFunctions.Error("Error selecting the current client row", generalException); }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error refreshing client details in the grid", generalException); }
        }
        private void refreshClientCombo()
        {
            try
            {
                if (Globals.ClientSourcePage == "ClientPage") // Don't allow changing
                {
                    ClientCombo.IsEnabled = false;            // Must come first as used in 'selection changed'
                    ClientCombo.Items.Clear();                // Just in case!
                    ClientCombo.Items.Add(Globals.SelectedClient);
                    ClientCombo.SelectedItem = Globals.SelectedClient;
                }
                else if (selectedClientGridRecord != null)
                {
                    ClientCombo.ItemsSource  = clientGridList;
                    ClientCombo.SelectedItem = selectedClientGridRecord;
                }
                else if (Globals.SelectedClient != null) // Back from the client contact details page
                {
                    refreshClientGrid();
                    ClientCombo.Items.Clear(); // Just in case!
                    ClientCombo.ItemsSource = clientGridList;
                    ClientProxy thisRecord = clientGridList.FirstOrDefault(cgl => cgl.ID == Globals.SelectedClient.ID);
                    if (thisRecord != null)
                    {
                        ClientCombo.SelectedItem = thisRecord;
                    }
                }

                //refreshContactGrid(); // Shouldn't be needed as the selection change does it for us
            }
            catch (Exception generalException) { MessageFunctions.Error("Error refreshing the clients drop-down", generalException); }
        }
        private void toActivated(bool ProjectList)
        {
            try
            {
                bool projectSelected = (ProjectList && ProjectTo.SelectedItem != null);
                bool productSelected = (!ProjectList && ProductTo.SelectedItem != null);

                if (projectSelected)
                {
                    selectedProjectProduct = (ProjectProductProxy)ProjectTo.SelectedItem;
                }
                else if (productSelected)
                {
                    selectedProjectProduct = (ProjectProductProxy)ProductTo.SelectedItem;
                }
                else
                {
                    selectedProjectProduct = null;
                }

                if (selectedProjectProduct != null && selectedProjectProduct.Stage().StageNumber < Globals.LiveStage)
                {
                    OldVersion.Text        = selectedProjectProduct.OldVersion.ToString("#0.0");
                    NewVersion.Text        = selectedProjectProduct.NewVersion.ToString("#0.0");
                    RemoveButton.IsEnabled = OldVersion.IsEnabled = NewVersion.IsEnabled = true;
                }
                else
                {
                    OldVersion.Text        = NewVersion.Text = "";
                    RemoveButton.IsEnabled = OldVersion.IsEnabled = NewVersion.IsEnabled = false;
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error activating the 'Remove' and 'Active' buttons", generalException); }
        }
        private void removeProject()
        {
            try
            {
                if (ProjectTo.SelectedItem != null)
                {
                    List <Projects>     removeList  = new List <Projects>();
                    ProjectProductProxy thisRecord  = (ProjectProductProxy)ProjectTo.SelectedItem;
                    Projects            thisProject = ProjectFunctions.GetProject(thisRecord.ProjectID);
                    removeList.Add(thisProject);

                    bool success = ProjectFunctions.ToggleProductProjects(removeList, false, selectedProduct);
                    if (success)
                    {
                        refreshProjectSummaries(false);
                        CommitButton.IsEnabled = true;
                    }
                }
                else
                {
                    MessageFunctions.Error("Error removing project from Product: no project selected.", null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error removing project from Product", generalException);
            }
        }
Пример #6
0
        public static void ChangePage(string newPageSource)
        {
            if (newPageSource != TilesPageURI)
            {
                try
                {
                    string mainFrameSource = ThisPageName();
                    string newPageName     = newPageSource.Replace(".xaml", "");
                    ToggleSideButtons(false);

                    if (mainFrameSource != TilesPageName && mainFrameSource == newPageName)
                    {
                        var  dInv1 = winMain.Dispatcher.Invoke(new Action(() => { navigate(TilesPageURI); })); // Open the tiles page in between to reset
                        var  task1 = Task.Factory.StartNew(() => dInv1);
                        var  dInv2 = winMain.Dispatcher.Invoke(new Action(() => { navigate(newPageSource); }));
                        Task task2 = task1.ContinueWith((antecedent) => dInv2);
                    }
                    else
                    {
                        navigate(newPageSource);
                    }
                }
                catch (Exception generalException) { MessageFunctions.Error("Error changing page", generalException); }
            }
            else
            {
                try
                {
                    navigate(newPageSource);
                    ToggleSideButtons(true);
                }
                catch (Exception generalException) { MessageFunctions.Error("Error changing page", generalException); }
            }
        }
        // Other/shared functions //
        private void refreshProjectDataGrid()
        {
            try
            {
                int selectedID = (Globals.SelectedProjectProxy != null) ? Globals.SelectedProjectProxy.ProjectID : 0;

                projectGridList             = ProjectFunctions.ProjectGridListByProduct(activeOnly, nameContains, selectedProductID, Globals.CurrentEntityID);
                ProjectDataGrid.ItemsSource = projectGridList;
                ProjectDataGrid.Items.SortDescriptions.Clear();
                ProjectDataGrid.Items.SortDescriptions.Add(new SortDescription("ProjectCode", ListSortDirection.Ascending));

                if (selectedID > 0)
                {
                    try
                    {
                        if (projectGridList.Exists(pgl => pgl.ProjectID == selectedID))
                        {
                            ProjectDataGrid.SelectedItem = projectGridList.First(pgl => pgl.ProjectID == selectedID);
                            ProjectDataGrid.ScrollIntoView(ProjectDataGrid.SelectedItem);
                        }
                    }
                    catch (Exception generalException) { MessageFunctions.Error("Error selecting record", generalException); }
                }

                // refreshProjectSummaries(true);
            }
            catch (Exception generalException) { MessageFunctions.Error("Error filling project grid", generalException); }
        }
Пример #8
0
 private void changeTimelineType(Globals.TimelineType type)
 {
     try
     {
         if (ProjectFunctions.FullStageList == null || ProjectFunctions.FullStageList.Count() == 0)
         {
             return;
         }                                                                                                      // Too early
         else if (type == Globals.SelectedTimelineType)
         {
             return;
         }                                                          // Cancelling the earlier change
         else if (checkForChanges())
         {
             Globals.SelectedTimelineType = type;
             clearChanges();
             refreshTimeData();
         }
         else
         {
             setTimelineType(Globals.SelectedTimelineType);
         }
     }
     catch (Exception generalException) { MessageFunctions.Error("Error changing timeline type", generalException); }
 }
Пример #9
0
        // -------------- Data updates -------------- //

        private void updateProjectStage(int newStageNumber, bool alreadyUpdated)
        {
            try
            {
                if (newStageNumber != currentStageNumber) // Allows looping round again if undoing the change
                {
                    bool confirm = MessageFunctions.ConfirmOKCancel("This will update the start dates of any future-dated stages that are now complete or in progress. Are you sure? "
                                                                    + "If the results are not as expected, use the 'Back' or 'Close' button afterwards to undo all changes.");
                    if (!confirm)
                    {
                        if (alreadyUpdated)
                        {
                            currentTimeline.Stage = ProjectFunctions.GetStageByNumber(currentStageNumber);
                        }
                        return;
                    }
                    currentStageNumber = newStageNumber;
                    if (!alreadyUpdated)
                    {
                        currentTimeline.Stage = ProjectFunctions.GetStageByNumber(newStageNumber);
                        displaySelectedStage();
                    }
                    stageChanged = true;
                    updateAffectedDates();
                    formatDatePickers();
                    NextButton.IsEnabled   = (!ProjectFunctions.IsLastStage(newStageNumber));
                    CommitButton.IsEnabled = true;
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error updating current project stage", generalException); }
        }
Пример #10
0
        // ---------------------- //
        // -- Data Management --- //
        // ---------------------- //

        // Data updates //
        private void ensureCurrentRecordDisplayed()
        {
            try
            {
                ProjectProxy currentRecord = (selectedProject != null && selectedProject.ProjectID > 0) ? selectedProject : null;
                int          clientID      = (Globals.SelectedClientProxy != null) ? ProjectFunctions.SelectedClientProxy.ID : 0;
                int          managerID     = (Globals.SelectedPMProxy != null) ? ProjectFunctions.SelectedPMProxy.ID : 0;
                Globals.ProjectStatusFilter statusFilter = Globals.SelectedStatusFilter;

                if (currentRecord != null) // Reset filters if necessary to show the selected record
                {
                    if (clientID != 0 && clientID != currentRecord.Client.ID)
                    {
                        Globals.SelectedClientProxy = Globals.AnyClient;
                    }
                    if (managerID != 0 && managerID != currentRecord.ProjectManager.ID)
                    {
                        Globals.SelectedPMProxy = Globals.AllPMs;
                    }
                    if (!ProjectFunctions.IsInFilter(statusFilter, currentRecord.Stage))
                    {
                        Globals.SelectedStatusFilter = Globals.ProjectStatusFilter.All;
                    }
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error displaying the current project record", generalException); }
        }
Пример #11
0
        private void refreshMainProjectGrid()
        {
            try
            {
                ProjectProxy currentRecord = (selectedProject != null) ? selectedProject : null;
                int          clientID      = (Globals.SelectedClientProxy != null)? ProjectFunctions.SelectedClientProxy.ID : 0;
                int          managerID     = (Globals.SelectedPMProxy != null) ? ProjectFunctions.SelectedPMProxy.ID : 0;
                Globals.ProjectStatusFilter statusFilter = Globals.SelectedStatusFilter;

                bool success = ProjectFunctions.SetProjectGridList(statusFilter, clientID, managerID);
                if (success)
                {
                    ProjectDataGrid.ItemsSource = ProjectFunctions.ProjectGridList;
                    if (currentRecord != null && ProjectFunctions.ProjectGridList.Exists(pgl => pgl.ProjectID == currentRecord.ProjectID))
                    {
                        ProjectDataGrid.SelectedItem = ProjectFunctions.ProjectGridList.First(pgl => pgl.ProjectID == currentRecord.ProjectID);
                        ProjectDataGrid.ScrollIntoView(ProjectDataGrid.SelectedItem);
                    }
                    else if (ProjectFunctions.ProjectGridList.Count == 1)
                    {
                        ProjectDataGrid.SelectedItem = ProjectFunctions.ProjectGridList.ElementAt(0);
                    }
                }
                else
                {
                    closePage(true);
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error populating project grid data", generalException); }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                pageMode = PageFunctions.pageParameter(this, "Mode");
                Globals.ProjectSourceMode = pageMode;
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving query details", generalException);
                PageFunctions.ShowTilesPage();
            }

            refreshClientCombo();
            refreshStatusCombo();
            refreshStageCombo();
            setTimelineType(Globals.SelectedTimelineType);
            FromDate.SelectedDate = Globals.SelectedFromDate;
            ToDate.SelectedDate   = Globals.SelectedToDate;
            PageFunctions.ShowFavouriteButton();
            if (pageMode == PageFunctions.View)
            {
                AmendImage.SetResourceReference(Image.SourceProperty, "ViewIcon");
                Instructions.Content += " Click 'Details' to see a project's full timeline.";
            }
            else
            {
                Instructions.Content += " Click 'Details' to amend a project's timeline.";
            }

            pageLoaded = true;
            refreshHistoryDataGrid();
            Globals.ProjectSourcePage = "StageHistoryPage";
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         pageMode      = PageFunctions.pageParameter(this, "Mode");
         staffIDString = PageFunctions.pageParameter(this, "StaffID");
     }
     catch (Exception generalException)
     {
         MessageFunctions.Error("Error retrieving query details", generalException);
         PageFunctions.ShowTilesPage();
     }
     canEditTeams = (pageMode != PageFunctions.View && Globals.MyPermissions.Allow("EditProjectTeams"));
     PageFunctions.ShowFavouriteButton();
     toggleEditMode(false);
     refreshStatusCombo();
     refreshRoleFilterCombo();
     setTeamTimeRadio();
     Int32.TryParse(staffIDString, out staffID);
     if (staffID > 0)
     {
         chooseStaffName(staffID);
     }
     this.DataContext = editTeamRecord;
     toggleBackButton();
     MessageFunctions.InfoAlert("Current key roles are bold. Future roles are blue, and past ones are grey; otherwise, Live (open) projects are green.", "Grid formatting:");
 }
        private void toggleEditMode(bool editing) // Note that when editing, this is called from setUpEdit rather than the other way round
        {
            try
            {
                if (editing && Globals.SelectedProjectProxy.IsOld)
                {
                    MessageFunctions.InvalidMessage("Staff cannot be amended for closed or cancelled projects.", "Project is Closed");
                    return;
                }

                AmendmentGrid.Visibility = CommitButton.Visibility = editing ? Visibility.Visible : Visibility.Hidden;
                StatusLabel.Visibility   = StatusCombo.Visibility = ProjectButton.Visibility = (editing) ? Visibility.Hidden : Visibility.Visible;
                NameLikeLabel.Visibility = NameLike.Visibility = RoleFilterLabel.Visibility = RoleFilterCombo.Visibility = StatusLabel.Visibility;
                toggleEditButtons(!editing && ProjectCombo.SelectedItem != null && ProjectCombo.SelectedItem != Globals.AllProjects);
                TeamDataGrid.Width            = editing ? TeamDataGrid.MinWidth : TeamDataGrid.MaxWidth;
                TimeGroup.HorizontalAlignment = editing ? HorizontalAlignment.Left : HorizontalAlignment.Right;
                ProjectCombo.IsEnabled        = TeamDataGrid.IsEnabled = !editing;
                if (!editing)
                {
                    Instructions.Content = defaultInstructions;
                }                                                             // Otherwise set up later depending on the mode
                CancelButtonText.Text = editing ? "Cancel" : "Close";
            }
            catch (Exception generalException) { MessageFunctions.Error("Error displaying required controls", generalException); }
        }
Пример #15
0
        public bool ConvertToProject(ref Projects project) // Uses a reference to easily amend an existing database record
        {
            try
            {
                project.ID             = ProjectID;
                project.EntityID       = EntityID;
                project.ProjectCode    = ProjectCode;
                project.TypeCode       = Type.TypeCode;
                project.ProjectName    = ProjectName;
                project.StartDate      = StartDate;
                project.StageID        = Stage.ID;
                project.ProjectSummary = ProjectSummary;
                if (Client.ID != NoID)
                {
                    project.ClientID = Client.ID;
                }                                                        // 'No client' is null in the database)

                return(true);
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error converting project summary to project record", generalException);
                return(false);
            }
        }
Пример #16
0
        private void updateDate(int i)
        {
            try
            {
                int position = positionFromStage(i);

                DateTime thisDate = (currentTimeline.DateHash[i] == null) ? Globals.InfiniteDate : (DateTime)currentTimeline.DateHash[i];
                if (i < currentTimeline.StageNumber && thisDate > Globals.Today)
                {
                    datePickers[position].SelectedDate = null;
                    ProjectFunctions.QueueDateChange(i);
                }
                else if (i == currentTimeline.StageNumber && !thisDate.Equals(Globals.Today))
                {
                    datePickers[position].SelectedDate = Globals.Today;
                    ProjectFunctions.QueueDateChange(i);
                }
                else if (i > currentTimeline.StageNumber && thisDate <= Globals.Today)
                {
                    datePickers[position].SelectedDate = (Globals.SelectedTimelineType == Globals.TimelineType.Effective) ?
                                                         ProjectFunctions.GetStageStartDate(projectID, i, true) :
                                                         datePickers[position].SelectedDate = null;
                    ProjectFunctions.QueueDateChange(i);
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error updating project date for stage number " + i.ToString(), generalException); }
        }
Пример #17
0
        // Page initialisation //
        public static string pageParameter(Page currentPage, string paramName)
        {
            try
            {
                string paramValue     = "";
                string originalString = currentPage.NavigationService.CurrentSource.OriginalString;

                string[] originalStringArray = originalString.Split('?', ','); // NB: NavigationService.CurrentSource.Query will not work as it is a relative URL
                foreach (string part in originalStringArray)
                {
                    if (part.StartsWith(paramName + "="))
                    {
                        paramValue = part.Replace(paramName + "=", "");
                    }
                }

                if (paramValue != "")
                {
                    return(paramValue);
                }
                else
                {
                    MessageFunctions.Error("No page parameter called " + paramName + " found.", null);
                    ShowTilesPage();
                    return(null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving page parameter " + paramName + "", generalException);
                ShowTilesPage();
                return(null);
            }
        }
Пример #18
0
        private void formatDatePickers()
        {
            try
            {
                if (datePickers.Count <= 0)
                {
                    return;
                }
                int  stageNumber = currentTimeline.StageNumber;
                bool actual      = (Globals.SelectedTimelineType == Globals.TimelineType.Actual);
                bool effective   = (Globals.SelectedTimelineType == Globals.TimelineType.Effective);
                bool target      = (Globals.SelectedTimelineType == Globals.TimelineType.Target);


                for (int i = 0; i < cancelledPosition; i++)
                {
                    formatPicker(stageNumber, actual, effective, target, i);
                }
                formatPicker(stageNumber, actual, effective, target, cancelledPosition);

                if (focusStage == Globals.CancelledStage)
                {
                    datePickers[cancelledPosition].Focus();
                }
                else
                {
                    datePickers[focusStage].Focus();
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error highlighing date statuses", generalException); }
        }
Пример #19
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                pageMode = PageFunctions.pageParameter(this, "Mode");
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving query details", generalException);
                PageFunctions.ShowTilesPage();
            }

            if (pageMode == PageFunctions.View)
            {
                CommitButton.Visibility   = Visibility.Hidden;
                AmendmentsGrid.Visibility = AmendButton.Visibility = AddButton.Visibility = BackButton.Visibility = Visibility.Hidden;
            }
            else if (pageMode == PageFunctions.New)
            {
                additionMode();
                AmendButton.Visibility = AddButton.Visibility = BackButton.Visibility = Visibility.Hidden;
                PageHeader.Content     = "Create New Product";
                HeaderImage2.SetResourceReference(Image.SourceProperty, "AddIcon");
            }
            else if (pageMode == PageFunctions.Amend)
            {
                ProductGrid.SelectionMode = DataGridSelectionMode.Single;
                PageHeader.Content        = allowAdd? "Amend (or Create) Products" : "Amend Products";
                HeaderImage2.SetResourceReference(Image.SourceProperty, "AmendIcon");
                amendmentSetup();
            }

            refreshProductGrid();
        }
Пример #20
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                pageMode  = PageFunctions.pageParameter(this, "Mode");
                projectID = Int32.Parse(PageFunctions.pageParameter(this, "ProjectID"));
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving query details", generalException);
                PageFunctions.ShowTilesPage();
            }
            if (pageMode == PageFunctions.View)
            {
                viewOnly = true;
                CommitButton.Visibility = NextButton.Visibility = Visibility.Hidden;
                StageCombo.IsEnabled    = false;
            }

            PageHeader.Content = "Project Timeline for Project " + ProjectFunctions.GetProject(projectID).ProjectCode;
            createControlArrays();
            refreshStageCombo();
            setTimelineType(Globals.SelectedTimelineType);
            refreshTimeData();
            MessageFunctions.InfoAlert("Effective date is the actual date for previous stages, and the target date for future ones. If targets are out of date, this can mean that "
                                       + "future stages show an earlier (target) date than historic ones.", "Please note");
        }
 private void fromActivated(bool ProjectList)
 {
     try
     {
         if (ProjectList && ProjectFrom.SelectedItems != null)
         {
             bool showAddButton = true;
             foreach (var selectedRow in ProjectFrom.SelectedItems)
             {
                 Projects selection = (Projects)selectedRow;
                 if (ProjectFunctions.GetStageNumber(selection.StageID) >= Globals.LiveStage)
                 {
                     showAddButton = false;
                     break;
                 }
             }
             AddButton.IsEnabled = showAddButton;
         }
         else
         {
             AddButton.IsEnabled = (!ProjectList && ProductFrom.SelectedItems != null);
         }
     }
     catch (Exception generalException) { MessageFunctions.Error("Error activating the 'Add' button", generalException); }
 }
Пример #22
0
        // ---------------------- //
        // -- Data Management --- //
        // ---------------------- //

        // Data updates //
        public void UpdateDetailsBlock()
        {
            try
            {
                Run userIDRun = new Run(Globals.MyUserID);
                userIDRun.FontWeight = FontWeights.Bold;
                Hyperlink userIDLink = new Hyperlink(userIDRun);
                userIDLink.Click += LoginMenu_Login_Click;

                Run currentEntityRun = new Run(Globals.CurrentEntityName);
                currentEntityRun.FontWeight = FontWeights.Bold;
                Hyperlink currentEntityLink = new Hyperlink(currentEntityRun);
                currentEntityLink.Click += ChangeEntity_Click;

                Run defaultEntityRun = new Run(Globals.MyDefaultEntityName);
                defaultEntityRun.FontWeight = FontWeights.Bold;
                Hyperlink defaultEntityLink = new Hyperlink(defaultEntityRun);
                defaultEntityLink.Click += DefaultEntity_Click;

                DetailsBlock.Inlines.Clear();
                DetailsBlock.Inlines.Add("UserID: ");
                DetailsBlock.Inlines.Add(userIDLink);
                DetailsBlock.Inlines.Add("\n" + "Name: " + Globals.MyName + "\n\n");

                DetailsBlock.Inlines.Add("Entity: ");
                DetailsBlock.Inlines.Add(currentEntityLink);
                DetailsBlock.Inlines.Add("\n" + "Default: ");
                DetailsBlock.Inlines.Add(defaultEntityLink);
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error refreshing current details", generalException);
            }
        }
        private void addProducts()
        {
            try
            {
                if (ProductFrom.SelectedItems != null)
                {
                    List <ClientProductProxy> addList = new List <ClientProductProxy>();
                    foreach (var selectedRow in ProductFrom.SelectedItems)
                    {
                        addList.Add((ClientProductProxy)selectedRow);
                    }

                    bool success = ProjectFunctions.ToggleProjectProducts(addList, true, Globals.SelectedProjectProxy);
                    if (success)
                    {
                        refreshProductSummaries(false);
                        CommitButton.IsEnabled = true;
                    }
                }
                else
                {
                    MessageFunctions.Error("Error adding products to project: no product selected.", null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error adding products to project", generalException);
            }
        }
        private void removeStaff()
        {
            try
            {
                if (StaffTo.SelectedItems != null)
                {
                    List <StaffProxySmall> toList = new List <StaffProxySmall>();
                    foreach (var selectedRow in StaffTo.SelectedItems)
                    {
                        toList.Add((StaffProxySmall)selectedRow);
                    }

                    bool success = StaffFunctions.ToggleEntityStaff(toList, false, selectedEntity);
                    if (success)
                    {
                        refreshStaffSummaries(false);
                        CommitButton.IsEnabled = true;
                        //AddButton.IsEnabled = DefaultButton.IsEnabled = RemoveButton.IsEnabled = false;
                    }
                }
                else
                {
                    MessageFunctions.Error("Error removing staff from Entity: no staff selected.", null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error removing staff from Entity", generalException);
            }
        }
Пример #25
0
        // Data retrieval

        public static List <Products> ProductsList(string search, bool includeAll = false)
        {
            try
            {
                ProjectTileSqlDatabase existingPtDb = SqlServerConnection.ExistingPtDbConnection();
                using (existingPtDb)
                {
                    List <Products> productGridList = new List <Products>();
                    productGridList = (from p in existingPtDb.Products
                                       where search == "" || p.ProductName.Contains(search) || p.ProductDescription.Contains(search)
                                       orderby p.ProductName
                                       select p).ToList();

                    if (includeAll)
                    {
                        Products dummyProduct = new Products {
                            ID = 0, ProductName = AllRecords, ProductDescription = "", LatestVersion = 0
                        };
                        productGridList.Add(dummyProduct);
                    }

                    return(productGridList);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving products list", generalException);
                return(null);
            }
        }
        private void removeEntities()
        {
            try
            {
                if (EntitiesTo.SelectedItems != null)
                {
                    List <EntityProxy> toList = new List <EntityProxy>();
                    foreach (var selectedRow in EntitiesTo.SelectedItems)
                    {
                        toList.Add((EntityProxy)selectedRow);
                    }

                    bool success = StaffFunctions.ToggleStaffEntities(toList, false, Globals.SelectedStaffMember);
                    if (success)
                    {
                        refreshEntitySummaries(false);
                        CommitButton.IsEnabled = true;
                        //AddButton.IsEnabled = DefaultButton.IsEnabled = RemoveButton.IsEnabled = false;
                    }
                }
                else
                {
                    MessageFunctions.Error("Error removing Entities from staff: no Entity selected.", null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error removing Entities from staff", generalException);
            }
        }
        private void refreshContactGrid()
        {
            try
            {
                int selectedID = 0;
                if (initialContactID > 0)
                {
                    selectedID       = initialContactID;
                    initialContactID = 0; // Only used at page initiation, so this stops it interfering later
                }
                else if (selectedContactGridRecord != null)
                {
                    selectedID = selectedContactGridRecord.ID;
                }

                contactGridList             = ClientFunctions.ContactGridList(contactContains, contactActiveOnly, Globals.SelectedClient.ID, includeJob: true);
                ContactDataGrid.ItemsSource = contactGridList;
                if (selectedID > 0)
                {
                    try
                    {
                        if (contactGridList.Exists(c => c.ID == selectedID))
                        {
                            ContactDataGrid.SelectedItem = contactGridList.First(c => c.ID == selectedID);
                            ContactDataGrid.ScrollIntoView(ContactDataGrid.SelectedItem);
                        }
                    }
                    catch (Exception generalException) { MessageFunctions.Error("Error selecting the current contact row", generalException); }
                }
            }
            catch (Exception generalException) { MessageFunctions.Error("Error refreshing client contact details in the grid", generalException); }
        }
Пример #28
0
        private void addYourQuestions()
        {
            addHeader("Your Questions");
            try
            {
                Paragraph para     = new Paragraph();
                Span      question = new Span();
                question.SetResourceReference(StyleProperty, "QuestionSpan");
                question.Inlines.Add("How do I get in touch to find out more?" + newLine);
                para.Inlines.Add(question);

                Span answer1 = new Span();
                answer1.SetResourceReference(StyleProperty, "AnswerSpan");
                answer1.Inlines.Add("Email ");

                //Span hyperSpan = new Span();
                //Run hyperText = new Run("*****@*****.**");
                Hyperlink hyperLink = new Hyperlink();
                hyperLink.Inlines.Add("*****@*****.**");
                hyperLink.NavigateUri = new Uri("mailto:[email protected]?subject=Regarding%20ProjectTile");
                //hyperLink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(requestNavigation);
                //hyperLink.Click += requestEmail;
                //hyperSpan.Inlines.Add(hyperText);

                Span answer2 = new Span();
                answer2.SetResourceReference(StyleProperty, "AnswerSpan");
                answer2.Inlines.Add(" with any further questions, comments or to get in touch regarding job opportunities.");

                para.Inlines.Add(answer1);
                para.Inlines.Add(hyperLink);
                para.Inlines.Add(answer2);
                thisDoc.Blocks.Add(para);
            }
            catch (Exception generalException) { MessageFunctions.Error("Error adding question", generalException); }
        }
 private void ClientDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (ClientDataGrid.SelectedItem != null)
         {
             selectedClientGridRecord = (ClientProxy)ClientDataGrid.SelectedItem;
             if (pageMode != PageFunctions.Lookup)
             {
                 ClientFunctions.SelectClient(selectedClientGridRecord.ID);
             }
             ContactButton.IsEnabled = true;
             checkForSingleContact();
         }
         else
         {
             clearClientSelection();
         }
     }
     catch (Exception generalException)
     {
         MessageFunctions.Error("Error processing client grid selection", generalException);
         clearClientSelection();
     }
 }
Пример #30
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                pageMode          = PageFunctions.pageParameter(this, "Mode");
                selectedProductID = Int32.Parse(PageFunctions.pageParameter(this, "ProductID"));
                refreshProductCombo(true);
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error retrieving query details", generalException);
                ClientFunctions.ReturnToTilesPage();
            }

            if (pageMode == PageFunctions.View)
            {
                ClientButton.Visibility = Visibility.Hidden;
                Instructions.Content    = "Select a client and click 'Products', or select a product to see its clients.";
            }
            else
            {
                Instructions.Content = activeInstructions;
            }

            CommitButton.Visibility = Visibility.Hidden;
            ClientFrom.Visibility   = ClientTo.Visibility = Visibility.Hidden;
            ClientLabel.Margin      = NameContainsLabel.Margin;
            ClientCombo.Margin      = NameContains.Margin;
            if (!Globals.MyPermissions.Allow("ActivateClientProducts"))
            {
                DisableButton.IsEnabled = false;
                DisableButton.ToolTip   = "Your current permissions do not allow activating or disabling client products";
            }

            if (Globals.SelectedClient != null) // Opened from the Clients Page or Project Products
            {
                fromSource            = Globals.ClientSourcePage;
                ClientCombo.IsEnabled = false; // Cannot easily recreate the same selection list
                refreshClientDataGrid();       // Ensure the record we want is listed, though
                viewProductsByClient();
            }
            else if (selectedProductID > 0) // Opened from Project Products
            {
                fromSource             = Globals.ClientSourcePage;
                ProductCombo.IsEnabled = false; // Cannot easily recreate the same selection list
                refreshClientDataGrid();        // Ensure the record we want is listed, though
                viewClientsByProduct();
            }
            else
            {
                fromSource             = Globals.TilesPageName;
                ClientLabel.Visibility = ClientCombo.Visibility = Visibility.Hidden;
                BackButton.Visibility  = Visibility.Hidden;
                ProductFrom.Visibility = ProductTo.Visibility = Visibility.Hidden;

                AddButton.Visibility    = RemoveButton.Visibility = Visibility.Hidden;
                VersionLabel.Visibility = Version.Visibility = DisableButton.Visibility = Visibility.Hidden;
                FromLabel.Visibility    = ToLabel.Visibility = Visibility.Hidden;
            }
        }