예제 #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();
            }
        }
예제 #2
0
        private void butLoad_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = TerminalList[gridMain.GetSelectedIndex()].Copy();

            if (terminal.PatNum != 0)
            {
                if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?"))
                {
                    return;
                }
            }
            long patNum = FormOpenDental.CurPatNum;

            terminal.PatNum = patNum;
            TerminalActives.Update(terminal);
            FillGrid();

            /*
             * else {
             *      //just load up a terminal on this computer in a modal window.  The terminal window itself will handle clearing it from the db when done.
             *      TerminalActives.DeleteAllForComputer(Environment.MachineName);
             *      TerminalActive terminal=new TerminalActive();
             *      terminal.ComputerName=Environment.MachineName;
             *      terminal.PatNum=FormOpenDental.CurPatNum;
             *      TerminalActives.Insert(terminal);
             *      //Still need to start the modal window
             * }*/
        }
예제 #3
0
        ///<summary></summary>
        public static void Insert(TerminalActive te)
        {
            if (PrefB.RandomKeys)
            {
                te.TerminalActiveNum = MiscData.GetKey("terminalactive", "TerminalActiveNum");
            }
            string command = "INSERT INTO terminalactive (";

            if (PrefB.RandomKeys)
            {
                command += "TerminalActiveNum,";
            }
            command += "ComputerName,TerminalStatus,PatNum) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(te.TerminalActiveNum) + "', ";
            }
            command +=
                "'" + POut.PString(te.ComputerName) + "', "
                + "'" + POut.PInt((int)te.TerminalStatus) + "', "
                + "'" + POut.PInt(te.PatNum) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                te.TerminalActiveNum = General.NonQ(command, true);
            }
        }
예제 #4
0
        private void butLoad_Click(object sender, EventArgs e)
        {
            if (listSheets.Items.Count == 0)
            {
                MsgBox.Show(this, "There are no sheets to send to the kiosk for the current patient.");
                return;
            }
            if (gridMain.GetSelectedIndex() == -1 || gridMain.GetSelectedIndex() >= _terminalList.Count)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = _terminalList[gridMain.GetSelectedIndex()];

            if (terminal.PatNum != 0 &&
                !MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their "
                             + "screen.  Continue anyway?"))
            {
                return;
            }
            TerminalActives.SetPatNum(terminal.TerminalActiveNum, _patNumCur);
            Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, Process.GetCurrentProcess().Id);
            FillGrid();
            FillPat();
        }
예제 #5
0
 ///<summary>Inserts one TerminalActive into the database.  Returns the new priKey.</summary>
 internal static long Insert(TerminalActive terminalActive)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         terminalActive.TerminalActiveNum=DbHelper.GetNextOracleKey("terminalactive","TerminalActiveNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(terminalActive,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     terminalActive.TerminalActiveNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(terminalActive,false);
     }
 }
예제 #6
0
 ///<summary>Returns true if Update(TerminalActive,TerminalActive) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(TerminalActive terminalActive, TerminalActive oldTerminalActive)
 {
     if (terminalActive.ComputerName != oldTerminalActive.ComputerName)
     {
         return(true);
     }
     if (terminalActive.TerminalStatus != oldTerminalActive.TerminalStatus)
     {
         return(true);
     }
     if (terminalActive.PatNum != oldTerminalActive.PatNum)
     {
         return(true);
     }
     if (terminalActive.SessionId != oldTerminalActive.SessionId)
     {
         return(true);
     }
     if (terminalActive.ProcessId != oldTerminalActive.ProcessId)
     {
         return(true);
     }
     if (terminalActive.SessionName != oldTerminalActive.SessionName)
     {
         return(true);
     }
     return(false);
 }
예제 #7
0
 ///<summary>Inserts one TerminalActive into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(TerminalActive terminalActive,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         terminalActive.TerminalActiveNum=ReplicationServers.GetKey("terminalactive","TerminalActiveNum");
     }
     string command="INSERT INTO terminalactive (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="TerminalActiveNum,";
     }
     command+="ComputerName,TerminalStatus,PatNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(terminalActive.TerminalActiveNum)+",";
     }
     command+=
          "'"+POut.String(terminalActive.ComputerName)+"',"
         +    POut.Int   ((int)terminalActive.TerminalStatus)+","
         +    POut.Long  (terminalActive.PatNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         terminalActive.TerminalActiveNum=Db.NonQ(command,true);
     }
     return terminalActive.TerminalActiveNum;
 }
예제 #8
0
        ///<summary>Inserts one TerminalActive into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(TerminalActive terminalActive, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO terminalactive (";

            if (!useExistingPK && isRandomKeys)
            {
                terminalActive.TerminalActiveNum = ReplicationServers.GetKeyNoCache("terminalactive", "TerminalActiveNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "TerminalActiveNum,";
            }
            command += "ComputerName,TerminalStatus,PatNum,SessionId,ProcessId,SessionName) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(terminalActive.TerminalActiveNum) + ",";
            }
            command +=
                "'" + POut.String(terminalActive.ComputerName) + "',"
                + POut.Int((int)terminalActive.TerminalStatus) + ","
                + POut.Long(terminalActive.PatNum) + ","
                + POut.Int(terminalActive.SessionId) + ","
                + POut.Int(terminalActive.ProcessId) + ","
                + "'" + POut.String(terminalActive.SessionName) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                terminalActive.TerminalActiveNum = Db.NonQ(command, true, "TerminalActiveNum", "terminalActive");
            }
            return(terminalActive.TerminalActiveNum);
        }
예제 #9
0
 ///<summary>Inserts one TerminalActive into the database.  Returns the new priKey.</summary>
 public static long Insert(TerminalActive terminalActive)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         terminalActive.TerminalActiveNum = DbHelper.GetNextOracleKey("terminalactive", "TerminalActiveNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(terminalActive, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     terminalActive.TerminalActiveNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(terminalActive, false));
     }
 }
예제 #10
0
        ///<summary>Inserts one TerminalActive into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(TerminalActive terminalActive, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                terminalActive.TerminalActiveNum = ReplicationServers.GetKey("terminalactive", "TerminalActiveNum");
            }
            string command = "INSERT INTO terminalactive (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "TerminalActiveNum,";
            }
            command += "ComputerName,TerminalStatus,PatNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(terminalActive.TerminalActiveNum) + ",";
            }
            command +=
                "'" + POut.String(terminalActive.ComputerName) + "',"
                + POut.Int((int)terminalActive.TerminalStatus) + ","
                + POut.Long(terminalActive.PatNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                terminalActive.TerminalActiveNum = Db.NonQ(command, true);
            }
            return(terminalActive.TerminalActiveNum);
        }
예제 #11
0
 private void butDone_Click(object sender, EventArgs e)
 {
     if (IsSimpleMode)
     {
         labelForms.Visible = false;
         listForms.Visible  = false;
         butDone.Visible    = false;
         Sheets.ClearFromTerminal(PatNum);
         PatNum = 0;
         labelThankYou.Visible = true;
     }
     else
     {
         Sheets.ClearFromTerminal(PatNum);
         UnloadPatient();
         //tell the database about it so that the terminal manager can see
         TerminalActive terminal = TerminalActives.GetTerminal(Environment.MachineName);
         if (terminal == null)
         {
             return;
         }
         terminal.PatNum = 0;
         TerminalActives.Update(terminal);
     }
 }
예제 #12
0
        private void menuItemMedical_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = TerminalList[gridMain.GetSelectedIndex()].Copy();

            if (terminal.TerminalStatus == TerminalStatusEnum.Standby)
            {
                MsgBox.Show(this, "Please load a patient onto this terminal first.");
                return;
            }
            //See if the selected patient already has diseases attached
            Disease[] DiseaseList = Diseases.Refresh(terminal.PatNum);
            if (DiseaseList.Length > 0)
            {
                MsgBox.Show(this, "This patient already has diseases attached.  This function is only intended for new patients.  Patient cannot be loaded.");
                return;
            }
            //See if the selected patient already has questions attached

            /*if(Questions.PatHasQuest(terminal.PatNum)) {
             *      MsgBox.Show(this,"This patient already has questions attached.  This function is only intended for new patients.  Patient cannot be loaded.");
             *      return;
             * }*/
            if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?"))
            {
                return;
            }
            terminal.TerminalStatus = TerminalStatusEnum.Medical;
            TerminalActives.Update(terminal);
            FillGrid();
        }
예제 #13
0
        private void butUpdatePatient_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = TerminalList[gridMain.GetSelectedIndex()].Copy();

            if (terminal.TerminalStatus != TerminalStatusEnum.Standby)
            {
                if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?"))
                {
                    return;
                }
            }
            if (FormOpenDental.CurPatNum == 0)
            {
                MsgBox.Show(this, "Please select a patient in the main window first.");
                return;
            }
            //FormPatientSelect FormP=new FormPatientSelect();
            //FormP.ShowDialog();
            //if(FormP.DialogResult!=DialogResult.OK) {
            //	return;
            //}
            //int patNum=
            terminal.PatNum         = FormOpenDental.CurPatNum;
            terminal.TerminalStatus = TerminalStatusEnum.UpdateOnly;
            TerminalActives.Update(terminal);
            FillGrid();
        }
예제 #14
0
        ///<summary>Updates one TerminalActive in the database.</summary>
        internal static void Update(TerminalActive terminalActive)
        {
            string command = "UPDATE terminalactive SET "
                             + "ComputerName     = '" + POut.String(terminalActive.ComputerName) + "', "
                             + "TerminalStatus   =  " + POut.Int((int)terminalActive.TerminalStatus) + ", "
                             + "PatNum           =  " + POut.Long(terminalActive.PatNum) + " "
                             + "WHERE TerminalActiveNum = " + POut.Long(terminalActive.TerminalActiveNum);

            Db.NonQ(command);
        }
예제 #15
0
        ///<summary></summary>
        public static void Update(TerminalActive te)
        {
            string command = "UPDATE terminalactive SET "
                             + "ComputerName = '" + POut.PString(te.ComputerName) + "'"
                             + ",TerminalStatus = '" + POut.PInt((int)te.TerminalStatus) + "'"
                             + ",PatNum = '" + POut.PInt(te.PatNum) + "'"
                             + " WHERE TerminalActiveNum  ='" + POut.PInt(te.TerminalActiveNum) + "'";

            General.NonQ(command);
        }
예제 #16
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<TerminalActive> TableToList(DataTable table){
			List<TerminalActive> retVal=new List<TerminalActive>();
			TerminalActive terminalActive;
			for(int i=0;i<table.Rows.Count;i++) {
				terminalActive=new TerminalActive();
				terminalActive.TerminalActiveNum= PIn.Long  (table.Rows[i]["TerminalActiveNum"].ToString());
				terminalActive.ComputerName     = PIn.String(table.Rows[i]["ComputerName"].ToString());
				terminalActive.TerminalStatus   = (OpenDentBusiness.TerminalStatusEnum)PIn.Int(table.Rows[i]["TerminalStatus"].ToString());
				terminalActive.PatNum           = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				retVal.Add(terminalActive);
			}
			return retVal;
		}
예제 #17
0
 ///<summary>Inserts one TerminalActive into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TerminalActive terminalActive)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(terminalActive, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             terminalActive.TerminalActiveNum = DbHelper.GetNextOracleKey("terminalactive", "TerminalActiveNum");                  //Cacheless method
         }
         return(InsertNoCache(terminalActive, true));
     }
 }
예제 #18
0
        ///<summary>Gets a list of all TerminalActives.  Used by the terminal monitor window and by the terminal window itself.  Data is retrieved at regular short intervals, so functions as a messaging system.</summary>
        private static TerminalActive[] RefreshAndFill(string command)
        {
            DataTable table = General.GetTable(command);

            TerminalActive[] List = new TerminalActive[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new TerminalActive();
                List[i].TerminalActiveNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].ComputerName      = PIn.PString(table.Rows[i][1].ToString());
                List[i].TerminalStatus    = (TerminalStatusEnum)PIn.PInt(table.Rows[i][2].ToString());
                List[i].PatNum            = PIn.PInt(table.Rows[i][3].ToString());
            }
            return(List);
        }
예제 #19
0
        ///<summary>Only if TerminalListenShut.  Occurs every 4 seconds. Checks database for status changes.  Shouldn't happen very often, because it means user will lose all data that they may have entered.</summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            TerminalActive terminal = TerminalActives.GetTerminal(Environment.MachineName);

            if (terminal == null)           //no terminal is supposed to be running here.
            {
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (terminal.PatNum == SheetCur.PatNum)
            {
                return;
            }
            //So terminal.PatNum must either be 0 or be an entirely different patient.
            DialogResult = DialogResult.Cancel;
        }
예제 #20
0
		private void butClear_Click(object sender,EventArgs e) {
			if(gridMain.GetSelectedIndex()==-1) {
				MsgBox.Show(this,"Please select a terminal first.");
				return;
			}
			TerminalActive terminal=TerminalList[gridMain.GetSelectedIndex()].Copy();
			if(terminal.PatNum==0) {
				return;
			}
			if(!MsgBox.Show(this,true,"A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?")) {
				return;
			}
			terminal.PatNum=0;
			TerminalActives.Update(terminal);
			FillGrid();
		}
예제 #21
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <TerminalActive> TableToList(DataTable table)
        {
            List <TerminalActive> retVal = new List <TerminalActive>();
            TerminalActive        terminalActive;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                terminalActive = new TerminalActive();
                terminalActive.TerminalActiveNum = PIn.Long(table.Rows[i]["TerminalActiveNum"].ToString());
                terminalActive.ComputerName      = PIn.String(table.Rows[i]["ComputerName"].ToString());
                terminalActive.TerminalStatus    = (TerminalStatusEnum)PIn.Int(table.Rows[i]["TerminalStatus"].ToString());
                terminalActive.PatNum            = PIn.Long(table.Rows[i]["PatNum"].ToString());
                retVal.Add(terminalActive);
            }
            return(retVal);
        }
예제 #22
0
        private void butDelete_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1 || gridMain.GetSelectedIndex() >= _terminalList.Count)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "A terminal row should not be deleted unless it is showing erroneously and there really is no "
                             + "terminal running on the computer shown.  Continue anyway?"))
            {
                return;
            }
            TerminalActive selectedTerm = _terminalList[gridMain.GetSelectedIndex()];

            TerminalActives.DeleteForCmptrSessionAndId(selectedTerm.ComputerName, selectedTerm.SessionId, processId: selectedTerm.ProcessId);
            Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, Process.GetCurrentProcess().Id);
            FillGrid();
            FillPat();
        }
예제 #23
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <TerminalActive> TableToList(DataTable table)
        {
            List <TerminalActive> retVal = new List <TerminalActive>();
            TerminalActive        terminalActive;

            foreach (DataRow row in table.Rows)
            {
                terminalActive = new TerminalActive();
                terminalActive.TerminalActiveNum = PIn.Long(row["TerminalActiveNum"].ToString());
                terminalActive.ComputerName      = PIn.String(row["ComputerName"].ToString());
                terminalActive.TerminalStatus    = (OpenDentBusiness.TerminalStatusEnum)PIn.Int(row["TerminalStatus"].ToString());
                terminalActive.PatNum            = PIn.Long(row["PatNum"].ToString());
                terminalActive.SessionId         = PIn.Int(row["SessionId"].ToString());
                terminalActive.ProcessId         = PIn.Int(row["ProcessId"].ToString());
                terminalActive.SessionName       = PIn.String(row["SessionName"].ToString());
                retVal.Add(terminalActive);
            }
            return(retVal);
        }
예제 #24
0
 private void FormTerminal_Load(object sender, EventArgs e)
 {
     this.Size               = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
     this.Location           = new Point(0, 0);
     labelConnection.Visible = false;
     if (IsSimpleMode)
     {
         timer1.Enabled      = false;
         textWelcome.Visible = false;
     }
     else
     {
         //tell the database that a terminal is newly active on this computer.
         TerminalActives.DeleteAllForComputer(Environment.MachineName);
         TerminalActive terminal = new TerminalActive();
         terminal.ComputerName = Environment.MachineName;
         TerminalActives.Insert(terminal);
         UnloadPatient();
         //do not load a patient
     }
 }
예제 #25
0
        /*private void menuItemQuestions_Click(object sender,EventArgs e) {
         *      if(gridMain.GetSelectedIndex()==-1) {
         *              MsgBox.Show(this,"Please select a terminal first.");
         *              return;
         *      }
         *      TerminalActive terminal=TerminalList[gridMain.GetSelectedIndex()].Copy();
         *      if(terminal.TerminalStatus==TerminalStatusEnum.Standby) {
         *              MsgBox.Show(this,"Please load a patient onto this terminal first.");
         *              return;
         *      }
         *      //See if the selected patient already has questions attached
         *      if(Questions.PatHasQuest(terminal.PatNum)) {
         *              MsgBox.Show(this,"This patient already has questions attached.  This function is only intended for new patients.  Patient cannot be loaded.");
         *              return;
         *      }
         *      if(!MsgBox.Show(this,true,"A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?")) {
         *              return;
         *      }
         *      terminal.TerminalStatus=TerminalStatusEnum.Questions;
         *      terminal.Update();
         *      FillGrid();
         * }*/

        private void menuItemUpdateOnly_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = TerminalList[gridMain.GetSelectedIndex()].Copy();

            if (terminal.TerminalStatus == TerminalStatusEnum.Standby)
            {
                MsgBox.Show(this, "Please load a patient onto this terminal first.");
                return;
            }
            if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  Continue anyway?"))
            {
                return;
            }
            terminal.TerminalStatus = TerminalStatusEnum.UpdateOnly;
            TerminalActives.Update(terminal);
            FillGrid();
        }
예제 #26
0
        private void butClear_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1 || gridMain.GetSelectedIndex() >= _terminalList.Count)
            {
                MsgBox.Show(this, "Please select a terminal first.");
                return;
            }
            TerminalActive terminal = _terminalList[gridMain.GetSelectedIndex()];

            if (terminal.PatNum == 0)
            {
                return;
            }
            if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their screen.  "
                             + "Continue anyway?"))
            {
                return;
            }
            TerminalActives.SetPatNum(terminal.TerminalActiveNum, 0);
            Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, Process.GetCurrentProcess().Id);
            FillGrid();
            FillPat();
        }
예제 #27
0
        ///<summary>Updates one TerminalActive in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(TerminalActive terminalActive, TerminalActive oldTerminalActive)
        {
            string command = "";

            if (terminalActive.ComputerName != oldTerminalActive.ComputerName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ComputerName = '" + POut.String(terminalActive.ComputerName) + "'";
            }
            if (terminalActive.TerminalStatus != oldTerminalActive.TerminalStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TerminalStatus = " + POut.Int((int)terminalActive.TerminalStatus) + "";
            }
            if (terminalActive.PatNum != oldTerminalActive.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(terminalActive.PatNum) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE terminalactive SET " + command
                      + " WHERE TerminalActiveNum = " + POut.Long(terminalActive.TerminalActiveNum);
            Db.NonQ(command);
        }
예제 #28
0
        ///<summary>Used in both modes.  Loads the list of sheets into the listbox.  Then launches the first sheet and goes through the sequence of sheets.
        ///If user clicks cancel, the seqeunce will exit.  If NOT IsSimpleMode, then the TerminalManager can also send a signal to immediately terminate
        ///the sequence.  If PatNum is 0, this will unload the patient by making the form list not visible and the welcome message visible.</summary>
        private void LoadPatient(bool isRefreshOnly)
        {
            TerminalActive terminal = null;

            _listSheets = new List <Sheet>();
            Process processCur = Process.GetCurrentProcess();

            if (IsSimpleMode)
            {
                if (PatNum > 0)
                {
                    _listSheets = Sheets.GetForTerminal(PatNum);
                }
            }
            else              //NOT IsSimpleMode
            {
                try{
                    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)
                    Close();                    //signal sent in form closing
                    return;
                }
                if (terminal.PatNum > 0)
                {
                    _listSheets = Sheets.GetForTerminal(terminal.PatNum);
                }
                if (_listSheets.Count == 0)               //either terminal.PatNum is 0 or no sheets for pat
                {
                    labelWelcome.Visible = true;
                    labelForms.Visible   = false;
                    listForms.Visible    = false;
                    butDone.Visible      = false;
                    if (terminal.PatNum > 0)                   //pat loaded but no sheets to show, unload pat, update db, send signal
                    {
                        TerminalActives.SetPatNum(terminal.TerminalActiveNum, 0);
                        Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id);
                    }
                    PatNum = 0;
                    if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                    {
                        _formSheetFillEdit.ForceClose();
                    }
                    return;
                }
            }
            //we have a patient loaded who has some sheets to show in the terminal
            labelWelcome.Visible = false;
            labelForms.Visible   = true;
            listForms.Visible    = true;
            butDone.Visible      = true;
            listForms.Items.Clear();
            _listSheets.ForEach(x => listForms.Items.Add(x.Description));
            if (!IsSimpleMode)
            {
                if (PatNum == terminal.PatNum)
                {
                    return;                    //if the pat was not cleared or replaced just return, if sheets are currently being displayed (loop below), continue displaying them
                }
                //PatNum is changed, set it to the db terminalactive and signal others, then begin displaying sheets (loop below)
                PatNum = terminal.PatNum;
                if (_formSheetFillEdit != null && !_formSheetFillEdit.IsDisposed)
                {
                    _formSheetFillEdit.ForceClose();
                }
                Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id);
            }
            if (!isRefreshOnly)
            {
                AutoShowSheets();
            }
        }
예제 #29
0
        ///<summary></summary>
        public static void Delete(TerminalActive te)
        {
            string command = "DELETE FROM terminalactive WHERE TerminalActiveNum =" + POut.PInt(te.TerminalActiveNum);

            General.NonQ(command);
        }
예제 #30
0
        private void FormTerminal_Load(object sender, EventArgs e)
        {
            Size     = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
            Location = new Point(0, 0);
            labelConnection.Visible = false;
            _listSheets             = new List <Sheet>();
            if (IsSimpleMode)
            {
                //PatNum set externally (in FormPatientForms)
                return;
            }
            //NOT SimpleMode from here down
            Process processCur = Process.GetCurrentProcess();

            //Delete all terminalactives for this computer, except new one, based on CompName and SessionID
            TerminalActives.DeleteForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, excludeId: processCur.Id);
            string clientName = null;
            string userName   = null;

            try {
                clientName = Environment.GetEnvironmentVariable("ClientName");
                userName   = Environment.GetEnvironmentVariable("UserName");
            }
            catch (Exception) {
                //user may not have permission to access environment variables or another error could happen
            }
            if (string.IsNullOrWhiteSpace(clientName))
            {
                //ClientName only set for remote sessions, try to find suitable replacement.
                clientName = userName;
                if (processCur.SessionId < 2 || string.IsNullOrWhiteSpace(userName))
                {
                    //if sessionId is 0 or 1, this is not a remote session, use MachineName
                    clientName = Environment.MachineName;
                }
            }
            if (string.IsNullOrWhiteSpace(clientName) || TerminalActives.IsCompClientNameInUse(Environment.MachineName, clientName))
            {
                InputBox iBox = new InputBox("Please enter a unique name to identify this kiosk.");
                iBox.setTitle(Lan.g(this, "Kiosk Session Name"));
                iBox.ShowDialog();
                while (iBox.DialogResult == DialogResult.OK && TerminalActives.IsCompClientNameInUse(Environment.MachineName, iBox.textResult.Text))
                {
                    MsgBox.Show(this, "The name entered is invalid or already in use.");
                    iBox.ShowDialog();
                }
                if (iBox.DialogResult != DialogResult.OK)
                {
                    DialogResult = DialogResult.Cancel;
                    return;                    //not allowed to enter kiosk mode unless a unique human-readable name is entered for this computer session
                }
                clientName = iBox.textResult.Text;
            }
            //if we get here, we have a SessionId (which could be 0 if not in a remote session) and a unique client name for this kiosk
            TerminalActive terminal = new TerminalActive();

            terminal.ComputerName = Environment.MachineName;
            terminal.SessionId    = processCur.SessionId;
            terminal.SessionName  = clientName;
            terminal.ProcessId    = processCur.Id;
            TerminalActives.Insert(terminal);                                          //tell the database that a terminal is newly active on this computer
            Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id); //signal FormTerminalManager to re-fill grids
            timer1.Enabled = true;
        }
예제 #31
0
 public SheetDevice(TerminalActive kiosk)
 {
     _computerKiosk = kiosk;
 }
예제 #32
0
 ///<summary>Inserts one TerminalActive into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TerminalActive terminalActive)
 {
     return(InsertNoCache(terminalActive, false));
 }
예제 #33
0
		///<summary>Updates one TerminalActive in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(TerminalActive terminalActive,TerminalActive oldTerminalActive){
			string command="";
			if(terminalActive.ComputerName != oldTerminalActive.ComputerName) {
				if(command!=""){ command+=",";}
				command+="ComputerName = '"+POut.String(terminalActive.ComputerName)+"'";
			}
			if(terminalActive.TerminalStatus != oldTerminalActive.TerminalStatus) {
				if(command!=""){ command+=",";}
				command+="TerminalStatus = "+POut.Int   ((int)terminalActive.TerminalStatus)+"";
			}
			if(terminalActive.PatNum != oldTerminalActive.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(terminalActive.PatNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE terminalactive SET "+command
				+" WHERE TerminalActiveNum = "+POut.Long(terminalActive.TerminalActiveNum);
			Db.NonQ(command);
			return true;
		}
예제 #34
0
		///<summary>Updates one TerminalActive in the database.</summary>
		public static void Update(TerminalActive terminalActive){
			string command="UPDATE terminalactive SET "
				+"ComputerName     = '"+POut.String(terminalActive.ComputerName)+"', "
				+"TerminalStatus   =  "+POut.Int   ((int)terminalActive.TerminalStatus)+", "
				+"PatNum           =  "+POut.Long  (terminalActive.PatNum)+" "
				+"WHERE TerminalActiveNum = "+POut.Long(terminalActive.TerminalActiveNum);
			Db.NonQ(command);
		}
예제 #35
0
        ///<summary>Updates one TerminalActive in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(TerminalActive terminalActive, TerminalActive oldTerminalActive)
        {
            string command = "";

            if (terminalActive.ComputerName != oldTerminalActive.ComputerName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ComputerName = '" + POut.String(terminalActive.ComputerName) + "'";
            }
            if (terminalActive.TerminalStatus != oldTerminalActive.TerminalStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TerminalStatus = " + POut.Int((int)terminalActive.TerminalStatus) + "";
            }
            if (terminalActive.PatNum != oldTerminalActive.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(terminalActive.PatNum) + "";
            }
            if (terminalActive.SessionId != oldTerminalActive.SessionId)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SessionId = " + POut.Int(terminalActive.SessionId) + "";
            }
            if (terminalActive.ProcessId != oldTerminalActive.ProcessId)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcessId = " + POut.Int(terminalActive.ProcessId) + "";
            }
            if (terminalActive.SessionName != oldTerminalActive.SessionName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SessionName = '" + POut.String(terminalActive.SessionName) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE terminalactive SET " + command
                      + " WHERE TerminalActiveNum = " + POut.Long(terminalActive.TerminalActiveNum);
            Db.NonQ(command);
            return(true);
        }