示例#1
0
        public bool OpenJob(string jobNumber)
        {
            if (IsJobOpen && jobNumber.Equals(CurrentJob.JobNumber))
            {
                StatusUpdate?.Invoke(this, new StatusArgs($"Job# {CurrentJob.JobNumber} is already opened. Ignoring re-open command."));
                _jobState = JobState.DuplicateJobNumber;
                return(false);
            }

            if (IsJobOpen && SavePending)
            {
                ExitChoice choice = CMessageBox.ShowExitDialog("There are unsaved changes to the currently opened job. What would you like to do?",
                                                               "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel, Resources.warning_64x64, true);
                switch (choice)
                {
                case ExitChoice.SaveAndExit:
                {
                    isClosing = true;
                    Save();
                    Close();
                    break;
                }

                case ExitChoice.ExitNoSave:
                {
                    isClosing = true;
                    Close();
                    break;
                }

                case ExitChoice.SaveOnly:
                {
                    Save();
                    return(false);
                }

                case ExitChoice.Cancel:
                {
                    StatusUpdate?.Invoke(this, new StatusArgs("Opening of Job# " + jobNumber + " canceled."));
                    return(false);
                }
                }
            }

            _jobState = Open(jobNumber);
            if (_jobState == JobState.OpenError)
            {
                StatusUpdate?.Invoke(this, new StatusArgs("An error occured while trying to open Job#: " + jobNumber + ". Perhaps it doesn't actually exist."));
                return(false);
            }

            if (CurrentJob != null)
            {
                _jobState = JobState.Opened;
            }

            return(CurrentJob != null);
        }
示例#2
0
        public bool CreateJob(string jobNumber)
        {
            if (IsJobOpen && SavePending)
            {
                ExitChoice choice = CMessageBox.ShowExitDialog("There are unsaved changes to the currently opened job. What would you like to do?",
                                                               "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel, Resources.warning_64x64, true);
                switch (choice)
                {
                case ExitChoice.SaveAndExit:
                {
                    isClosing = true;
                    Save();
                    break;
                }

                case ExitChoice.ExitNoSave:
                {
                    isClosing = true;
                    Close();
                    break;
                }

                case ExitChoice.SaveOnly:
                {
                    Save();
                    return(false);
                }

                case ExitChoice.Cancel:
                {
                    StatusUpdate?.Invoke(this, new StatusArgs("Creation of Job# " + jobNumber + " canceled."));
                    _jobState = JobState.CreateCancelled;
                    return(false);
                }
                }
            }

            _jobState = Create(jobNumber);
            if (_jobState == JobState.DuplicateJobNumber)
            {
                StatusUpdate?.Invoke(this, new StatusArgs($"Job# {jobNumber} already exists. Try opening it instead."));
                _jobState = JobState.DuplicateJobNumber;
                return(false);
            }

            if (CurrentJob != null)
            {
                _jobState = JobState.Opened;
            }

            return(true);
        }
示例#3
0
        public bool CloseJob(bool isOpeningOtherJob = false)
        {
            if (IsJobOpen && SavePending)
            {
                ExitChoice choice = CMessageBox.ShowExitDialog("There are unsaved changes to the currently opened job. What would you like to do?",
                                                               "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel, Resources.warning_64x64, true, isOpeningOtherJob);
                switch (choice)
                {
                case ExitChoice.SaveAndExit:
                {
                    isClosing = true;
                    Save();
                    break;
                }

                case ExitChoice.ExitNoSave:
                {
                    Close();
                    break;
                }

                case ExitChoice.SaveOnly:
                {
                    Save();
                    return(false);
                }

                case ExitChoice.Cancel:
                {
                    StatusUpdate?.Invoke(this, new StatusArgs("Closing of Job# " + CurrentJob.JobNumber + " canceled."));
                    _jobState = JobState.CloseCancelled;
                    return(false);
                }

                default:
                    return(false);
                }
            }
            else
            {
                _jobState = Close();
            }
            return(_jobState != JobState.CloseError);
        }