Example #1
0
        ///<summary>Only in nonSimpleMode.  Occurs every 4 seconds. Checks the database to verify that this kiosk should still be running and that the
        ///correct patient's forms are loaded.  If there shouldn't be forms loaded, clears the forms.  If this kiosk (terminalactive row) has been deleted
        ///then this form is closed.  If FormSheetFillEdit is visible, signals that form to force it closed (user will lose any unsaved data).</summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            TerminalActive terminal = null;

            try{
                Process processCur = Process.GetCurrentProcess();
                terminal = TerminalActives.GetForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, processCur.Id);
                labelConnection.Visible = false;
            }
            catch (Exception) {           //SocketException if db connection gets lost.
                labelConnection.Visible = true;
                return;
            }
            if (terminal == null)
            {
                //this terminal shouldn't be running, receptionist must've deleted this kiosk, close the form (causes application exit if NOT IsSimpleMode)
                if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                {
                    _formSheetFillEdit.ForceClose();
                }
                Close();
                return;
            }
            if (_formSheetFillEdit == null || _formSheetFillEdit.IsDisposed)
            {
                return;
            }
            List <Sheet> listSheets = Sheets.GetForTerminal(terminal.PatNum);

            if (terminal.PatNum == 0 || terminal.PatNum != PatNum || listSheets.Count == 0 || listSheets.All(x => x.SheetNum != _formSheetFillEdit.SheetCur.SheetNum))
            {
                //patient has been changed or cleared, or there are no forms to fill for the selected patient, force FormSheetFillEdit closed if open
                _formSheetFillEdit.ForceClose();
            }
        }