示例#1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDaysPast.errorProvider1.GetError(textDaysPast) != "" ||
                textMaxReminders.errorProvider1.GetError(textMaxReminders) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textPostcardsPerSheet.Text != "1" &&
                textPostcardsPerSheet.Text != "3" &&
                textPostcardsPerSheet.Text != "4")
            {
                MsgBox.Show(this, "The value in postcards per sheet must be 1, 3, or 4");
                return;
            }
            if (comboStatusMailedReactivation.SelectedIndex == -1 ||
                comboStatusEmailedReactivation.SelectedIndex == -1 ||
                comboStatusTextedReactivation.SelectedIndex == -1 ||
                comboStatusEmailTextReactivation.SelectedIndex == -1)
            {
                MsgBox.Show(this, "All status options on the left must be set.");
                return;
            }
            //End of Validation
            bool didChange = false;

            didChange |= Prefs.UpdateString(PrefName.ReactivationPostcardsPerSheet, textPostcardsPerSheet.Text);
            if (didChange)
            {
                if (textPostcardsPerSheet.Text == "1")
                {
                    MsgBox.Show(this, "If using 1 postcard per sheet, you must adjust the position, and also the preview will not work");
                }
            }
            didChange |= Prefs.UpdateBool(PrefName.ReactivationGroupByFamily, checkGroupFamilies.Checked);
            didChange |= Prefs.UpdateLongAsNegOne(PrefName.ReactivationDaysPast, textDaysPast.Text);
            didChange |= Prefs.UpdateLongAsNegOne(PrefName.ReactivationContactInterval, textDaysContactInterval.Text);
            didChange |= Prefs.UpdateLongAsNegOne(PrefName.ReactivationCountContactMax, textMaxReminders.Text);
            //combo boxes These have already been checked for -1
            didChange |= Prefs.UpdateLong(PrefName.ReactivationStatusEmailed, comboStatusEmailedReactivation.GetSelected <Def>().DefNum);
            didChange |= Prefs.UpdateLong(PrefName.ReactivationStatusMailed, comboStatusMailedReactivation.GetSelected <Def>().DefNum);
            didChange |= Prefs.UpdateLong(PrefName.ReactivationStatusTexted, comboStatusTextedReactivation.GetSelected <Def>().DefNum);
            didChange |= Prefs.UpdateLong(PrefName.ReactivationStatusEmailedTexted, comboStatusEmailTextReactivation.GetSelected <Def>().DefNum);
            if (didChange)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            DialogResult = DialogResult.OK;
        }