Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVDocument.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVDocument.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVDocument.cs	(revision 1117)
@@ -252,5 +252,5 @@
 				Debug.Write("CreateAvailabilityAuto -- new AV block created\n");
 
-				UpdateAllViews();
+				//UpdateAllViews();
 
 				aCopy.AppointmentKey = nApptID;
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1117)
@@ -884,4 +884,5 @@
 			//TODO:  Create these components
 			this.calendarGrid1.Resources = this.m_Document.Resources;
+            this.calendarGrid1.Appointments = (CGAppointments)this.m_Document.m_AVBlocks.Clone();
 			this.calendarGrid1.OnUpdateArrays();
 			this.lblResource.Text = this.m_Document.DocName;
@@ -1042,10 +1043,7 @@
 			 * Display dialog to collect:
 			 * - Number of weeks to apply template
-			 * - Starting week Monday
+			 * - Starting week (application starts on Culture WeekStartDay of selected week)
 			 * - Template path & filename
 			 * 
-			 * for each week,
-			 *	Delete all availability during that week
-			 *  apply the template
 			 * 
 			 */
@@ -1506,5 +1504,5 @@
             dtStart = newStartDate;
             int nWeeksToApply = dlg.WeeksToApply;
-            DateTime dtEnd = dtStart.AddDays(6); // or 7?
+            DateTime dtEnd = dtStart.AddDays(6); // or 7? smh:: not 7 for sure.
 
             string sResourceID = this.m_Document.ResourceID.ToString();
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1117)
@@ -1246,5 +1246,5 @@
         }
 
-        public string AppointmentNoShow(int nApptID, bool bNoShow)
+        public string AppointmentNoShow(CGAppointment a, bool bNoShow)
         {
             /*
@@ -1253,5 +1253,5 @@
              *
              */
-
+            int nApptID = a.AppointmentKey;
             string sTest = bNoShow.ToString();
             string sNoShow = (bNoShow == true) ? "1" : "0";
@@ -1270,7 +1270,28 @@
             }
 
-            bool bRet = RefreshSchedule();
+            //All okay over here... then set appointment noshow or not no show...
+            a.NoShow = bNoShow ? true : false;
+
+            //bool bRet = RefreshSchedule();
 
             return sErrorID;
+        }
+
+        public bool AppointmentUndoCheckin(CGAppointment a, out string msg)
+        {
+            msg = "";
+            //zero good, anything else bad
+            DataTable dt = CGDocumentManager.Current.DAL.RemoveCheckIn(a.AppointmentKey);
+            if (dt.Rows[0][0].ToString() == "0")
+            {
+                a.CheckInTime = DateTime.MinValue; // remove check-in time.
+                return true;
+            }
+
+            else
+            {
+                msg = dt.Rows[0][0].ToString();
+                return false;
+            }
         }
 
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1117)
@@ -354,6 +354,6 @@
             threadSplash.Start(m_ds); // pass form as parameter.
 
-            //There are 19 steps to load the application. That's max for the progress bar.
-            setMaxProgressDelegate(19);
+            //There are 21 steps to load the application. That's max for the progress bar.
+            setMaxProgressDelegate(21);
             
             // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
@@ -472,6 +472,5 @@
             }
            
-            //User Preferences Object
-            _current.UserPreferences = new UserPreferences();
+            
 
             //User Interface Culture (m_CultureName is set from the command line flag /culture)
@@ -536,6 +535,12 @@
 			setStatusDelegate("Setting Application Context to BSDXRPC...");
 			m_ConnectInfo.AppContext = "BSDXRPC";
-	
-			//Load global recordsets
+
+            //User Preferences Object
+            setProgressDelegate(4); //next number is 6 b/c two calls
+            setStatusDelegate("Getting User Preferences from the Server...");
+
+            _current.UserPreferences = new UserPreferences(); // Does the calling to do that...
+            
+            //Load global recordsets
             string statusConst = "Loading VistA data tables...";
 			setStatusDelegate(statusConst);
@@ -545,5 +550,5 @@
             //Schedule User Info
             // Table #4
-            setProgressDelegate(4);
+            setProgressDelegate(6);
             setStatusDelegate(statusConst + " Schedule User");
             DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
@@ -560,5 +565,5 @@
             //Get Access Types
             // Table #5
-            setProgressDelegate(5);
+            setProgressDelegate(7);
             setStatusDelegate(statusConst + " Access Types");
             DataTable dtAccessTypes = _dal.GetAccessTypes();
@@ -568,5 +573,5 @@
             //Get Access Groups
             // Table #6
-            setProgressDelegate(6);
+            setProgressDelegate(8);
             setStatusDelegate(statusConst + " Access Groups");
             LoadAccessGroupsTable();
@@ -583,5 +588,5 @@
             // But they are heavily referenced throughout the code.
             // Table #7
-            setProgressDelegate(7);
+            setProgressDelegate(9);
             setStatusDelegate(statusConst + " Access Group Types");
             LoadAccessGroupTypesTable();
@@ -603,5 +608,5 @@
             // Table #8
             // What shows up on the tree. The groups the user has access to.
-            setProgressDelegate(8);
+            setProgressDelegate(10);
             setStatusDelegate(statusConst + " Resource Groups By User");
             LoadResourceGroupTable();
@@ -610,5 +615,5 @@
             // Table #9
             // Individual Resources
-            setProgressDelegate(9);
+            setProgressDelegate(11);
             setStatusDelegate(statusConst + " Resources By User");
             LoadBSDXResourcesTable();
@@ -622,5 +627,5 @@
             // Table #10
             // Resource Groups and Indivdual Resources together
-            setProgressDelegate(10);
+            setProgressDelegate(12);
             setStatusDelegate(statusConst + " Group Resources");
             LoadGroupResourcesTable();
@@ -640,5 +645,5 @@
             //HospitalLocation table
             //Table #11
-            setProgressDelegate(11);
+            setProgressDelegate(13);
             setStatusDelegate(statusConst + " Clinics");
             //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
@@ -661,5 +666,5 @@
             //Build ScheduleUser table
             //Table #12
-            setProgressDelegate(12);
+            setProgressDelegate(14);
             setStatusDelegate(statusConst + " Schedule User");
             this.LoadScheduleUserTable();
@@ -674,5 +679,5 @@
             //Table #13
             //Acess to Resources by [this] User
-            setProgressDelegate(13);
+            setProgressDelegate(15);
             setStatusDelegate(statusConst + " Resource User");
             this.LoadResourceUserTable();
@@ -693,5 +698,5 @@
             //Table #14
             //TODO: Lazy load the provider table; no need to load in advance.
-            setProgressDelegate(14);
+            setProgressDelegate(16);
             setStatusDelegate(statusConst + " Providers");
             sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
@@ -701,5 +706,5 @@
             //Build the HOLIDAY table
             //Table #15
-            setProgressDelegate(15);
+            setProgressDelegate(17);
             setStatusDelegate(statusConst + " Holiday");
             sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE INTERNAL[DATE] > '" + FMDateTime.Create(DateTime.Today).DateOnly.FMDateString + "'";
@@ -721,14 +726,14 @@
             setStatusDelegate("Subscribing to Server Events");
             //Table #16
-            setProgressDelegate(16);
+            setProgressDelegate(18);
             _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
 			//Table #17
-            setProgressDelegate(17);
+            setProgressDelegate(19);
             _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
 			//Table #18
-            setProgressDelegate(18);
+            setProgressDelegate(20);
             _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
 			//Table #19
-            setProgressDelegate(19);
+            setProgressDelegate(21);
             _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
 
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1117)
@@ -37,5 +37,5 @@
     </RemoteDebugMachine>
     <StartAction>Project</StartAction>
-    <StartArguments>/s=172.16.16.108 /p=9250 /a=BASMA.ALDWAIRI /v=SELEN.123 /culture="ar-JO"</StartArguments>
+    <StartArguments>/s=172.16.16.108 /p=9250 /a=BASMA.ALDWAIRI /v=SELEN.123 /culture=ar-JO</StartArguments>
     <StartPage>
     </StartPage>
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs	(revision 1117)
@@ -17,4 +17,5 @@
         
         delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName); // for use in calling (Sync and Async)
+        delegate string TransmitRPCAsync(string RPCName, string Params); //same idea
 
         /// <summary>
@@ -174,4 +175,62 @@
 
         /// <summary>
+        /// Remove the check-in for the appointment
+        /// </summary>
+        /// <param name="ApptID">Appointment IEN/Key</param>
+        /// <returns>Table with 1 columns: ERRORID. ErrorID of "0" is okay; 
+        /// any other (negative numbers plus text) is bad</returns>
+        public DataTable RemoveCheckIn(int ApptID)
+        {
+            string cmd = string.Format("BSDX REMOVE CHECK-IN^{0}", ApptID);
+            return RPMSDataTable(cmd, "");
+        }
+
+        /// <summary>
+        /// Save User Preference in DB For Printing Routing Slip
+        /// Uses Parameter BSDX AUTO PRINT RS
+        /// </summary>
+        /// <remarks>
+        /// Notice Code-Fu for Async Save...
+        /// </remarks>
+        public bool AutoPrintRoutingSlip
+        {
+            get
+            {
+                string val = _thisConnection.bmxNetLib.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT RS");  //1 = true; 0 = false; "" = not set
+                return val == "1" ? true : false;
+            }
+            set
+            {
+                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.bmxNetLib.TransmitRPC);
+                // 0 = success; anything else is wrong. Not being tested here as its success is not critical to application use.
+                _asyncTransmitter.BeginInvoke("BSDX SET PARAM", String.Format("{0}^{1}", "BSDX AUTO PRINT RS", value ? "1" : "0"), null, null);
+            }
+        }
+
+        /// <summary>
+        /// Save User Preference in DB For Printing Routing Slip
+        /// Uses Parameter BSDX AUTO PRINT AS
+        /// </summary>
+        /// <remarks>
+        /// Notice Code-Fu for Async Save...
+        /// </remarks>
+        public bool AutoPrintAppointmentSlip
+        {
+            get
+            {
+                string val = _thisConnection.bmxNetLib.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT AS");  //1 = true; 0 = false; "" = not set
+                return val == "1" ? true : false;
+            }
+            set
+            {
+                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.bmxNetLib.TransmitRPC);
+                // 0 = success; anything else is wrong. Not being tested here as its success is not critical to application use.
+                _asyncTransmitter.BeginInvoke("BSDX SET PARAM", String.Format("{0}^{1}", "BSDX AUTO PRINT AS", value ? "1" : "0"), null, null);
+            }
+        }
+
+
+
+        /// <summary>
         /// Workhorse
         /// </summary>
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs	(revision 1117)
@@ -671,4 +671,5 @@
         private string          m_sCountry;
         private int          m_iAccessTypeID;
+        private bool _myCodeIsFiringIstheCheckBoxChangedEvent;
 
 		#endregion //fields
@@ -719,5 +720,7 @@
                 groupBox4.Controls.Add(UC);
 
+                _myCodeIsFiringIstheCheckBoxChangedEvent = true;
                 chkPrint.Checked = CGDocumentManager.Current.UserPreferences.PrintAppointmentSlipAutomacially;
+                _myCodeIsFiringIstheCheckBoxChangedEvent = false;
             }
 			catch(Exception e)
@@ -862,6 +865,5 @@
 
         /// <summary>
-        /// Save Print Slip preference in UserPreferences object. For now, it always starts false since
-        /// it isn't saved in the DB; but that will change in the future.
+        /// Save Print Slip preference in UserPreferences object.
         /// </summary>
         /// <param name="sender"></param>
@@ -869,4 +871,6 @@
         private void chkPrint_CheckedChanged(object sender, EventArgs e)
         {
+            if (_myCodeIsFiringIstheCheckBoxChangedEvent) return;
+
             CGDocumentManager.Current.UserPreferences.PrintAppointmentSlipAutomacially = chkPrint.Checked;
         }
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs	(revision 1117)
@@ -25,4 +25,6 @@
             //
             InitializeComponent();
+
+            
         }
 
@@ -60,4 +62,5 @@
         private List<Provider> _providers;
         private ToolTip toolTip1;
+        private bool _myCodeIsFiringIstheCheckBoxChangedEvent; // To prevent the event from firing when I set the control from code
         
         #endregion Fields
@@ -233,6 +236,7 @@
             }
 
-            //Print Routing Slip based on user preferences.
+            _myCodeIsFiringIstheCheckBoxChangedEvent = true;
             chkRoutingSlip.Checked = CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically;
+            _myCodeIsFiringIstheCheckBoxChangedEvent = false;
 
             UpdateDialogData(true);
@@ -475,4 +479,6 @@
         private void chkRoutingSlip_CheckedChanged(object sender, EventArgs e)
         {
+            if (_myCodeIsFiringIstheCheckBoxChangedEvent) return;
+
             CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically = chkRoutingSlip.Checked;
         }
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs	(revision 1117)
@@ -68,5 +68,5 @@
             // 
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-            this.ClientSize = new System.Drawing.Size(648, 398);
+            this.ClientSize = new System.Drawing.Size(748, 443);
             this.Name = "DPatientLetter";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -404,4 +404,5 @@
             _currentApptPrinting = 0; 
         }
+
 	}
 }
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.resx
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.resx	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.resx	(revision 1117)
@@ -113,20 +113,20 @@
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="printAppts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>116, 17</value>
+  <metadata name="printAppts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>122, 17</value>
   </metadata>
-  <metadata name="printReminderLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>218, 17</value>
+  <metadata name="printReminderLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>231, 17</value>
   </metadata>
-  <metadata name="printCancelLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>374, 17</value>
+  <metadata name="printCancelLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>397, 17</value>
   </metadata>
-  <metadata name="printRebookLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>515, 17</value>
+  <metadata name="printRebookLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>547, 17</value>
   </metadata>
 </root>
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/UserPreferences.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/UserPreferences.cs	(revision 1112)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/UserPreferences.cs	(revision 1117)
@@ -7,16 +7,34 @@
 {
     /// <summary>
-    /// Designed to keep user preferences. Very basic for now.
+    /// Designed to keep user preferences. Gets settings from DB in constructor; Writes them back when changed.
     /// </summary>
     public class UserPreferences
     {
+        bool _printAppointmentSlipAutomacially;
+        bool _printRoutingSlipAutomatically;
+        
         public UserPreferences()
         {
-            PrintAppointmentSlipAutomacially = false;
-            PrintRoutingSlipAutomatically = false;
+            _printAppointmentSlipAutomacially = CGDocumentManager.Current.DAL.AutoPrintAppointmentSlip;
+            _printRoutingSlipAutomatically = CGDocumentManager.Current.DAL.AutoPrintRoutingSlip;
+            
         }
 
-        public bool PrintAppointmentSlipAutomacially { get; set; }
-        public bool PrintRoutingSlipAutomatically { get; set; }
+        public bool PrintAppointmentSlipAutomacially {
+            get { return _printAppointmentSlipAutomacially; }
+            set
+            {
+                CGDocumentManager.Current.DAL.AutoPrintAppointmentSlip = _printAppointmentSlipAutomacially = value; 
+            }
+        }
+
+        public bool PrintRoutingSlipAutomatically
+        {
+            get { return _printRoutingSlipAutomatically; }
+            set 
+            { 
+                CGDocumentManager.Current.DAL.AutoPrintRoutingSlip = _printRoutingSlipAutomatically = value; 
+            }
+        }
     }
 }
