private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateDue.errorProvider1.GetError(textDateDue) != "" ||
         textYears.errorProvider1.GetError(textYears) != "" ||
         textMonths.errorProvider1.GetError(textMonths) != "" ||
         textWeeks.errorProvider1.GetError(textWeeks) != "" ||
         textDays.errorProvider1.GetError(textDays) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     RecallCur.IsDisabled            = checkIsDisabled.Checked;
     RecallCur.DateDue               = PIn.PDate(textDateDue.Text);
     RecallCur.RecallInterval.Years  = PIn.PInt(textYears.Text);
     RecallCur.RecallInterval.Months = PIn.PInt(textMonths.Text);
     RecallCur.RecallInterval.Weeks  = PIn.PInt(textWeeks.Text);
     RecallCur.RecallInterval.Days   = PIn.PInt(textDays.Text);
     if (comboStatus.SelectedIndex == 0)
     {
         RecallCur.RecallStatus = 0;
     }
     else
     {
         RecallCur.RecallStatus
             = DefB.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex - 1].DefNum;
     }
     RecallCur.Note = textNote.Text;
     if (IsNew)
     {
         if (!Recalls.IsAllDefault(RecallCur))                //only save if something meaningful
         {
             Recalls.Insert(RecallCur);
         }
     }
     else
     {
         if (Recalls.IsAllDefault(RecallCur))
         {
             Recalls.Delete(RecallCur);
             DialogResult = DialogResult.OK;
             return;
         }
         else
         {
             Recalls.Update(RecallCur);
         }
     }
     Recalls.Synch(PatCur.PatNum, RecallCur);
     DialogResult = DialogResult.OK;
 }
Example #2
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (RecallCur.DatePrevious.Year > 1880)
     {
         if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This recall should not normally be deleted because the Previous Date has a value.  You should use the Disabled checkBox instead.  But if you are just deleting a duplicate, it's ok to continue.  Continue?"))
         {
             return;
         }
     }
     else if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete this recall?"))
     {
         return;
     }
     Recalls.Delete(RecallCur);
     DialogResult = DialogResult.OK;
 }
Example #3
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (RecallCur.DatePrevious.Year > 1880)
     {
         if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This recall should not normally be deleted because the Previous Date has a value.  You should use the Disabled checkBox instead.  But if you are just deleting a duplicate, it's ok to continue.  Continue?"))
         {
             return;
         }
     }
     else if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete this recall?"))
     {
         return;
     }
     Recalls.Delete(RecallCur);
     SecurityLogs.MakeLogEntry(Permissions.RecallEdit, RecallCur.PatNum
                               , "Recall deleted with type '" + RecallTypes.GetSpecialTypeStr(RecallCur.RecallTypeNum) + "' and interval '" + RecallCur.RecallInterval + "'");
     DialogResult = DialogResult.OK;
 }
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (RecallCur.DatePrevious.Year < 1880)          //Can only be deleted if DatePrevious is blank.
     {
         if (IsNew)
         {
             DialogResult = DialogResult.Cancel;
         }
         else
         {
             if (!MsgBox.Show(this, true, "Delete this recall?"))
             {
                 return;
             }
             Recalls.Delete(RecallCur);
             DialogResult = DialogResult.OK;
         }
     }
     else
     {
         MsgBox.Show(this, "This recall can not be deleted because Previous Date has a value.  You should use the Disabled checkBox instead.");
     }
 }
Example #5
0
        ///<summary>Synchronizes all recall for one patient. If datePrevious has changed, then it completely deletes the old recall information and sets a new dateDueCalc and DatePrevious.  Also updates dateDue to match dateDueCalc if not disabled.  The supplied recall can be null if patient has no existing recall. Deletes or creates any recalls as necessary.</summary>
        public static void Synch(int patNum, Recall recall)
        {
            DateTime previousDate = GetPreviousDate(patNum);

            if (recall != null &&
                !recall.IsDisabled &&
                previousDate.Year > 1880 &&              //this protects recalls that were manually added as part of a conversion
                previousDate != recall.DatePrevious)                     //if datePrevious has changed, reset
            {
                recall.RecallStatus = 0;
                recall.Note         = "";
                recall.DateDue      = recall.DateDueCalc; //now it is allowed to be changed in the steps below
            }
            if (previousDate.Year < 1880)                 //if no previous date
            {
                if (recall == null)                       //no recall present
                //do nothing.
                {
                }
                else
                {
                    recall.DatePrevious = DateTime.MinValue;
                    if (recall.DateDue == recall.DateDueCalc)                  //user did not enter a DateDue
                    {
                        recall.DateDue = DateTime.MinValue;
                    }
                    recall.DateDueCalc = DateTime.MinValue;
                    Recalls.Update(recall);
                    if (Recalls.IsAllDefault(recall))                    //no useful info
                    {
                        Recalls.Delete(recall);
                        recall = null;
                    }
                }
            }
            else                    //if previous date is a valid date
            {
                if (recall == null) //no recall present
                {
                    recall                = new Recall();
                    recall.PatNum         = patNum;
                    recall.DatePrevious   = previousDate;
                    recall.RecallInterval = new Interval(0, 0, 6, 0);
                    recall.DateDueCalc    = previousDate + recall.RecallInterval;
                    recall.DateDue        = recall.DateDueCalc;
                    Recalls.Insert(recall);
                    return;
                }
                else
                {
                    recall.DatePrevious = previousDate;
                    if (recall.IsDisabled)                  //if the existing recall is disabled
                    {
                        recall.DateDue = DateTime.MinValue; //DateDue is always blank
                    }
                    else                                    //but if not disabled
                    {
                        if (recall.DateDue == recall.DateDueCalc ||                  //if user did not enter a DateDue
                            recall.DateDue.Year < 1880)                                   //or DateDue was blank
                        {
                            recall.DateDue = recall.DatePrevious + recall.RecallInterval; //set same as DateDueCalc
                        }
                    }
                    recall.DateDueCalc = recall.DatePrevious + recall.RecallInterval;
                    Recalls.Update(recall);
                }
            }
        }