Пример #1
0
        public static List <DefCatOptions> GetOptionsForDefCats(Array defCatVals)
        {
            List <DefCatOptions> listDefCatOptions = new List <DefCatOptions>();

            foreach (DefCat defCatCur in defCatVals)
            {
                if (defCatCur.GetDescription() == "NotUsed")
                {
                    continue;
                }
                if (defCatCur.GetDescription().Contains("HqOnly") && !PrefC.IsODHQ)
                {
                    continue;
                }
                DefCatOptions defCOption = new DefCatOptions(defCatCur);
                switch (defCatCur)
                {
                case DefCat.AccountColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes the color of text for different types of entries in Account Module");
                    break;

                case DefCat.AccountQuickCharge:
                    defCOption.CanDelete   = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Procedure Codes");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Account Proc Quick Add items.  Each entry can be a series of procedure codes separated by commas (e.g. D0180,D1101,D8220).  Used in the account module to quickly charge patients for items.");
                    break;

                case DefCat.AdjTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "+, -, or dp");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Plus increases the patient balance.  Minus decreases it.  Dp means discount plan.  Not allowed to change value after creating new type since changes affect all patient accounts.");
                    break;

                case DefCat.AppointmentColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes colors of background in Appointments Module, and colors for completed appointments.");
                    break;

                case DefCat.ApptConfirmed:
                    defCOption.EnableColor = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Abbrev");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Color shows on each appointment if Appointment View is set to show ConfirmedColor.");
                    break;

                case DefCat.ApptProcsQuickAdd:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "ADA Code(s)");
                    if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum))
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These are the procedures that you can quickly add to the treatment plan from within the appointment editing window.  Multiple procedures may be separated by commas with no spaces. These definitions may be freely edited without affecting any patient records.");
                    }
                    else
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These are the procedures that you can quickly add to the treatment plan from within the appointment editing window.  They must not require a tooth number. Multiple procedures may be separated by commas with no spaces. These definitions may be freely edited without affecting any patient records.");
                    }
                    break;

                case DefCat.AutoDeposit:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Account Number");
                    break;

                case DefCat.AutoNoteCats:
                    defCOption.CanDelete     = true;
                    defCOption.CanHide       = false;
                    defCOption.EnableValue   = true;
                    defCOption.IsValueDefNum = true;
                    defCOption.ValueText     = Lans.g("FormDefinitions", "Parent Category");
                    defCOption.HelpText      = Lans.g("FormDefinitions", "Leave the Parent Category blank for categories at the root level. Assign a Parent Category to move a category within another. The order set here will only affect the order within the assigned Parent Category in the Auto Note list. For example, a category may be moved above its parent in this list, but it will still be within its Parent Category in the Auto Note list.");
                    break;

                case DefCat.BillingTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "E, C, or CE");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "E=Email bill, C=Collection, CE=Collection Excluded.  It is recommended to use as few billing types as possible.  They can be useful when running reports to separate delinquent accounts, but can cause 'forgotten accounts' if used without good office procedures. Changes affect all patients.");
                    break;

                case DefCat.BlockoutTypes:
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Blockout types are used in the appointments module.");
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Flags");
                    break;

                case DefCat.ChartGraphicColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum))
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These colors will be used to graphically display treatments.");
                    }
                    else
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These colors will be used on the graphical tooth chart to draw restorations.");
                    }
                    break;

                case DefCat.ClaimCustomTracking:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Days Suppressed");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Some offices may set up claim tracking statuses such as 'review', 'hold', 'riskmanage', etc.") + "\r\n"
                                             + Lans.g("FormDefinitions", "Set the value of 'Days Suppressed' to the number of days the claim will be suppressed from the Outstanding Claims Report "
                                                      + "when the status is changed to the selected status.");
                    break;

                case DefCat.ClaimErrorCode:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Description");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Used to track error codes when entering claim custom statuses.");
                    break;

                case DefCat.ClaimPaymentTracking:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Value");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "EOB adjudication method codes to be used for insurance payments.  Last entry cannot be hidden.");
                    break;

                case DefCat.ClaimPaymentGroups:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Value");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Used to group claim payments in the daily payments report.");
                    break;

                case DefCat.ClinicSpecialty:
                    defCOption.CanHide   = true;
                    defCOption.CanDelete = false;
                    defCOption.HelpText  = Lans.g("FormDefinitions", "You can add as many specialties as you want.  Changes affect all current records.");
                    break;

                case DefCat.CommLogTypes:
                    defCOption.EnableValue   = true;
                    defCOption.EnableColor   = true;
                    defCOption.DoShowNoColor = true;
                    string commItemTypes = string.Join(", ", Commlogs.GetCommItemTypes().Select(x => x.GetDescription(useShortVersionIfAvailable: true)));
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Changes affect all current commlog entries.  Optionally set Usage to one of the following: "
                                                  + commItemTypes + ". Only one of each. This helps automate new entries.");
                    break;

                case DefCat.ContactCategories:
                    defCOption.HelpText = Lans.g("FormDefinitions", "You can add as many categories as you want.  Changes affect all current contact records.");
                    break;

                case DefCat.Diagnosis:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "1 or 2 letter abbreviation");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "The diagnosis list is shown when entering a procedure.  Ones that are less used should go lower on the list.  The abbreviation is shown in the progress notes.  BE VERY CAREFUL.  Changes affect all patients.");
                    break;

                case DefCat.FeeColors:
                    defCOption.CanEditName = false;
                    defCOption.CanHide     = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are the colors associated to fee types.");
                    break;

                case DefCat.ImageCats:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "These are the categories that will be available in the image and chart modules.  If you hide a category, images in that category will be hidden, so only hide a category if you are certain it has never been used.  Multiple categories can be set to show in the Chart module, but only one category should be set for patient pictures, statements, and tooth charts. Selecting multiple categories for treatment plans will save the treatment plan in each category. Affects all patient records.");
                    break;

                case DefCat.InsurancePaymentType:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "N=Not selected for deposit");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are claim payment types for insurance payments attached to claims.");
                    break;

                case DefCat.InsuranceVerificationStatus:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "These are statuses for the insurance verification list.");
                    break;

                case DefCat.JobPriorities:
                    defCOption.CanDelete   = false;
                    defCOption.CanHide     = true;
                    defCOption.EnableValue = true;
                    defCOption.EnableColor = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Comma-delimited keywords");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are job priorities that determine how jobs are sorted in the Job Manager System.  Required values are: OnHold, Low, Normal, MediumHigh, High, Urgent, BugDefault, JobDefault, DocumentationDefault.");
                    break;

                case DefCat.LetterMergeCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Categories for Letter Merge.  You can safely make any changes you want.");
                    break;

                case DefCat.MiscColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = "";
                    break;

                case DefCat.PaymentTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "N=Not selected for deposit");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Types of payments that patients might make. Any changes will affect all patients.");
                    break;

                case DefCat.PayPlanCategories:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Assign payment plans to different categories");
                    break;

                case DefCat.PaySplitUnearnedType:
                    defCOption.ValueText   = "Do Not Show on Account";
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Usually only used by offices that use accrual basis accounting instead of cash basis accounting. Any changes will affect all patients.");
                    defCOption.EnableValue = true;
                    break;

                case DefCat.ProcButtonCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are similar to the procedure code categories, but are only used for organizing and grouping the procedure buttons in the Chart module.");
                    break;

                case DefCat.ProcCodeCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are the categories for organizing procedure codes. They do not have to follow ADA categories.  There is no relationship to insurance categories which are setup in the Ins Categories section.  Does not affect any patient records.");
                    break;

                case DefCat.ProgNoteColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes color of text for different types of entries in the Chart Module Progress Notes.");
                    break;

                case DefCat.Prognosis:
                    //Nothing special. Might add HelpText later.
                    break;

                case DefCat.ProviderSpecialties:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Provider specialties cannot be deleted.  Changes to provider specialties could affect e-claims.");
                    break;

                case DefCat.RecallUnschedStatus:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Abbreviation");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Recall/Unsched Status.  Abbreviation must be 7 characters or less.  Changes affect all patients.");
                    break;

                case DefCat.Regions:
                    defCOption.CanHide  = false;
                    defCOption.HelpText = Lans.g("FormDefinitions", "The region identifying the clinic it is assigned to.");
                    break;

                case DefCat.SupplyCats:
                    defCOption.CanDelete = true;
                    defCOption.CanHide   = false;
                    defCOption.HelpText  = Lans.g("FormDefinitions", "The categories for inventory supplies.");
                    break;

                case DefCat.TaskPriorities:
                    defCOption.EnableColor = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "D = Default, R = Reminder");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Priorities available for selection within the task edit window.  Task lists are sorted using the order of these priorities.  They can have any description and color.  At least one priority should be Default (D).  If more than one priority is flagged as the default, the last default in the list will be used.  If no default is set, the last priority will be used.  Use (R) to indicate the initial reminder task priority to use when creating reminder tasks.  Changes affect all tasks where the definition is used.");
                    break;

                case DefCat.TxPriorities:
                    defCOption.EnableColor            = true;
                    defCOption.EnableValue            = true;
                    defCOption.DoShowItemOrderInValue = true;
                    defCOption.ValueText = Lan.g(_lanThis, "Internal Priority");
                    defCOption.HelpText  = Lan.g(_lanThis, "Displayed order should match order of priority of treatment.  They are used in Treatment Plan and Chart "
                                                 + "modules. They can be simple numbers or descriptive abbreviations 7 letters or less.  Changes affect all procedures where the "
                                                 + "definition is used.  'Internal Priority' does not show, but is used for list order and for automated selection of which procedures "
                                                 + "are next in a planned appointment.");
                    break;

                case DefCat.WebSchedNewPatApptTypes:
                    defCOption.CanDelete = true;
                    defCOption.CanHide   = false;
                    defCOption.ValueText = Lans.g("FormDefinitions", "Appointment Type");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Appointment types to be displayed in the Web Sched New Pat Appt web application.  These are selectable for the new patients and will be saved to the appointment note.");
                    break;

                case DefCat.CarrierGroupNames:
                    defCOption.CanHide  = true;
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are group names for Carriers.");
                    break;

                case DefCat.TimeCardAdjTypes:
                    defCOption.CanEditName = true;
                    defCOption.CanHide     = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are PTO Adjustments Types used for tracking on employee time cards and ADP export.");
                    break;
                }
                listDefCatOptions.Add(defCOption);
            }
            return(listDefCatOptions);
        }
Пример #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (Defs.IsHidable(DefCur.Category) && checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (DefCur.DefNum == PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeArrivedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeSeatedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeDismissedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.BillingChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PrepaymentUnearnedType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.SalesTaxAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.RecurringChargesPayTypeCC) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TpUnearnedType))
                    {
                        MsgBox.Show(this, "You cannot hide a definition if it is in use within Module Preferences.");
                        return;
                    }
                    else if (DefCur.DefNum.In(
                                 PrefC.GetLong(PrefName.RecallStatusMailed),
                                 PrefC.GetLong(PrefName.RecallStatusTexted),
                                 PrefC.GetLong(PrefName.RecallStatusEmailed),
                                 PrefC.GetLong(PrefName.RecallStatusEmailedTexted)))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as a status in the Setup Recall window.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedNewPatConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched New Pat Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedRecallConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched Recall Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType))
                    {
                        MsgBox.Show(this, "You cannot hide a billing type when it is selected as the practice default billing type.");
                        return;
                    }
                    else
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                        {
                            return;
                        }
                    }
                }
                //Stop users from hiding the last definition in categories that must have at least one def in them.
                if (!_defsList.Any(x => x.DefNum != DefCur.DefNum && !x.IsHidden))
                {
                    MsgBox.Show(this, "You cannot hide the last definition in this category.");
                    return;
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch (DefCur.Category)
            {
            case DefCat.AccountQuickCharge:
            case DefCat.ApptProcsQuickAdd:
                string[]      procCodes     = textValue.Text.Split(',');
                List <string> listProcCodes = new List <string>();
                for (int i = 0; i < procCodes.Length; i++)
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(procCodes[i]);
                    if (procCode.CodeNum == 0)
                    {
                        //Now check to see if the trimmed version of the code does not exist either.
                        procCode = ProcedureCodes.GetProcCode(procCodes[i].Trim());
                        if (procCode.CodeNum == 0)
                        {
                            MessageBox.Show(Lan.g(this, "Invalid procedure code entered") + ": " + procCodes[i]);
                            return;
                        }
                    }
                    listProcCodes.Add(procCode.ProcCode);
                }
                textValue.Text = String.Join(",", listProcCodes);
                break;

            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-" && textValue.Text != "dp")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are +, -, or dp."));
                    return;
                }
                break;

            case DefCat.BillingTypes:
                if (!textValue.Text.ToLower().In("", "e", "c", "ce"))
                {
                    MsgBox.Show(this, "Valid values are blank, E, C, or CE.");
                    return;
                }
                if (checkHidden.Checked && Patients.IsBillingTypeInUse(DefCur.DefNum))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients, insurance plans, or preferences."))
                    {
                        return;
                    }
                }
                break;

            case DefCat.ClaimCustomTracking:
                int value = 0;
                if (!Int32.TryParse(textValue.Text, out value) || value < 0)
                {
                    MsgBox.Show(this, "Days Suppressed must be a valid non-negative number.");
                    return;
                }
                break;

            case DefCat.CommLogTypes:
                List <string> listCommItemTypes = Commlogs.GetCommItemTypes().Select(x => x.GetDescription(useShortVersionIfAvailable: true)).ToList();
                if (textValue.Text != "" && !listCommItemTypes.Any(x => x == textValue.Text))
                {
                    MessageBox.Show(Lan.g(this, "Valid values are:") + " " + string.Join(", ", listCommItemTypes));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try {
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            /*case DefCat.FeeSchedNames:
             *      if(textValue.Text=="C" || textValue.Text=="c") {
             *              textValue.Text="C";
             *      }
             *      else if(textValue.Text=="A" || textValue.Text=="a") {
             *              textValue.Text="A";
             *      }
             *      else textValue.Text="";
             *      break;*/
            case DefCat.ImageCats:
                textValue.Text = textValue.Text.ToUpper().Replace(",", "");
                if (!Regex.IsMatch(textValue.Text, @"^[XPS]*$"))
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.InsurancePaymentType:
                if (textValue.Text != "" && textValue.Text != "N")
                {
                    MsgBox.Show(this, "Valid values are blank or N.");
                    return;
                }
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.PaySplitUnearnedType:
                if (!textValue.Text.ToLower().In("", "x"))
                {
                    MsgBox.Show(this, "Valid values are blank or 'X'");
                    return;
                }
                List <Def> listDefsForUnearnedType = _defsList.FindAll(x => x.Category == DefCat.PaySplitUnearnedType);
                if (listDefsForUnearnedType.FindAll(x => string.IsNullOrEmpty(x.ItemValue)).Count == 1 && DefCur.ItemValue == "" &&
                    (textValue.Text != "" || checkHidden.Checked))
                {
                    MsgBox.Show(this, "Must have at least one definition that shows in Account.");
                    return;
                }
                else if (listDefsForUnearnedType.FindAll(x => !string.IsNullOrEmpty(x.ItemValue)).Count == 1 && DefCur.ItemValue != "" &&
                         (textValue.Text == "" || checkHidden.Checked))
                {
                    MsgBox.Show(this, "Must have at least one definition that does not show in Account.");
                    return;
                }
                break;

            case DefCat.ProcCodeCats:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "At least one procedure code category must be enabled.");
                        return;
                    }
                }
                break;

            case DefCat.ProviderSpecialties:
                if (checkHidden.Checked &&
                    (Providers.IsSpecialtyInUse(DefCur.DefNum) ||
                     Referrals.IsSpecialtyInUse(DefCur.DefNum)))
                {
                    MsgBox.Show(this, "You cannot hide a specialty if it is in use by a provider or a referral source.");
                    checkHidden.Checked = false;
                    return;
                }
                break;

            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.TaskPriorities:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "You cannot hide the last priority.");
                        return;
                    }
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            default:
                break;
            }            //end switch DefCur.Category
            DefCur.ItemName  = textName.Text;
            DefCur.ItemValue = _selectedValueString;
            if (_defCatOptions.EnableValue && !_defCatOptions.IsValueDefNum)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (_defCatOptions.EnableColor)
            {
                //If checkNoColor is checked, insert empty into the database. Otherwise, use the color they picked.
                DefCur.ItemColor = (checkNoColor.Checked ? Color.Empty : butColor.BackColor);
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            //Must be after the upsert so that we have access to the DefNum for new Defs.
            if (DefCur.Category == DefCat.ApptConfirmed)
            {
                //==================== EXCLUDE SEND ====================
                if (checkExcludeSend.Checked)
                {
                    _listExcludeSendNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeSendNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string sendString = string.Join(",", _listExcludeSendNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeESend, sendString);
                //==================== EXCLUDE CONFIRM ====================
                if (checkExcludeConfirm.Checked)
                {
                    _listExcludeConfirmNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeConfirmNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string confirmString = string.Join(",", _listExcludeConfirmNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeEConfirm, confirmString);
                //==================== EXCLUDE REMIND ====================
                if (checkExcludeRemind.Checked)
                {
                    _listExcludeRemindNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeRemindNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string remindString = string.Join(",", _listExcludeRemindNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeERemind, remindString);
                Signalods.SetInvalid(InvalidType.Prefs);
            }
            DialogResult = DialogResult.OK;
        }