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); }
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); }
public bool OpenJob(Survey s) { if (IsJobOpen) { if (s.JobNumber.Equals(CurrentJob.JobNumber)) { StatusUpdate?.Invoke(this, new StatusArgs($"Job# {CurrentJob.JobNumber} is already opened. Ignoring re-open command.")); _jobState = JobState.DuplicateJobNumber; return(false); } } _jobState = Open(s); switch (_jobState) { case JobState.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(); OpenJob(s); break; } case ExitChoice.ExitNoSave: { isClosing = true; Close(); OpenJob(s); break; } case ExitChoice.SaveOnly: { Save(); return(false); } case ExitChoice.Cancel: { StatusUpdate?.Invoke(this, new StatusArgs("Opening of Job# " + s.JobNumber + " canceled.")); return(false); } } break; } case JobState.OpenError: { StatusUpdate?.Invoke(this, new StatusArgs("An error occured while trying to open Job#: " + s.JobNumber + ". Perhaps it doesn't actually exist.")); _jobState = JobState.OpenError; return(false); } } if (CurrentJob != null) { _jobState = JobState.Opened; } return(CurrentJob != null); }