private void FormApptViewEdit_Load(object sender, System.EventArgs e) { textDescription.Text = ApptViewCur.Description; if (ApptViewCur.RowsPerIncr == 0) { textRowsPerIncr.Text = "1"; } else { textRowsPerIncr.Text = ApptViewCur.RowsPerIncr.ToString(); } ApptViewItems.GetForCurView(ApptViewCur); for (int i = 0; i < Operatories.ListShort.Length; i++) { listOps.Items.Add(Operatories.ListShort[i].OpName); if (ApptViewItems.OpIsInView(Operatories.ListShort[i].OperatoryNum)) { listOps.SetSelected(i, true); } } for (int i = 0; i < Providers.List.Length; i++) { listProv.Items.Add (Providers.List[i].Abbr + " - " + Providers.List[i].LName + ", " + Providers.List[i].FName); if (ApptViewItems.ProvIsInView(Providers.List[i].ProvNum)) { listProv.SetSelected(i, true); } } allElements = new ArrayList(); allElements.Add("AddrNote"); allElements.Add("Age"); allElements.Add("ChartNumAndName"); allElements.Add("ChartNumber"); allElements.Add("HmPhone"); allElements.Add("Lab"); allElements.Add("MedUrgNote"); allElements.Add("PremedFlag"); allElements.Add("Note"); allElements.Add("PatientName"); allElements.Add("PatNum"); allElements.Add("PatNumAndName"); allElements.Add("Procs"); allElements.Add("ProcDescript"); allElements.Add("Production"); allElements.Add("Provider"); allElements.Add("WirelessPhone"); allElements.Add("WkPhone"); displayedElements = new ArrayList(); for (int i = 0; i < ApptViewItems.ApptRows.Length; i++) { displayedElements.Add(ApptViewItems.ApptRows[i]); } FillElements(); }
private void FormApptViewEdit_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (DialogResult == DialogResult.OK) { return; } if (IsNew) { ApptViewItems.DeleteAllForView(ApptViewCur); ApptViews.Delete(ApptViewCur); } }
private void butDelete_Click(object sender, System.EventArgs e) { //this does mess up the item orders a little, but missing numbers don't actually hurt anything. if (MessageBox.Show(Lan.g(this, "Delete this category?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } ApptViewItems.DeleteAllForView(ApptViewCur); ApptViews.Delete(ApptViewCur); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (listOps.SelectedIndices.Count == 0 || listProv.SelectedIndices.Count == 0) { MessageBox.Show(Lan.g(this, "At least one operatory and one provider must be selected.")); return; } if (textDescription.Text == "") { MessageBox.Show(Lan.g(this, "A description must be entered.")); return; } if (displayedElements.Count == 0) { MessageBox.Show(Lan.g(this, "At least one row type must be displayed.")); return; } ApptViewItems.DeleteAllForView(ApptViewCur); //start with a clean slate for (int i = 0; i < Operatories.ListShort.Length; i++) { if (listOps.SelectedIndices.Contains(i)) { ApptViewItem ApptViewItemCur = new ApptViewItem(); ApptViewItemCur.ApptViewNum = ApptViewCur.ApptViewNum; ApptViewItemCur.OpNum = Operatories.ListShort[i].OperatoryNum; ApptViewItems.Insert(ApptViewItemCur); } } for (int i = 0; i < Providers.List.Length; i++) { if (listProv.SelectedIndices.Contains(i)) { ApptViewItem ApptViewItemCur = new ApptViewItem(); ApptViewItemCur.ApptViewNum = ApptViewCur.ApptViewNum; ApptViewItemCur.ProvNum = Providers.List[i].ProvNum; ApptViewItems.Insert(ApptViewItemCur); } } for (int i = 0; i < displayedElements.Count; i++) { ApptViewItem ApptViewItemCur = (ApptViewItem)displayedElements[i]; ApptViewItemCur.ApptViewNum = ApptViewCur.ApptViewNum; //elementDesc and elementColor already handled. ApptViewItemCur.ElementOrder = i; ApptViewItems.Insert(ApptViewItemCur); } ApptViewCur.Description = textDescription.Text; ApptViewCur.RowsPerIncr = PIn.PInt(textRowsPerIncr.Text); ApptViews.Update(ApptViewCur); //same whether isnew or not DialogResult = DialogResult.OK; }
///<summary>Called from SetLocation to establish X position of control.</summary> private int ConvertToX() { if (ContrApptSheet.IsWeeklyView) { return(ContrApptSheet.TimeWidth + ContrApptSheet.ColDayWidth * ((int)PIn.PDateT(DataRoww["AptDateTime"].ToString()).DayOfWeek - 1) + 1 + (int)(ContrApptSheet.ColAptWidth * (float)ApptViewItems.GetIndexOp(PIn.PInt(DataRoww["Op"].ToString())))); } else { return(ContrApptSheet.TimeWidth + ContrApptSheet.ProvWidth * ContrApptSheet.ProvCount + ContrApptSheet.ColWidth * (ApptViewItems.GetIndexOp(PIn.PInt(DataRoww["Op"].ToString()))) + 1); //Info.MyApt.Op))+1; } }
private void FillViewList() { ApptViews.Refresh(); ApptViewItems.Refresh(); listViews.Items.Clear(); string F; for (int i = 0; i < ApptViews.List.Length; i++) { if (i < 12) { F = "F" + (i + 1).ToString() + "-"; } else { F = ""; } listViews.Items.Add(F + ApptViews.List[i].Description); } }
///<summary>Fills visProvs, visOps, forCurView, apptRows, and rowsPerIncr based on the appointment view passed in and whether it is for the week view or not. This method uses 'out' variables so that the encompassing logic doesn't ALWAYS affect the global static variables used to draw the appointment views. We don't want the following logic to affect the global static variables in the case where we are trying to get information needed to filter the waiting room.</summary> public static void FillForApptView(bool isWeekly, ApptView apptViewCur, out List <Provider> visProvs, out List <Operatory> visOps, out List <ApptViewItem> forCurView, out List <ApptViewItem> apptRows, out int rowsPerIncr, bool isFillVisProvs = true) { forCurView = new List <ApptViewItem>(); visProvs = new List <Provider>(); visOps = new List <Operatory>(); apptRows = new List <ApptViewItem>(); //If there are no appointment views set up (therefore, none selected), then use a hard-coded default view. if (ApptViews.IsNoneView(apptViewCur)) { //make visible ops exactly the same as the short ops list (all except hidden) visOps.AddRange( Operatories.GetWhere(x => !PrefC.HasClinicsEnabled || //if clinics disabled Clinics.ClinicNum == 0 || //or if program level ClinicNum set to Headquarters x.ClinicNum == Clinics.ClinicNum //or this is the program level ClinicNum , true) ); if (isFillVisProvs) { if (PrefC.HasClinicsEnabled) { foreach (Operatory op in visOps) { Provider provDent = Providers.GetProv(op.ProvDentist); Provider provHyg = Providers.GetProv(op.ProvHygienist); if (provDent != null) { visProvs.Add(provDent); } if (provHyg != null) { visProvs.Add(provHyg); } } } else { //make visible provs exactly the same as the prov list (all except hidden) visProvs.AddRange(Providers.GetDeepCopy(true)); } } //Hard coded elements showing apptRows.Add(new ApptViewItem("PatientName", 0, Color.Black)); apptRows.Add(new ApptViewItem("ASAP", 1, Color.DarkRed)); apptRows.Add(new ApptViewItem("MedUrgNote", 2, Color.DarkRed)); apptRows.Add(new ApptViewItem("PremedFlag", 3, Color.DarkRed)); apptRows.Add(new ApptViewItem("Lab", 4, Color.DarkRed)); apptRows.Add(new ApptViewItem("Procs", 5, Color.Black)); apptRows.Add(new ApptViewItem("Note", 6, Color.Black)); rowsPerIncr = 1; } //An appointment view is selected, so add provs and ops from the view to our lists of indexes. else { List <ApptViewItem> listApptViewItems = ApptViewItems.GetWhere(x => x.ApptViewNum == apptViewCur.ApptViewNum); for (int i = 0; i < listApptViewItems.Count; i++) { forCurView.Add(listApptViewItems[i]); if (listApptViewItems[i].OpNum > 0) //op { if (apptViewCur.OnlyScheduledProvs && !isWeekly) { continue; //handled below in AddOpsForScheduledProvs } Operatory op = Operatories.GetFirstOrDefault(x => x.OperatoryNum == listApptViewItems[i].OpNum, true); if (op != null) { visOps.Add(op); } } else if (listApptViewItems[i].ProvNum > 0) //prov { if (!isFillVisProvs) { continue; } Provider prov = Providers.GetFirstOrDefault(x => x.ProvNum == listApptViewItems[i].ProvNum, true); if (prov != null) { visProvs.Add(prov); } } else //element or apptfielddef { apptRows.Add(listApptViewItems[i]); } } rowsPerIncr = apptViewCur.RowsPerIncr; } //Remove any duplicates before return. visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList(); if (isFillVisProvs) { visProvs = visProvs.GroupBy(x => x.ProvNum).Select(x => x.First()).ToList(); } }
///<summary>When looking at a daily appointment module and the current appointment view is has 'OnlyScheduleProvs' turned on, this method will dynamically add additional operatories to visOps for providers that are scheduled to work.</summary> public static void AddOpsForScheduledProvs(bool isWeekly, List <Schedule> dailySched, ApptView apptViewCur, ref List <Operatory> visOps) { //if this appt view has the option to show only scheduled providers and this is daily view. //Remember that there is no intelligence in weekly view for this option, and it behaves just like it always did. if (ApptViews.IsNoneView(apptViewCur) || dailySched == null || visOps == null || !apptViewCur.OnlyScheduledProvs || isWeekly) { return; } //intelligently decide what ops to show. It's based on the schedule for the day. //visOps will be totally empty right now because it looped out of the above section of code. List <long> listSchedOps; bool opAdded; int indexOp; List <Operatory> listOpsShort = Operatories.GetDeepCopy(true); List <long> listApptViewOpNums = ApptViewItems.GetOpsForView(apptViewCur.ApptViewNum); for (int i = 0; i < listOpsShort.Count; i++) //loop through all ops for all views (except the hidden ones, of course) //If this operatory was not one of the selected Ops from the Appt View Edit window, skip it. { if (!listApptViewOpNums.Contains(listOpsShort[i].OperatoryNum)) { continue; } //find any applicable sched for the op opAdded = false; for (int s = 0; s < dailySched.Count; s++) { if (dailySched[s].SchedType != ScheduleType.Provider) { continue; } if (dailySched[s].StartTime == new TimeSpan(0)) //skip if block starts at midnight. { continue; } if (dailySched[s].StartTime == dailySched[s].StopTime) //skip if block has no length. { continue; } if (apptViewCur.OnlySchedAfterTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime < apptViewCur.OnlySchedAfterTime || dailySched[s].StopTime < apptViewCur.OnlySchedAfterTime) { continue; } } if (apptViewCur.OnlySchedBeforeTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime > apptViewCur.OnlySchedBeforeTime || dailySched[s].StopTime > apptViewCur.OnlySchedBeforeTime) { continue; } } //this 'sched' must apply to this situation. //listSchedOps is the ops for this 'sched'. listSchedOps = dailySched[s].Ops; //Add all the ops for this 'sched' to the list of visible ops for (int p = 0; p < listSchedOps.Count; p++) { //Filter the ops if the clinic option was set for the appt view. if (apptViewCur.ClinicNum > 0 && apptViewCur.ClinicNum != Operatories.GetOperatory(listSchedOps[p]).ClinicNum) { continue; } if (listSchedOps[p] == listOpsShort[i].OperatoryNum) { Operatory op = listOpsShort[i]; indexOp = Operatories.GetOrder(listSchedOps[p]); if (indexOp != -1 && !visOps.Contains(op)) //prevents adding duplicate ops { visOps.Add(op); opAdded = true; break; } } } //If the provider is not scheduled to any op(s), add their default op(s). if (listOpsShort[i].ProvDentist == dailySched[s].ProvNum && listSchedOps.Count == 0) //only if the sched does not specify any ops //Only add the op if the clinic option was not set in the appt view or if the op is assigned to that clinic. { if (apptViewCur.ClinicNum == 0 || apptViewCur.ClinicNum == listOpsShort[i].ClinicNum) { indexOp = Operatories.GetOrder(listOpsShort[i].OperatoryNum); if (indexOp != -1 && !visOps.Contains(listOpsShort[i])) { visOps.Add(listOpsShort[i]); opAdded = true; } } } if (opAdded) { break; //break out of the loop of schedules. Continue with the next op. } } } //Remove any duplicates before return. visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList(); }
///<summary>Draws all the blockouts for the entire period.</summary> private void DrawBlockouts(Graphics g) { Schedule[] schedForType; schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Blockout, 0); SolidBrush blockBrush; Pen blockOutlinePen = new Pen(Color.Black, 1); Pen penOutline; Font blockFont = new Font("Arial", 8); string blockText; RectangleF rect; //g.TextRenderingHint=TextRenderingHint.SingleBitPerPixelGridFit;//to make printing clearer for (int i = 0; i < schedForType.Length; i++) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType)); penOutline = new Pen(DefB.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType), 2); blockText = DefB.GetName(DefCat.BlockoutTypes, schedForType[i].BlockoutType) + "\r\n" + schedForType[i].Note; if (IsWeeklyView) { if (schedForType[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + 1 + ((int)schedForType[i].SchedDate.DayOfWeek - 1) * ColDayWidth , schedForType[i].StartTime.Hour * Lh * RowsPerHr //6 + schedForType[i].StartTime.Minute * Lh / MinPerRow //10 , ColDayWidth - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedForType[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + 1 + ((int)schedForType[i].SchedDate.DayOfWeek - 1) * ColDayWidth + ColAptWidth * ApptViewItems.GetIndexOp(schedForType[i].Op) + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr + schedForType[i].StartTime.Minute * Lh / MinPerRow , ColAptWidth - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } } else { if (schedForType[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr //6 + schedForType[i].StartTime.Minute * Lh / MinPerRow //10 , ColWidth * ColCount - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedForType[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + ColWidth * ApptViewItems.GetIndexOp(schedForType[i].Op) + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr + schedForType[i].StartTime.Minute * Lh / MinPerRow , ColWidth - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } } //paint either solid block or outline if (PrefB.GetBool("SolidBlockouts")) { g.FillRectangle(blockBrush, rect); g.DrawLine(blockOutlinePen, rect.X, rect.Y + 1, rect.Right - 1, rect.Y + 1); } else { g.DrawRectangle(penOutline, rect.X + 1, rect.Y + 2, rect.Width - 2, rect.Height - 3); } g.DrawString(blockText, blockFont, new SolidBrush(DefB.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect); } }
///<summary>Draws all the blockouts for the entire day.</summary> private void DrawBlockouts(Graphics g) { SchedDefault[] schedDefs; //for one type at a time Schedule[] schedForType; schedForType = Schedules.GetForType(SchedListDay, ScheduleType.Blockout, 0); SolidBrush blockBrush; Pen blockOutlinePen = new Pen(Color.Black, 1); Font blockFont = new Font("Arial", 8); string blockText; RectangleF rect; g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit; //to make printing clearer if (schedForType.Length == 0) //use default sched { schedDefs = SchedDefaults.GetForType(ScheduleType.Blockout, 0); for (int i = 0; i < schedDefs.Length; i++) { if (schedDefs[i].DayOfWeek == (int)Appointments.DateSelected.DayOfWeek) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes, schedDefs[i].BlockoutType)); blockText = DefB.GetName(DefCat.BlockoutTypes, schedDefs[i].BlockoutType); if (schedDefs[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + 1 , schedDefs[i].StartTime.Hour * Lh * RowsPerHr + schedDefs[i].StartTime.Minute * Lh / MinPerRow , ColWidth * ColCount - 1 , (schedDefs[i].StopTime - schedDefs[i].StartTime).Hours * Lh * RowsPerHr + (schedDefs[i].StopTime - schedDefs[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedDefs[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + ColWidth * ApptViewItems.GetIndexOp(schedDefs[i].Op) + 1 , schedDefs[i].StartTime.Hour * Lh * RowsPerHr + schedDefs[i].StartTime.Minute * Lh / MinPerRow , ColWidth - 1 , (schedDefs[i].StopTime - schedDefs[i].StartTime).Hours * Lh * RowsPerHr + (schedDefs[i].StopTime - schedDefs[i].StartTime).Minutes * Lh / MinPerRow); } g.FillRectangle(blockBrush, rect); g.DrawRectangle(blockOutlinePen, rect.X + 1, rect.Y + 2, rect.Width - 2, rect.Height - 4); g.DrawString(blockText, blockFont , new SolidBrush(DefB.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect); } } } else //use schedForType { for (int i = 0; i < schedForType.Length; i++) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType)); blockText = DefB.GetName(DefCat.BlockoutTypes, schedForType[i].BlockoutType) + "\r\n" + schedForType[i].Note; if (schedForType[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr //6 + schedForType[i].StartTime.Minute * Lh / MinPerRow //10 , ColWidth * ColCount - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedForType[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + ColWidth * ApptViewItems.GetIndexOp(schedForType[i].Op) + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr + schedForType[i].StartTime.Minute * Lh / MinPerRow , ColWidth - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } g.FillRectangle(blockBrush, rect); //g.DrawRectangle(blockOutlinePen,rect.X,rect.Y+1,rect.Width-1,rect.Height-3); g.DrawLine(blockOutlinePen, rect.X, rect.Y + 1, rect.Right - 1, rect.Y + 1); g.DrawString(blockText, blockFont , new SolidBrush(DefB.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect); } } }
private void CopyOverBlockouts(long numRepeat, string type) { if (DateCopyStart.Year < 1880) { MsgBox.Show(this, "Please copy a selection to the clipboard first."); return; } //calculate which day or week is currently selected. DateTime dateSelectedStart; DateTime dateSelectedEnd; bool isWeek = DateCopyStart != DateCopyEnd; if (isWeek) { //Always start week on Monday if (DateSelected.DayOfWeek == DayOfWeek.Sunday) //if selecting Sunday, go back to the previous Monday. { dateSelectedStart = DateSelected.AddDays(-6); } else //Any other day. eg Wed.AddDays(1-3)=Wed.AddDays(-2)=Monday { dateSelectedStart = DateSelected.AddDays(1 - (int)DateSelected.DayOfWeek); //eg Wed.AddDays(1-3)=Wed.AddDays(-2)=Monday } //DateCopyEnd is greater than DateCopyStart and is either 4 days greater or 6 days greater, so clear/paste the same number of days dateSelectedEnd = dateSelectedStart.AddDays((DateCopyEnd - DateCopyStart).Days); } else { dateSelectedStart = DateSelected; dateSelectedEnd = DateSelected; } //When pasting, it's not allowed to paste back over the same day or week. if (dateSelectedStart == DateCopyStart && type == "Paste") { MsgBox.Show(this, "Not allowed to paste back onto the same date as is on the clipboard."); return; } Cursor = Cursors.WaitCursor; //it is allowed to paste back over the same day or week. List <long> opNums = ApptViewItems.GetOpsForView(ApptViewNumCur); List <Schedule> SchedList = Schedules.RefreshPeriodBlockouts(DateCopyStart, DateCopyEnd, opNums); //Build a list of blockouts that can't be Cut/Copy/Pasted List <Def> listUserBlockoutDefs = Defs.GetDefsForCategory(DefCat.BlockoutTypes, true) .FindAll(x => x.ItemValue.Contains(BlockoutType.DontCopy.GetDescription())); //No SchedList only contains blockouts that are NOT marked "Do not Cut/Copy/Paste" SchedList.RemoveAll(x => listUserBlockoutDefs.Any(y => y.DefNum == x.BlockoutType)); Schedule sched; int weekDelta = 0; TimeSpan span; if (isWeek) { span = dateSelectedStart - DateCopyStart; weekDelta = span.Days / 7; //usually a positive # representing a future paste, but can be negative } int dayDelta = 0; //this is needed when repeat pasting days in order to calculate skipping weekends. //dayDelta will start out zero and increment separately from r. for (int r = 0; r < numRepeat; r++) { if (checkReplace.Checked) { if (type == "Repeat") { if (isWeek) { Schedules.ClearBlockouts(dateSelectedStart.AddDays(r * 7), dateSelectedEnd.AddDays(r * 7), opNums); } else { //dateSelectedStart will equal dateSelectedEnd if repeating a single day Schedules.ClearBlockouts(dateSelectedStart.AddDays(dayDelta), dateSelectedEnd.AddDays(dayDelta), opNums); } } else { Schedules.ClearBlockouts(dateSelectedStart, dateSelectedEnd, opNums); } } List <Schedule> listNewScheds = new List <Schedule>(); for (int i = 0; i < SchedList.Count; i++) { sched = SchedList[i].Copy(); sched.ScheduleNum = 0; //So that overlap logic works. if (isWeek) { sched.SchedDate = sched.SchedDate.AddDays((weekDelta + r) * 7); } else { sched.SchedDate = dateSelectedStart.AddDays(dayDelta); } if (!checkReplace.Checked && Schedules.Overlaps(sched)) { MessageBox.Show(Lans.g("Schedule", "A blockout overlaps with an existing blockout. Could not paste the blockout on") + " " + sched.SchedDate.ToShortDateString() + " " + sched.StartTime.ToShortTimeString()); Cursor = Cursors.Default; return; } listNewScheds.Add(sched); } //dayDelta is only used for repeating single days, not for repeating weeks, so we don't need to determine whether or not they copied weekends, we can rely on checkWeekend.Checked if (!checkWeekend.Checked && dateSelectedStart.AddDays(dayDelta).DayOfWeek == DayOfWeek.Friday) { dayDelta += 3; } else { dayDelta++; } //This is located outside of the previous for loop because we do not want to insert any blockouts unless there were no overlaps. foreach (Schedule schedule in listNewScheds) { Schedules.Insert(schedule, true); //Doing it this way makes use of validation to prevent overlaps } } Cursor = Cursors.Default; Close(); }
private void butRepeat_Click(object sender, EventArgs e) { try { int.Parse(textRepeat.Text); } catch { MsgBox.Show(this, "Please fix number box first."); return; } if (DateCopyStart.Year < 1880) { MsgBox.Show(this, "Please copy a selection to the clipboard first."); return; } //calculate which day or week is currently selected. DateTime dateSelectedStart; DateTime dateSelectedEnd; bool isWeek = DateCopyStart != DateCopyEnd; if (isWeek) { if (checkWeekend.Checked) { dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek); dateSelectedEnd = dateSelectedStart.AddDays(6); } else { dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek + 1); dateSelectedEnd = dateSelectedStart.AddDays(4); } } else { dateSelectedStart = DateSelected; dateSelectedEnd = DateSelected; } //it is allowed to paste back over the same day or week. int[] opNums = ApptViewItems.GetOpsForView(ApptViewNumCur); List <Schedule> SchedList = Schedules.RefreshPeriodBlockouts(DateCopyStart, DateCopyEnd, opNums); Schedule sched; int weekDelta = 0; TimeSpan span; if (isWeek) { span = dateSelectedStart - DateCopyStart; weekDelta = span.Days / 7; //usually a positive # representing a future paste, but can be negative } int dayDelta = 0; //this is needed when repeat pasting days in order to calculate skipping weekends. //dayDelta will start out zero and increment separately from r. for (int r = 0; r < PIn.PInt(textRepeat.Text); r++) { if (checkReplace.Checked) { if (isWeek) { Schedules.ClearBlockouts(dateSelectedStart.AddDays(r * 7), dateSelectedEnd.AddDays(r * 7), opNums); } else { Schedules.ClearBlockouts(dateSelectedStart.AddDays(dayDelta), dateSelectedEnd.AddDays(dayDelta), opNums); } } for (int i = 0; i < SchedList.Count; i++) { sched = SchedList[i].Copy(); if (isWeek) { sched.SchedDate = sched.SchedDate.AddDays((weekDelta + r) * 7); } else { sched.SchedDate = dateSelectedStart.AddDays(dayDelta); } Schedules.Insert(sched); } if (!checkWeekend.Checked && dateSelectedStart.AddDays(dayDelta).DayOfWeek == DayOfWeek.Friday) { dayDelta += 3; } else { dayDelta++; } } Close(); }
private void butPaste_Click(object sender, EventArgs e) { if (DateCopyStart.Year < 1880) { MsgBox.Show(this, "Please copy a selection to the clipboard first."); return; } //calculate which day or week is currently selected. DateTime dateSelectedStart; DateTime dateSelectedEnd; bool isWeek = DateCopyStart != DateCopyEnd; if (isWeek) { if (checkWeekend.Checked) { dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek); dateSelectedEnd = dateSelectedStart.AddDays(6); } else { dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek + 1); dateSelectedEnd = dateSelectedStart.AddDays(4); } } else { dateSelectedStart = DateSelected; dateSelectedEnd = DateSelected; } //it's not allowed to paste back over the same day or week. if (dateSelectedStart == DateCopyStart) { MsgBox.Show(this, "Not allowed to paste back onto the same date as is on the clipboard."); return; } int[] opNums = ApptViewItems.GetOpsForView(ApptViewNumCur); List <Schedule> SchedList = Schedules.RefreshPeriodBlockouts(DateCopyStart, DateCopyEnd, opNums); if (checkReplace.Checked) { Schedules.ClearBlockouts(dateSelectedStart, dateSelectedEnd, opNums); } Schedule sched; int weekDelta = 0; if (isWeek) { TimeSpan span = dateSelectedStart - DateCopyStart; weekDelta = span.Days / 7; //usually a positive # representing a future paste, but can be negative } for (int i = 0; i < SchedList.Count; i++) { sched = SchedList[i]; if (isWeek) { sched.SchedDate = sched.SchedDate.AddDays(weekDelta * 7); } else { sched.SchedDate = dateSelectedStart; } Schedules.Insert(sched); } Close(); }
private void DoSearch() { Cursor = Cursors.WaitCursor; DateTime startDate = dateSearchFrom.Value.Date.AddDays(-1); //Text on boxes is To/From. This will effecitvely make it the 'afterDate'. DateTime endDate = dateSearchTo.Value.Date.AddDays(1); _listOpenings.Clear(); #region validation if (startDate.Year < 1880 || endDate.Year < 1880) { Cursor = Cursors.Default; MsgBox.Show(this, "Invalid date selection."); return; } TimeSpan beforeTime = new TimeSpan(0); if (textBefore.Text != "") { try { beforeTime = GetBeforeAfterTime(textBefore.Text, radioBeforePM.Checked); } catch { Cursor = Cursors.Default; MsgBox.Show(this, "Invalid 'Starting before' time."); return; } } TimeSpan afterTime = new TimeSpan(0); if (textAfter.Text != "") { try { afterTime = GetBeforeAfterTime(textAfter.Text, radioAfterPM.Checked); } catch { Cursor = Cursors.Default; MsgBox.Show(this, "Invalid 'Starting after' time."); return; } } if (comboBoxMultiProv.SelectedTags <Provider>().Contains(null) && comboBlockout.GetSelectedDefNum() == 0) { Cursor = Cursors.Default; MsgBox.Show(this, "Please pick a provider or a blockout type."); return; } #endregion //get lists of info to do the search List <long> listOpNums = new List <long>(); List <long> listClinicNums = new List <long>(); List <long> listProvNums = new List <long>(); long blockoutType = 0; if (comboBlockout.GetSelectedDefNum() != 0) { blockoutType = comboBlockout.GetSelectedDefNum(); listProvNums.Add(0); //providers don't matter for blockouts } if (!comboBoxMultiProv.SelectedTags <Provider>().Contains(null)) { foreach (ODBoxItem <Provider> provBoxItem in comboBoxMultiProv.ListSelectedItems) { listProvNums.Add(provBoxItem.Tag.ProvNum); } } if (PrefC.HasClinicsEnabled) { if (comboBoxClinic.SelectedClinicNum != 0) { listClinicNums.Add(comboBoxClinic.SelectedClinicNum); listOpNums = Operatories.GetOpsForClinic(comboBoxClinic.SelectedClinicNum).Select(x => x.OperatoryNum).ToList(); } else //HQ //and unassigned (which is clinic num 0) { long apptViewNum = comboApptView.GetSelected <ApptView>().ApptViewNum; //get the disctinct clinic nums for the operatories in the current appointment view List <long> listOpsForView = ApptViewItems.GetOpsForView(apptViewNum); List <Operatory> listOperatories = Operatories.GetOperatories(listOpsForView, true); listClinicNums = listOperatories.Select(x => x.ClinicNum).Distinct().ToList(); listOpNums = listOperatories.Select(x => x.OperatoryNum).ToList(); } } else //no clinics { listOpNums = Operatories.GetDeepCopy(true).Select(x => x.OperatoryNum).ToList(); } if (blockoutType != 0 && listProvNums.Max() > 0) { _listOpenings.AddRange(ApptSearch.GetSearchResultsForBlockoutAndProvider(listProvNums, _appt.AptNum, startDate, endDate, listOpNums, listClinicNums , beforeTime, afterTime, blockoutType, 15)); } else { _listOpenings = ApptSearch.GetSearchResults(_appt.AptNum, startDate, endDate, listProvNums, listOpNums, listClinicNums , beforeTime, afterTime, blockoutType, resultCount: 15); } Cursor = Cursors.Default; FillGrid(); }
///<summary>Called from SetLocation to establish X position of control.</summary> private int ConvertToX() { return(ContrApptSheet.TimeWidth + ContrApptSheet.ProvWidth * ContrApptSheet.ProvCount + ContrApptSheet.ColWidth * (ApptViewItems.GetIndexOp(Info.MyApt.Op)) + 1); }