Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 821)
@@ -27,5 +27,5 @@
 		public int				m_nTimeUnits;
 		private string			m_sDocName;
-		public ArrayList		m_sResourcesArray;
+		public ArrayList		m_sResourcesArray; //keeps the resources
 		public ScheduleType		m_ScheduleType;
 		private DateTime		m_dSelectedDate; //Holds the user's selection from the dtpicker
@@ -201,11 +201,17 @@
 				DataTable			rAppointmentSchedule;
 
+                //Nice to know that it gets set here!!!
 				m_dLastRefresh = DateTime.Now;
 
 				this.m_appointments.ClearAllAppointments();
 
+                //  calls RPC to (presumably--not sure yet) get appointments
 				rAppointmentSchedule = CGSchedLib.CreateAppointmentSchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate);
-				CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule");
-				foreach (DataRow r in rAppointmentSchedule.Rows) 
+				
+                // Datatable dumper into Debug Log (nice to know that this exists)
+                CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule");
+				
+                
+                foreach (DataRow r in rAppointmentSchedule.Rows) 
 				{
 				
@@ -279,4 +285,6 @@
 			//			DateTime dDate = new DateTime(2001,12,05);  //Testing line
 			DateTime dDate = DateTime.Today;
+            
+            //smh: Question: Where does bRet get used? It's a useless varaible so far.
 			bool bRet = this.WeekNeedsRefresh(2,dDate, out this.m_dStartDate, out this.m_dEndDate);
 
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 821)
@@ -236,5 +236,5 @@
                 m_ds.Refresh();
 				this.Activate();
-                System.Configuration.ConfigurationManager.GetSection("appSettings");
+                // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
                 m_ds.SetStatus("Connecting to VistA Server...");
                 m_ds.Refresh();
@@ -262,6 +262,8 @@
 				do
 				{
+                    // login crap
                     try
                     {
+                        // Not my code
                         if (bReLogin == true)
                         {
@@ -269,4 +271,5 @@
                             _current.m_ConnectInfo.LoadConnectInfo("", "");
                         }
+                        // My code -- buts looks so ugly!
                         else
                         {
@@ -337,4 +340,5 @@
 				}
 				
+                //smh -- why get handles?
 				System.IntPtr pHandle = this.Handle;
 				System.IntPtr pConnHandle = this.ConnectInfo.Handle;
@@ -376,4 +380,5 @@
 #if DEBUG
             // Print console messages to console if launched from console
+            // Note: Imported From kernel32.dll
             AttachConsole(ATTACH_PARENT_PROCESS);
 #endif
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 821)
@@ -140,5 +140,7 @@
 			this.Document = doc;
 			this.Appointments = cgAppts;
-			this.Text = this.DocManager.ConnectInfo.UserName;
+			
+            // Set username and division up top
+            this.Text = this.DocManager.ConnectInfo.UserName;
 			if (sText != null)
 				this.Text += " - " + sText;
@@ -269,4 +271,5 @@
             this.lblResource = new System.Windows.Forms.Label();
             this.panelCenter = new System.Windows.Forms.Panel();
+            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
             this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
             this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
@@ -280,4 +283,5 @@
             this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
             this.menuItem10 = new System.Windows.Forms.MenuItem();
+            this.ctxCalGridReprintRoutingSlip = new System.Windows.Forms.MenuItem();
             this.panelBottom = new System.Windows.Forms.Panel();
             this.statusBar1 = new System.Windows.Forms.StatusBar();
@@ -285,6 +289,4 @@
             this.splitter2 = new System.Windows.Forms.Splitter();
             this.printRoutingSlip = new System.Drawing.Printing.PrintDocument();
-            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
-            this.ctxCalGridReprintRoutingSlip = new System.Windows.Forms.MenuItem();
             this.panelRight.SuspendLayout();
             this.panelClip.SuspendLayout();
@@ -795,117 +797,4 @@
             this.panelCenter.Size = new System.Drawing.Size(668, 321);
             this.panelCenter.TabIndex = 7;
-            // 
-            // ctxCalendarGrid
-            // 
-            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.ctxCalGridAdd,
-            this.ctxCalGridEdit,
-            this.ctxCalGridDelete,
-            this.ctxCalGridCheckIn,
-            this.menuItem2,
-            this.ctxCalGridNoShow,
-            this.ctxCalGridNoShowUndo,
-            this.menuItem9,
-            this.ctxCalGridWalkin,
-            this.menuItem10,
-            this.ctxCalGridReprintRoutingSlip});
-            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
-            // 
-            // ctxCalGridAdd
-            // 
-            this.ctxCalGridAdd.Index = 0;
-            this.ctxCalGridAdd.Text = "Add Appointment";
-            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
-            // 
-            // ctxCalGridEdit
-            // 
-            this.ctxCalGridEdit.Index = 1;
-            this.ctxCalGridEdit.Text = "Edit Appointment";
-            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
-            // 
-            // ctxCalGridDelete
-            // 
-            this.ctxCalGridDelete.Index = 2;
-            this.ctxCalGridDelete.Text = "Cancel Appointment";
-            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
-            // 
-            // ctxCalGridCheckIn
-            // 
-            this.ctxCalGridCheckIn.Index = 3;
-            this.ctxCalGridCheckIn.Text = "Check In Patient";
-            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
-            // 
-            // menuItem2
-            // 
-            this.menuItem2.Index = 4;
-            this.menuItem2.Text = "-";
-            // 
-            // ctxCalGridNoShow
-            // 
-            this.ctxCalGridNoShow.Index = 5;
-            this.ctxCalGridNoShow.Text = "Mark as No Show";
-            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
-            // 
-            // ctxCalGridNoShowUndo
-            // 
-            this.ctxCalGridNoShowUndo.Index = 6;
-            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
-            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
-            // 
-            // menuItem9
-            // 
-            this.menuItem9.Index = 7;
-            this.menuItem9.Text = "-";
-            // 
-            // ctxCalGridWalkin
-            // 
-            this.ctxCalGridWalkin.Index = 8;
-            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
-            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
-            // 
-            // menuItem10
-            // 
-            this.menuItem10.Index = 9;
-            this.menuItem10.Text = "-";
-            // 
-            // panelBottom
-            // 
-            this.panelBottom.Controls.Add(this.statusBar1);
-            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelBottom.Location = new System.Drawing.Point(136, 345);
-            this.panelBottom.Name = "panelBottom";
-            this.panelBottom.Size = new System.Drawing.Size(668, 24);
-            this.panelBottom.TabIndex = 8;
-            // 
-            // statusBar1
-            // 
-            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.statusBar1.Location = new System.Drawing.Point(0, 0);
-            this.statusBar1.Name = "statusBar1";
-            this.statusBar1.Size = new System.Drawing.Size(668, 24);
-            this.statusBar1.SizingGrip = false;
-            this.statusBar1.TabIndex = 0;
-            // 
-            // splitter1
-            // 
-            this.splitter1.Location = new System.Drawing.Point(128, 24);
-            this.splitter1.Name = "splitter1";
-            this.splitter1.Size = new System.Drawing.Size(8, 345);
-            this.splitter1.TabIndex = 9;
-            this.splitter1.TabStop = false;
-            // 
-            // splitter2
-            // 
-            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
-            this.splitter2.Location = new System.Drawing.Point(804, 24);
-            this.splitter2.Name = "splitter2";
-            this.splitter2.Size = new System.Drawing.Size(3, 345);
-            this.splitter2.TabIndex = 10;
-            this.splitter2.TabStop = false;
-            // 
-            // printRoutingSlip
-            // 
-            this.printRoutingSlip.DocumentName = "Routing Slip";
-            this.printRoutingSlip.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printRoutingSlip_PrintPage);
             // 
             // calendarGrid1
@@ -937,4 +826,77 @@
             this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
             // 
+            // ctxCalendarGrid
+            // 
+            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.ctxCalGridAdd,
+            this.ctxCalGridEdit,
+            this.ctxCalGridDelete,
+            this.ctxCalGridCheckIn,
+            this.menuItem2,
+            this.ctxCalGridNoShow,
+            this.ctxCalGridNoShowUndo,
+            this.menuItem9,
+            this.ctxCalGridWalkin,
+            this.menuItem10,
+            this.ctxCalGridReprintRoutingSlip});
+            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
+            // 
+            // ctxCalGridAdd
+            // 
+            this.ctxCalGridAdd.Index = 0;
+            this.ctxCalGridAdd.Text = "Add Appointment";
+            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
+            // 
+            // ctxCalGridEdit
+            // 
+            this.ctxCalGridEdit.Index = 1;
+            this.ctxCalGridEdit.Text = "Edit Appointment";
+            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
+            // 
+            // ctxCalGridDelete
+            // 
+            this.ctxCalGridDelete.Index = 2;
+            this.ctxCalGridDelete.Text = "Cancel Appointment";
+            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
+            // 
+            // ctxCalGridCheckIn
+            // 
+            this.ctxCalGridCheckIn.Index = 3;
+            this.ctxCalGridCheckIn.Text = "Check In Patient";
+            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
+            // 
+            // menuItem2
+            // 
+            this.menuItem2.Index = 4;
+            this.menuItem2.Text = "-";
+            // 
+            // ctxCalGridNoShow
+            // 
+            this.ctxCalGridNoShow.Index = 5;
+            this.ctxCalGridNoShow.Text = "Mark as No Show";
+            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
+            // 
+            // ctxCalGridNoShowUndo
+            // 
+            this.ctxCalGridNoShowUndo.Index = 6;
+            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
+            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
+            // 
+            // menuItem9
+            // 
+            this.menuItem9.Index = 7;
+            this.menuItem9.Text = "-";
+            // 
+            // ctxCalGridWalkin
+            // 
+            this.ctxCalGridWalkin.Index = 8;
+            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
+            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
+            // 
+            // menuItem10
+            // 
+            this.menuItem10.Index = 9;
+            this.menuItem10.Text = "-";
+            // 
             // ctxCalGridReprintRoutingSlip
             // 
@@ -942,4 +904,44 @@
             this.ctxCalGridReprintRoutingSlip.Text = "&Reprint Routing Slip";
             this.ctxCalGridReprintRoutingSlip.Click += new System.EventHandler(this.ctxCalGridReprintRoutingSlip_Click);
+            // 
+            // panelBottom
+            // 
+            this.panelBottom.Controls.Add(this.statusBar1);
+            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.panelBottom.Location = new System.Drawing.Point(136, 345);
+            this.panelBottom.Name = "panelBottom";
+            this.panelBottom.Size = new System.Drawing.Size(668, 24);
+            this.panelBottom.TabIndex = 8;
+            // 
+            // statusBar1
+            // 
+            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.statusBar1.Location = new System.Drawing.Point(0, 0);
+            this.statusBar1.Name = "statusBar1";
+            this.statusBar1.Size = new System.Drawing.Size(668, 24);
+            this.statusBar1.SizingGrip = false;
+            this.statusBar1.TabIndex = 0;
+            // 
+            // splitter1
+            // 
+            this.splitter1.Location = new System.Drawing.Point(128, 24);
+            this.splitter1.Name = "splitter1";
+            this.splitter1.Size = new System.Drawing.Size(8, 345);
+            this.splitter1.TabIndex = 9;
+            this.splitter1.TabStop = false;
+            // 
+            // splitter2
+            // 
+            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
+            this.splitter2.Location = new System.Drawing.Point(804, 24);
+            this.splitter2.Name = "splitter2";
+            this.splitter2.Size = new System.Drawing.Size(3, 345);
+            this.splitter2.TabIndex = 10;
+            this.splitter2.TabStop = false;
+            // 
+            // printRoutingSlip
+            // 
+            this.printRoutingSlip.DocumentName = "Routing Slip";
+            this.printRoutingSlip.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printRoutingSlip_PrintPage);
             // 
             // CGView
@@ -2291,9 +2293,12 @@
 		{
 			Debug.Assert(this.InvokeRequired == false,"CGView.UpdateArrays InvokeRequired");
+            // This is where you set how the grid will look
 			try 
 			{
 				this.calendarGrid1.AvailabilityArray = this.m_Document.AvailabilityArray;
 				this.calendarGrid1.Resources = this.m_Document.Resources;
-				this.calendarGrid1.OnUpdateArrays();
+                // this.calendarGrid1.Columns = 7; //test
+                this.calendarGrid1.StartDate = DateTime.Parse("10-10-2007"); // another test
+				this.calendarGrid1.OnUpdateArrays(); // this draws the Calendar
 				this.lblResource.Text = this.m_Document.DocName;
 				this.calendarGrid1.Invalidate();
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs	(revision 821)
@@ -10,10 +10,9 @@
     using System.Windows.Forms;
     /// <summary>
-    /// This class was regenerated from Calendargrid.dll using Reflector.exe
-    /// by Sam Habiel for WorldVista. The original source code is lost.
+    /// This class is reponsible for rendering the Calendar Grid.
     /// </summary>
     public class CalendarGrid : Panel
     {
-        private Container components;
+        private IContainer components;
         private Font fontArial10;
         private Font fontArial8;
@@ -49,8 +48,8 @@
         private StringFormat m_sfRight;
         private ArrayList m_sResourcesArray;
-        private Timer m_Timer;
+        private Timer m_Timer;                  // Timeer used in Drag and Drop Operations
         private ToolTip m_toolTip;
-        private const int WM_HSCROLL = 0x114;
-        private const int WM_VSCROLL = 0x115;
+        private const int WM_HSCROLL = 0x114;   // Horizontal Scrolling Windows Message
+        private const int WM_VSCROLL = 0x115;   // Vertical Scrolling Windows Message
 
         public event CGAppointmentChangedHandler CGAppointmentAdded;
@@ -70,5 +69,5 @@
             this.m_selectedRange = new CGRange();
             this.m_SelectedAppointments = new CGAppointments();
-            this.m_dtStart = new DateTime(0x7d3, 1, 0x1b);
+            this.m_dtStart = new DateTime(2003, 1, 27);
             this.m_ApptOverlapTable = new Hashtable();
             this.m_ColumnInfoTable = new Hashtable();
@@ -123,5 +122,5 @@
                 int nColumns = this.m_nColumns;
                 int num2 = 60 / this.m_nTimeScale;
-                int num3 = 0x18 * num2;
+                int num3 = 24 * num2;
                 nColumns++;
                 num3++;
@@ -287,4 +286,27 @@
                 }
                 this.m_toolTip.RemoveAll();
+
+                ////smh new code -- select cell
+                //int nRow = -1;
+                //int nCol = -1;
+
+                ////Is the mouse over a known cell? If so, highlight cell
+                //if (this.HitTest(x, y, ref nRow, ref nCol))
+                //{
+                //    CGCell cellFromRowCol = this.m_gridCells.GetCellFromRowCol(nRow, nCol);
+                //    if (cellFromRowCol != null)
+                //    {
+                //        this.m_currentCell = cellFromRowCol;
+                //        this.m_selectedRange.StartCell = null;
+                //        this.m_selectedRange.EndCell = null;
+                //        this.m_selectedRange.CreateRange(this.m_gridCells, cellFromRowCol, cellFromRowCol);
+                //        this.m_bSelectingRange = true;
+                //        cellFromRowCol.IsSelected = true;
+                //        base.Invalidate(this.m_currentCell.CellRectangle);
+                //        //base.Invalidate();
+                //    }
+                //}
+
+
             }
         }
@@ -418,154 +440,205 @@
         private void DrawGrid(Graphics g)
         {
-            try
-            {
-                Pen pen = new Pen(Color.Black);
-                SizeF ef = g.MeasureString("Test", this.m_fCell);
-                int num = 10;
-                this.m_cellHeight = ((int) ef.Height) + num;
-                int nColumns = this.m_nColumns;
-                int num3 = 60 / this.m_nTimeScale;
-                int num4 = 0x18 * num3;
-                nColumns++;
-                num4++;
-                this.m_cellWidth = 600 / nColumns;
-                if (base.ClientRectangle.Width > 600)
-                {
-                    this.m_cellWidth = (base.ClientRectangle.Width - this.m_col0Width) / (nColumns - 1);
-                }
-                if (this.m_nColumns == 1)
-                {
-                    this.m_cellWidth = base.ClientRectangle.Width - this.m_col0Width;
-                }
-                base.AutoScrollMinSize = new Size(600, this.m_cellHeight * num4);
-                g.FillRectangle(Brushes.LightGray, base.ClientRectangle);
-                int num5 = 0;
-                int num6 = 0;
-                bool flag = this.m_gridCells.CellCount == 0;
-                g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
-                for (int i = 1; i < num4; i++)
-                {
-                    int x = 0;
-                    Point point = new Point(x, i * this.m_cellHeight);
-                    Rectangle rectangle2 = new Rectangle(point.X, point.Y, this.m_cellWidth, this.m_cellHeight);
-                    Rectangle rect = new Rectangle(0, rectangle2.Y, this.m_col0Width, rectangle2.Height * num3);
-                    int height = rect.Height;
-                    height = (height > (this.m_col0Width / 4)) ? (this.m_col0Width / 4) : height;
-                    if (num5 == 0)
-                    {
-                        g.FillRectangle(Brushes.LightGray, rect);
-                        g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
-                        string str = string.Format("{0}", num6).PadLeft(2, '0');
-                        Font font = new Font("Arial", (float) height, FontStyle.Bold, GraphicsUnit.Pixel);
-                        Rectangle rectangle3 = new Rectangle(rect.X, rect.Y, rect.Width / 2, rect.Height);
-                        g.DrawString(str, font, Brushes.Black, rectangle3, this.m_sfHour);
-                        num6++;
-                        font.Dispose();
-                    }
-                    string s = string.Format("{0}", num5);
-                    s = ":" + s.PadLeft(2, '0');
-                    Rectangle layoutRectangle = new Rectangle(rect.X + ((rect.Width * 2) / 3), rectangle2.Top, rect.Width / 3, rectangle2.Height);
-                    g.DrawString(s, this.m_fCell, Brushes.Black, layoutRectangle, this.m_sfRight);
-                    Point point2 = new Point(rect.X + ((rect.Width * 2) / 3), rectangle2.Bottom);
-                    Point point3 = new Point(rect.Right, rectangle2.Bottom);
-                    g.DrawLine(pen, point2, point3);
-                    num5 += this.m_nTimeScale;
-                    num5 = (num5 >= 60) ? 0 : num5;
-                    if ((i == (num4 - 1)) && !this.m_bScroll)
-                    {
-                        g.TranslateTransform((float) -base.AutoScrollPosition.X, (float) -base.AutoScrollPosition.Y);
-                        rect = new Rectangle(0, 0, this.m_col0Width, this.m_cellHeight);
-                        g.FillRectangle(Brushes.LightGray, rect);
-                        g.DrawRectangle(pen, rect);
-                        g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
-                    }
-                }
-                for (int j = num4; j > -1; j--)
-                {
-                    for (int k = 1; k < nColumns; k++)
-                    {
-                        int num12 = 0;
-                        if (k == 1)
-                        {
-                            num12 = this.m_col0Width;
-                        }
-                        if (k > 1)
-                        {
-                            num12 = this.m_col0Width + (this.m_cellWidth * (k - 1));
-                        }
-                        Point point4 = new Point(num12, j * this.m_cellHeight);
-                        Rectangle r = new Rectangle(point4.X, point4.Y, this.m_cellWidth, this.m_cellHeight);
-                        if (j != 0)
-                        {
-                            CGCell cellFromRowCol = null;
-                            if (flag)
+            //Default color of grid lines is black
+            Pen pen = new Pen(Color.Black);
+
+            //each cell's height is Height of Arial Font 10pt + 10 pixels (by default 26 pixels)
+            SizeF ef = g.MeasureString("Test", this.m_fCell);
+            int num = 10;
+            this.m_cellHeight = ((int) ef.Height) + num;
+
+            // Number of columns is dynamic based on user of Grid. See Property Columns. Default 5 in init.
+            int nColumns = this.m_nColumns;
+
+            //Time scale is also dynamic. Property TimeScale. Default 20 (minutes)
+            //num3 stands for number of cells per hour
+            int num3 = 60 / this.m_nTimeScale;
+            //num4 stands for number of cells per day (aka rows in the grid)
+            int num4 = 24 * num3;
+            //Add extra column to hold time in the left hand corner
+            nColumns++;
+            //add extra row to represent dates or resources (depending on which view we are in)
+            //Not sure of which variable controls view yet.
+            num4++;
+
+            // 100 px is reserved no matter our column sizes for displaying the time scale
+
+            // Minimum cell width is 600/columns (100 px by default)
+            this.m_cellWidth = 600 / nColumns;
+
+            // if we happen to have more than 600 pixels in our Client Window then cell
+            // is (Width-100) / (number of date columns)
+            if (base.ClientRectangle.Width > 600)
+            {
+                this.m_cellWidth = (base.ClientRectangle.Width - this.m_col0Width) / (nColumns - 1);
+            }
+
+            // If we have one column, the cell width is the itself - 100
+            if (this.m_nColumns == 1)
+            {
+                this.m_cellWidth = base.ClientRectangle.Width - this.m_col0Width;
+            }
+
+            // Our rectangle will start scrolling if width is less than 600 and height less than  height of all cells comb
+            // Of course Height will scroll all the time unless you have a humungous screen
+            base.AutoScrollMinSize = new Size(600, this.m_cellHeight * num4);
+
+            // Default Rectangle is Gray
+            g.FillRectangle(Brushes.LightGray, base.ClientRectangle);
+            
+            int num5 = 0; //Minutes (start at 0)
+            int num6 = 0; //Hour (starts at 0)
+            
+            // flag is true only if there are no cells what so ever in the screen
+            // Only true when no resource is selected.
+            bool flag = this.m_gridCells.CellCount == 0;
+
+            // Move the base point from the client screen to the scrolling region top-left corner.
+            g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
+
+            // For each row except the first one (i starts from 1 rather than zero)
+            for (int i = 1; i < num4; i++)
+            {
+                int x = 0;
+                //point is (0, 1st Cell Start) then (0, 2nd Cell Start) until we run out
+                Point point = new Point(x, i * this.m_cellHeight);
+                //rectangle2 represents each cell rectangle
+                Rectangle rectangle2 = new Rectangle(point.X, point.Y, this.m_cellWidth, this.m_cellHeight);
+                //rect stands for the time scale rectangle; width is 100px; Height is length of the hour on grid
+                Rectangle rect = new Rectangle(0, rectangle2.Y, this.m_col0Width, rectangle2.Height * num3);
+                //height is length of hour
+                int height = rect.Height;
+                //Min font height is 25 pixels (100/4)--see below where it's used
+                height = (height > (this.m_col0Width / 4)) ? (this.m_col0Width / 4) : height;
+
+                //if we are the top of the time scale (at hour:00) -- num5 is min
+                if (num5 == 0)
+                {
+                    // Fill time scale triangle with Gray (remember, this is the whole hour!)
+                    g.FillRectangle(Brushes.LightGray, rect);
+                    // Draw Rectangle
+                    g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
+                    //Pad time with at least one zero to make it 2 digits
+                    string str = string.Format("{0}", num6).PadLeft(2, '0');
+                    //Font height using pixels. Min is 25 pixels
+                    Font font = new Font("Arial", (float) height, FontStyle.Bold, GraphicsUnit.Pixel);
+                    // rectangle3 is the left half of the time rectangle
+                    Rectangle rectangle3 = new Rectangle(rect.X, rect.Y, rect.Width / 2, rect.Height);
+                    // In this left half, draw the hours (m_sfHour is the stringformat:
+                    // Horizontal Center and Right Justified to rectangle3
+                    g.DrawString(str, font, Brushes.Black, rectangle3, this.m_sfHour);
+                    // Increment hour
+                    num6++;
+                    font.Dispose();
+                }
+                
+                // Pad minutes with zeros to be 2 digits long
+                string s = string.Format("{0}", num5);
+                s = ":" + s.PadLeft(2, '0');
+                // Rectangle starts at 
+                // X: 2/3rds of width of Time Rectangle
+                // Y: Top of the current time slot cell
+                // Width: 1/3rd of the width of the Time Rectangle
+                // Height: Height of a time slot
+                Rectangle layoutRectangle = new Rectangle(rect.X + ((rect.Width * 2) / 3), rectangle2.Top, rect.Width / 3, rectangle2.Height);
+                // At in this rectangle, write the minutes. Horizontal Ctr and Right Justified to Rectangle
+                g.DrawString(s, this.m_fCell, Brushes.Black, layoutRectangle, this.m_sfRight);
+                Point point2 = new Point(rect.X + ((rect.Width * 2) / 3), rectangle2.Bottom);
+                Point point3 = new Point(rect.Right, rectangle2.Bottom);
+                g.DrawLine(pen, point2, point3);
+                num5 += this.m_nTimeScale;
+                num5 = (num5 >= 60) ? 0 : num5;
+                if ((i == (num4 - 1)) && !this.m_bScroll)
+                {
+                    g.TranslateTransform((float) -base.AutoScrollPosition.X, (float) -base.AutoScrollPosition.Y);
+                    rect = new Rectangle(0, 0, this.m_col0Width, this.m_cellHeight);
+                    g.FillRectangle(Brushes.LightGray, rect);
+                    g.DrawRectangle(pen, rect);
+                    g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
+                }
+            }
+            for (int j = num4; j > -1; j--)
+            {
+                for (int k = 1; k < nColumns; k++)
+                {
+                    int num12 = 0;
+                    if (k == 1)
+                    {
+                        num12 = this.m_col0Width;
+                    }
+                    if (k > 1)
+                    {
+                        num12 = this.m_col0Width + (this.m_cellWidth * (k - 1));
+                    }
+                    Point point4 = new Point(num12, j * this.m_cellHeight);
+                    Rectangle r = new Rectangle(point4.X, point4.Y, this.m_cellWidth, this.m_cellHeight);
+                    if (j != 0)
+                    {
+                        CGCell cellFromRowCol = null;
+                        if (flag)
+                        {
+                            cellFromRowCol = new CGCell(r, j, k);
+                            this.m_gridCells.AddCell(cellFromRowCol);
+                        }
+                        else
+                        {
+                            cellFromRowCol = this.m_gridCells.GetCellFromRowCol(j, k);
+                            cellFromRowCol.CellRectangle = r;
+                        }
+                        if (this.m_sResourcesArray.Count > 0)
+                        {
+                            if (this.m_selectedRange.CellIsInRange(cellFromRowCol))
                             {
-                                cellFromRowCol = new CGCell(r, j, k);
-                                this.m_gridCells.AddCell(cellFromRowCol);
+                                g.FillRectangle(Brushes.Aquamarine, r);
                             }
                             else
                             {
-                                cellFromRowCol = this.m_gridCells.GetCellFromRowCol(j, k);
-                                cellFromRowCol.CellRectangle = r;
+                                g.FillRectangle(cellFromRowCol.AppointmentTypeColor, r);
                             }
-                            if (this.m_sResourcesArray.Count > 0)
+                            g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height);
+                            if (j == 1)
                             {
-                                if (this.m_selectedRange.CellIsInRange(cellFromRowCol))
+                                this.DrawAppointments(g, this.m_col0Width, this.m_cellWidth, this.m_cellHeight);
+                            }
+                        }
+                        continue;
+                    }
+                    if (!this.m_bScroll)
+                    {
+                        g.TranslateTransform(0f, (float) -base.AutoScrollPosition.Y);
+                        Rectangle rectangle6 = r;
+                        g.FillRectangle(Brushes.LightBlue, rectangle6);
+                        g.DrawRectangle(pen, rectangle6.X, rectangle6.Y, rectangle6.Width, rectangle6.Height);
+                        string str3 = "";
+                        if (this.m_sResourcesArray.Count > 1)
+                        {
+                            foreach (DictionaryEntry entry in this.m_ColumnInfoTable)
+                            {
+                                int num13 = (int) entry.Value;
+                                num13++;
+                                if (num13 == k)
                                 {
-                                    g.FillRectangle(Brushes.Aquamarine, r);
-                                }
-                                else
-                                {
-                                    g.FillRectangle(cellFromRowCol.AppointmentTypeColor, r);
-                                }
-                                g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height);
-                                if (j == 1)
-                                {
-                                    this.DrawAppointments(g, this.m_col0Width, this.m_cellWidth, this.m_cellHeight);
+                                    str3 = entry.Key.ToString();
+                                    break;
                                 }
                             }
-                            continue;
-                        }
-                        if (!this.m_bScroll)
-                        {
-                            g.TranslateTransform(0f, (float) -base.AutoScrollPosition.Y);
-                            Rectangle rectangle6 = r;
-                            g.FillRectangle(Brushes.LightBlue, rectangle6);
-                            g.DrawRectangle(pen, rectangle6.X, rectangle6.Y, rectangle6.Width, rectangle6.Height);
-                            string str3 = "";
-                            if (this.m_sResourcesArray.Count > 1)
+                        }
+                        else
+                        {
+                            DateTime dtStart = this.m_dtStart;
+                            if (k > 1)
                             {
-                                foreach (DictionaryEntry entry in this.m_ColumnInfoTable)
-                                {
-                                    int num13 = (int) entry.Value;
-                                    num13++;
-                                    if (num13 == k)
-                                    {
-                                        str3 = entry.Key.ToString();
-                                        break;
-                                    }
-                                }
+                                dtStart = dtStart.AddDays((double) (k - 1));
                             }
-                            else
-                            {
-                                DateTime dtStart = this.m_dtStart;
-                                if (k > 1)
-                                {
-                                    dtStart = dtStart.AddDays((double) (k - 1));
-                                }
-                                string format = "ddd, MMM d";
-                                str3 = dtStart.ToString(format, DateTimeFormatInfo.InvariantInfo);
-                            }
-                            g.DrawString(str3, this.m_fCell, Brushes.Black, rectangle6, this.m_sf);
-                            g.TranslateTransform(0f, (float) base.AutoScrollPosition.Y);
-                        }
-                    }
-                }
-                this.m_bScroll = false;
-                pen.Dispose();
-            }
-            catch (Exception)
-            {
-            }
+                            string format = "ddd, MMM d";
+                            str3 = dtStart.ToString(format, DateTimeFormatInfo.InvariantInfo);
+                        }
+                        g.DrawString(str3, this.m_fCell, Brushes.Black, rectangle6, this.m_sf);
+                        g.TranslateTransform(0f, (float) base.AutoScrollPosition.Y);
+                    }
+                }
+            }
+            this.m_bScroll = false;
+            pen.Dispose();
         }
 
@@ -776,19 +849,26 @@
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            this.m_toolTip = new System.Windows.Forms.ToolTip(this.components);
+            this.SuspendLayout();
+            // 
+            // CalendarGrid
+            // 
             this.AutoScroll = true;
-            base.AutoScrollMinSize = new Size(600, 400);
-            this.BackColor = SystemColors.Window;
-            base.Paint += new PaintEventHandler(this.CalendarGrid_Paint);
-            base.MouseDown += new MouseEventHandler(this.CalendarGrid_MouseDown);
-            base.MouseUp += new MouseEventHandler(this.CalendarGrid_MouseUp);
-            base.MouseMove += new MouseEventHandler(this.CalendarGrid_MouseMove);
-            base.DragEnter += new DragEventHandler(this.CalendarGrid_DragEnter);
-            base.DragDrop += new DragEventHandler(this.CalendarGrid_DragDrop);
-            this.m_toolTip = new ToolTip();
+            this.AutoScrollMinSize = new System.Drawing.Size(600, 400);
+            this.BackColor = System.Drawing.SystemColors.Window;
+            this.Paint += new System.Windows.Forms.PaintEventHandler(this.CalendarGrid_Paint);
+            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseMove);
+            this.DragDrop += new System.Windows.Forms.DragEventHandler(this.CalendarGrid_DragDrop);
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseDown);
+            this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseUp);
+            this.DragEnter += new System.Windows.Forms.DragEventHandler(this.CalendarGrid_DragEnter);
+            this.ResumeLayout(false);
+
         }
 
         private int MinSince80(DateTime d)
         {
-            DateTime time = new DateTime(0x7bc, 1, 1, 0, 0, 0);
+            DateTime time = new DateTime(1980, 1, 1, 0, 0, 0);
             TimeSpan span = (TimeSpan) (d - time);
             return (int) span.TotalMinutes;
@@ -995,4 +1075,5 @@
                 this.m_ApptOverlapTable.Add(num4, 0);
             }
+            // Here it draws the Dates on Top
             if (this.m_ApptOverlapTable.Count != 0)
             {
@@ -1062,9 +1143,17 @@
         }
 
+        /// <summary>
+        /// The purpose of this is to properly draw the date boxes at the top of the calendar grid.
+        /// Otherwise, when scrolling, it gets garbled.
+        /// </summary>
+        /// <param name="msg">Handles two messages:
+        /// WM_VSCROLL (0x115 - Vertical Scrolling)
+        /// WM_HSCROLL (0x114 - Horizontal Scrolling)
+        /// </param>
         protected override void WndProc(ref Message msg)
         {
             try
             {
-                if (msg.Msg == 0x115)
+                if (msg.Msg == WM_VSCROLL)
                 {
                     this.m_bScroll = true;
@@ -1072,5 +1161,5 @@
                     this.m_bScroll = false;
                 }
-                if (msg.Msg == 0x114)
+                if (msg.Msg == WM_HSCROLL)
                 {
                     base.Invalidate(false);
@@ -1273,4 +1362,5 @@
             }
         }
+
     }
 }
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs	(revision 821)
@@ -238,4 +238,11 @@
                 if (nRow.Length > 0) nFind = m_dtProvider.Rows.IndexOf(nRow[0]);
                 cboProvider.SelectedIndex = nFind;
+
+                //an experiment: LINQ
+                var defProv = from Provider in m_dtProvider.AsEnumerable() 
+                              where 
+                                Provider["DEFAULT"] == "YES" 
+                              select Provider;
+
             }
             //otherwise, just use the default provider table
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/bin/Release/ClinicalScheduling.XML
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/bin/Release/ClinicalScheduling.XML	(revision 805)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/bin/Release/ClinicalScheduling.XML	(revision 821)
@@ -46,7 +46,16 @@
         <member name="T:IndianHealthService.ClinicalScheduling.CalendarGrid">
             <summary>
-            This class was regenerated from Calendargrid.dll using Reflector.exe
-            by Sam Habiel for WorldVista. The original source code is lost.
-            </summary>
+            This class is reponsible for rendering the Calendar Grid.
+            </summary>
+        </member>
+        <member name="M:IndianHealthService.ClinicalScheduling.CalendarGrid.WndProc(System.Windows.Forms.Message@)">
+            <summary>
+            The purpose of this is to properly draw the date boxes at the top of the calendar grid.
+            Otherwise, when scrolling, it gets garbled.
+            </summary>
+            <param name="msg">Handles two messages:
+            WM_VSCROLL (0x115 - Vertical Scrolling)
+            WM_HSCROLL (0x114 - Horizontal Scrolling)
+            </param>
         </member>
         <member name="T:IndianHealthService.ClinicalScheduling.DPatientLookup">
