// ---------------------- //
        // -- 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); }
        }
        // ---------------------- //
        // -- 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);
            }
        }
        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); }
        }
Beispiel #8
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); }
        }
Beispiel #9
0
        private void closePage(bool closeAll, bool checkFirst)
        {
            if (checkFirst && pageMode != PageFunctions.View)
            {
                bool doClose = checkForChanges();
                if (!doClose)
                {
                    return;
                }
            }
            clearChanges();
            MessageFunctions.CancelInfoAlert();

            Globals.SelectedHistory = ProjectFunctions.GetHistoryRecord(projectID, focusStage);
            bool closeFully = closeAll ? true : !fromProjectPage;

            if (closeFully)
            {
                ProjectFunctions.ReturnToTilesPage();
            }
            else
            {
                ProjectFunctions.ReturnToSourcePage(pageMode);
            }
        }
Beispiel #10
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); }
 }
Beispiel #11
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); }
        }
Beispiel #12
0
        // ---------------------- //
        // -- Event Management -- //
        // ---------------------- //

        // Control-specific events //
        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            string userID   = UserID.Text;
            string password = Password.Password;

            // First check that the details are correct
            if (userID == "")
            {
                MessageFunctions.InvalidMessage("Please enter your User ID in the 'UserID' text box.", "User ID Required");
                return;
            }
            else if (SSOCheckBox.IsChecked == false && password == "")
            {
                string strContext = (pageMode == PageFunctions.PassChange) ? "existing " : "";
                MessageFunctions.InvalidMessage("Please enter your " + strContext + "password in the 'Password' text box.", "Password Required");
                return;
            }

            /*
             * try
             * {
             *  DoubleAnimation spinAnimation = new DoubleAnimation(0, 365, new Duration(TimeSpan.FromSeconds(1)));
             *  Storyboard.SetTargetName(spinAnimation, "RectangleSpin");
             *  Storyboard.SetTargetProperty(spinAnimation, new PropertyPath(RotateTransform.AngleProperty));
             *  spinStoryboard = new Storyboard();
             *  spinStoryboard.RepeatBehavior = RepeatBehavior.Forever;
             *  spinStoryboard.Children.Add(spinAnimation);
             *  spinStoryboard.Begin(this, true);
             * }
             * catch (Exception generalException) { MessageFunctions.Error("Animation error", generalException); }
             */

            // Show the 'please wait' message and queue the next activity for afterwards
            manageCommit(userID, password);
        }
Beispiel #13
0
 private void commitAction(string userID, string password)
 {
     if (pageMode == PageFunctions.LogIn && SSOCheckBox.IsChecked == true && LoginFunctions.SingleSignon(userID))
     {
         pageSuccess = true;
     }
     else if (!LoginFunctions.CheckPassword(userID, password))
     {
         MessageFunctions.InvalidMessage("Incorrect existing username or password. Please check and try again.", "Incorrect Login");
     }
     else if (pageMode == PageFunctions.LogIn)
     {
         LoginFunctions.AttemptLogin(userID, password);
         pageSuccess = true;
     }
     else if (pageMode == PageFunctions.PassChange)
     {
         bool success = LoginFunctions.ChangeLoginDetails(Globals.MyStaffID, userID, NewPassword.Password, ConfirmPassword.Password);
         if (success)
         {
             MessageFunctions.SuccessAlert("Your password has been changed successfully.", "Password Changed");
             pageSuccess = true;
         }
     }
 }
        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); }
        }
        // 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);
            }
        }
Beispiel #16
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); }
        }
        // Utilities //
        public static bool SqlInputOK(string inputText, bool mandatory, string fieldName, string fieldTitle = "", string invalidCharacters = "")
        {
            if (fieldTitle == "")
            {
                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo    = cultureInfo.TextInfo;
                fieldTitle = textInfo.ToTitleCase(fieldName);
            }

            if (mandatory && inputText == "")
            {
                MessageFunctions.InvalidMessage(fieldName + "s cannot be blank. Please enter a value in the '" + fieldTitle + "' field and try again.", "No " + fieldTitle + " Entered");
                return(false);
            }
            else if (invalidCharacters != "")
            {
                List <char> inputChars   = inputText.ToCharArray().ToList();
                List <char> invalidChars = invalidCharacters.ToCharArray().ToList();

                foreach (char badChar in invalidChars)
                {
                    if (inputChars.Contains(badChar))
                    {
                        MessageFunctions.InvalidMessage(fieldName + " cannot contain the character '" + badChar.ToString() + "'. Please remove it and try again.", "Invalid Character");
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #18
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");
        }
Beispiel #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();
        }
        // ---------------------- //
        // -- 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 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); }
 }
        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);
            }
        }
        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 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);
            }
        }
Beispiel #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 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 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); }
        }
        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);
            }
        }
 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();
     }
 }
        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";
        }