private void PromptTextASAPList() { if (!PrefC.GetBool(PrefName.WebSchedAsapEnabled) || Appointments.RefreshASAP(0, 0, _appt.ClinicNum, new List <ApptStatus>()).Count == 0 || !MsgBox.Show("Appointment", MsgBoxButtons.YesNo, "Text patients on the ASAP List and offer them this opening?")) { return; } DateTime slotStart = AppointmentL.DateSelected.Date; //Midnight DateTime slotEnd = AppointmentL.DateSelected.Date.AddDays(1); //Midnight tomorrow //Loop through all other appts in the op to find a slot that will not overlap. List <Appointment> listApptsInOp = Appointments.GetAppointmentsForOpsByPeriod(new List <long> { _appt.Op }, _appt.AptDateTime); foreach (Appointment otherAppt in listApptsInOp.Where(x => x.AptNum != _appt.AptNum)) { DateTime dateEndApt = otherAppt.AptDateTime.AddMinutes(otherAppt.Pattern.Length * 5); if (dateEndApt.Between(slotStart, _appt.AptDateTime)) { slotStart = dateEndApt; } if (otherAppt.AptDateTime.Between(_appt.AptDateTime, slotEnd)) { slotEnd = otherAppt.AptDateTime; } } slotStart = ODMathLib.Max(slotStart, _appt.AptDateTime.AddHours(-1)); slotEnd = ODMathLib.Min(slotEnd, _appt.AptDateTime.AddHours(3)); FormASAP formASAP = new FormASAP(_appt.AptDateTime, slotStart, slotEnd, _appt.Op); formASAP.ShowDialog(); }
private void ButUpdateProvs_Click(object sender, EventArgs e) { if (IsNew) { MsgBox.Show(this, "Not for new operatories."); return; } //Check against cache. Instead of saving changes, make them get out and reopen. Safer and simpler. Operatory op = Operatories.GetOperatory(OpCur.OperatoryNum); if (op.OpName != textOpName.Text || op.Abbrev != textAbbrev.Text || op.IsHidden != checkIsHidden.Checked || op.ClinicNum != comboClinic.SelectedClinicNum || op.ProvDentist != comboProv.GetSelectedProvNum() || op.ProvHygienist != comboHyg.GetSelectedProvNum() || op.IsHygiene != checkIsHygiene.Checked || op.SetProspective != checkSetProspective.Checked || op.IsWebSched != checkIsWebSched.Checked) { MsgBox.Show(this, "Changes were detected above. Save all changes, get completely out of the operatories window, and then re-enter."); return; } if (!Security.IsAuthorized(Permissions.Setup) || !Security.IsAuthorized(Permissions.AppointmentEdit)) { return; } //Operatory operatory=Operatories.GetOperatory(contrApptPanel.OpNumClicked); if (Security.CurUser.ClinicIsRestricted && !Clinics.GetForUserod(Security.CurUser).Exists(x => x.ClinicNum == OpCur.ClinicNum)) { MsgBox.Show(this, "You are restricted from accessing the clinic belonging to the selected operatory. No changes will be made."); return; } if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "WARNING: We recommend backing up your database before running this tool. " + "This tool may take a very long time to run and should be run after hours. " + "In addition, this tool could potentially change hundreds of appointments. " + "The changes made by this tool can only be manually reversed. " + "Are you sure you want to continue?")) { return; } SecurityLogs.MakeLogEntry(Permissions.Setup, 0, Lan.g(this, "Update Provs on Future Appts tool run on operatory ") + OpCur.Abbrev + "."); List <Appointment> listAppts = Appointments.GetAppointmentsForOpsByPeriod(new List <long>() { OpCur.OperatoryNum }, DateTime.Now); //no end date, so all future List <Appointment> listApptsOld = new List <Appointment>(); foreach (Appointment appt in listAppts) { listApptsOld.Add(appt.Copy()); } ContrApptRef.MoveAppointments(listAppts, listApptsOld, OpCur); MsgBox.Show(this, "Done"); }