Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs	(revision 1050)
@@ -28,5 +28,5 @@
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.4.2.*")]
+[assembly: AssemblyVersion("1.5.0.*")]
 
 //
@@ -58,4 +58,4 @@
 [assembly: AssemblyKeyFile("")]
 [assembly: AssemblyKeyName("")]
-[assembly: AssemblyFileVersionAttribute("1.4.2.0")]
+[assembly: AssemblyFileVersionAttribute("1.5.0.0")]
 [assembly: ComVisibleAttribute(false)]
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1050)
@@ -430,5 +430,4 @@
 					m_DocManager.ConnectInfo.LoadConnectInfo();
 				}
-				System.IntPtr pHandle = m_DocManager.Handle;
 
 				m_pAvArray.Clear();
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1050)
@@ -4,4 +4,5 @@
 using System.Data;
 using System.Diagnostics;
+using System.Threading;
 using IndianHealthService.BMXNet;
 using Mono.Options;
@@ -11,26 +12,24 @@
 {
 	/// <summary>
-	/// Summary description for DocumentManager.
+	/// Main Worker. Handles sub-forms.
 	/// </summary>
-	public class CGDocumentManager : System.Windows.Forms.Form
+	public class CGDocumentManager //: System.Windows.Forms.Form
 	{
 		#region Member Variables
 
 		private static CGDocumentManager	_current;
-		private Hashtable					_views = new Hashtable();
-		private Hashtable					m_AVViews = new Hashtable();
+		private Hashtable					_views = new Hashtable();       //Returns the list of currently opened documents
+		private Hashtable					m_AVViews = new Hashtable();    // List of currently opened CGAVViews
 		private string						m_sWindowText = "Clinical Scheduling"; //Default Window Text
-		private bool						m_bSchedManager;
-		private bool						m_bExitOK = true;
-        public string                       m_sHandle = "0";
+		private bool						m_bSchedManager = false;    // Do you have the XUPROGMODE or BSDXZMGR?
+		private bool						m_bExitOK = true;           // Okay to exit program? Used to control Re-logins. Default true.
+        public string                       m_sHandle = "0";            // Not Used
         
-        //Connection variables
+        //Connection variables (tied to command line parameters /a /v /s /p /e)
         private string                      m_AccessCode="";
         private string                      m_VerifyCode="";
         private string                      m_Server="";
         private int                         m_Port=0;
-
-        //Encoding string (empty by default)
-        private string                      m_Encoding="";
+        private string                      m_Encoding="";  //Encoding is "" by default;
 
         //Data Access Layer
@@ -38,19 +37,167 @@
 
 		//M Connection member variables
-		private DataSet									m_dsGlobal = null;
-		private System.ComponentModel.IContainer		components = null;
-		private BMXNetConnectInfo						m_ConnectInfo = null;
-		private BMXNetConnectInfo.BMXNetEventDelegate	CDocMgrEventDelegate;
+		private DataSet									m_dsGlobal = null;      // Holds all user data
+		private BMXNetConnectInfo						m_ConnectInfo = null;   // Connection to VISTA object
+        private BMXNetConnectInfo.BMXNetEventDelegate CDocMgrEventDelegate;     // Delegate to respond to messages from VISTA. Responds to event: BMXNetConnectInfo.BMXNetEvent
 
 		#endregion
 
+        #region Properties
+
         /// <summary>
-        /// Constructor. Sets up connector, and ties BMXNet Events to function here.
+        /// Returns the document manager's BMXNetConnectInfo member
+        /// </summary>
+        public BMXNetConnectInfo ConnectInfo
+        {
+            get
+            {
+                return m_ConnectInfo;
+            }
+        }
+
+        /// <summary>
+        /// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
+        /// </summary>
+        public bool ScheduleManager
+        {
+            get
+            {
+                return m_bSchedManager;
+            }
+        }
+
+        /// <summary>
+        /// Holds the user and division
+        /// </summary>
+        public string WindowText
+        {
+            get
+            {
+                return m_sWindowText;
+            }
+        }
+
+        /// <summary>
+        /// This dataset contains tables used by the entire application
+        /// </summary>		
+        public DataSet GlobalDataSet
+        {
+            get
+            {
+                return m_dsGlobal;
+            }
+            set
+            {
+                m_dsGlobal = value;
+            }
+        }
+ 
+        /// <summary>
+        /// Returns the single CGDocumentManager object
+        /// </summary>
+        public static CGDocumentManager Current
+        {
+            get
+            {
+                return _current;
+            }
+        }
+
+
+        /// <summary>
+        /// Returns the list of currently opened documents
+        /// </summary>
+        public Hashtable Views
+        {
+            get
+            {
+                return _views;
+            }
+        }
+
+        /// <summary>
+        /// Returns the list of currently opened CGAVViews
+        /// </summary>
+        public Hashtable AvailabilityViews
+        {
+            get
+            {
+                return this.m_AVViews;
+            }
+        }
+
+        public DAL DAL
+        {
+            get { return this._dal; }
+        }
+
+
+        #endregion
+
+        /// <summary>
+        /// Constructor. Does absolutely nothing at this point.
         /// </summary>
 		public CGDocumentManager()
 		{
-			InitializeComponent();
-            m_bSchedManager = false;
         }
+
+
+#if DEBUG
+        //To write to the console
+        [DllImport("kernel32.dll")]
+        static extern bool AttachConsole(int dwProcessId);
+        private const int ATTACH_PARENT_PROCESS = -1;
+#endif
+        /// <summary>
+        /// Main Entry Point
+        /// </summary>
+        /// <param name="args">We accept the following Arguments:
+        /// /s or -s = Server ip address or name
+        /// /p or -p = port number (must be numeric)
+        /// /a or -a = Access Code
+        /// /v or -v = Verify Code
+        /// /e or -e = Encoding (name of encoding as known to windows, such as windows-1256)
+        /// </param>
+        /// <remarks>
+        /// Encoding decision is complex. This is the order of priority:
+        /// - If the M DB runs in UTF-8, that's what we are going to use.
+        /// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move forward.
+        /// - If /e is not supplied or is not recognized, the default encoding is the Windows default Encoding for the user.
+        /// </remarks>
+        [STAThread()]
+        static void Main(string[] args)
+        {
+#if DEBUG
+            // Print console messages to console if launched from console
+            // Note: Imported From kernel32.dll
+            AttachConsole(ATTACH_PARENT_PROCESS);
+#endif
+            //Store a class instance of manager. Actual constructor does nothing.
+            _current = new CGDocumentManager();
+
+            //Get command line options; store in private variables
+            var opset = new OptionSet() {
+                { "s=", s => _current.m_Server = s },
+                { "p=", p => _current.m_Port = int.Parse(p) },
+                { "a=", a => _current.m_AccessCode = a },
+                { "v=", v => _current.m_VerifyCode = v },
+                { "e=", e => _current.m_Encoding = e}
+            };
+
+            opset.Parse(args);
+
+            
+            _current.InitializeApp();
+
+            //Create the first empty document
+            CGDocument doc = new CGDocument();
+            doc.DocManager = _current;
+            doc.OnNewDocument();
+            Application.DoEvents();
+
+            //Run the application
+            Application.Run();
+        }
+
 
         #region BMXNet Event Handler
@@ -71,5 +218,6 @@
 				string sMsg = e.BMXParam;
 				ShowAdminMsgDelegate samd = new ShowAdminMsgDelegate(ShowAdminMsg);
-				this.Invoke(samd, new object [] {sMsg});
+				//this.Invoke(samd, new object [] {sMsg});
+                samd.Invoke(sMsg);
 			}
 			if (e.BMXEvent == "BSDX ADMIN SHUTDOWN")
@@ -77,5 +225,6 @@
 				string sMsg = e.BMXParam;
 				CloseAllDelegate cad = new CloseAllDelegate(CloseAll);
-				this.Invoke(cad, new object [] {sMsg});
+				//this.Invoke(cad, new object [] {sMsg});
+                cad.Invoke(sMsg);
 			}
 		}
@@ -90,377 +239,354 @@
         #endregion  BMXNet Event Handler
 
-        #region Properties
+
+		#region Methods & Events
+
+        
+		private void StartSplash(object form)
+		{
+            ((DSplash)form).ShowDialog();
+		}
 
         /// <summary>
-		/// Returns the document manager's BMXNetConnectInfo member
+        /// See InitializeApp(bool) below
+        /// </summary>
+		private void InitializeApp()
+		{
+			InitializeApp(false);
+		}
+
+		/// <summary>
+		/// Does a million things:
+        /// 1. Starts Connection and displays log-in dialogs
+        /// 2. Starts Splash screen
+        /// 3. Loads data tables
 		/// </summary>
-		public BMXNetConnectInfo ConnectInfo
-		{
-			get
-			{
-				return m_ConnectInfo;
-			}
-		}
-
-		/// <summary>
-		/// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
-		/// </summary>
-		public bool ScheduleManager
-		{
-			get
-			{
-				return m_bSchedManager;
-			}
-		}
-
-		/// <summary>
-		/// Holds the user and division
-		/// </summary>
-		public string WindowText
-		{
-			get
-			{
-				return m_sWindowText;
-			}
-		}
-
-		/// <summary>
-		/// This dataset contains tables used by the entire application
-		/// </summary>		
-		public DataSet GlobalDataSet
-		{
-			get
-			{
-				return m_dsGlobal;
-			}
-			set
-			{
-				m_dsGlobal = value;
-			}
-		}
-        //public BMXNetConnection ADOConnection 
-        //{
-        //    get
-        //    {
-        //        return m_ADOConnection;
-        //    }
-        //}
-
-		/// <summary>
-		/// Returns the single CGDocumentManager object
-		/// </summary>
-		public static CGDocumentManager Current
-		{
-			get
-			{
-				return _current;
-			}
-		}
-
-		/// <summary>
-		/// Returns the list of currently opened documents
-		/// </summary>
-		public Hashtable Views
-		{
-			get
-			{
-				return _views;
-			}
-		}
-
-		/// <summary>
-		/// Returns the list of currently opened CGAVViews
-		/// </summary>
-		public Hashtable AvailabilityViews
-		{
-			get
-			{
-				return this.m_AVViews;
-			}
-		}
-
-        public DAL DAL
-        {
-            get { return this._dal; }
-        }
-
-
-		#endregion
-
-		#region Methods & Events
-		/// <summary>
-		/// Clean up any resources being used.
-		/// </summary>
-		protected override void Dispose( bool disposing )
-		{
-			if( disposing )
-			{
-				if (m_ConnectInfo != null)
-				{
-					m_ConnectInfo.EventPollingEnabled = false;
-					m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
-					m_ConnectInfo.UnSubscribeEvent("BSDX CALL WORKSTATIONS");
-					m_ConnectInfo.CloseConnection();
-				}
-				if (components != null) 
-				{
-					components.Dispose();
-				}
-			}
-			base.Dispose( disposing );
-		}
-
-
-		private void InitializeComponent()
-		{
-		}
-
-
-		private DSplash m_ds;
-		public void StartSplash()
-		{
-			m_ds = new DSplash();
-			m_ds.ShowDialog();
-		}
-
-		private void InitializeApp()
-		{
-			InitializeApp(false);
-		}
-
-		private void InitializeApp(bool bReLogin)
-		{
+		/// <param name="bReLogin">Is the User logging in again from a currently running instance?
+        /// If so, display a dialog to collect access and verify codes.</param>
+        private void InitializeApp(bool bReLogin)
+		{
+            //Set M connection info
             m_ConnectInfo = new BMXNetConnectInfo(m_Encoding); // Encoding is "" unless passed in command line
             _dal = new DAL(m_ConnectInfo);   // Data access layer
             //m_ConnectInfo.bmxNetLib.StartLog();    //This line turns on logging of messages
+            
+            //Create a delegate to process events raised by BMX.
             CDocMgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(CDocMgrEventHandler);
+            //Tie delegate to Events generated by BMX.
             m_ConnectInfo.BMXNetEvent += CDocMgrEventDelegate;
+            //Disable polling (But does this really work???? I don't see how it gets disabled)
             m_ConnectInfo.EventPollingEnabled = false;
 
-			try
-			{
-				//Set M connection info
-				//Show a splash screen while initializing
-				m_ds = new DSplash();
-                m_ds.Show(this);
-				m_ds.SetStatus("Loading Configuration Settings...");
-                m_ds.Refresh();
-				this.Activate();
-                // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
-                m_ds.SetStatus("Connecting to VistA Server...");
-                m_ds.Refresh();
-				bool bRetry = true;
-
-                //Try to connect using supplied values for Server and Port
-                //Why am I doing this? The library BMX net uses prompts for access and verify code
-                //whether you can connect or not. Not good. So I test first whether
-                //we can connect at all by doing a simple connection and disconnect.
-                //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response.
-
-                if (m_Server != "" && m_Port != 0)
+            //Show a splash screen while initializing
+            DSplash m_ds = new DSplash();
+            DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
+            DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
+            DSplash.dAny hideSplashDelegate = new DSplash.dAny(m_ds.RemoteHide);
+
+            Thread threadSplash = new Thread(new ParameterizedThreadStart(StartSplash));
+            threadSplash.IsBackground = true; //expendable -- exit even if still running.
+            threadSplash.Start(m_ds);
+
+            
+          	//m_ds.SetStatus("Loading Configuration Settings...");
+            //m_ds.Refresh();
+			//this.Activate();
+            // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
+            setStatusDelegate("Connecting to VISTA");
+            //m_ds.Refresh();
+			bool bRetry = true;
+
+            //Try to connect using supplied values for Server and Port
+            //Why am I doing this? The library BMX net uses prompts for access and verify code
+            //whether you can connect or not. Not good. So I test first whether
+            //we can connect at all by doing a simple connection and disconnect.
+            //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response.
+
+            //m_ds.Refresh();
+
+            if (m_Server != "" && m_Port != 0)
+            {
+                System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient();
+                try
                 {
-                    System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient();
-                    try
+                    tcpClient.Connect(m_Server, m_Port); // open it
+                    tcpClient.Close();                  // then close it
+                }
+                catch (System.Net.Sockets.SocketException ex)
+                {
+                    throw ex;
+                }
+            }
+
+			do
+			{
+                // login crap
+                try
+                {
+                    // Not my code
+                    if (bReLogin == true)
                     {
-                        tcpClient.Connect(m_Server, m_Port); // open it
-                        tcpClient.Close();                  // then close it
+                        //Prompt for Access and Verify codes
+                        _current.m_ConnectInfo.LoadConnectInfo("", "");
                     }
-                    catch (System.Net.Sockets.SocketException ex)
+                    // My code -- buts looks so ugly!
+                    else
                     {
+                        if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
+                            && m_VerifyCode != String.Empty)
+                        {
+                            m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
+                        }
+                        else if (m_Server != String.Empty && m_Port != 0)
+                            m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
+                        else
+                            m_ConnectInfo.LoadConnectInfo();
+                    }
+                    bRetry = false;
+                }
+                catch (System.Net.Sockets.SocketException)
+                {
+                    MessageBox.Show("Cannot connect to VistA. ");
+                }
+                catch (Exception ex)
+                {
+                    //m_ds.Close();
+                    if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
+                    {
+                        bRetry = true;
+                        _current.m_ConnectInfo.ChangeServerInfo();
+                    }
+                    else
+                    {
+                        closeSplashDelegate();
+                        bRetry = false;
                         throw ex;
                     }
                 }
-				do
-				{
-                    // login crap
-                    try
-                    {
-                        // Not my code
-                        if (bReLogin == true)
-                        {
-                            //Prompt for Access and Verify codes
-                            _current.m_ConnectInfo.LoadConnectInfo("", "");
-                        }
-                        // My code -- buts looks so ugly!
-                        else
-                        {
-                            if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
-                                && m_VerifyCode != String.Empty)
-                            {
-                                m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
-                            }
-                            else if (m_Server != String.Empty && m_Port != 0)
-                                m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
-                            else
-                                m_ConnectInfo.LoadConnectInfo();
-                        }
-                        bRetry = false;
-                    }
-                    catch (System.Net.Sockets.SocketException)
-                    {
-                        MessageBox.Show("Cannot connect to VistA. ");
-                    }
-                    catch (Exception ex)
-                    {
-                        m_ds.Close();
-                        if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
-                        {
-                            bRetry = true;
-                            _current.m_ConnectInfo.ChangeServerInfo();
-                        }
-                        else
-                        {
-                            bRetry = false;
-                            throw ex;
-                        }
-                    }
-				}while (bRetry == true);
-
-				//Create global dataset
-				_current.m_dsGlobal = new DataSet("GlobalDataSet");
-
-				//Version info
-				m_ds.SetStatus("Getting Version Info...");
-                m_ds.Refresh();
-
-                DataTable ver = _dal.GetVersion("BSDX");
-                ver.TableName = "VersionInfo";
-                m_dsGlobal.Tables.Add(ver);
+			}while (bRetry == true);
+            
+            //Create global dataset
+			_current.m_dsGlobal = new DataSet("GlobalDataSet");
+
+			//Version info
+            //m_ds.Activate();
+			setStatusDelegate("Getting Version Info from Server...");
+
+            DataTable ver = _dal.GetVersion("BSDX");
+            ver.TableName = "VersionInfo";
+            m_dsGlobal.Tables.Add(ver);
                 
-				//How to extract the version numbers:
-                DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
-                Debug.Assert(dtVersion.Rows.Count == 1);
-                DataRow rVersion = dtVersion.Rows[0];
-                string sMajor = rVersion["MAJOR_VERSION"].ToString();
-                string sMinor = rVersion["MINOR_VERSION"].ToString();
-                string sBuild = rVersion["BUILD"].ToString();
-                decimal fBuild = Convert.ToDecimal(sBuild);
-
-                //Make sure that the server is running the same version the client is.
-                Version x = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
-
-                //if version numbers mismatch, don't continue.
-                //TODO: For future: Include in v. 1.5
-                /*
-                if (!(x.Major.ToString() == sMajor && x.Minor.ToString() + x.Build.ToString() == sMinor))
-                {
-                    MessageBox.Show(
-                        "Server runs version " + sMajor + "." + sMinor + "\r\n" +
-                        "You are running " + x.ToString() + "\r\n\r\n" +
-                        "Major, Minor and Build versions must match",
-                        "Version Mismatch");
-                    m_ds.Close();
-                    return;
-                }
-                */
+			//How to extract the version numbers:
+            DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
+            Debug.Assert(dtVersion.Rows.Count == 1);
+            DataRow rVersion = dtVersion.Rows[0];
+            string sMajor = rVersion["MAJOR_VERSION"].ToString();
+            string sMinor = rVersion["MINOR_VERSION"].ToString();
+            string sBuild = rVersion["BUILD"].ToString();
+            decimal fBuild = Convert.ToDecimal(sBuild);
+
+            //Make sure that the server is running the same version the client is.
+            Version x = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
+
+            //if version numbers mismatch, don't continue.
+            //TODO: For future: Include in v. 1.5
+            /*
+            if (!(x.Major.ToString() == sMajor && x.Minor.ToString() + x.Build.ToString() == sMinor))
+            {
+                MessageBox.Show(
+                    "Server runs version " + sMajor + "." + sMinor + "\r\n" +
+                    "You are running " + x.ToString() + "\r\n\r\n" +
+                    "Major, Minor and Build versions must match",
+                    "Version Mismatch");
+                m_ds.Close();
+                return;
+            }
+            */
  
 
-                //Change encoding
-                if (m_Encoding == String.Empty)
-                {
-                    string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
-                    if (utf8_server_support == "1")
-                        m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
-                }
-				//Set application context
-				m_ds.SetStatus("Setting Application Context to BSDXRPC...");
-                m_ds.Refresh();
-				m_ConnectInfo.AppContext = "BSDXRPC";
+            //Change encoding
+            setStatusDelegate("Setting encoding...");
+
+            if (m_Encoding == String.Empty)
+            {
+                string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
+                if (utf8_server_support == "1")
+                    m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
+            }
+			//Set application context
+			setStatusDelegate("Setting Application Context to BSDXRPC...");
+			m_ConnectInfo.AppContext = "BSDXRPC";
 	
-				//Load global recordsets
-				m_ds.SetStatus("Loading VistA data tables...");
-                m_ds.Refresh();
-				if (_current.LoadGlobalRecordsets() == false)
-				{
-					MessageBox.Show("Unable to create VistA recordsets"); //TODO Improve this message
-					m_ds.Close();
-					return;
-				}
-				
-                //smh -- why get handles?
-				System.IntPtr pHandle = this.Handle;
-				System.IntPtr pConnHandle = this.ConnectInfo.Handle;
-                this.m_sHandle = pHandle.ToString();
-
-                _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
+			//Load global recordsets
+            string statusConst = "Loading VistA data tables...";
+			setStatusDelegate(statusConst);
+
+            string sCommandText;
+
+            setStatusDelegate(statusConst + " Schedule User");
+            //Schedule User Info
+            DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
+            dtUser.TableName = "SchedulingUser";
+            m_dsGlobal.Tables.Add(dtUser);
+            Debug.Assert(dtUser.Rows.Count == 1);
+
+            // Only one row and one column named "MANAGER". Set local var m_bSchedManager to true if Manager.
+            DataRow rUser = dtUser.Rows[0];
+            Object oUser = rUser["MANAGER"];
+            string sUser = oUser.ToString();
+            m_bSchedManager = (sUser == "YES") ? true : false;
+
+            setStatusDelegate(statusConst + " Access Types");
+            //Get Access Types
+            DataTable dtAccessTypes = _dal.GetAccessTypes();
+            dtAccessTypes.TableName = "AccessTypes";
+            m_dsGlobal.Tables.Add(dtAccessTypes);
+
+            setStatusDelegate(statusConst + " Access Groups");
+            //AccessGroups
+            LoadAccessGroupsTable();
+
+            //Build Primary Key for AccessGroup table
+            DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
+            DataColumn dcKey = dtGroups.Columns["ACCESS_GROUP"];
+            DataColumn[] dcKeys = new DataColumn[1];
+            dcKeys[0] = dcKey;
+            dtGroups.PrimaryKey = dcKeys;
+
+            setStatusDelegate(statusConst + " Access Group Types");
+            //AccessGroupType
+            LoadAccessGroupTypesTable();
+
+            //Build Primary Key for AccessGroupType table
+            DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
+            DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
+            DataColumn[] dcGTKeys = new DataColumn[1];
+            dcGTKeys[0] = dcGTKey;
+            dtAGTypes.PrimaryKey = dcGTKeys;
+
+            //Build Data Relationship between AccessGroupType and AccessTypes tables
+            DataRelation dr = new DataRelation("AccessGroupType",	//Relation Name
+                m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"],	//Parent
+                m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]);	//Child
+            m_dsGlobal.Relations.Add(dr);
+
+            setStatusDelegate(statusConst + " Resource Groups By User");
+            //ResourceGroup Table (Resource Groups by User)
+            LoadResourceGroupTable();
+
+            setStatusDelegate(statusConst + " Resources By User");
+            //Resources by user
+            LoadBSDXResourcesTable();
+
+            //Build Primary Key for Resources table
+            DataColumn[] dc = new DataColumn[1];
+            dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
+            m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
+
+            setStatusDelegate(statusConst + " Group Resources");
+            //GroupResources table
+            LoadGroupResourcesTable();
+
+            //Build Primary Key for ResourceGroup table
+            dc = new DataColumn[1];
+            dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
+            m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
+
+            //Build Data Relationships between ResourceGroup and GroupResources tables
+            dr = new DataRelation("GroupResource",	//Relation Name
+                m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"],	//Parent
+                m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]);	//Child
+            CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
+            m_dsGlobal.Relations.Add(dr);
+
+            setStatusDelegate(statusConst + " Clinics");
+            //HospitalLocation table
+            //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
+            sCommandText = "BSDX HOSPITAL LOCATION";
+            ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
+            Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
+
+            //Build Primary Key for HospitalLocation table
+            dc = new DataColumn[1];
+            DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
+            dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
+            m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
+
+            //Build Data Relationships between Resources and HospitalLocation tables
+            dr = new DataRelation("HospitalLocationResource",	//Relation Name
+                m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],	//Parent
+                m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false);	//Child
+            m_dsGlobal.Relations.Add(dr);
+
+            setStatusDelegate(statusConst + " Schedule User");
+            //Build ScheduleUser table
+            this.LoadScheduleUserTable();
+
+            //Build Primary Key for ScheduleUser table
+            dc = new DataColumn[1];
+            dtTemp = m_dsGlobal.Tables["ScheduleUser"];
+            dc[0] = dtTemp.Columns["USERID"];
+            m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
+
+            setStatusDelegate(statusConst + " Resource User");
+            //Build ResourceUser table
+            this.LoadResourceUserTable();
+
+            //Build Primary Key for ResourceUser table
+            dc = new DataColumn[1];
+            dtTemp = m_dsGlobal.Tables["ResourceUser"];
+            dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
+            m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
+
+            //Create relation between BSDX Resource and BSDX Resource User tables
+            dr = new DataRelation("ResourceUser",	//Relation Name
+                m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"],	//Parent
+                m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]);	//Child
+            m_dsGlobal.Relations.Add(dr);
+
+            setStatusDelegate(statusConst + " Providers");
+            //Build active provider table
+            sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
+            ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
+            Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
+
+            setStatusDelegate(statusConst + " Clinic Stops");
+            //Build the CLINIC_STOP table
+            // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
+            sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
+            ConnectInfo.RPMSDataTable(sCommandText, "ClinicStop", m_dsGlobal);
+            Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
+
+            setStatusDelegate(statusConst + " Holiday");
+            //Build the HOLIDAY table
+            sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
+            ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
+            Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
+
+
+            //Save the xml schema
+            //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
+            //----------------------------------------------
+            
+
+            _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
 
 #if DEBUG
-                _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
+            _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
 #endif 
-				_current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
-				_current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
-				_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
-				_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
-
-				_current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
-				_current.m_ConnectInfo.EventPollingEnabled = true;
-				_current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
-
-				m_ds.Close();
-			}
-			catch (Exception ex)
-			{
-				m_ds.Close();
-				Debug.Write(ex.Message);
-				MessageBox.Show(ex.Message + ex.StackTrace, "Clinical Scheduling Error -- Closing Application");
-				throw ex;
-			}
-		}
-
-        //To write to the console
-        [DllImport("kernel32.dll")]
-        static extern bool AttachConsole(int dwProcessId);
-        private const int ATTACH_PARENT_PROCESS = -1;
-
-		[STAThread()] 
-        static void Main(string[] args)
-		{
-#if DEBUG
-            // Print console messages to console if launched from console
-            // Note: Imported From kernel32.dll
-            AttachConsole(ATTACH_PARENT_PROCESS);
-#endif
-            try
-            {
-                 //Store the current manager
-                _current = new CGDocumentManager();
-                
-                //Get command line options; store in private variables
-                var opset = new OptionSet () {
-                    { "s=", s => _current.m_Server = s },
-                    { "p=", p => _current.m_Port = int.Parse(p) },
-                    { "a=", a => _current.m_AccessCode = a },
-                    { "v=", v => _current.m_VerifyCode = v },
-                    { "e=", e => _current.m_Encoding = e}
-                };
-
-                opset.Parse(args);
-                
-                try
-                {
-                    _current.InitializeApp();
-                }
-                catch (Exception ex)
-                {
-                    Debug.Write(ex.Message);
-                    return;
-                }
-
-                //Create the first empty document
-                CGDocument doc = new CGDocument();
-                doc.DocManager = _current;
-                doc.OnNewDocument();
-                Application.DoEvents();
-
-                //Run the application
-                Application.Run();
-            }
-            catch (Exception ex)
-            {
-                Debug.Write(ex.Message);
-                MessageBox.Show(ex.Message + ex.StackTrace, "CGDocumentManager.Main(): Clinical Scheduling Error -- Closing Application");
-                return;
-            }
-		}
+			_current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
+			_current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
+			_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
+			_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
+
+			_current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
+			_current.m_ConnectInfo.EventPollingEnabled = true;
+			_current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
+
+            //Close Splash Screen
+            closeSplashDelegate();
+			
+		}
+
 
 
@@ -529,169 +655,15 @@
 		public void LoadResourceUserTable(bool bAllUsers)
 		{
-            string sCommandText = "SELECT BMXIEN RESOURCEUSER_ID, RESOURCENAME, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, MODIFY_APPOINTMENTS, USERNAME, INTERNAL[USERNAME] USERID FROM BSDX_RESOURCE_USER"; // WHERE INTERNAL[INSTITUTION]=" + m_ConnectInfo.DUZ2;
+            string sCommandText = @"SELECT BMXIEN RESOURCEUSER_ID, RESOURCENAME, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, MODIFY_APPOINTMENTS, USERNAME, INTERNAL[USERNAME] USERID FROM BSDX_RESOURCE_USER"; // WHERE INTERNAL[INSTITUTION]=" + m_ConnectInfo.DUZ2;
+            
+            if (!bAllUsers)
+            {
+                sCommandText += String.Format(" WHERE INTERNAL[USERNAME] = {0}", m_ConnectInfo.DUZ);
+            }
+
 			ConnectInfo.RPMSDataTable(sCommandText, "ResourceUser", m_dsGlobal);
 			Debug.Write("LoadGlobalRecordsets -- ResourceUser loaded\n");
 		}
 
-		private bool LoadGlobalRecordsets() 
-		{
-			
-            string sCommandText;
-
-            //Schedule User Info
-			DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
-            dtUser.TableName = "SchedulingUser";
-            m_dsGlobal.Tables.Add(dtUser);
-			Debug.Assert(dtUser.Rows.Count == 1);
-
-            // Only one row and one column named "MANAGER". Set local var m_bSchedManager to true if Manager.
-			DataRow rUser = dtUser.Rows[0];
-			Object oUser = rUser["MANAGER"];
-			string sUser = oUser.ToString();
-			m_bSchedManager = (sUser == "YES")?true:false;
-
-            //Get Access Types
-            DataTable dtAccessTypes = _dal.GetAccessTypes();
-            dtAccessTypes.TableName = "AccessTypes";
-            m_dsGlobal.Tables.Add(dtAccessTypes);
-
-			//AccessGroups
-			LoadAccessGroupsTable();
-
-			//Build Primary Key for AccessGroup table
-			DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
-            DataColumn dcKey = dtGroups.Columns["ACCESS_GROUP"];
-            DataColumn[] dcKeys = new DataColumn[1];
-			dcKeys[0] = dcKey;
-			dtGroups.PrimaryKey = dcKeys;
-
-			//AccessGroupType
-			LoadAccessGroupTypesTable();
-
-			//Build Primary Key for AccessGroupType table
-			DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
-			DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
-			DataColumn[] dcGTKeys = new DataColumn[1];
-			dcGTKeys[0] = dcGTKey;
-			dtAGTypes.PrimaryKey = dcGTKeys;
-
-			//Build Data Relationship between AccessGroupType and AccessTypes tables
-			DataRelation dr = new DataRelation("AccessGroupType",	//Relation Name
-				m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"],	//Parent
-				m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]);	//Child
-			m_dsGlobal.Relations.Add(dr);
-
-			//ResourceGroup Table (Resource Groups by User)
-			LoadResourceGroupTable();
-			
-			//Resources by user
-			LoadBSDXResourcesTable();
-
-			//Build Primary Key for Resources table
-			DataColumn[] dc = new DataColumn[1];
-			dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
-			m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
-
-			//GroupResources table
-			LoadGroupResourcesTable();
-
-			//Build Primary Key for ResourceGroup table
-			dc = new DataColumn[1];
-			dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
-			m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
-			
-			//Build Data Relationships between ResourceGroup and GroupResources tables
-			dr = new DataRelation("GroupResource",	//Relation Name
-				m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"],	//Parent
-				m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]);	//Child
-			CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
-			m_dsGlobal.Relations.Add(dr);
-
-			//HospitalLocation table
-			//cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
-			sCommandText = "BSDX HOSPITAL LOCATION";
-			ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
-			Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
-
-			//Build Primary Key for HospitalLocation table
-			dc = new DataColumn[1];
-			DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
-			dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
-			m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
-
-            //smh
-			//LoadClinicSetupTable();
-
-            //smh
-			//Build Primary Key for ClinicSetupParameters table
-			/*dc = new DataColumn[1];
-			dtTemp = m_dsGlobal.Tables["ClinicSetupParameters"];
-			dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
-			m_dsGlobal.Tables["ClinicSetupParameters"].PrimaryKey = dc;
-
-			//Build Data Relationships between ClinicSetupParameters and HospitalLocation tables
-			dr = new DataRelation("HospitalLocationClinic",	//Relation Name
-				m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],	//Parent
-				m_dsGlobal.Tables["ClinicSetupParameters"].Columns["HOSPITAL_LOCATION_ID"], false);	//Child
-			m_dsGlobal.Relations.Add(dr);*/
-            /*SMH
-			dtTemp.Columns.Add("PROVIDER", System.Type.GetType("System.String"), "Parent.DEFAULT_PROVIDER");
-			dtTemp.Columns.Add("CLINIC_STOP", System.Type.GetType("System.String"), "Parent.STOP_CODE_NUMBER");
-			dtTemp.Columns.Add("INACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.INACTIVATE_DATE");
-			dtTemp.Columns.Add("REACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.REACTIVATE_DATE");
-            */
-
-			//Build Data Relationships between Resources and HospitalLocation tables
-			dr = new DataRelation("HospitalLocationResource",	//Relation Name
-				m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],	//Parent
-				m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false);	//Child
-			m_dsGlobal.Relations.Add(dr);
-
-			//Build ScheduleUser table
-			this.LoadScheduleUserTable();
-
-			//Build Primary Key for ScheduleUser table
-			dc = new DataColumn[1];
-			dtTemp = m_dsGlobal.Tables["ScheduleUser"];
-			dc[0] = dtTemp.Columns["USERID"];
-			m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
-
-			//Build ResourceUser table
-			this.LoadResourceUserTable();
-
-			//Build Primary Key for ResourceUser table
-			dc = new DataColumn[1];
-			dtTemp = m_dsGlobal.Tables["ResourceUser"];
-			dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
-			m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
-
-			//Create relation between BSDX Resource and BSDX Resource User tables
-			dr = new DataRelation("ResourceUser",	//Relation Name
-				m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"],	//Parent
-				m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]);	//Child
-			m_dsGlobal.Relations.Add(dr);
-
-			//Build active provider table
-			sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
-			ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
-			Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
-
-			//Build the CLINIC_STOP table
-			// sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
-            sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
-			ConnectInfo.RPMSDataTable(sCommandText, "ClinicStop", m_dsGlobal);
-			Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
-
-			//Build the HOLIDAY table
-			sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
-			ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
-            Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
-
-
-			//Save the xml schema
-			//m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
-
-			return true;
-		}
 
 		public void RegisterDocumentView(CGDocument doc, CGView view)
@@ -792,4 +764,9 @@
 		}
 
+        /// <summary>
+        /// Removes view and Handles Disconnection from Database if no views are left.
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
 		private void ViewClosed(object sender, EventArgs e)
 		{
@@ -996,5 +973,5 @@
 				CloseAll();
 				m_bExitOK = true;
-				_current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();
+				//_current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();//smh redundant
 				this.InitializeApp(true);
 				//Create a new document
@@ -1068,5 +1045,6 @@
 				//System.IntPtr pHandle = this.Handle;
 				RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(ConnectInfo.RPMSDataTable);
-				dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
+				//dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
+                dtOut = rdtd.Invoke(sSQL, sTableName);
 			}
 
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1050)
@@ -192,7 +192,5 @@
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="CGDocumentManager.cs">
-      <SubType>Form</SubType>
-    </Compile>
+    <Compile Include="CGDocumentManager.cs" />
     <Compile Include="CGRange.cs" />
     <Compile Include="CGResource.cs" />
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1050)
@@ -37,5 +37,5 @@
     </RemoteDebugMachine>
     <StartAction>Project</StartAction>
-    <StartArguments>/s=172.16.16.51 /p=9250 /a=s.habiel /v=catdog.55</StartArguments>
+    <StartArguments>/s=10.161.20.25 /p=9280 /a=s.habiel /v=catdog.55</StartArguments>
     <StartPage>
     </StartPage>
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs	(revision 1050)
@@ -13,7 +13,8 @@
 	{
 		private System.Windows.Forms.Label label1;
-        //private System.Windows.Forms.Label lblVersion;
 		private System.Windows.Forms.LinkLabel lnkMail;
 		private System.Windows.Forms.Label lblStatus;
+        private Label lblVersion;
+        private Label label2;
 		/// <summary>
 		/// Required designer variable.
@@ -55,7 +56,10 @@
 		private void InitializeComponent()
 		{
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DSplash));
             this.label1 = new System.Windows.Forms.Label();
             this.lnkMail = new System.Windows.Forms.LinkLabel();
             this.lblStatus = new System.Windows.Forms.Label();
+            this.lblVersion = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
@@ -63,9 +67,9 @@
             // 
             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.label1.Location = new System.Drawing.Point(24, 32);
+            this.label1.Location = new System.Drawing.Point(12, 67);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(448, 40);
+            this.label1.Size = new System.Drawing.Size(464, 40);
             this.label1.TabIndex = 0;
-            this.label1.Text = "VistA Clinical Scheduling";
+            this.label1.Text = "Clinical Scheduling";
             this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
             // 
@@ -80,5 +84,5 @@
             // 
             this.lblStatus.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
-            this.lblStatus.Location = new System.Drawing.Point(88, 160);
+            this.lblStatus.Location = new System.Drawing.Point(80, 159);
             this.lblStatus.Name = "lblStatus";
             this.lblStatus.Size = new System.Drawing.Size(328, 16);
@@ -86,13 +90,37 @@
             this.lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
             // 
+            // lblVersion
+            // 
+            this.lblVersion.AutoSize = true;
+            this.lblVersion.Location = new System.Drawing.Point(210, 117);
+            this.lblVersion.Name = "lblVersion";
+            this.lblVersion.Size = new System.Drawing.Size(52, 13);
+            this.lblVersion.TabIndex = 5;
+            this.lblVersion.Text = "lblVersion";
+            this.lblVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("Book Antiqua", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label2.Location = new System.Drawing.Point(180, 21);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(130, 46);
+            this.label2.TabIndex = 6;
+            this.label2.Text = "VISTA";
+            // 
             // DSplash
             // 
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
             this.ClientSize = new System.Drawing.Size(488, 252);
             this.ControlBox = false;
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.lblVersion);
             this.Controls.Add(this.lblStatus);
             this.Controls.Add(this.lnkMail);
             this.Controls.Add(this.label1);
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.Name = "DSplash";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -100,34 +128,45 @@
             this.Load += new System.EventHandler(this.DSplash_Load);
             this.ResumeLayout(false);
+            this.PerformLayout();
 
 		}
 		#endregion
 
-		public void SetStatus(string sStatus)
+        public delegate void dSetStatus(string sStatus);
+        public delegate void dAny();
+		
+        public void SetStatus(string sStatus)
 		{
-			this.Status = sStatus;
+            if (this.InvokeRequired == true)
+            {
+                dSetStatus d = new dSetStatus(SetStatus);
+                this.Invoke(d, new object[] { sStatus });
+                return;
+            }
+            
+            System.Diagnostics.Debug.Assert(this.InvokeRequired == false);
+			this.lblStatus.Text = sStatus;
+            this.Refresh();
 		}
 
 		private void DSplash_Load(object sender, System.EventArgs e)
 		{
-			//this.lblVersion.Text = "Version " + Application.ProductVersion;
+			this.lblVersion.Text = "Version " + Application.ProductVersion;
 		}
 
-		#region Properties
-		/// <summary>
-		/// Gets or sets the value of the Status displayed on the splash screen
-		/// </summary>
-		public String Status
-		{
-			get
-			{
-				return lblStatus.Text;
-			}
-			set
-			{
-				lblStatus.Text = value;
-			}
-		}
-		#endregion Properties
+        public void RemoteClose()
+        {
+            dAny d = new dAny(this.Close);
+            this.Invoke(d);
+        }
+
+        public void RemoteHide()
+        {
+            dAny d = new dAny(this.Hide);
+            this.Invoke(d);
+        }
 	}
+
+
+    
 }
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.resx
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.resx	(revision 1049)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.resx	(revision 1050)
@@ -118,3 +118,26 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        AAABAAIAICAQAAAAAADoAgAAJgAAABAQEAAAAAAAKAEAAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAAAIAC
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/
+        AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIh3iI
+        iId4iAAAAAAAAAAACId4iIiHeIAiIiIggAAAAAAAAAAAAAgCqqqqoggAAAAAAAAAAACAKqqqqiAIAAiH
+        eId4iIiIAqqqqqIAAIAIh3iHeIiIgCqqqqogAACAAAAAAAAACAKqqqqiAAAAgAAAAAAAAIAqqqqqIAAA
+        AIAAAAAAAAgCqqqqogAAAAgAAAAAAAAAIiIiIiAAAACAAAAA////8AAAAAAAAAAIAAAAAP////8Aqqqq
+        IAAAgAAAAAD/iIj/gCqqqqIACAAAAAAA/4iI/4gCqqqqIIAAAAAAAP//////8AAAAAgAAAAAAAD/////
+        //+IiIiPAAAAAAAA/4iI/4iI/4iI/wAAAAAAAP+IiP+IiP+IiP8AAAAAAAD/////////////AAAAAAAA
+        /////////////wAAAAAAAP+IiP+IiP+IiP8AAAAAAAD/iIj/iIj/iIj/AAAAAAAA/////////////wAA
+        AAAAAP////////////8AAAAAAERERERERERERERERAAAAABEREREREREREREREQAAAAARERERERERERE
+        REREAAAAAERERERERERERERERAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////
+        ///4AAAP+AAAB///gAP//wADgAAAAYAAAAH/+AAB//AAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8AA
+        AD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/////////
+        //8oAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAA
+        AACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAHh4iHgA
+        CAAAAAAAACIiAAh4eIgCqqIIAAAAACqqIAAAAAACqqIAAAAP/wAAAAAAAA+IgKqiAAAAD//4AADwAAAP
+        iPiPiPAAAA//////8AAAD4j4j4jwAAAP//////AAAERERERERAAAREREREREAAAAAAAAAAAA//8AAMAD
+        AAD/gQAAgAAAAP4AAADAAQAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMADAADAAwAA//8AAA==
+</value>
+  </data>
 </root>
