Changeset 1106


Ignore:
Timestamp:
Mar 20, 2011, 3:22:11 AM (13 years ago)
Author:
Sam Habiel
Message:

CalendarGrid:

  • Support for Autoscrolling corrected.
  • A little optimization: Grid is only drawn once now when starting, not twice (don't know why original code did that).

CGAppointment:

  • Added member Patient (new Class)

CGDocument:

  • OnOpenDocument now accepts input of DateTime to decide where to open document.
  • SlotsAvailable algorithm now includes code for scaling according to timescale and code to merge Blocks if they are adjacent.

CGDocumentManager:

  • Fix bug having to do with canceling log-in after first retry. BMX lib threw an exception which was not caught.

CGView: Many changes:

  • SlotsAvailable signature changed in CGDocument. All references to it had to be changed.
  • Opening a node in the tvSchedules by clicking on the plus sign did not select it. Code changes to make it select it.
  • UpdateStatusBar now uses a string builder; and shows a more comprehensive message on the availability in the Status Bar.
  • Focus issues on various controls.
  • Support for printing a slip after an appointment is made automatically has been added.

CustomPrinting:

  • now includes a method to print a single appointment slip

DAppointPage:

  • Checkbox to decide whether to print appt slip added.
  • New readonly property to get the appointment that has been made (of type CGAppointment).

DApptSearch:

  • StartDate and EndDate now autoadjust based on each other.
  • lblMessage added to show user message if no appointments are found.
Location:
Scheduling/trunk/cs/bsdx0200GUISourceCode
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAppointment.cs

    r900 r1106  
    303303            }
    304304        }
     305
     306        public Patient Patient { get; set; }
    305307    }
    306308}
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs

    r1097 r1106  
    88using IndianHealthService.BMXNet;
    99using System.Linq;
     10using System.Collections.Generic;
    1011
    1112namespace IndianHealthService.ClinicalScheduling
     
    321322        }
    322323
    323         public void OnOpenDocument()
     324        public void OnOpenDocument(DateTime dDate)
    324325        {
    325326            try
     
    328329                m_ScheduleType = (m_sResourcesArray.Count == 1) ? ScheduleType.Resource : ScheduleType.Clinic;
    329330                bool bRet = false;
    330 
    331                 //Set initial From and To dates based on current day
    332                 DateTime dDate = DateTime.Today;
     331               
    333332                if (m_ScheduleType == ScheduleType.Resource)
    334333                {
     
    396395        private bool RefreshSchedule()
    397396        {
    398             try
    399             {
    400                 bool bRet = this.RefreshAvailabilitySchedule();
    401                 if (bRet == false)
    402                 {
    403                     return bRet;
    404                 }
    405                 bRet = this.RefreshDaysSchedule();
    406                 return bRet;
    407             }
    408             catch (ApplicationException aex)
    409             {
    410                 Debug.Write("CGDocument.RefreshSchedule Application Error:  " + aex.Message + "\n");
    411                 return false;
    412             }
    413             catch (Exception ex)
    414             {
    415                 MessageBox.Show("CGDocument.RefreshSchedule error:  " + ex.Message + "\n");
    416                 return false;
    417             }
     397            this.RefreshAvailabilitySchedule();
     398            this.RefreshDaysSchedule();
     399            return true;
    418400        }
    419401
     
    637619        /// <param name="sAvailabilityMessage">Out: Access Note</param>
    638620        /// <returns>Number of slots</returns>
    639         public int SlotsAvailable(DateTime dSelStart, DateTime dSelEnd, string sResource, out string sAccessType, out string sAvailabilityMessage)
    640         {
    641 
    642 
    643             sAccessType = "";               //default out value
    644             sAvailabilityMessage = "";      //default out value
     621        public int SlotsAvailable(DateTime dSelStart, DateTime dSelEnd, string sResource, int viewTimeScale, out CGAvailability resultantAV)
     622        {
     623
     624            resultantAV = null;
    645625
    646626            double slotsAvailable = 0;      //defalut return value
     627
     628            double effectiveSlotsAvailable = 0;    //Slots available based on the time scale.
     629
    647630
    648631            //NOTE: What's this lock? This lock makes sure that nobody is editing the availability array
     
    660643            {
    661644                //This foreach loop looks for an availability that overlaps where the user clicked.
    662                 //There can only be one, as availabilites cannot overlap each other (enforced at the DB level)
     645                //Availabilites cannot overlap each other (enforced at the DB level)
    663646                //If selection hits multiple blocks, get the block with the most slots (reflected by the sorting here)
    664                 CGAvailability[] pAVs = (from pAV in this.m_pAvArray.Cast<CGAvailability>()
    665                                          where (sResource == pAV.ResourceList && CalendarGrid.TimesOverlap(dSelStart, dSelEnd, pAV.StartTime, pAV.EndTime))
    666                                          orderby pAV.Slots descending
    667                                          select pAV)
    668                                          .ToArray<CGAvailability>();
    669 
    670                 if ((pAVs.Length) == 0) return 0;
    671 
    672                 slotsAvailable = pAVs[0].Slots;
    673                 sAccessType = pAVs[0].AccessTypeName;
    674                 sAvailabilityMessage = pAVs[0].Note;
    675 
     647                List<CGAvailability> lstAV = (from avail in this.m_pAvArray.Cast<CGAvailability>()
     648                           where (sResource == avail.ResourceList && CalendarGrid.TimesOverlap(dSelStart, dSelEnd, avail.StartTime, avail.EndTime))
     649                           select avail).ToList();
     650
     651                //if we don't have any availabilities, then return with zero slots.
     652                if (lstAV.Count == 0) return 0;
     653               
     654                CGAvailability pAV;
     655
     656                //if there is just one, that's it.
     657                if (lstAV.Count == 1) pAV = lstAV.First();
     658                //otherwise...
     659                else
     660                {
     661                    //if availabilities are contigous to each other, need to join them together.
     662
     663                    //First, are they the same?
     664                    string firsttype = lstAV.First().AccessTypeName;
     665                    bool bAllSameType = lstAV.All(av => av.AccessTypeName == firsttype);
     666
     667                    //Second are they ALL contigous?
     668                    DateTime lastEndTime = DateTime.Today; //bogus value to please compiler who wants it assigned.
     669                    int index = 0;
     670
     671                    bool bContigous = lstAV.OrderBy(av => av.StartTime)
     672                       .All(av =>
     673                       {
     674                           index++;
     675                           if (index == 1)
     676                           {
     677                               lastEndTime = av.EndTime;
     678                               return true;
     679                           }
     680                           if (av.StartTime == lastEndTime)
     681                           {
     682                               lastEndTime = av.EndTime;
     683                               return true;
     684                           }
     685
     686                           return false;
     687                       });
     688
     689
     690
     691                    if (bContigous && bAllSameType)
     692                    {
     693                        var enumAVOrdered = lstAV.OrderBy(av => av.StartTime);
     694
     695                        pAV = new CGAvailability
     696                        {
     697                            StartTime = enumAVOrdered.First().StartTime,
     698                            EndTime = enumAVOrdered.Last().EndTime,
     699                            Slots = enumAVOrdered.Sum(av => av.Slots),
     700                            AccessTypeName = enumAVOrdered.First().AccessTypeName,
     701                            Note = enumAVOrdered.First().Note
     702                        };
     703                    }
     704                    else
     705                    {
     706                        pAV = lstAV.OrderByDescending(av => av.Slots).First();
     707                    }
     708                }
     709
     710                resultantAV = pAV; // out var
     711               
     712                slotsAvailable = pAV.Slots;
     713               
    676714                //Subtract total slots current appointments take up.
    677715                slotsAvailable -= (from appt in this.Appointments.AppointmentTable.Values.Cast<CGAppointment>()
    678716                                   //If the resource is the same and the user selection overlaps, then...
    679                                    where (sResource == appt.Resource && CalendarGrid.TimesOverlap(pAVs[0].StartTime, pAVs[0].EndTime, appt.StartTime, appt.EndTime))
     717                                   where (sResource == appt.Resource && CalendarGrid.TimesOverlap(pAV.StartTime, pAV.EndTime, appt.StartTime, appt.EndTime))
    680718                                   // if appt starttime is before avail start time, only count against the avail starting from the availability start time
    681                                    let startTimeToCountAgainstBlock = appt.StartTime < pAVs[0].StartTime ? pAVs[0].StartTime : appt.StartTime
     719                                   let startTimeToCountAgainstBlock = appt.StartTime < pAV.StartTime ? pAV.StartTime : appt.StartTime
    682720                                   // if appt endtime is after the avail ends, only count against the avail up to where the avail ends
    683                                    let endTimeToCountAgainstBlock = appt.EndTime > pAVs[0].EndTime ? pAVs[0].EndTime : appt.EndTime
     721                                   let endTimeToCountAgainstBlock = appt.EndTime > pAV.EndTime ? pAV.EndTime : appt.EndTime
    684722                                   // theoretical minutes per slot for the availability
    685                                    let minPerSlot = (pAVs[0].EndTime - pAVs[0].StartTime).TotalMinutes / pAVs[0].Slots
     723                                   let minPerSlot = (pAV.EndTime - pAV.StartTime).TotalMinutes / pAV.Slots
    686724                                   // how many minutes does this appointment take away from the slot
    687725                                   let minPerAppt = (endTimeToCountAgainstBlock - startTimeToCountAgainstBlock).TotalMinutes
     
    691729                                   // add up SlotsConsumed to substract from slotsAvailable
    692730                                   .Sum();
    693             }
    694 
    695             return (int)slotsAvailable;
     731
     732                //theoretical minutes per slot for the availability
     733                double minPerSlot2 = (pAV.EndTime - pAV.StartTime).TotalMinutes / pAV.Slots;
     734               
     735                //Convert it to the view's time scale.
     736                effectiveSlotsAvailable = (minPerSlot2 / viewTimeScale) * slotsAvailable;
     737
     738            }
     739           
     740            //round it down.
     741            return (int)effectiveSlotsAvailable;
    696742
    697743            /* OLD ALGOTHRIM 2
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs

    r1104 r1106  
    410410                    {
    411411                        bRetry = true;
    412                         _current.m_ConnectInfo.ChangeServerInfo();
     412                        //I hate this, but this is how the library is designed. It throws an error if the user cancels. XXX: Won't fix library until BMX 4.0 port.
     413                        try { _current.m_ConnectInfo.ChangeServerInfo(); }
     414                        catch (Exception)
     415                        {
     416                            closeSplashDelegate();
     417                            bRetry = false;
     418                            return false; //tell main that it's a no go.
     419                        }
    413420                    }
    414421                    else
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs

    r1097 r1106  
    617617            this.tvSchedules.Location = new System.Drawing.Point(0, 0);
    618618            this.tvSchedules.Name = "tvSchedules";
    619             this.tvSchedules.Size = new System.Drawing.Size(128, 358);
     619            this.tvSchedules.Size = new System.Drawing.Size(128, 393);
    620620            this.tvSchedules.Sorted = true;
    621621            this.tvSchedules.TabIndex = 1;
    622622            this.tvSchedules.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvSchedules_AfterSelect);
    623             this.tvSchedules.Click += new System.EventHandler(this.tvSchedules_Click);
     623            this.tvSchedules.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvSchedules_NodeMouseClick);
    624624            this.tvSchedules.DoubleClick += new System.EventHandler(this.tvSchedules_DoubleClick);
     625            this.tvSchedules.MouseEnter += new System.EventHandler(this.tvSchedules_MouseEnter);
    625626            //
    626627            // contextMenu1
     
    662663            this.panelRight.Controls.Add(this.panelClip);
    663664            this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
    664             this.panelRight.Location = new System.Drawing.Point(941, 0);
     665            this.panelRight.Location = new System.Drawing.Point(996, 0);
    665666            this.panelRight.Name = "panelRight";
    666             this.panelRight.Size = new System.Drawing.Size(128, 358);
     667            this.panelRight.Size = new System.Drawing.Size(128, 393);
    667668            this.panelRight.TabIndex = 3;
    668669            this.panelRight.Visible = false;
     
    730731            this.panelTop.Location = new System.Drawing.Point(128, 0);
    731732            this.panelTop.Name = "panelTop";
    732             this.panelTop.Size = new System.Drawing.Size(813, 24);
     733            this.panelTop.Size = new System.Drawing.Size(868, 24);
    733734            this.panelTop.TabIndex = 6;
    734735            //
     
    737738            this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Right;
    738739            this.dateTimePicker1.DropDownAlign = System.Windows.Forms.LeftRightAlignment.Right;
    739             this.dateTimePicker1.Location = new System.Drawing.Point(607, 0);
     740            this.dateTimePicker1.Location = new System.Drawing.Point(662, 0);
    740741            this.dateTimePicker1.Name = "dateTimePicker1";
    741742            this.dateTimePicker1.Size = new System.Drawing.Size(206, 20);
     
    760761            this.panelCenter.Location = new System.Drawing.Point(136, 24);
    761762            this.panelCenter.Name = "panelCenter";
    762             this.panelCenter.Size = new System.Drawing.Size(802, 310);
     763            this.panelCenter.Size = new System.Drawing.Size(857, 345);
    763764            this.panelCenter.TabIndex = 7;
    764765            //
     
    846847            this.panelBottom.Controls.Add(this.statusBar1);
    847848            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
    848             this.panelBottom.Location = new System.Drawing.Point(136, 334);
     849            this.panelBottom.Location = new System.Drawing.Point(136, 369);
    849850            this.panelBottom.Name = "panelBottom";
    850             this.panelBottom.Size = new System.Drawing.Size(802, 24);
     851            this.panelBottom.Size = new System.Drawing.Size(857, 24);
    851852            this.panelBottom.TabIndex = 8;
    852853            //
     
    856857            this.statusBar1.Location = new System.Drawing.Point(0, 0);
    857858            this.statusBar1.Name = "statusBar1";
    858             this.statusBar1.Size = new System.Drawing.Size(802, 24);
     859            this.statusBar1.Size = new System.Drawing.Size(857, 24);
    859860            this.statusBar1.SizingGrip = false;
    860861            this.statusBar1.TabIndex = 0;
     
    864865            this.splitter1.Location = new System.Drawing.Point(128, 24);
    865866            this.splitter1.Name = "splitter1";
    866             this.splitter1.Size = new System.Drawing.Size(8, 334);
     867            this.splitter1.Size = new System.Drawing.Size(8, 369);
    867868            this.splitter1.TabIndex = 9;
    868869            this.splitter1.TabStop = false;
     
    871872            //
    872873            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
    873             this.splitter2.Location = new System.Drawing.Point(938, 24);
     874            this.splitter2.Location = new System.Drawing.Point(993, 24);
    874875            this.splitter2.Name = "splitter2";
    875             this.splitter2.Size = new System.Drawing.Size(3, 334);
     876            this.splitter2.Size = new System.Drawing.Size(3, 369);
    876877            this.splitter2.TabIndex = 10;
    877878            this.splitter2.TabStop = false;
     
    901902            this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
    902903            this.calendarGrid1.SelectedAppointment = 0;
    903             this.calendarGrid1.Size = new System.Drawing.Size(802, 310);
     904            this.calendarGrid1.Size = new System.Drawing.Size(857, 345);
    904905            this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
    905906            this.calendarGrid1.TabIndex = 0;
     
    914915            //
    915916            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    916             this.ClientSize = new System.Drawing.Size(1069, 358);
     917            this.ClientSize = new System.Drawing.Size(1124, 393);
    917918            this.Controls.Add(this.panelCenter);
    918919            this.Controls.Add(this.panelBottom);
     
    946947                private CGDocumentManager       m_DocManager;
    947948                private int                                     m_nSlots;
    948                 bool                                            bSchedulesClicked = false;
    949949                private ArrayList                       m_alSelectedTreeResourceArray = new ArrayList();
    950950                private string                          m_sDocName;
     
    13601360                }
    13611361
    1362                 void UpdateStatusBar(DateTime dStart, DateTime dEnd, string sAccessType, string sAvailabilityMessage)
    1363                 {
    1364                         string sMsg =  dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString();
    1365                         if (m_nSlots > 0)
    1366                         {
    1367                                 sMsg = sMsg + ": " + m_nSlots.ToString() + " slot";
    1368                                 sMsg = sMsg + ((m_nSlots > 1)?"s " : " ");
    1369                                 sMsg = sMsg + "available";
    1370                                 if (sAccessType != "")
    1371                                 {
    1372                                         sMsg = sMsg + " for " + sAccessType;
    1373                                 }
    1374                                 sMsg = sMsg + ".";
    1375                                 if (sAvailabilityMessage != "")
    1376                                 {
    1377                                         sMsg = sMsg + "  Note: " + sAvailabilityMessage;
    1378                                 }
    1379                         }
     1362                void UpdateStatusBar(DateTime dStart, DateTime dEnd, CGAvailability av)
     1363                {
     1364            System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(100);
     1365                    sbMsg.Append(dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString());
     1366                        if (av != null && m_nSlots > 0)
     1367                        {
     1368                sbMsg.Append(String.Format(" has {0} slot(s) available for {1}. ", m_nSlots.ToString(), av.AccessTypeName));
     1369            }
    13801370                        else
    13811371                        {
    1382                                 sMsg += ": No appointment slots available.";
    1383                         }
    1384 
    1385                         this.statusBar1.Text = sMsg;
     1372                                sbMsg.Append(": No appointment slots available. ");
     1373                        }
     1374
     1375            if (av != null)
     1376            {
     1377                sbMsg.Append(String.Format("Source Block: {0} to {1} with {2} slot(s) of type {3}",
     1378                    av.StartTime.ToShortTimeString(),
     1379                    av.EndTime.ToShortTimeString(),
     1380                    av.Slots.ToString(),
     1381                    av.AccessTypeName));
     1382
     1383                sbMsg.Append(". ");
     1384
     1385                if (av.Note.Trim().Length > 0) sbMsg.Append("Note: " + av.Note + ".");
     1386            }
     1387
     1388            this.statusBar1.Text = sbMsg.ToString();
    13861389                }
    13871390
     
    14751478                                v.Activate();
    14761479                                v.dateTimePicker1.Value = dDate;
     1480                v.RequestRefreshGrid();
    14771481                return;
    14781482                        }
     
    15071511            try
    15081512                        {
    1509                                 doc.OnOpenDocument();
     1513                                doc.OnOpenDocument(dDate);
    15101514                        }
    15111515                               
     
    16381642                        try
    16391643                        {
    1640                                 doc.OnOpenDocument();
     1644                                doc.OnOpenDocument(DateTime.Today);
    16411645                        }
    16421646                        catch (Exception ex)
     
    20462050                //SMH: Takes too long to do.
    20472051                                //this.Document.RefreshDocument();
    2048                                 string sAccessType = "";
    2049                                 string sAvailabilityMessage = "";
    2050                                 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, out sAccessType, out sAvailabilityMessage);
     2052                CGAvailability resultantAvail;
     2053
     2054                                m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
    20512055
    20522056                                if (m_nSlots < 1)
     
    21552159                                }
    21562160                               
    2157                                 TimeSpan tsDuration = dEnd - dStart;
    2158                                 int nDuration = (int) tsDuration.TotalMinutes;
    2159                                 Debug.Assert(nDuration > 0);
    2160 
    2161 
    21622161                //Sam: takes too long. Remove this call; deal with the issue of concurrent appointments another way.
    21632162                //this.Document.RefreshDocument();
    2164                                 string sAccessType = "";
    2165                                 string sAvailabilityMessage = "";
    2166                                 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, out sAccessType, out sAvailabilityMessage);
     2163                CGAvailability resultantAvail;
     2164                m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
    21672165
    21682166                                if (m_nSlots < 1)
     
    21922190                                dAppt.DocManager = this.m_DocManager;
    21932191                                string sNote = "";
    2194                                 dAppt.InitializePage(dPat.PatientIEN, dStart, nDuration, sResource, sNote);
     2192                dAppt.InitializePage(dPat.PatientIEN, dStart, dEnd, sResource, sNote, nAccessTypeID);
    21952193
    21962194                                if (dAppt.ShowDialog(this) == DialogResult.Cancel)
     
    21992197                                }
    22002198
    2201                 CGAppointment appt = new CGAppointment();
     2199                CGAppointment appt = dAppt.Appointment;
     2200                   
     2201                // old way of making an appointment
     2202                    /*new CGAppointment();
    22022203                                appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
    22032204                                appt.PatientName = dPat.PatientName;
     
    22082209                                appt.HealthRecordNumber = dPat.HealthRecordNumber;
    22092210                                appt.AccessTypeID = nAccessTypeID;
     2211                    */
    22102212
    22112213                                //Call Document to add a new appointment. Document adds appointment to CGAppointments array.
    22122214                                this.Document.CreateAppointment(appt);
     2215
     2216                //Experimental now.
     2217                if (dAppt.PrintAppointmentSlip)
     2218                {
     2219                    System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
     2220                    pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintAppointmentSlip(appt, e);
     2221                    pd.Print();
     2222                }
    22132223
    22142224                //Show the new set of appointments by calling UpdateArrays. Fetches Document's CGAppointments
     
    25052515                calendarGrid1.Focus();
    25062516        }
     2517
     2518        /// <summary>
     2519        /// If mouse enters the Tree Section, check if the grid is on the active form first before stealing the focus
     2520        /// </summary>
     2521        /// <param name="sender"></param>
     2522        /// <param name="e"></param>
     2523        private void tvSchedules_MouseEnter(object sender, EventArgs e)
     2524        {
     2525            if (GetActiveWindow() == this.Handle)
     2526                tvSchedules.Focus();
     2527        }
    25072528       
    25082529        private void CGView_Load(object sender, System.EventArgs e)
     
    25202541            //Show the Form
    25212542            this.Activate();
     2543
     2544            //Set focus on the calendar grid
     2545            this.calendarGrid1.Focus();
    25222546                }
    25232547
     
    25922616                }
    25932617
    2594                 private void tvSchedules_Click(object sender, System.EventArgs e)
    2595                 {
    2596                         bSchedulesClicked = true;
    2597                 }
     2618
    25982619
    25992620                private void tvSchedules_DoubleClick(object sender, System.EventArgs e)
     
    26362657        }
    26372658
     2659
    26382660                private void tvSchedules_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
    2639                 {
    2640                         if (bSchedulesClicked == false)
    2641                                 return;
    2642                         bSchedulesClicked = false;
    2643                        
     2661                {       
    26442662                        m_alSelectedTreeResourceArray = new ArrayList();
    26452663                        string sResource = e.Node.FullPath;
     
    26622680                }
    26632681
     2682        /// <summary>
     2683        /// Makes sure that the node gets selected no matter where we click.
     2684        /// Incidentally, Invokes AfterSelect event.
     2685        /// </summary>
     2686        /// <param name="sender"></param>
     2687        /// <param name="e"></param>
     2688        private void tvSchedules_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
     2689        {
     2690            e.Node.TreeView.SelectedNode = e.Node;
     2691        }
     2692
     2693        /// <summary>
     2694        /// Useless code now... Good place to test something.
     2695        /// </summary>
     2696        /// <param name="sender"></param>
     2697        /// <param name="e"></param>
    26642698                private void mnuTest1_Click(object sender, System.EventArgs e)
    26652699                {
     
    27182752                private void calendarGrid1_CGSelectionChanged(object sender, IndianHealthService.ClinicalScheduling.CGSelectionChangedArgs e)
    27192753                {
    2720                         string sAccessType = "";
    2721                         string sAvailabilityMessage = "";
    2722                         m_nSlots = m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage);
    2723                         UpdateStatusBar(e.StartTime, e.EndTime, sAccessType, sAvailabilityMessage);
     2754            CGAvailability resultantAvail;
     2755            m_nSlots = m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail);
     2756                        UpdateStatusBar(e.StartTime, e.EndTime, resultantAvail);
    27242757                }
    27252758
     
    27582791
    27592792                                //20040909 Cherokee Replaced this block with following
    2760                                 string sAccessType = "";
    2761                                 string sAvailabilityMessage = "";
    27622793                                //                              if (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) < 1)
    27632794                                //                              {
     
    27752806                                        bModSchedule =  (bool) this.m_htModifySchedule[e.Resource.ToString()];
    27762807                                }
    2777                                 bool bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) > 0);
     2808                CGAvailability resultantAvail;
     2809                bool bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
    27782810                                if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
    27792811                                {
     
    29662998                        try
    29672999                        {
    2968                                 string sAccessType = "";
    2969                                 string sAvailabilityMessage = "";
    29703000                                bool    bSlotsAvailable;
    29713001                                bool    bOverbook;
     
    29903020                                bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
    29913021                                bModSchedule =  (bool) this.m_htModifySchedule[e.Resource.ToString()];
    2992                                 bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) > 0);
     3022                CGAvailability resultantAvail;
     3023
     3024                bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
    29933025
    29943026                                if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
     
    33393371        }
    33403372
     3373
     3374
     3375
     3376
    33413377       
    33423378
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs

    r1095 r1106  
    2424        private bool m_bDrawWalkIns = true;
    2525        private bool m_bGridEnter;
    26         private bool m_bInitialUpdate;
     26        //private bool m_bInitialUpdate;
    2727        private bool m_bMouseDown;
    2828        private bool m_bScroll;
     
    4949        private StringFormat m_sfRight;
    5050        private ArrayList m_sResourcesArray;
    51         private Timer m_Timer;                  // Timeer used in Drag and Drop Operations
     51        private Timer m_Timer;                  // Timer used in Drag and Drop Operations
    5252        private ToolTip m_toolTip;
    5353        private const int WM_HSCROLL = 0x114;       // Horizontal Scrolling Windows Message
    5454        private const int WM_VSCROLL = 0x115;       // Vertical Scrolling Windows Message
    5555        private const int WM_MOUSEWHEEL = 0x20a;    // Windows Mouse Scrolling Message
     56        private System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
     57
    5658
    5759        public delegate void CGAppointmentChangedHandler(object sender, CGAppointmentChangedArgs e);
     
    9092            this.m_sfHour.LineAlignment = StringAlignment.Center;
    9193            this.m_sfHour.Alignment = StringAlignment.Far;
    92             this.m_bInitialUpdate = false;
     94            // this.m_bInitialUpdate = false;
    9395        }
    9496
     
    113115            {
    114116                this.m_Timer.Stop();
     117                this.m_Timer.Tick -= new EventHandler(this.tickEventHandler);
    115118                this.m_Timer.Dispose();
    116119                this.m_Timer = null;
     
    232235        private void CalendarGrid_MouseDown(object sender, MouseEventArgs e)
    233236        {
     237            //watch.Restart();
    234238            if (e.Button == MouseButtons.Left)
    235239            {
     
    247251        private void CalendarGrid_MouseMove(object Sender, MouseEventArgs e)
    248252        {
     253            //test
     254            //System.Diagnostics.Debug.Write(watch.ElapsedMilliseconds + "\n");
     255            //test
     256
     257            //if the left mouse button is down and we are moving the mouse...
    249258            if (this.m_bMouseDown)
    250259            {
     260                //if Y axis is outside the top or bottom
    251261                if ((e.Y >= base.ClientRectangle.Bottom) || (e.Y <= base.ClientRectangle.Top))
    252262                {
     263                    //start auto scrolling. m_bScrollDown decides whether we scroll up or down.
    253264                    this.m_bScrollDown = e.Y >= base.ClientRectangle.Bottom;
    254                 }
     265                    AutoDragStart();
     266                }
     267
     268                //if Y axis within client rectagle, stop dragging (whether you started or not)
    255269                if ((e.Y < base.ClientRectangle.Bottom) && (e.Y > base.ClientRectangle.Top))
    256270                {
    257                     bool bAutoDrag = this.m_bAutoDrag;
     271                    AutoDragStop();
    258272                }
    259273                if (this.m_bSelectingRange)
     
    278292            else
    279293            {
     294                //test
     295                AutoDragStop(); //is this needed?
     296                //test
    280297                int y = e.Y - base.AutoScrollPosition.Y;
    281298                int x = e.X - base.AutoScrollPosition.X;
     
    348365            {
    349366                this.DrawGrid(e.Graphics);
     367                /*
    350368                if (!this.m_bInitialUpdate)
    351369                {
     
    354372                    this.m_bInitialUpdate = true;
    355373                }
     374                 */
    356375            }
    357376        }
     
    602621                        if (this.m_sResourcesArray.Count > 0)
    603622                        {
     623                            //IMP
     624                            //this is the place where we the selected cells are drawn in Light Light Blue.
     625                            //IMP
    604626                            if (this.m_selectedRange.CellIsInRange(cellFromRowCol))
    605627                            {
    606628                                g.FillRectangle(Brushes.Aquamarine, r);
     629                                //g.FillRectangle(Brushes.AntiqueWhite, r);
    607630                            }
    608631                            else
     
    11421165        }
    11431166
     1167        /// <summary>
     1168        /// Handles scrolling when the mouse button is down
     1169        /// </summary>
     1170        /// <param name="o"></param>
     1171        /// <param name="e"></param>
    11441172        private void tickEventHandler(object o, EventArgs e)
    11451173        {
     1174            //if there are still WM_TIME messages in the Queue after the timer is dead, don't do anything.
     1175            if (this.m_Timer == null) return;
     1176
    11461177            Point point = new Point(base.AutoScrollPosition.X, base.AutoScrollPosition.Y);
    11471178            int x = point.X;
    11481179            int num = point.Y * -1;
    1149             num = this.m_bScrollDown ? (num + 5) : (num - 5);
     1180            num = this.m_bScrollDown ? (num + 2) : (num - 2);
    11501181            point.Y = num;
    11511182            base.AutoScrollPosition = point;
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj

    r1098 r1106  
    302302    </Compile>
    303303    <Compile Include="Options.cs" />
     304    <Compile Include="Patient.cs" />
    304305    <Compile Include="Printing.cs" />
    305306    <Compile Include="UCPatientAppts.cs">
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.sln

    r1099 r1106  
    1111        EndGlobalSection
    1212        GlobalSection(ProjectConfigurationPlatforms) = postSolution
    13                 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Release|Any CPU
    14                 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Release|Any CPU
     13                {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     14                {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1515                {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
    1616                {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.Build.0 = Release|Any CPU
    17                 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Release|Any CPU
    18                 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Release|Any CPU
     17                {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     18                {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1919                {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.ActiveCfg = Release|Any CPU
    2020                {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.Build.0 = Release|Any CPU
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CustomPrinting.cs

    r1091 r1106  
    112112            }
    113113        }
    114        
     114
     115        /// <summary>
     116        /// Prints a single appointment slip to give to the patient
     117        /// </summary>
     118        /// <param name="appt">The Appointment to print</param>
     119        /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
     120        public virtual void PrintAppointmentSlip(CGAppointment appt, PrintPageEventArgs e)
     121        {
     122            Rectangle printArea = e.MarginBounds;
     123            Graphics g = e.Graphics;
     124            StringFormat sf = new StringFormat();
     125            sf.Alignment = StringAlignment.Center; //for title
     126            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
     127            Font fBody = new Font(FontFamily.GenericSerif, 12);
     128            string s = "Appointment Reminder Slip";
     129            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
     130
     131            // move down
     132            int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
     133            printArea.Y += titleHeight;
     134            printArea.Height -= titleHeight;
     135
     136            // draw underline
     137            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     138            printArea.Y += 15;
     139            printArea.Height -= 15;
     140
     141
     142
     143        }
     144
     145
    115146        /// <summary>
    116147        /// Print Letter to be given or mailed to the patient
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs

    r913 r1106  
    6363        private Label label7;
    6464        private TextBox txtCountry;
     65        private CheckBox chkPrint;
    6566        private IContainer components;
    6667
     
    125126            this.dsPatientApptDisplay2BindingSource = new System.Windows.Forms.BindingSource(this.components);
    126127            this.dsPatientApptDisplay2 = new IndianHealthService.ClinicalScheduling.dsPatientApptDisplay2();
     128            this.chkPrint = new System.Windows.Forms.CheckBox();
    127129            this.tabControl1.SuspendLayout();
    128130            this.tabAppointment.SuspendLayout();
     
    532534            // panel1
    533535            //
     536            this.panel1.Controls.Add(this.chkPrint);
    534537            this.panel1.Controls.Add(this.cmdCancel);
    535538            this.panel1.Controls.Add(this.cmdOK);
     
    573576            this.dsPatientApptDisplay2.DataSetName = "dsPatientApptDisplay2";
    574577            this.dsPatientApptDisplay2.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     578            //
     579            // chkPrint
     580            //
     581            this.chkPrint.AutoSize = true;
     582            this.chkPrint.Location = new System.Drawing.Point(13, 14);
     583            this.chkPrint.Name = "chkPrint";
     584            this.chkPrint.Size = new System.Drawing.Size(144, 17);
     585            this.chkPrint.TabIndex = 2;
     586            this.chkPrint.Text = "Print Appointment Letter";
     587            this.chkPrint.UseVisualStyleBackColor = true;
    575588            //
    576589            // DAppointPage
     
    596609            this.groupBox2.PerformLayout();
    597610            this.panel1.ResumeLayout(false);
     611            this.panel1.PerformLayout();
    598612            ((System.ComponentModel.ISupportInitialize)(this.patientApptsBindingSource)).EndInit();
    599613            ((System.ComponentModel.ISupportInitialize)(this.dsPatientApptDisplay2BindingSource)).EndInit();
     
    611625                private string                  m_sPatientHRN;
    612626                private string                  m_sPatientIEN;
    613                 private string                  m_sPatientDOB;
     627                private DateTime                m_dPatientDOB;
    614628                private string                  m_sPatientPID;
    615629
     
    623637                private string                  m_sNote;
    624638                private DateTime                m_dStartTime;
     639        private DateTime        m_dEndTime;
    625640                private int                             m_nDuration;
    626641                private string                  m_sClinic;
     
    629644        private string          m_sEmail;
    630645        private string          m_sCountry;
     646        private int          m_iAccessTypeID;
    631647
    632648                #endregion //fields
     
    636652                public void InitializePage(CGAppointment a)
    637653                {
    638                         InitializePage(a.PatientID.ToString(), a.StartTime, a.Duration, "", a.Note);
     654                        InitializePage(a.PatientID.ToString(), a.StartTime, a.EndTime, "", a.Note, a.AccessTypeID);
    639655                }
    640656
    641                 public void InitializePage(string sPatientIEN, DateTime dStart, int nDuration, string sClinic, string sNote)
     657                public void InitializePage(string sPatientIEN, DateTime dStart, DateTime dEnd, string sClinic, string sNote, int iAccessTypeID)
    642658                {
    643659                        m_dStartTime = dStart;
    644                         m_nDuration = nDuration;
     660            m_dEndTime = dEnd;
     661                        m_nDuration = (int)(dEnd - dStart).TotalMinutes;
     662            m_iAccessTypeID = iAccessTypeID;
    645663                        m_sClinic = sClinic;
    646664                        m_sPatientIEN = sPatientIEN;
     
    659677                                this.m_sPatientIEN = r["IEN"].ToString();
    660678                this.m_sPatientPID = r["PID"].ToString();
    661                                 DateTime dDob =(DateTime) r["DOB"]; //what if it's null?
    662                                 this.m_sPatientDOB = dDob.ToShortDateString();
     679                                this.m_dPatientDOB = (DateTime) r["DOB"];
    663680                                this.m_sStreet = r["STREET"].ToString();
    664681                                this.m_sCity = r["CITY"].ToString();
     
    695712
    696713                                txtCity.Text = this.m_sCity;
    697                                 txtDOB.Text = this.m_sPatientDOB;
     714                                txtDOB.Text = this.m_dPatientDOB.ToShortDateString();
    698715                                txtHRN.Text = this.m_sPatientHRN;
    699716                                txtNote.Text = this.m_sNote;
     
    767784                }
    768785
     786        public bool PrintAppointmentSlip
     787        {
     788            get { return chkPrint.Checked; }
     789        }
     790
     791        public CGAppointment Appointment
     792        {
     793            get
     794            {
     795                Patient pt = new Patient
     796                {
     797                    DFN = Int32.Parse(m_sPatientIEN),
     798                    Name = m_sPatientName,
     799                    DOB = m_dPatientDOB,
     800                    ID = m_sPatientPID,
     801                    HRN = m_sPatientHRN,
     802                    Appointments = null, //for now
     803                    Street = m_sStreet,
     804                    City = m_sCity,
     805                    State = m_sState,
     806                    Zip = m_sZip,
     807                    Country = m_sCountry,
     808                    Email = m_sEmail,
     809                    HomePhone = m_sPhoneHome,
     810                    WorkPHone = m_sPhoneOffice,
     811                    CellPhone = m_sPhoneCell
     812                };
     813
     814                CGAppointment appt = new CGAppointment()
     815                {
     816                    PatientID = Convert.ToInt32(m_sPatientIEN),
     817                    PatientName = m_sPatientName,
     818                    StartTime = m_dStartTime,
     819                    EndTime = m_dEndTime,
     820                    Resource = m_sClinic,
     821                    Note = m_sNote,
     822                    HealthRecordNumber = m_sPatientHRN,
     823                    AccessTypeID = m_iAccessTypeID,
     824                    Patient = pt
     825                };
     826
     827                return appt;
     828            }
     829        }
    769830                #endregion //Properties
    770831
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.resx

    r913 r1106  
    113113  </resheader>
    114114  <resheader name="reader">
    115     <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     115    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    116116  </resheader>
    117117  <resheader name="writer">
    118     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <metadata name="patientApptsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     120  <metadata name="patientApptsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121121    <value>412, 17</value>
    122122  </metadata>
    123   <metadata name="dsPatientApptDisplay2BindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     123  <metadata name="dsPatientApptDisplay2BindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124124    <value>179, 17</value>
    125125  </metadata>
    126   <metadata name="dsPatientApptDisplay2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     126  <metadata name="dsPatientApptDisplay2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    127127    <value>17, 17</value>
    128128  </metadata>
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DApptSearch.cs

    r1097 r1106  
    5353        private ColumnHeader colDOW;
    5454        private ColumnHeader colID;
     55        private Label lblMessage;
    5556     
    5657        private System.ComponentModel.IContainer components;
     
    312313            this.colSlots = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
    313314            this.colAccessType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     315            this.lblMessage = new System.Windows.Forms.Label();
    314316            this.panel1.SuspendLayout();
    315317            this.pnlDescription.SuspendLayout();
     
    323325            // panel1
    324326            //
     327            this.panel1.Controls.Add(this.lblMessage);
    325328            this.panel1.Controls.Add(this.cmdSearch);
    326329            this.panel1.Controls.Add(this.cmdCancel);
     
    334337            // cmdSearch
    335338            //
    336             this.cmdSearch.Location = new System.Drawing.Point(536, 8);
     339            this.cmdSearch.Location = new System.Drawing.Point(33, 6);
    337340            this.cmdSearch.Name = "cmdSearch";
    338341            this.cmdSearch.Size = new System.Drawing.Size(72, 24);
     
    344347            //
    345348            this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    346             this.cmdCancel.Location = new System.Drawing.Point(616, 8);
     349            this.cmdCancel.Location = new System.Drawing.Point(828, 8);
    347350            this.cmdCancel.Name = "cmdCancel";
    348351            this.cmdCancel.Size = new System.Drawing.Size(64, 24);
     
    353356            //
    354357            this.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK;
    355             this.btnAccept.Location = new System.Drawing.Point(128, 8);
     358            this.btnAccept.Location = new System.Drawing.Point(135, 8);
    356359            this.btnAccept.Name = "btnAccept";
    357360            this.btnAccept.Size = new System.Drawing.Size(176, 24);
     
    436439            this.dtEnd.Size = new System.Drawing.Size(200, 20);
    437440            this.dtEnd.TabIndex = 65;
     441            this.dtEnd.ValueChanged += new System.EventHandler(this.dtEnd_ValueChanged);
    438442            //
    439443            // dtStart
     
    443447            this.dtStart.Size = new System.Drawing.Size(200, 20);
    444448            this.dtStart.TabIndex = 64;
     449            this.dtStart.ValueChanged += new System.EventHandler(this.dtStart_ValueChanged);
    445450            //
    446451            // label3
     
    672677            this.colAccessType.Width = 101;
    673678            //
     679            // lblMessage
     680            //
     681            this.lblMessage.AutoSize = true;
     682            this.lblMessage.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     683            this.lblMessage.ForeColor = System.Drawing.Color.Red;
     684            this.lblMessage.Location = new System.Drawing.Point(337, 16);
     685            this.lblMessage.Name = "lblMessage";
     686            this.lblMessage.Size = new System.Drawing.Size(0, 16);
     687            this.lblMessage.TabIndex = 3;
     688            //
    674689            // DApptSearch
    675690            //
     
    685700            this.Text = "Find Clinic Availability";
    686701            this.panel1.ResumeLayout(false);
     702            this.panel1.PerformLayout();
    687703            this.pnlDescription.ResumeLayout(false);
    688704            this.grpDescription.ResumeLayout(false);
     
    703719                        //Tell user we are processing
    704720            this.Cursor = Cursors.WaitCursor;
    705            
     721            this.lblMessage.Text = String.Empty;
     722
    706723            //Get the control data into local vars
    707724                        UpdateDialogData(false);
     
    879896            lstResults.Items.Clear(); //empty it from old data
    880897
    881             //if (items.Length == 0) lstResults.Items.Add(new ListViewItem(new string[] { "", "", "", "" , "", "No Slots found", "", "" })); // no results
    882898            if (items.Length > 0) lstResults.Items.AddRange(items); // add new data
     899            else this.lblMessage.Text = "No available Appointment Slots Found!";
    883900
    884901            lstResults.EndUpdate(); // ok done adding items, draw now.
     
    904921                }
    905922
    906                 private void grdResult_DoubleClick(object sender, System.EventArgs e)
    907                 {
    908                         /*
    909             if (lstResults.DataSource == null)
    910                                 return;
    911 
    912                         DataGridViewCell dgCell;
    913                         dgCell = this.grdResult.CurrentCell;
    914             this.m_sSelectedResource = grdResult.SelectedRows[0].Cells[2].ToString();
    915             this.m_sSelectedDate = (DateTime)grdResult.SelectedRows[0].Cells[0].Value;
    916                         this.DialogResult = DialogResult.OK;
    917                         this.Close();
    918              */
    919                 }
    920 
    921                 private void grdResult_CurrentCellChanged(object sender, System.EventArgs e)
    922                 {
    923                         /*
    924             DataGridViewCell dgCell;
    925             dgCell = this.grdResult.CurrentCell;
    926              */
    927         }
    928 
    929         /// <summary>
    930         /// BAAAAAAAAAAAAAAAAAD. Use a shared method instead.
    931         /// </summary>
    932         /// <param name="sender"></param>
    933         /// <param name="e"></param>
     923
    934924        private void lstResults_DoubleClick(object sender, EventArgs e)
    935925        {
    936             btnAccept_Click(sender, e);
     926            ProcessChoice(sender, e);
    937927        }
    938928
    939929        private void btnAccept_Click(object sender, EventArgs e)
     930        {
     931            ProcessChoice(sender, e);
     932        }
     933
     934        /// <summary>
     935        /// Shared method to process a user's choice
     936        /// </summary>
     937        /// <param name="s">sender</param>
     938        /// <param name="e">EventArgs</param>
     939        private void ProcessChoice(object s, EventArgs e)
    940940        {
    941941            if (lstResults.SelectedIndices.Count == 0)
    942942            {
    943943                this.DialogResult = DialogResult.None;
     944                lblMessage.Text = "No Appointment Slot selected!";
    944945                return;
    945946            }
     
    952953        }
    953954
     955        /// <summary>
     956        /// Adjust start date based on end date.
     957        /// </summary>
     958        /// <param name="sender"></param>
     959        /// <param name="e"></param>
     960        private void dtStart_ValueChanged(object sender, EventArgs e)
     961        {
     962            if (dtEnd.Value < dtStart.Value) dtEnd.Value = dtStart.Value;
     963        }
     964
     965        /// <summary>
     966        /// Adjust end date based on start date.
     967        /// </summary>
     968        /// <param name="sender"></param>
     969        /// <param name="e"></param>
     970        private void dtEnd_ValueChanged(object sender, EventArgs e)
     971        {
     972            if (dtStart.Value > dtEnd.Value) dtStart.Value = dtEnd.Value;
     973        }
     974
    954975        #endregion  Event Handlers
    955976
    956977        #region Properties
    957 
    958978       
    959979        /// <summary>
     
    966986
    967987                #endregion Properties
     988
     989
    968990    }
    969991}
Note: See TracChangeset for help on using the changeset viewer.