コード例 #1
0
        ///<summary>Returns true if the PrefName.ApptPreventChangesToCompleted is true, the appointment has completed procedures attached, and the appointment
        ///has a completed status. Otherwise it will return false.</summary>
        public static bool DoPreventChangesToCompletedAppt(Appointment apt, PreventChangesApptAction action, out string msg, List <Procedure> listAttachedProcs = null, bool doSupressMsg = false)
        {
            msg = null;
            if (apt == null)
            {
                return(true);
            }
            if (!PrefC.GetBool(PrefName.ApptPreventChangesToCompleted) ||         //The preference is turned off.
                (apt.AptStatus != ApptStatus.Complete) ||              //The appointment status is not complete. Allow changes.
                !Appointments.HasCompletedProcsAttached(apt.AptNum, listAttachedProcs))                  //Apt does not have completed procedures attached
            {
                return(false);
            }
            //Prepare the message text that the user will see before we return true.
            string strAction;

            switch (action)
            {
            case PreventChangesApptAction.Break:
                strAction = "break the appointment";
                break;

            case PreventChangesApptAction.Delete:
                strAction = "delete the appointment";
                break;

            case PreventChangesApptAction.Status:
                strAction = "change the appointment status";
                break;

            case PreventChangesApptAction.Procedures:
                strAction = "detach completed procedures";
                break;

            default:                    //CompletedApptAction.Unsched
                strAction = "send the appointment to the unscheduled list";
                break;
            }
            msg = $"Not allowed to {strAction} when there are completed procedures attached to this appointment.\r\n\r\nChange the status of the "
                  + "completed procedures to Treatment Planned if they were not completed, or delete the procedures before trying again.";
            if (!doSupressMsg)
            {
                MsgBox.Show(msg);
            }
            return(true);
        }