Example #1
0
		///<summary>Inserts one EhrLabNote into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EhrLabNote ehrLabNote,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				ehrLabNote.EhrLabNoteNum=ReplicationServers.GetKey("ehrlabnote","EhrLabNoteNum");
			}
			string command="INSERT INTO ehrlabnote (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EhrLabNoteNum,";
			}
			command+="EhrLabNum,EhrLabResultNum,Comments) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(ehrLabNote.EhrLabNoteNum)+",";
			}
			command+=
				     POut.Long  (ehrLabNote.EhrLabNum)+","
				+    POut.Long  (ehrLabNote.EhrLabResultNum)+","
				+    DbHelper.ParamChar+"paramComments)";
			if(ehrLabNote.Comments==null) {
				ehrLabNote.Comments="";
			}
			OdSqlParameter paramComments=new OdSqlParameter("paramComments",OdDbType.Text,ehrLabNote.Comments);
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command,paramComments);
			}
			else {
				ehrLabNote.EhrLabNoteNum=Db.NonQ(command,true,paramComments);
			}
			return ehrLabNote.EhrLabNoteNum;
		}
Example #2
0
 ///<summary>Inserts one EhrLabNote into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrLabNote ehrLabNote)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         ehrLabNote.EhrLabNoteNum = DbHelper.GetNextOracleKey("ehrlabnote", "EhrLabNoteNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(ehrLabNote, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     ehrLabNote.EhrLabNoteNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(ehrLabNote, false));
     }
 }
Example #3
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrLabNote> TableToList(DataTable table){
			List<EhrLabNote> retVal=new List<EhrLabNote>();
			EhrLabNote ehrLabNote;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrLabNote=new EhrLabNote();
				ehrLabNote.EhrLabNoteNum  = PIn.Long  (table.Rows[i]["EhrLabNoteNum"].ToString());
				ehrLabNote.EhrLabNum      = PIn.Long  (table.Rows[i]["EhrLabNum"].ToString());
				ehrLabNote.EhrLabResultNum= PIn.Long  (table.Rows[i]["EhrLabResultNum"].ToString());
				ehrLabNote.Comments       = PIn.String(table.Rows[i]["Comments"].ToString());
				retVal.Add(ehrLabNote);
			}
			return retVal;
		}
Example #4
0
 ///<summary>Inserts one EhrLabNote into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrLabNote ehrLabNote)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ehrLabNote, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ehrLabNote.EhrLabNoteNum = DbHelper.GetNextOracleKey("ehrlabnote", "EhrLabNoteNum");                  //Cacheless method
         }
         return(InsertNoCache(ehrLabNote, true));
     }
 }
Example #5
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrLabNote> TableToList(DataTable table)
        {
            List <EhrLabNote> retVal = new List <EhrLabNote>();
            EhrLabNote        ehrLabNote;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                ehrLabNote = new EhrLabNote();
                ehrLabNote.EhrLabNoteNum   = PIn.Long(table.Rows[i]["EhrLabNoteNum"].ToString());
                ehrLabNote.EhrLabNum       = PIn.Long(table.Rows[i]["EhrLabNum"].ToString());
                ehrLabNote.EhrLabResultNum = PIn.Long(table.Rows[i]["EhrLabResultNum"].ToString());
                ehrLabNote.Comments        = PIn.String(table.Rows[i]["Comments"].ToString());
                retVal.Add(ehrLabNote);
            }
            return(retVal);
        }
Example #6
0
        ///<summary>Updates one EhrLabNote in the database.</summary>
        public static void Update(EhrLabNote ehrLabNote)
        {
            string command = "UPDATE ehrlabnote SET "
                             + "EhrLabNum      =  " + POut.Long(ehrLabNote.EhrLabNum) + ", "
                             + "EhrLabResultNum=  " + POut.Long(ehrLabNote.EhrLabResultNum) + ", "
                             + "Comments       =  " + DbHelper.ParamChar + "paramComments "
                             + "WHERE EhrLabNoteNum = " + POut.Long(ehrLabNote.EhrLabNoteNum);

            if (ehrLabNote.Comments == null)
            {
                ehrLabNote.Comments = "";
            }
            OdSqlParameter paramComments = new OdSqlParameter("paramComments", OdDbType.Text, ehrLabNote.Comments);

            Db.NonQ(command, paramComments);
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrLabNote> TableToList(DataTable table)
        {
            List <EhrLabNote> retVal = new List <EhrLabNote>();
            EhrLabNote        ehrLabNote;

            foreach (DataRow row in table.Rows)
            {
                ehrLabNote = new EhrLabNote();
                ehrLabNote.EhrLabNoteNum   = PIn.Long(row["EhrLabNoteNum"].ToString());
                ehrLabNote.EhrLabNum       = PIn.Long(row["EhrLabNum"].ToString());
                ehrLabNote.EhrLabResultNum = PIn.Long(row["EhrLabResultNum"].ToString());
                ehrLabNote.Comments        = PIn.String(row["Comments"].ToString());
                retVal.Add(ehrLabNote);
            }
            return(retVal);
        }
 ///<summary>Returns true if Update(EhrLabNote,EhrLabNote) 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(EhrLabNote ehrLabNote, EhrLabNote oldEhrLabNote)
 {
     if (ehrLabNote.EhrLabNum != oldEhrLabNote.EhrLabNum)
     {
         return(true);
     }
     if (ehrLabNote.EhrLabResultNum != oldEhrLabNote.EhrLabResultNum)
     {
         return(true);
     }
     if (ehrLabNote.Comments != oldEhrLabNote.Comments)
     {
         return(true);
     }
     return(false);
 }
        ///<summary>Updates one EhrLabNote 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(EhrLabNote ehrLabNote, EhrLabNote oldEhrLabNote)
        {
            string command = "";

            if (ehrLabNote.EhrLabNum != oldEhrLabNote.EhrLabNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EhrLabNum = " + POut.Long(ehrLabNote.EhrLabNum) + "";
            }
            if (ehrLabNote.EhrLabResultNum != oldEhrLabNote.EhrLabResultNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EhrLabResultNum = " + POut.Long(ehrLabNote.EhrLabResultNum) + "";
            }
            if (ehrLabNote.Comments != oldEhrLabNote.Comments)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Comments = " + DbHelper.ParamChar + "paramComments";
            }
            if (command == "")
            {
                return(false);
            }
            if (ehrLabNote.Comments == null)
            {
                ehrLabNote.Comments = "";
            }
            OdSqlParameter paramComments = new OdSqlParameter("paramComments", OdDbType.Text, POut.StringParam(ehrLabNote.Comments));

            command = "UPDATE ehrlabnote SET " + command
                      + " WHERE EhrLabNoteNum = " + POut.Long(ehrLabNote.EhrLabNoteNum);
            Db.NonQ(command, paramComments);
            return(true);
        }
Example #10
0
        ///<summary>Inserts one EhrLabNote into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EhrLabNote ehrLabNote, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO ehrlabnote (";

            if (!useExistingPK && isRandomKeys)
            {
                ehrLabNote.EhrLabNoteNum = ReplicationServers.GetKeyNoCache("ehrlabnote", "EhrLabNoteNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EhrLabNoteNum,";
            }
            command += "EhrLabNum,EhrLabResultNum,Comments) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(ehrLabNote.EhrLabNoteNum) + ",";
            }
            command +=
                POut.Long(ehrLabNote.EhrLabNum) + ","
                + POut.Long(ehrLabNote.EhrLabResultNum) + ","
                + DbHelper.ParamChar + "paramComments)";
            if (ehrLabNote.Comments == null)
            {
                ehrLabNote.Comments = "";
            }
            OdSqlParameter paramComments = new OdSqlParameter("paramComments", OdDbType.Text, POut.StringParam(ehrLabNote.Comments));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramComments);
            }
            else
            {
                ehrLabNote.EhrLabNoteNum = Db.NonQ(command, true, "EhrLabNoteNum", "ehrLabNote", paramComments);
            }
            return(ehrLabNote.EhrLabNoteNum);
        }
Example #11
0
        ///<summary>Inserts one EhrLabNote into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EhrLabNote ehrLabNote, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                ehrLabNote.EhrLabNoteNum = ReplicationServers.GetKey("ehrlabnote", "EhrLabNoteNum");
            }
            string command = "INSERT INTO ehrlabnote (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EhrLabNoteNum,";
            }
            command += "EhrLabNum,EhrLabResultNum,Comments) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(ehrLabNote.EhrLabNoteNum) + ",";
            }
            command +=
                POut.Long(ehrLabNote.EhrLabNum) + ","
                + POut.Long(ehrLabNote.EhrLabResultNum) + ","
                + DbHelper.ParamChar + "paramComments)";
            if (ehrLabNote.Comments == null)
            {
                ehrLabNote.Comments = "";
            }
            OdSqlParameter paramComments = new OdSqlParameter("paramComments", OdDbType.Text, ehrLabNote.Comments);

            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command, paramComments);
            }
            else
            {
                ehrLabNote.EhrLabNoteNum = Db.NonQ(command, true, paramComments);
            }
            return(ehrLabNote.EhrLabNoteNum);
        }
Example #12
0
		///<summary>Inserts one EhrLabNote into the database.  Returns the new priKey.</summary>
		public static long Insert(EhrLabNote ehrLabNote){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				ehrLabNote.EhrLabNoteNum=DbHelper.GetNextOracleKey("ehrlabnote","EhrLabNoteNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(ehrLabNote,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							ehrLabNote.EhrLabNoteNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(ehrLabNote,false);
			}
		}
Example #13
0
		///<summary>Updates one EhrLabNote 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(EhrLabNote ehrLabNote,EhrLabNote oldEhrLabNote){
			string command="";
			if(ehrLabNote.EhrLabNum != oldEhrLabNote.EhrLabNum) {
				if(command!=""){ command+=",";}
				command+="EhrLabNum = "+POut.Long(ehrLabNote.EhrLabNum)+"";
			}
			if(ehrLabNote.EhrLabResultNum != oldEhrLabNote.EhrLabResultNum) {
				if(command!=""){ command+=",";}
				command+="EhrLabResultNum = "+POut.Long(ehrLabNote.EhrLabResultNum)+"";
			}
			if(ehrLabNote.Comments != oldEhrLabNote.Comments) {
				if(command!=""){ command+=",";}
				command+="Comments = "+DbHelper.ParamChar+"paramComments";
			}
			if(command==""){
				return false;
			}
			if(ehrLabNote.Comments==null) {
				ehrLabNote.Comments="";
			}
			OdSqlParameter paramComments=new OdSqlParameter("paramComments",OdDbType.Text,ehrLabNote.Comments);
			command="UPDATE ehrlabnote SET "+command
				+" WHERE EhrLabNoteNum = "+POut.Long(ehrLabNote.EhrLabNoteNum);
			Db.NonQ(command,paramComments);
			return true;
		}
Example #14
0
		///<summary>Updates one EhrLabNote in the database.</summary>
		public static void Update(EhrLabNote ehrLabNote){
			string command="UPDATE ehrlabnote SET "
				+"EhrLabNum      =  "+POut.Long  (ehrLabNote.EhrLabNum)+", "
				+"EhrLabResultNum=  "+POut.Long  (ehrLabNote.EhrLabResultNum)+", "
				+"Comments       =  "+DbHelper.ParamChar+"paramComments "
				+"WHERE EhrLabNoteNum = "+POut.Long(ehrLabNote.EhrLabNoteNum);
			if(ehrLabNote.Comments==null) {
				ehrLabNote.Comments="";
			}
			OdSqlParameter paramComments=new OdSqlParameter("paramComments",OdDbType.Text,ehrLabNote.Comments);
			Db.NonQ(command,paramComments);
		}
Example #15
0
 ///<summary>Inserts one EhrLabNote into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrLabNote ehrLabNote)
 {
     return(Insert(ehrLabNote, false));
 }