Пример #1
0
        // ---------------------- //
        // -- Event Management -- //
        // ---------------------- //

        // Control-specific events //
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            bool confirm = MessageFunctions.WarningYesNo("This returns back to the application's Main Menu without saving any changes. Are you sure?", "Return to main menu?");

            if (confirm)
            {
                ClientFunctions.ReturnToTilesPage();
            }
        }
Пример #2
0
        public static bool AmendProduct(int productID, string productName, string productDescription, string version)
        {
            try
            {
                decimal versionNumber;

                if (!Decimal.TryParse(version, out versionNumber))
                {
                    MessageFunctions.InvalidMessage("Cannot amend product '" + productName + "': new version number is not a decimal.", "Invalid Version");
                    return(false);
                }

                try
                {
                    ProjectTileSqlDatabase existingPtDb = SqlServerConnection.ExistingPtDbConnection();
                    using (existingPtDb)
                    {
                        Products thisProduct = existingPtDb.Products.Find(productID);
                        if (thisProduct.LatestVersion > versionNumber)
                        {
                            bool carryOn = MessageFunctions.WarningYesNo("The new version number is lower than the existing one. Is that correct?", "Unexpected Version");
                            if (!carryOn)
                            {
                                return(false);
                            }
                        }
                        thisProduct.ProductName        = productName;
                        thisProduct.ProductDescription = productDescription;
                        thisProduct.LatestVersion      = versionNumber;

                        if (ValidateProduct(ref thisProduct, productID))
                        {
                            existingPtDb.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception generalException)
                {
                    MessageFunctions.Error("Problem saving changes to product '" + productName + "'", generalException);
                    return(false);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error amending product '" + productName + "'", generalException);
                return(false);
            }
        }
Пример #3
0
        private bool checkForChanges()
        {
            bool changesExist = (stageChanged || ProjectFunctions.StageDatesChanged.Count > 0);

            if (!changesExist)
            {
                return(true);
            }
            bool isOK = MessageFunctions.WarningYesNo("This will undo all unsaved changes, including changes to the project's current stage. Is this correct?", "Override changes?");

            return(isOK);
        }
Пример #4
0
 private bool checkIgnoreChanges()
 {
     if (!editing || !changesMade)
     {
         return(true);
     }
     else
     {
         bool ignore = MessageFunctions.WarningYesNo("This will clear all unsaved changes you have made. Continue?", "Undo Unsaved Changes?");
         if (ignore)
         {
             resetChanges();
         }
         return(ignore);
     }
 }
        private bool rolesCheck()
        {
            if (!projectSelected || Globals.SelectedProjectProxy == null || Globals.SelectedProjectProxy.ProjectID <= 0)
            {
                return(true);
            }
            string missingRoles = ProjectFunctions.FindMissingRoles(Globals.SelectedProjectProxy.ProjectID, false);

            if (missingRoles == "")
            {
                return(true);
            }
            else
            {
                return(MessageFunctions.WarningYesNo("The following key roles are missing for this project: " + missingRoles + ". Are you sure you want to leave them vacant? "
                                                     + "The project will not be able to progress beyond Initiation until these roles are filled.", "Ignore Vacant Roles?"));
            }
        }
        private void closeDetailsPage(bool closeAll, bool checkFirst)
        {
            if (checkFirst && pageMode != PageFunctions.View)
            {
                bool doClose = MessageFunctions.WarningYesNo("Are you sure you want to close this page? Any changes you have made will be lost.");
                if (!doClose)
                {
                    return;
                }
            }
            bool closeFully = closeAll ? true : !fromProjectPage;

            if (closeFully)
            {
                ProjectFunctions.ReturnToTilesPage();
            }
            else
            {
                ProjectFunctions.ReturnToProjectPage();
            }
        }
Пример #7
0
 // Other/shared functions //
 public bool ConfirmClosure()
 {
     try
     {
         string thisPage = PageFunctions.ThisPageName();
         string question = "Are you sure you want to exit?";
         if (thisPage != Globals.TilesPageName && thisPage != "LoginPage")
         {
             question = question + " Any unsaved changes you have made would be lost.";
             return(MessageFunctions.WarningYesNo(question, "Close ProjectTile Application?"));
         }
         else
         {
             return(MessageFunctions.ConfirmOKCancel(question, "Close ProjectTile Application?"));
         }
     }
     catch
     {
         // Do nothing as it's not worth raising an error when the user wants to leave
         return(true);
     }
 }
Пример #8
0
        public static bool AskQuery(string mainQuery = "", string caption = "")
        {
            if (mainQuery == "" & queryList.Count == 0)
            {
                return(true);
            }

            string isCorrect      = " Was this intended?";
            string areIntentional = " Also, are the following intentional?" + "\n";
            string fullMessage    = mainQuery;

            if (queryList.Count == 0)
            {
            }                             // Nothing else required, just show the query
            else if (queryList.Count == 1)
            {
                string query = queryList[0];
                if (fullMessage == "")
                {
                    query = RemoveAlso(query);
                }
                fullMessage = fullMessage + query + isCorrect;
            }
            else
            {
                if (fullMessage == "")
                {
                    areIntentional = areIntentional.Replace(" Also, are", "Are");
                }
                fullMessage = fullMessage + areIntentional;
                foreach (string query in queryList)
                {
                    fullMessage = fullMessage + "\n" + RemoveAlso(query);
                }
            }

            ClearQuery();
            return(MessageFunctions.WarningYesNo(fullMessage, caption));
        }