Exemplo n.º 1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description cannot be blank.");
                return;
            }
            if (textYears.errorProvider1.GetError(textYears) != "" ||
                textMonths.errorProvider1.GetError(textMonths) != "" ||
                textWeeks.errorProvider1.GetError(textWeeks) != "" ||
                textDays.errorProvider1.GetError(textDays) != ""
                )
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            //if(RecallTypes.List comboSpecial.SelectedIndex

            /*
             * if(listTriggers.Items.Count==0 && comboSpecial.SelectedIndex!=2) {//except child prophy
             *      if(!MsgBox.Show(this,true,"Warning! clearing all triggers for a recall type will cause all patient recalls of that type to be deleted, even those with notes.  Continue anyway?")){
             *              return;
             *      }
             * }*/
            RecallTypeCur.Description = textDescription.Text;
            Interval interval = new Interval(
                PIn.Int(textDays.Text),
                PIn.Int(textWeeks.Text),
                PIn.Int(textMonths.Text),
                PIn.Int(textYears.Text));

            RecallTypeCur.DefaultInterval = interval;
            RecallTypeCur.TimePattern     = textPattern.Text;
            if (listProcs.Items.Count == 0)
            {
                RecallTypeCur.Procedures = "";
            }
            //otherwise, already taken care of.
            try{
                if (RecallTypeCur.IsNew)
                {
                    RecallTypes.Insert(RecallTypeCur);
                }
                else
                {
                    RecallTypes.Update(RecallTypeCur);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            RecallTriggers.SetForType(RecallTypeCur.RecallTypeNum, TriggerList);
            bool changed = false;

            if (comboSpecial.SelectedIndex == 0)          //none
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 1)          //Prophy
            {
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 2)          //ChildProphy
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 3)          //Perio
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
            }
            DataValid.SetInvalid(InvalidType.RecallTypes);
            if (changed)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            //Ask user to update recalls for patients if they changed the DefaultInterval.
            if (!RecallTypeCur.IsNew && defaultIntervalOld != RecallTypeCur.DefaultInterval)
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Default interval has been changed.  Reset all current patient intervals of this type?"))
                {
                    Recalls.UpdateDefaultIntervalForPatients(RecallTypeCur.RecallTypeNum, defaultIntervalOld, RecallTypeCur.DefaultInterval);
                }
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description cannot be blank.");
                return;
            }
            for (int i = 0; i < textPattern.Text.Length; i++)
            {
                if (textPattern.Text[i] != '/' && textPattern.Text[i] != 'X')
                {
                    MsgBox.Show(this, "Time Pattern may only contain '/' and 'X'.  Please fix to continue.");
                    return;
                }
            }
            if (textYears.errorProvider1.GetError(textYears) != "" ||
                textMonths.errorProvider1.GetError(textMonths) != "" ||
                textWeeks.errorProvider1.GetError(textWeeks) != "" ||
                textDays.errorProvider1.GetError(textDays) != ""
                )
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            //if(RecallTypes.List comboSpecial.SelectedIndex

            /*
             * if(listTriggers.Items.Count==0 && comboSpecial.SelectedIndex!=2) {//except child prophy
             *      if(!MsgBox.Show(this,true,"Warning! clearing all triggers for a recall type will cause all patient recalls of that type to be deleted, even those with notes.  Continue anyway?")){
             *              return;
             *      }
             * }*/
            bool changed = false;

            if (comboSpecial.SelectedIndex == 2)          //childProphy
            {
                if (textRecallAgeAdult.errorProvider1.GetError(textRecallAgeAdult) != "")
                {
                    MsgBox.Show(this, "Please fix data entry errors first.");
                    return;
                }
                if (Prefs.UpdateInt(PrefName.RecallAgeAdult, PIn.Int(textRecallAgeAdult.Text)))
                {
                    changed = true;
                }
                TriggerList.Clear(); //triggers for child prophy special type are handled by the prophy special type
            }
            else                     //for child prophy, interval will default to 0, since this special type uses the Prophy default interval
            {
                Interval interval = new Interval(
                    PIn.Int(textDays.Text),
                    PIn.Int(textWeeks.Text),
                    PIn.Int(textMonths.Text),
                    PIn.Int(textYears.Text));
                RecallTypeCur.DefaultInterval = interval;
            }
            RecallTypeCur.Description     = textDescription.Text;
            RecallTypeCur.TimePattern     = textPattern.Text;
            RecallTypeCur.AppendToSpecial = checkAppendToSpecial.Checked;
            if (listProcs.Items.Count == 0)
            {
                RecallTypeCur.Procedures = "";
            }
            //otherwise, already taken care of.
            try{
                if (RecallTypeCur.IsNew)
                {
                    RecallTypes.Insert(RecallTypeCur);
                    SecurityLogs.MakeLogEntry(Permissions.RecallEdit, 0, "Recall type added '" + RecallTypeCur.Description + "'");
                }
                else
                {
                    SecurityLogs.MakeLogEntry(Permissions.RecallEdit, 0, "Recall type having description '" + RecallTypeCur.Description + "' edited");
                    RecallTypes.Update(RecallTypeCur);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            RecallTriggers.SetForType(RecallTypeCur.RecallTypeNum, TriggerList);
            //The combo for special type is allowed to be changed by user.  But since the field is in the pref table instead of in the RecallType table, there's extra work involved in saving the selection.
            if (comboSpecial.SelectedIndex == 0)                                                    //none:  If this recall type is now not any special type
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum) //and it used to be the special prophy type
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 1)                                                //Prophy: If this recall type is now the prophy type.
            {
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, RecallTypeCur.RecallTypeNum)) //and it was already the prophy type
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)              //but it used to be the childprophy type.
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 2)          //ChildProphy
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 3)          //Perio
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
            }
            DataValid.SetInvalid(InvalidType.RecallTypes);
            if (changed)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            //Ask user to update recalls for patients if they changed the DefaultInterval.
            if (!RecallTypeCur.IsNew && defaultIntervalOld != RecallTypeCur.DefaultInterval)
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Default interval has been changed.  Reset all current patient intervals of this type?"))
                {
                    Recalls.UpdateDefaultIntervalForPatients(RecallTypeCur.RecallTypeNum, defaultIntervalOld, RecallTypeCur.DefaultInterval);
                }
            }
            DialogResult = DialogResult.OK;
        }