예제 #1
0
 ///<summary>Inserts one EhrSummaryCcd into the database.  Returns the new priKey.</summary>
 internal static long Insert(EhrSummaryCcd ehrSummaryCcd)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         ehrSummaryCcd.EhrSummaryCcdNum = DbHelper.GetNextOracleKey("ehrsummaryccd", "EhrSummaryCcdNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(ehrSummaryCcd, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     ehrSummaryCcd.EhrSummaryCcdNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(ehrSummaryCcd, false));
     }
 }
예제 #2
0
		///<summary>Inserts one EhrSummaryCcd into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EhrSummaryCcd ehrSummaryCcd,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				ehrSummaryCcd.EhrSummaryCcdNum=ReplicationServers.GetKey("ehrsummaryccd","EhrSummaryCcdNum");
			}
			string command="INSERT INTO ehrsummaryccd (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EhrSummaryCcdNum,";
			}
			command+="PatNum,DateSummary,ContentSummary,EmailAttachNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(ehrSummaryCcd.EhrSummaryCcdNum)+",";
			}
			command+=
				     POut.Long  (ehrSummaryCcd.PatNum)+","
				+    POut.Date  (ehrSummaryCcd.DateSummary)+","
				+    DbHelper.ParamChar+"paramContentSummary,"
				+    POut.Long  (ehrSummaryCcd.EmailAttachNum)+")";
			if(ehrSummaryCcd.ContentSummary==null) {
				ehrSummaryCcd.ContentSummary="";
			}
			OdSqlParameter paramContentSummary=new OdSqlParameter("paramContentSummary",OdDbType.Text,ehrSummaryCcd.ContentSummary);
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command,paramContentSummary);
			}
			else {
				ehrSummaryCcd.EhrSummaryCcdNum=Db.NonQ(command,true,paramContentSummary);
			}
			return ehrSummaryCcd.EhrSummaryCcdNum;
		}
예제 #3
0
 ///<summary>Inserts one EhrSummaryCcd into the database.  Returns the new priKey.</summary>
 internal static long Insert(EhrSummaryCcd ehrSummaryCcd)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         ehrSummaryCcd.EhrSummaryCcdNum=DbHelper.GetNextOracleKey("ehrsummaryccd","EhrSummaryCcdNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(ehrSummaryCcd,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     ehrSummaryCcd.EhrSummaryCcdNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(ehrSummaryCcd,false);
     }
 }
예제 #4
0
        ///<summary>Updates one EhrSummaryCcd 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(EhrSummaryCcd ehrSummaryCcd, EhrSummaryCcd oldEhrSummaryCcd)
        {
            string command = "";

            if (ehrSummaryCcd.PatNum != oldEhrSummaryCcd.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(ehrSummaryCcd.PatNum) + "";
            }
            if (ehrSummaryCcd.DateSummary.Date != oldEhrSummaryCcd.DateSummary.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateSummary = " + POut.Date(ehrSummaryCcd.DateSummary) + "";
            }
            if (ehrSummaryCcd.ContentSummary != oldEhrSummaryCcd.ContentSummary)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ContentSummary = " + DbHelper.ParamChar + "paramContentSummary";
            }
            if (ehrSummaryCcd.EmailAttachNum != oldEhrSummaryCcd.EmailAttachNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EmailAttachNum = " + POut.Long(ehrSummaryCcd.EmailAttachNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (ehrSummaryCcd.ContentSummary == null)
            {
                ehrSummaryCcd.ContentSummary = "";
            }
            OdSqlParameter paramContentSummary = new OdSqlParameter("paramContentSummary", OdDbType.Text, POut.StringParam(ehrSummaryCcd.ContentSummary));

            command = "UPDATE ehrsummaryccd SET " + command
                      + " WHERE EhrSummaryCcdNum = " + POut.Long(ehrSummaryCcd.EhrSummaryCcdNum);
            Db.NonQ(command, paramContentSummary);
            return(true);
        }
예제 #5
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrSummaryCcd> TableToList(DataTable table){
			List<EhrSummaryCcd> retVal=new List<EhrSummaryCcd>();
			EhrSummaryCcd ehrSummaryCcd;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrSummaryCcd=new EhrSummaryCcd();
				ehrSummaryCcd.EhrSummaryCcdNum= PIn.Long  (table.Rows[i]["EhrSummaryCcdNum"].ToString());
				ehrSummaryCcd.PatNum          = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				ehrSummaryCcd.DateSummary     = PIn.Date  (table.Rows[i]["DateSummary"].ToString());
				ehrSummaryCcd.ContentSummary  = PIn.String(table.Rows[i]["ContentSummary"].ToString());
				ehrSummaryCcd.EmailAttachNum  = PIn.Long  (table.Rows[i]["EmailAttachNum"].ToString());
				retVal.Add(ehrSummaryCcd);
			}
			return retVal;
		}
예제 #6
0
 ///<summary>Inserts one EhrSummaryCcd into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrSummaryCcd ehrSummaryCcd)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ehrSummaryCcd, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ehrSummaryCcd.EhrSummaryCcdNum = DbHelper.GetNextOracleKey("ehrsummaryccd", "EhrSummaryCcdNum");                  //Cacheless method
         }
         return(InsertNoCache(ehrSummaryCcd, true));
     }
 }
예제 #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <EhrSummaryCcd> TableToList(DataTable table)
        {
            List <EhrSummaryCcd> retVal = new List <EhrSummaryCcd>();
            EhrSummaryCcd        ehrSummaryCcd;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                ehrSummaryCcd = new EhrSummaryCcd();
                ehrSummaryCcd.EhrSummaryCcdNum = PIn.Long(table.Rows[i]["EhrSummaryCcdNum"].ToString());
                ehrSummaryCcd.PatNum           = PIn.Long(table.Rows[i]["PatNum"].ToString());
                ehrSummaryCcd.DateSummary      = PIn.Date(table.Rows[i]["DateSummary"].ToString());
                ehrSummaryCcd.ContentSummary   = PIn.String(table.Rows[i]["ContentSummary"].ToString());
                retVal.Add(ehrSummaryCcd);
            }
            return(retVal);
        }
예제 #8
0
        ///<summary>Updates one EhrSummaryCcd in the database.</summary>
        internal static void Update(EhrSummaryCcd ehrSummaryCcd)
        {
            string command = "UPDATE ehrsummaryccd SET "
                             + "PatNum          =  " + POut.Long(ehrSummaryCcd.PatNum) + ", "
                             + "DateSummary     =  " + POut.Date(ehrSummaryCcd.DateSummary) + ", "
                             + "ContentSummary  =  " + DbHelper.ParamChar + "paramContentSummary "
                             + "WHERE EhrSummaryCcdNum = " + POut.Long(ehrSummaryCcd.EhrSummaryCcdNum);

            if (ehrSummaryCcd.ContentSummary == null)
            {
                ehrSummaryCcd.ContentSummary = "";
            }
            OdSqlParameter paramContentSummary = new OdSqlParameter("paramContentSummary", OdDbType.Text, ehrSummaryCcd.ContentSummary);

            Db.NonQ(command, paramContentSummary);
        }
예제 #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrSummaryCcd> TableToList(DataTable table)
        {
            List <EhrSummaryCcd> retVal = new List <EhrSummaryCcd>();
            EhrSummaryCcd        ehrSummaryCcd;

            foreach (DataRow row in table.Rows)
            {
                ehrSummaryCcd = new EhrSummaryCcd();
                ehrSummaryCcd.EhrSummaryCcdNum = PIn.Long(row["EhrSummaryCcdNum"].ToString());
                ehrSummaryCcd.PatNum           = PIn.Long(row["PatNum"].ToString());
                ehrSummaryCcd.DateSummary      = PIn.Date(row["DateSummary"].ToString());
                ehrSummaryCcd.ContentSummary   = PIn.String(row["ContentSummary"].ToString());
                ehrSummaryCcd.EmailAttachNum   = PIn.Long(row["EmailAttachNum"].ToString());
                retVal.Add(ehrSummaryCcd);
            }
            return(retVal);
        }
예제 #10
0
        ///<summary>Updates one EhrSummaryCcd 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(EhrSummaryCcd ehrSummaryCcd, EhrSummaryCcd oldEhrSummaryCcd)
        {
            string command = "";

            if (ehrSummaryCcd.PatNum != oldEhrSummaryCcd.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(ehrSummaryCcd.PatNum) + "";
            }
            if (ehrSummaryCcd.DateSummary != oldEhrSummaryCcd.DateSummary)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateSummary = " + POut.Date(ehrSummaryCcd.DateSummary) + "";
            }
            if (ehrSummaryCcd.ContentSummary != oldEhrSummaryCcd.ContentSummary)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ContentSummary = " + DbHelper.ParamChar + "paramContentSummary";
            }
            if (command == "")
            {
                return;
            }
            if (ehrSummaryCcd.ContentSummary == null)
            {
                ehrSummaryCcd.ContentSummary = "";
            }
            OdSqlParameter paramContentSummary = new OdSqlParameter("paramContentSummary", OdDbType.Text, ehrSummaryCcd.ContentSummary);

            command = "UPDATE ehrsummaryccd SET " + command
                      + " WHERE EhrSummaryCcdNum = " + POut.Long(ehrSummaryCcd.EhrSummaryCcdNum);
            Db.NonQ(command, paramContentSummary);
        }
예제 #11
0
 ///<summary>Returns true if Update(EhrSummaryCcd,EhrSummaryCcd) 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(EhrSummaryCcd ehrSummaryCcd, EhrSummaryCcd oldEhrSummaryCcd)
 {
     if (ehrSummaryCcd.PatNum != oldEhrSummaryCcd.PatNum)
     {
         return(true);
     }
     if (ehrSummaryCcd.DateSummary.Date != oldEhrSummaryCcd.DateSummary.Date)
     {
         return(true);
     }
     if (ehrSummaryCcd.ContentSummary != oldEhrSummaryCcd.ContentSummary)
     {
         return(true);
     }
     if (ehrSummaryCcd.EmailAttachNum != oldEhrSummaryCcd.EmailAttachNum)
     {
         return(true);
     }
     return(false);
 }
예제 #12
0
        ///<summary>Inserts one EhrSummaryCcd into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EhrSummaryCcd ehrSummaryCcd, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO ehrsummaryccd (";

            if (!useExistingPK && isRandomKeys)
            {
                ehrSummaryCcd.EhrSummaryCcdNum = ReplicationServers.GetKeyNoCache("ehrsummaryccd", "EhrSummaryCcdNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EhrSummaryCcdNum,";
            }
            command += "PatNum,DateSummary,ContentSummary,EmailAttachNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(ehrSummaryCcd.EhrSummaryCcdNum) + ",";
            }
            command +=
                POut.Long(ehrSummaryCcd.PatNum) + ","
                + POut.Date(ehrSummaryCcd.DateSummary) + ","
                + DbHelper.ParamChar + "paramContentSummary,"
                + POut.Long(ehrSummaryCcd.EmailAttachNum) + ")";
            if (ehrSummaryCcd.ContentSummary == null)
            {
                ehrSummaryCcd.ContentSummary = "";
            }
            OdSqlParameter paramContentSummary = new OdSqlParameter("paramContentSummary", OdDbType.Text, POut.StringParam(ehrSummaryCcd.ContentSummary));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramContentSummary);
            }
            else
            {
                ehrSummaryCcd.EhrSummaryCcdNum = Db.NonQ(command, true, "EhrSummaryCcdNum", "ehrSummaryCcd", paramContentSummary);
            }
            return(ehrSummaryCcd.EhrSummaryCcdNum);
        }
예제 #13
0
        ///<summary>Inserts one EhrSummaryCcd into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EhrSummaryCcd ehrSummaryCcd, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                ehrSummaryCcd.EhrSummaryCcdNum = ReplicationServers.GetKey("ehrsummaryccd", "EhrSummaryCcdNum");
            }
            string command = "INSERT INTO ehrsummaryccd (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EhrSummaryCcdNum,";
            }
            command += "PatNum,DateSummary,ContentSummary,EmailAttachNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(ehrSummaryCcd.EhrSummaryCcdNum) + ",";
            }
            command +=
                POut.Long(ehrSummaryCcd.PatNum) + ","
                + POut.Date(ehrSummaryCcd.DateSummary) + ","
                + DbHelper.ParamChar + "paramContentSummary,"
                + POut.Long(ehrSummaryCcd.EmailAttachNum) + ")";
            if (ehrSummaryCcd.ContentSummary == null)
            {
                ehrSummaryCcd.ContentSummary = "";
            }
            OdSqlParameter paramContentSummary = new OdSqlParameter("paramContentSummary", OdDbType.Text, ehrSummaryCcd.ContentSummary);

            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command, paramContentSummary);
            }
            else
            {
                ehrSummaryCcd.EhrSummaryCcdNum = Db.NonQ(command, true, paramContentSummary);
            }
            return(ehrSummaryCcd.EhrSummaryCcdNum);
        }
예제 #14
0
		///<summary>Updates one EhrSummaryCcd 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(EhrSummaryCcd ehrSummaryCcd,EhrSummaryCcd oldEhrSummaryCcd){
			string command="";
			if(ehrSummaryCcd.PatNum != oldEhrSummaryCcd.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(ehrSummaryCcd.PatNum)+"";
			}
			if(ehrSummaryCcd.DateSummary != oldEhrSummaryCcd.DateSummary) {
				if(command!=""){ command+=",";}
				command+="DateSummary = "+POut.Date(ehrSummaryCcd.DateSummary)+"";
			}
			if(ehrSummaryCcd.ContentSummary != oldEhrSummaryCcd.ContentSummary) {
				if(command!=""){ command+=",";}
				command+="ContentSummary = "+DbHelper.ParamChar+"paramContentSummary";
			}
			if(ehrSummaryCcd.EmailAttachNum != oldEhrSummaryCcd.EmailAttachNum) {
				if(command!=""){ command+=",";}
				command+="EmailAttachNum = "+POut.Long(ehrSummaryCcd.EmailAttachNum)+"";
			}
			if(command==""){
				return false;
			}
			if(ehrSummaryCcd.ContentSummary==null) {
				ehrSummaryCcd.ContentSummary="";
			}
			OdSqlParameter paramContentSummary=new OdSqlParameter("paramContentSummary",OdDbType.Text,ehrSummaryCcd.ContentSummary);
			command="UPDATE ehrsummaryccd SET "+command
				+" WHERE EhrSummaryCcdNum = "+POut.Long(ehrSummaryCcd.EhrSummaryCcdNum);
			Db.NonQ(command,paramContentSummary);
			return true;
		}
예제 #15
0
		///<summary>Updates one EhrSummaryCcd in the database.</summary>
		public static void Update(EhrSummaryCcd ehrSummaryCcd){
			string command="UPDATE ehrsummaryccd SET "
				+"PatNum          =  "+POut.Long  (ehrSummaryCcd.PatNum)+", "
				+"DateSummary     =  "+POut.Date  (ehrSummaryCcd.DateSummary)+", "
				+"ContentSummary  =  "+DbHelper.ParamChar+"paramContentSummary, "
				+"EmailAttachNum  =  "+POut.Long  (ehrSummaryCcd.EmailAttachNum)+" "
				+"WHERE EhrSummaryCcdNum = "+POut.Long(ehrSummaryCcd.EhrSummaryCcdNum);
			if(ehrSummaryCcd.ContentSummary==null) {
				ehrSummaryCcd.ContentSummary="";
			}
			OdSqlParameter paramContentSummary=new OdSqlParameter("paramContentSummary",OdDbType.Text,ehrSummaryCcd.ContentSummary);
			Db.NonQ(command,paramContentSummary);
		}
예제 #16
0
 ///<summary>Inserts one EhrSummaryCcd into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrSummaryCcd ehrSummaryCcd)
 {
     return(Insert(ehrSummaryCcd, false));
 }