///<summary>Inserts one UserodApptView into the database.  Returns the new priKey.</summary>
 public static long Insert(UserodApptView userodApptView)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         userodApptView.UserodApptViewNum = DbHelper.GetNextOracleKey("userodapptview", "UserodApptViewNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(userodApptView, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     userodApptView.UserodApptViewNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(userodApptView, false));
     }
 }
        ///<summary>Inserts one UserodApptView into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(UserodApptView userodApptView, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                userodApptView.UserodApptViewNum = ReplicationServers.GetKey("userodapptview", "UserodApptViewNum");
            }
            string command = "INSERT INTO userodapptview (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "UserodApptViewNum,";
            }
            command += "UserNum,ClinicNum,ApptViewNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(userodApptView.UserodApptViewNum) + ",";
            }
            command +=
                POut.Long(userodApptView.UserNum) + ","
                + POut.Long(userodApptView.ClinicNum) + ","
                + POut.Long(userodApptView.ApptViewNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                userodApptView.UserodApptViewNum = Db.NonQ(command, true, "UserodApptViewNum", "userodApptView");
            }
            return(userodApptView.UserodApptViewNum);
        }
        ///<summary>Inserts one UserodApptView into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(UserodApptView userodApptView, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO userodapptview (";

            if (!useExistingPK && isRandomKeys)
            {
                userodApptView.UserodApptViewNum = ReplicationServers.GetKeyNoCache("userodapptview", "UserodApptViewNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "UserodApptViewNum,";
            }
            command += "UserNum,ClinicNum,ApptViewNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(userodApptView.UserodApptViewNum) + ",";
            }
            command +=
                POut.Long(userodApptView.UserNum) + ","
                + POut.Long(userodApptView.ClinicNum) + ","
                + POut.Long(userodApptView.ApptViewNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                userodApptView.UserodApptViewNum = Db.NonQ(command, true, "UserodApptViewNum", "userodApptView");
            }
            return(userodApptView.UserodApptViewNum);
        }
        ///<summary>Updates one UserodApptView in the database.</summary>
        public static void Update(UserodApptView userodApptView)
        {
            string command = "UPDATE userodapptview SET "
                             + "UserNum          =  " + POut.Long(userodApptView.UserNum) + ", "
                             + "ClinicNum        =  " + POut.Long(userodApptView.ClinicNum) + ", "
                             + "ApptViewNum      =  " + POut.Long(userodApptView.ApptViewNum) + " "
                             + "WHERE UserodApptViewNum = " + POut.Long(userodApptView.UserodApptViewNum);

            Db.NonQ(command);
        }
Beispiel #5
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<UserodApptView> TableToList(DataTable table){
			List<UserodApptView> retVal=new List<UserodApptView>();
			UserodApptView userodApptView;
			for(int i=0;i<table.Rows.Count;i++) {
				userodApptView=new UserodApptView();
				userodApptView.UserodApptViewNum= PIn.Long  (table.Rows[i]["UserodApptViewNum"].ToString());
				userodApptView.UserNum          = PIn.Long  (table.Rows[i]["UserNum"].ToString());
				userodApptView.ClinicNum        = PIn.Long  (table.Rows[i]["ClinicNum"].ToString());
				userodApptView.ApptViewNum      = PIn.Long  (table.Rows[i]["ApptViewNum"].ToString());
				retVal.Add(userodApptView);
			}
			return retVal;
		}
 ///<summary>Inserts one UserodApptView into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(UserodApptView userodApptView)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(userodApptView, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             userodApptView.UserodApptViewNum = DbHelper.GetNextOracleKey("userodapptview", "UserodApptViewNum");                  //Cacheless method
         }
         return(InsertNoCache(userodApptView, true));
     }
 }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <UserodApptView> TableToList(DataTable table)
        {
            List <UserodApptView> retVal = new List <UserodApptView>();
            UserodApptView        userodApptView;

            foreach (DataRow row in table.Rows)
            {
                userodApptView = new UserodApptView();
                userodApptView.UserodApptViewNum = PIn.Long(row["UserodApptViewNum"].ToString());
                userodApptView.UserNum           = PIn.Long(row["UserNum"].ToString());
                userodApptView.ClinicNum         = PIn.Long(row["ClinicNum"].ToString());
                userodApptView.ApptViewNum       = PIn.Long(row["ApptViewNum"].ToString());
                retVal.Add(userodApptView);
            }
            return(retVal);
        }
 ///<summary>Returns true if Update(UserodApptView,UserodApptView) 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(UserodApptView userodApptView, UserodApptView oldUserodApptView)
 {
     if (userodApptView.UserNum != oldUserodApptView.UserNum)
     {
         return(true);
     }
     if (userodApptView.ClinicNum != oldUserodApptView.ClinicNum)
     {
         return(true);
     }
     if (userodApptView.ApptViewNum != oldUserodApptView.ApptViewNum)
     {
         return(true);
     }
     return(false);
 }
        ///<summary>Updates one UserodApptView 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(UserodApptView userodApptView, UserodApptView oldUserodApptView)
        {
            string command = "";

            if (userodApptView.UserNum != oldUserodApptView.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(userodApptView.UserNum) + "";
            }
            if (userodApptView.ClinicNum != oldUserodApptView.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(userodApptView.ClinicNum) + "";
            }
            if (userodApptView.ApptViewNum != oldUserodApptView.ApptViewNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ApptViewNum = " + POut.Long(userodApptView.ApptViewNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE userodapptview SET " + command
                      + " WHERE UserodApptViewNum = " + POut.Long(userodApptView.UserodApptViewNum);
            Db.NonQ(command);
            return(true);
        }
Beispiel #10
0
		///<summary>Inserts one UserodApptView into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(UserodApptView userodApptView,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				userodApptView.UserodApptViewNum=ReplicationServers.GetKey("userodapptview","UserodApptViewNum");
			}
			string command="INSERT INTO userodapptview (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="UserodApptViewNum,";
			}
			command+="UserNum,ClinicNum,ApptViewNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(userodApptView.UserodApptViewNum)+",";
			}
			command+=
				     POut.Long  (userodApptView.UserNum)+","
				+    POut.Long  (userodApptView.ClinicNum)+","
				+    POut.Long  (userodApptView.ApptViewNum)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				userodApptView.UserodApptViewNum=Db.NonQ(command,true);
			}
			return userodApptView.UserodApptViewNum;
		}
Beispiel #11
0
		///<summary>Inserts one UserodApptView into the database.  Returns the new priKey.</summary>
		public static long Insert(UserodApptView userodApptView){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				userodApptView.UserodApptViewNum=DbHelper.GetNextOracleKey("userodapptview","UserodApptViewNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(userodApptView,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							userodApptView.UserodApptViewNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(userodApptView,false);
			}
		}
Beispiel #12
0
		///<summary>Updates one UserodApptView 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(UserodApptView userodApptView,UserodApptView oldUserodApptView){
			string command="";
			if(userodApptView.UserNum != oldUserodApptView.UserNum) {
				if(command!=""){ command+=",";}
				command+="UserNum = "+POut.Long(userodApptView.UserNum)+"";
			}
			if(userodApptView.ClinicNum != oldUserodApptView.ClinicNum) {
				if(command!=""){ command+=",";}
				command+="ClinicNum = "+POut.Long(userodApptView.ClinicNum)+"";
			}
			if(userodApptView.ApptViewNum != oldUserodApptView.ApptViewNum) {
				if(command!=""){ command+=",";}
				command+="ApptViewNum = "+POut.Long(userodApptView.ApptViewNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE userodapptview SET "+command
				+" WHERE UserodApptViewNum = "+POut.Long(userodApptView.UserodApptViewNum);
			Db.NonQ(command);
			return true;
		}
Beispiel #13
0
		///<summary>Updates one UserodApptView in the database.</summary>
		public static void Update(UserodApptView userodApptView){
			string command="UPDATE userodapptview SET "
				+"UserNum          =  "+POut.Long  (userodApptView.UserNum)+", "
				+"ClinicNum        =  "+POut.Long  (userodApptView.ClinicNum)+", "
				+"ApptViewNum      =  "+POut.Long  (userodApptView.ApptViewNum)+" "
				+"WHERE UserodApptViewNum = "+POut.Long(userodApptView.UserodApptViewNum);
			Db.NonQ(command);
		}
 ///<summary>Inserts one UserodApptView into the database.  Returns the new priKey.</summary>
 public static long Insert(UserodApptView userodApptView)
 {
     return(Insert(userodApptView, false));
 }