Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1038)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1039)
@@ -59,5 +59,4 @@
             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();
@@ -93,4 +92,5 @@
             this.splitter1 = new System.Windows.Forms.Splitter();
             this.saveAccessBlocksWorker = new System.ComponentModel.BackgroundWorker();
+            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
             this.panelRight.SuspendLayout();
             this.panelClip.SuspendLayout();
@@ -106,5 +106,5 @@
             this.panelRight.Location = new System.Drawing.Point(728, 0);
             this.panelRight.Name = "panelRight";
-            this.panelRight.Size = new System.Drawing.Size(120, 393);
+            this.panelRight.Size = new System.Drawing.Size(120, 364);
             this.panelRight.TabIndex = 1;
             // 
@@ -167,5 +167,5 @@
             this.panelBottom.Controls.Add(this.statusBar1);
             this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelBottom.Location = new System.Drawing.Point(8, 369);
+            this.panelBottom.Location = new System.Drawing.Point(8, 340);
             this.panelBottom.Name = "panelBottom";
             this.panelBottom.Size = new System.Drawing.Size(720, 24);
@@ -219,6 +219,251 @@
             this.panelCenter.Location = new System.Drawing.Point(8, 24);
             this.panelCenter.Name = "panelCenter";
-            this.panelCenter.Size = new System.Drawing.Size(712, 345);
+            this.panelCenter.Size = new System.Drawing.Size(712, 316);
             this.panelCenter.TabIndex = 4;
+            // 
+            // ctxCalendarGrid
+            // 
+            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.ctxCalGridAdd,
+            this.ctxCalGridEdit,
+            this.ctxCalGridDelete});
+            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
+            // 
+            // ctxCalGridAdd
+            // 
+            this.ctxCalGridAdd.Index = 0;
+            this.ctxCalGridAdd.Text = "Add New Access Block";
+            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
+            // 
+            // ctxCalGridEdit
+            // 
+            this.ctxCalGridEdit.Index = 1;
+            this.ctxCalGridEdit.Text = "Edit Access Block";
+            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
+            // 
+            // ctxCalGridDelete
+            // 
+            this.ctxCalGridDelete.Index = 2;
+            this.ctxCalGridDelete.Text = "Delete Access Block";
+            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
+            // 
+            // tvSchedules
+            // 
+            this.tvSchedules.BackColor = System.Drawing.SystemColors.ControlLight;
+            this.tvSchedules.Dock = System.Windows.Forms.DockStyle.Left;
+            this.tvSchedules.HotTracking = true;
+            this.tvSchedules.Location = new System.Drawing.Point(0, 0);
+            this.tvSchedules.Name = "tvSchedules";
+            this.tvSchedules.Size = new System.Drawing.Size(8, 364);
+            this.tvSchedules.Sorted = true;
+            this.tvSchedules.TabIndex = 5;
+            // 
+            // mainMenu1
+            // 
+            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.menuItem1,
+            this.mnuAvailability,
+            this.mnuCalendar,
+            this.mnuHelp});
+            // 
+            // menuItem1
+            // 
+            this.menuItem1.Index = 0;
+            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.mnuLoadTemplate,
+            this.mnuSaveTemplate,
+            this.mnuDeleteAllSlots,
+            this.menuItem6,
+            this.mnuSchedulingManagment,
+            this.menuItem5,
+            this.mnuClose});
+            this.menuItem1.Text = "&File";
+            // 
+            // mnuLoadTemplate
+            // 
+            this.mnuLoadTemplate.Index = 0;
+            this.mnuLoadTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
+            this.mnuLoadTemplate.Text = "&Apply Template";
+            this.mnuLoadTemplate.Click += new System.EventHandler(this.mnuLoadTemplate_Click);
+            // 
+            // mnuSaveTemplate
+            // 
+            this.mnuSaveTemplate.Index = 1;
+            this.mnuSaveTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
+            this.mnuSaveTemplate.Text = "&Save Template";
+            this.mnuSaveTemplate.Click += new System.EventHandler(this.mnuSaveTemplate_Click);
+            // 
+            // mnuDeleteAllSlots
+            // 
+            this.mnuDeleteAllSlots.Index = 2;
+            this.mnuDeleteAllSlots.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
+            this.mnuDeleteAllSlots.Text = "&Delete All Slots";
+            this.mnuDeleteAllSlots.Click += new System.EventHandler(this.mnuDeleteAllSlots_Click);
+            // 
+            // menuItem6
+            // 
+            this.menuItem6.Index = 3;
+            this.menuItem6.Text = "-";
+            // 
+            // mnuSchedulingManagment
+            // 
+            this.mnuSchedulingManagment.Index = 4;
+            this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
+            this.mnuSchedulingManagment.Text = "Scheduling &Management";
+            this.mnuSchedulingManagment.Click += new System.EventHandler(this.mnuSchedulingManagment_Click);
+            // 
+            // menuItem5
+            // 
+            this.menuItem5.Index = 5;
+            this.menuItem5.Text = "-";
+            // 
+            // mnuClose
+            // 
+            this.mnuClose.Index = 6;
+            this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
+            this.mnuClose.Text = "&Close";
+            this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
+            // 
+            // mnuAvailability
+            // 
+            this.mnuAvailability.Index = 1;
+            this.mnuAvailability.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.mnuAddNewAV,
+            this.mnuRemoveAV,
+            this.mnuEditAV});
+            this.mnuAvailability.Text = "&Access Blocks";
+            this.mnuAvailability.Popup += new System.EventHandler(this.mnuAvailability_Popup);
+            // 
+            // mnuAddNewAV
+            // 
+            this.mnuAddNewAV.Index = 0;
+            this.mnuAddNewAV.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
+            this.mnuAddNewAV.Text = "Add &New Block";
+            this.mnuAddNewAV.Click += new System.EventHandler(this.mnuAddNewAV_Click);
+            // 
+            // mnuRemoveAV
+            // 
+            this.mnuRemoveAV.Index = 1;
+            this.mnuRemoveAV.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
+            this.mnuRemoveAV.Text = "&Remove Block";
+            this.mnuRemoveAV.Click += new System.EventHandler(this.mnuRemoveAV_Click);
+            // 
+            // mnuEditAV
+            // 
+            this.mnuEditAV.Index = 2;
+            this.mnuEditAV.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
+            this.mnuEditAV.Text = "&Edit Block";
+            this.mnuEditAV.Click += new System.EventHandler(this.mnuEditAV_Click);
+            // 
+            // mnuCalendar
+            // 
+            this.mnuCalendar.Index = 2;
+            this.mnuCalendar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.mnu1Day,
+            this.mnu5Day,
+            this.mnu7Day,
+            this.menuItem7,
+            this.mnuTimeScale,
+            this.mnuViewRightPanel});
+            this.mnuCalendar.Text = "&View";
+            // 
+            // mnu1Day
+            // 
+            this.mnu1Day.Index = 0;
+            this.mnu1Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl1;
+            this.mnu1Day.Text = "&1-Day View";
+            this.mnu1Day.Click += new System.EventHandler(this.mnu1Day_Click);
+            // 
+            // mnu5Day
+            // 
+            this.mnu5Day.Index = 1;
+            this.mnu5Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl5;
+            this.mnu5Day.Text = "&5-Day View";
+            this.mnu5Day.Click += new System.EventHandler(this.mnu5Day_Click);
+            // 
+            // mnu7Day
+            // 
+            this.mnu7Day.Index = 2;
+            this.mnu7Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl7;
+            this.mnu7Day.Text = "&7-Day View";
+            this.mnu7Day.Click += new System.EventHandler(this.mnu7Day_Click);
+            // 
+            // menuItem7
+            // 
+            this.menuItem7.Index = 3;
+            this.menuItem7.Text = "-";
+            // 
+            // mnuTimeScale
+            // 
+            this.mnuTimeScale.Index = 4;
+            this.mnuTimeScale.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.mnu10Minute,
+            this.mnu15Minute,
+            this.mnu20Minute,
+            this.mnu30Minute});
+            this.mnuTimeScale.Text = "&Time Scale";
+            // 
+            // mnu10Minute
+            // 
+            this.mnu10Minute.Index = 0;
+            this.mnu10Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl0;
+            this.mnu10Minute.Text = "&10-Minute";
+            this.mnu10Minute.Click += new System.EventHandler(this.mnu10Minute_Click);
+            // 
+            // mnu15Minute
+            // 
+            this.mnu15Minute.Index = 1;
+            this.mnu15Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl4;
+            this.mnu15Minute.Text = "&15-Minute";
+            this.mnu15Minute.Click += new System.EventHandler(this.mnu15Minute_Click);
+            // 
+            // mnu20Minute
+            // 
+            this.mnu20Minute.Index = 2;
+            this.mnu20Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl3;
+            this.mnu20Minute.Text = "&20-Minute";
+            this.mnu20Minute.Click += new System.EventHandler(this.mnu20Minute_Click);
+            // 
+            // mnu30Minute
+            // 
+            this.mnu30Minute.Index = 3;
+            this.mnu30Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl2;
+            this.mnu30Minute.Text = "&30-Minute";
+            this.mnu30Minute.Click += new System.EventHandler(this.mnu30Minute_Click);
+            // 
+            // mnuViewRightPanel
+            // 
+            this.mnuViewRightPanel.Index = 5;
+            this.mnuViewRightPanel.Text = "&Access Block Clipboard";
+            this.mnuViewRightPanel.Click += new System.EventHandler(this.mnuViewRightPanel_Click);
+            // 
+            // mnuHelp
+            // 
+            this.mnuHelp.Index = 3;
+            this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.mnuHelpAbout});
+            this.mnuHelp.Text = "&Help";
+            // 
+            // mnuHelpAbout
+            // 
+            this.mnuHelpAbout.Index = 0;
+            this.mnuHelpAbout.Text = "&About";
+            this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
+            // 
+            // splitter1
+            // 
+            this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
+            this.splitter1.Location = new System.Drawing.Point(720, 24);
+            this.splitter1.Name = "splitter1";
+            this.splitter1.Size = new System.Drawing.Size(8, 316);
+            this.splitter1.TabIndex = 6;
+            this.splitter1.TabStop = false;
+            // 
+            // saveAccessBlocksWorker
+            // 
+            this.saveAccessBlocksWorker.WorkerReportsProgress = true;
+            this.saveAccessBlocksWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.saveAccessBlocksWorker_DoWork);
+            this.saveAccessBlocksWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.saveAccessBlocksWorker_ProgressChanged);
+            this.saveAccessBlocksWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.saveAccessBlocksWorker_RunWorkerCompleted);
             // 
             // calendarGrid1
@@ -241,5 +486,5 @@
             this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
             this.calendarGrid1.SelectedAppointment = 0;
-            this.calendarGrid1.Size = new System.Drawing.Size(712, 345);
+            this.calendarGrid1.Size = new System.Drawing.Size(712, 316);
             this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
             this.calendarGrid1.TabIndex = 2;
@@ -250,253 +495,8 @@
             this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick);
             // 
-            // ctxCalendarGrid
-            // 
-            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.ctxCalGridAdd,
-            this.ctxCalGridEdit,
-            this.ctxCalGridDelete});
-            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
-            // 
-            // ctxCalGridAdd
-            // 
-            this.ctxCalGridAdd.Index = 0;
-            this.ctxCalGridAdd.Text = "Add New Access Block";
-            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
-            // 
-            // ctxCalGridEdit
-            // 
-            this.ctxCalGridEdit.Index = 1;
-            this.ctxCalGridEdit.Text = "Edit Access Block";
-            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
-            // 
-            // ctxCalGridDelete
-            // 
-            this.ctxCalGridDelete.Index = 2;
-            this.ctxCalGridDelete.Text = "Delete Access Block";
-            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
-            // 
-            // tvSchedules
-            // 
-            this.tvSchedules.BackColor = System.Drawing.SystemColors.ControlLight;
-            this.tvSchedules.Dock = System.Windows.Forms.DockStyle.Left;
-            this.tvSchedules.HotTracking = true;
-            this.tvSchedules.Location = new System.Drawing.Point(0, 0);
-            this.tvSchedules.Name = "tvSchedules";
-            this.tvSchedules.Size = new System.Drawing.Size(8, 393);
-            this.tvSchedules.Sorted = true;
-            this.tvSchedules.TabIndex = 5;
-            // 
-            // mainMenu1
-            // 
-            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.menuItem1,
-            this.mnuAvailability,
-            this.mnuCalendar,
-            this.mnuHelp});
-            // 
-            // menuItem1
-            // 
-            this.menuItem1.Index = 0;
-            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnuLoadTemplate,
-            this.mnuSaveTemplate,
-            this.mnuDeleteAllSlots,
-            this.menuItem6,
-            this.mnuSchedulingManagment,
-            this.menuItem5,
-            this.mnuClose});
-            this.menuItem1.Text = "&File";
-            // 
-            // mnuLoadTemplate
-            // 
-            this.mnuLoadTemplate.Index = 0;
-            this.mnuLoadTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
-            this.mnuLoadTemplate.Text = "&Apply Template";
-            this.mnuLoadTemplate.Click += new System.EventHandler(this.mnuLoadTemplate_Click);
-            // 
-            // mnuSaveTemplate
-            // 
-            this.mnuSaveTemplate.Index = 1;
-            this.mnuSaveTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
-            this.mnuSaveTemplate.Text = "&Save Template";
-            this.mnuSaveTemplate.Click += new System.EventHandler(this.mnuSaveTemplate_Click);
-            // 
-            // mnuDeleteAllSlots
-            // 
-            this.mnuDeleteAllSlots.Index = 2;
-            this.mnuDeleteAllSlots.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
-            this.mnuDeleteAllSlots.Text = "&Delete All Slots";
-            this.mnuDeleteAllSlots.Click += new System.EventHandler(this.mnuDeleteAllSlots_Click);
-            // 
-            // menuItem6
-            // 
-            this.menuItem6.Index = 3;
-            this.menuItem6.Text = "-";
-            // 
-            // mnuSchedulingManagment
-            // 
-            this.mnuSchedulingManagment.Index = 4;
-            this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
-            this.mnuSchedulingManagment.Text = "Scheduling &Management";
-            this.mnuSchedulingManagment.Click += new System.EventHandler(this.mnuSchedulingManagment_Click);
-            // 
-            // menuItem5
-            // 
-            this.menuItem5.Index = 5;
-            this.menuItem5.Text = "-";
-            // 
-            // mnuClose
-            // 
-            this.mnuClose.Index = 6;
-            this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
-            this.mnuClose.Text = "&Close";
-            this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
-            // 
-            // mnuAvailability
-            // 
-            this.mnuAvailability.Index = 1;
-            this.mnuAvailability.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnuAddNewAV,
-            this.mnuRemoveAV,
-            this.mnuEditAV});
-            this.mnuAvailability.Text = "&Access Blocks";
-            this.mnuAvailability.Popup += new System.EventHandler(this.mnuAvailability_Popup);
-            // 
-            // mnuAddNewAV
-            // 
-            this.mnuAddNewAV.Index = 0;
-            this.mnuAddNewAV.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
-            this.mnuAddNewAV.Text = "Add &New Block";
-            this.mnuAddNewAV.Click += new System.EventHandler(this.mnuAddNewAV_Click);
-            // 
-            // mnuRemoveAV
-            // 
-            this.mnuRemoveAV.Index = 1;
-            this.mnuRemoveAV.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
-            this.mnuRemoveAV.Text = "&Remove Block";
-            this.mnuRemoveAV.Click += new System.EventHandler(this.mnuRemoveAV_Click);
-            // 
-            // mnuEditAV
-            // 
-            this.mnuEditAV.Index = 2;
-            this.mnuEditAV.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
-            this.mnuEditAV.Text = "&Edit Block";
-            this.mnuEditAV.Click += new System.EventHandler(this.mnuEditAV_Click);
-            // 
-            // mnuCalendar
-            // 
-            this.mnuCalendar.Index = 2;
-            this.mnuCalendar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnu1Day,
-            this.mnu5Day,
-            this.mnu7Day,
-            this.menuItem7,
-            this.mnuTimeScale,
-            this.mnuViewRightPanel});
-            this.mnuCalendar.Text = "&View";
-            // 
-            // mnu1Day
-            // 
-            this.mnu1Day.Index = 0;
-            this.mnu1Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl1;
-            this.mnu1Day.Text = "&1-Day View";
-            this.mnu1Day.Click += new System.EventHandler(this.mnu1Day_Click);
-            // 
-            // mnu5Day
-            // 
-            this.mnu5Day.Index = 1;
-            this.mnu5Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl5;
-            this.mnu5Day.Text = "&5-Day View";
-            this.mnu5Day.Click += new System.EventHandler(this.mnu5Day_Click);
-            // 
-            // mnu7Day
-            // 
-            this.mnu7Day.Index = 2;
-            this.mnu7Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl7;
-            this.mnu7Day.Text = "&7-Day View";
-            this.mnu7Day.Click += new System.EventHandler(this.mnu7Day_Click);
-            // 
-            // menuItem7
-            // 
-            this.menuItem7.Index = 3;
-            this.menuItem7.Text = "-";
-            // 
-            // mnuTimeScale
-            // 
-            this.mnuTimeScale.Index = 4;
-            this.mnuTimeScale.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnu10Minute,
-            this.mnu15Minute,
-            this.mnu20Minute,
-            this.mnu30Minute});
-            this.mnuTimeScale.Text = "&Time Scale";
-            // 
-            // mnu10Minute
-            // 
-            this.mnu10Minute.Index = 0;
-            this.mnu10Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl0;
-            this.mnu10Minute.Text = "&10-Minute";
-            this.mnu10Minute.Click += new System.EventHandler(this.mnu10Minute_Click);
-            // 
-            // mnu15Minute
-            // 
-            this.mnu15Minute.Index = 1;
-            this.mnu15Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl4;
-            this.mnu15Minute.Text = "&15-Minute";
-            this.mnu15Minute.Click += new System.EventHandler(this.mnu15Minute_Click);
-            // 
-            // mnu20Minute
-            // 
-            this.mnu20Minute.Index = 2;
-            this.mnu20Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl3;
-            this.mnu20Minute.Text = "&20-Minute";
-            this.mnu20Minute.Click += new System.EventHandler(this.mnu20Minute_Click);
-            // 
-            // mnu30Minute
-            // 
-            this.mnu30Minute.Index = 3;
-            this.mnu30Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl2;
-            this.mnu30Minute.Text = "&30-Minute";
-            this.mnu30Minute.Click += new System.EventHandler(this.mnu30Minute_Click);
-            // 
-            // mnuViewRightPanel
-            // 
-            this.mnuViewRightPanel.Index = 5;
-            this.mnuViewRightPanel.Text = "&Access Block Clipboard";
-            this.mnuViewRightPanel.Click += new System.EventHandler(this.mnuViewRightPanel_Click);
-            // 
-            // mnuHelp
-            // 
-            this.mnuHelp.Index = 3;
-            this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnuHelpAbout});
-            this.mnuHelp.Text = "&Help";
-            // 
-            // mnuHelpAbout
-            // 
-            this.mnuHelpAbout.Index = 0;
-            this.mnuHelpAbout.Text = "&About";
-            this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
-            // 
-            // splitter1
-            // 
-            this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
-            this.splitter1.Location = new System.Drawing.Point(720, 24);
-            this.splitter1.Name = "splitter1";
-            this.splitter1.Size = new System.Drawing.Size(8, 345);
-            this.splitter1.TabIndex = 6;
-            this.splitter1.TabStop = false;
-            // 
-            // saveAccessBlocksWorker
-            // 
-            this.saveAccessBlocksWorker.WorkerReportsProgress = true;
-            this.saveAccessBlocksWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.saveAccessBlocksWorker_DoWork);
-            this.saveAccessBlocksWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.saveAccessBlocksWorker_ProgressChanged);
-            this.saveAccessBlocksWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.saveAccessBlocksWorker_RunWorkerCompleted);
-            // 
             // CGAVView
             // 
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-            this.ClientSize = new System.Drawing.Size(848, 393);
+            this.ClientSize = new System.Drawing.Size(848, 364);
             this.Controls.Add(this.panelCenter);
             this.Controls.Add(this.splitter1);
@@ -768,30 +768,41 @@
 		}//End AvailabilityAddNew
 
+
+        /// <summary>
+        /// Delete All slots from certain dates in one swoop. DAL does actualy deletion.
+        /// </summary>
         private void MassSlotDelete()
         {
-            DialogResult msgResult = MessageBox.Show("Delete all Access Slots?", "Delete Slots?",MessageBoxButtons.YesNo);
-            if (msgResult != DialogResult.Yes) return;
-
-            CGAppointments appointments = new CGAppointments();
-            appointments = this.Document.AVBlocks;
-
-            foreach (CGAppointment a in appointments.AppointmentTable.Values)
-            {
-                int nApptID = a.AppointmentKey;
-                Debug.Assert(nApptID != 0);
-                try
-                {
-                    Document.DeleteAvailability(nApptID);
-                }
-                catch (Exception ex)
-                {
-                    MessageBox.Show("Unable to delete access block" + ex.Message, "Clinical Scheduling");
-                }
-
-            }
-
-            this.m_DocManager.UpdateViews((string)this.m_Document.Resources[0], "");
+            // Ask users for from and to dates
+            DMassSlotDelete dMassSlotDelete = new DMassSlotDelete();
+            DialogResult res = dMassSlotDelete.ShowDialog();
+
+            // peel off if user cancelled.
+            if (res != DialogResult.OK) return;
+
+            // Get this ResourceID from here, and the start and end dates from the dialog.
+            string sResourceID = this.m_Document.ResourceID.ToString();
+            DateTime dStartDate = dMassSlotDelete.StartDate;
+            DateTime dEndDate = dMassSlotDelete.EndDate;
+
+            // Deletes Slots through DAL.
+            DataTable result = this.m_DocManager.DAL.MassSlotDelete(sResourceID, dStartDate, dEndDate);
+            
+            // One row (and only one) expected:
+            Debug.Assert(result.Rows.Count == 1);
+
+            // -1 Expected in first row, otherwise, there is an error
+            if (result.Rows[0][0].ToString() != "-1")
+                throw new ApplicationException(
+                    @"VISTA couldn't delete the slots. Contact tech support.\r\n
+                     Error Message from VISTA: " + result.Rows[0][1].ToString());
+
+            // Update Access Blocks views
+            this.Document.RefreshDaysSchedule(); // Retrieve the slots from the server
+            this.Document.UpdateAllViews(); // Recalibrate the calendar grid with the new cells
+            this.calendarGrid1.Invalidate(); // Redraw it.
+
+            // Tell other clients that slots have changed.
             RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
-            this.calendarGrid1.Invalidate();
         }
 
@@ -1050,4 +1061,9 @@
 			{
                 this.saveAccessBlocksWorker.RunWorkerAsync(dlg);
+                /*
+                 * Moved to RunWorkerAsync. Leave until I think I am safe removing it.
+                 * 
+                */ 
+                
                 //OpenFileDialog openFileDialog1 = dlg.FileDialog;
                 //openFileDialog1.RestoreDirectory = false; // go back to our dir
@@ -1494,25 +1510,11 @@
 
             string sResourceID = this.m_Document.ResourceID.ToString();
-            DataTable dt;
 
             for (int j = 1; j < nWeeksToApply + 1; j++)
             {
-                float fProgressPercentage = ((float)j / (float)nWeeksToApply) * 100;
+                float fProgressPercentage = ((float)(j-1) / (float)nWeeksToApply) * 100;
                 int iProgressPercentage = (int)fProgressPercentage;
                 worker.ReportProgress(iProgressPercentage);
-                //Convert start and end to string
-                //string sStart = dtStart.ToString("M/d/yyyy");
-                //string sEnd = dtEnd.ToString("M/d/yyyy");
-                //i18n
-                string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
-                string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
-                //Cancel all existing access blocks in the date range
-                string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
-                CGDocumentManager.RPMSDataTableDelegate d = new CGDocumentManager.RPMSDataTableDelegate(m_DocManager.RPMSDataTable);
-                //dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
-                dt = d(sSql, "Cancelled");
-                //for each CGAppointment in AVBlocks, call AddNew
-                string sResource = "";
-                sResource = (string)this.Document.Resources[0];
+                string sResource = (string)this.Document.Resources[0];
                 foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
                 {
@@ -1548,4 +1550,12 @@
         private void saveAccessBlocksWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
         {
+            // Update Access Blocks views
+            this.Document.RefreshDaysSchedule(); // Retrieve the slots from the server
+            this.Document.UpdateAllViews(); // Recalibrate the calendar grid with the new cells
+            this.calendarGrid1.Invalidate(); // Redraw it.
+
+            // Tell other clients that slots have changed.
+            RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
+
             this.statusBar1.Text = "Done saving access blocks.";
         }
@@ -1558,5 +1568,5 @@
         private void mnuDeleteAllSlots_Click(object sender, EventArgs e)
         {
-
+            MassSlotDelete();
         }
 
