コード例 #1
0
        ///<summary>Inserts one FamilyHealth into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(FamilyHealth familyHealth, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                familyHealth.FamilyHealthNum = ReplicationServers.GetKey("familyhealth", "FamilyHealthNum");
            }
            string command = "INSERT INTO familyhealth (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "FamilyHealthNum,";
            }
            command += "PatNum,Relationship,DiseaseDefNum,PersonName) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(familyHealth.FamilyHealthNum) + ",";
            }
            command +=
                POut.Long(familyHealth.PatNum) + ","
                + POut.Int((int)familyHealth.Relationship) + ","
                + POut.Long(familyHealth.DiseaseDefNum) + ","
                + "'" + POut.String(familyHealth.PersonName) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                familyHealth.FamilyHealthNum = Db.NonQ(command, true);
            }
            return(familyHealth.FamilyHealthNum);
        }
コード例 #2
0
 ///<summary>Inserts one FamilyHealth into the database.  Returns the new priKey.</summary>
 public static long Insert(FamilyHealth familyHealth)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         familyHealth.FamilyHealthNum = DbHelper.GetNextOracleKey("familyhealth", "FamilyHealthNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(familyHealth, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     familyHealth.FamilyHealthNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(familyHealth, false));
     }
 }
コード例 #3
0
        ///<summary>Inserts one FamilyHealth into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(FamilyHealth familyHealth, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO familyhealth (";

            if (!useExistingPK && isRandomKeys)
            {
                familyHealth.FamilyHealthNum = ReplicationServers.GetKeyNoCache("familyhealth", "FamilyHealthNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "FamilyHealthNum,";
            }
            command += "PatNum,Relationship,DiseaseDefNum,PersonName) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(familyHealth.FamilyHealthNum) + ",";
            }
            command +=
                POut.Long(familyHealth.PatNum) + ","
                + POut.Int((int)familyHealth.Relationship) + ","
                + POut.Long(familyHealth.DiseaseDefNum) + ","
                + "'" + POut.String(familyHealth.PersonName) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                familyHealth.FamilyHealthNum = Db.NonQ(command, true, "FamilyHealthNum", "familyHealth");
            }
            return(familyHealth.FamilyHealthNum);
        }
コード例 #4
0
		///<summary>Inserts one FamilyHealth into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(FamilyHealth familyHealth,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				familyHealth.FamilyHealthNum=ReplicationServers.GetKey("familyhealth","FamilyHealthNum");
			}
			string command="INSERT INTO familyhealth (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="FamilyHealthNum,";
			}
			command+="PatNum,Relationship,DiseaseDefNum,PersonName) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(familyHealth.FamilyHealthNum)+",";
			}
			command+=
				     POut.Long  (familyHealth.PatNum)+","
				+    POut.Int   ((int)familyHealth.Relationship)+","
				+    POut.Long  (familyHealth.DiseaseDefNum)+","
				+"'"+POut.String(familyHealth.PersonName)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				familyHealth.FamilyHealthNum=Db.NonQ(command,true);
			}
			return familyHealth.FamilyHealthNum;
		}
コード例 #5
0
        ///<summary>Updates one FamilyHealth in the database.</summary>
        public static void Update(FamilyHealth familyHealth)
        {
            string command = "UPDATE familyhealth SET "
                             + "PatNum         =  " + POut.Long(familyHealth.PatNum) + ", "
                             + "Relationship   =  " + POut.Int((int)familyHealth.Relationship) + ", "
                             + "DiseaseDefNum  =  " + POut.Long(familyHealth.DiseaseDefNum) + ", "
                             + "PersonName     = '" + POut.String(familyHealth.PersonName) + "' "
                             + "WHERE FamilyHealthNum = " + POut.Long(familyHealth.FamilyHealthNum);

            Db.NonQ(command);
        }
コード例 #6
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<FamilyHealth> TableToList(DataTable table){
			List<FamilyHealth> retVal=new List<FamilyHealth>();
			FamilyHealth familyHealth;
			for(int i=0;i<table.Rows.Count;i++) {
				familyHealth=new FamilyHealth();
				familyHealth.FamilyHealthNum= PIn.Long  (table.Rows[i]["FamilyHealthNum"].ToString());
				familyHealth.PatNum         = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				familyHealth.Relationship   = (FamilyRelationship)PIn.Int(table.Rows[i]["Relationship"].ToString());
				familyHealth.DiseaseDefNum  = PIn.Long  (table.Rows[i]["DiseaseDefNum"].ToString());
				familyHealth.PersonName     = PIn.String(table.Rows[i]["PersonName"].ToString());
				retVal.Add(familyHealth);
			}
			return retVal;
		}
コード例 #7
0
 ///<summary>Inserts one FamilyHealth into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(FamilyHealth familyHealth)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(familyHealth, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             familyHealth.FamilyHealthNum = DbHelper.GetNextOracleKey("familyhealth", "FamilyHealthNum");                  //Cacheless method
         }
         return(InsertNoCache(familyHealth, true));
     }
 }
コード例 #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <FamilyHealth> TableToList(DataTable table)
        {
            List <FamilyHealth> retVal = new List <FamilyHealth>();
            FamilyHealth        familyHealth;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                familyHealth = new FamilyHealth();
                familyHealth.FamilyHealthNum = PIn.Long(table.Rows[i]["FamilyHealthNum"].ToString());
                familyHealth.PatNum          = PIn.Long(table.Rows[i]["PatNum"].ToString());
                familyHealth.Relationship    = (FamilyRelationship)PIn.Int(table.Rows[i]["Relationship"].ToString());
                familyHealth.DiseaseDefNum   = PIn.Long(table.Rows[i]["DiseaseDefNum"].ToString());
                familyHealth.PersonName      = PIn.String(table.Rows[i]["PersonName"].ToString());
                retVal.Add(familyHealth);
            }
            return(retVal);
        }
コード例 #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <FamilyHealth> TableToList(DataTable table)
        {
            List <FamilyHealth> retVal = new List <FamilyHealth>();
            FamilyHealth        familyHealth;

            foreach (DataRow row in table.Rows)
            {
                familyHealth = new FamilyHealth();
                familyHealth.FamilyHealthNum = PIn.Long(row["FamilyHealthNum"].ToString());
                familyHealth.PatNum          = PIn.Long(row["PatNum"].ToString());
                familyHealth.Relationship    = (OpenDentBusiness.FamilyRelationship)PIn.Int(row["Relationship"].ToString());
                familyHealth.DiseaseDefNum   = PIn.Long(row["DiseaseDefNum"].ToString());
                familyHealth.PersonName      = PIn.String(row["PersonName"].ToString());
                retVal.Add(familyHealth);
            }
            return(retVal);
        }
コード例 #10
0
        ///<summary>Updates one FamilyHealth 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(FamilyHealth familyHealth, FamilyHealth oldFamilyHealth)
        {
            string command = "";

            if (familyHealth.PatNum != oldFamilyHealth.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(familyHealth.PatNum) + "";
            }
            if (familyHealth.Relationship != oldFamilyHealth.Relationship)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Relationship = " + POut.Int((int)familyHealth.Relationship) + "";
            }
            if (familyHealth.DiseaseDefNum != oldFamilyHealth.DiseaseDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DiseaseDefNum = " + POut.Long(familyHealth.DiseaseDefNum) + "";
            }
            if (familyHealth.PersonName != oldFamilyHealth.PersonName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PersonName = '" + POut.String(familyHealth.PersonName) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE familyhealth SET " + command
                      + " WHERE FamilyHealthNum = " + POut.Long(familyHealth.FamilyHealthNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #11
0
 ///<summary>Returns true if Update(FamilyHealth,FamilyHealth) 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(FamilyHealth familyHealth, FamilyHealth oldFamilyHealth)
 {
     if (familyHealth.PatNum != oldFamilyHealth.PatNum)
     {
         return(true);
     }
     if (familyHealth.Relationship != oldFamilyHealth.Relationship)
     {
         return(true);
     }
     if (familyHealth.DiseaseDefNum != oldFamilyHealth.DiseaseDefNum)
     {
         return(true);
     }
     if (familyHealth.PersonName != oldFamilyHealth.PersonName)
     {
         return(true);
     }
     return(false);
 }
コード例 #12
0
		///<summary>Inserts one FamilyHealth into the database.  Returns the new priKey.</summary>
		public static long Insert(FamilyHealth familyHealth){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				familyHealth.FamilyHealthNum=DbHelper.GetNextOracleKey("familyhealth","FamilyHealthNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(familyHealth,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							familyHealth.FamilyHealthNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(familyHealth,false);
			}
		}
コード例 #13
0
		///<summary>Updates one FamilyHealth 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>
		public static void Update(FamilyHealth familyHealth,FamilyHealth oldFamilyHealth){
			string command="";
			if(familyHealth.PatNum != oldFamilyHealth.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(familyHealth.PatNum)+"";
			}
			if(familyHealth.Relationship != oldFamilyHealth.Relationship) {
				if(command!=""){ command+=",";}
				command+="Relationship = "+POut.Int   ((int)familyHealth.Relationship)+"";
			}
			if(familyHealth.DiseaseDefNum != oldFamilyHealth.DiseaseDefNum) {
				if(command!=""){ command+=",";}
				command+="DiseaseDefNum = "+POut.Long(familyHealth.DiseaseDefNum)+"";
			}
			if(familyHealth.PersonName != oldFamilyHealth.PersonName) {
				if(command!=""){ command+=",";}
				command+="PersonName = '"+POut.String(familyHealth.PersonName)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE familyhealth SET "+command
				+" WHERE FamilyHealthNum = "+POut.Long(familyHealth.FamilyHealthNum);
			Db.NonQ(command);
		}
コード例 #14
0
		///<summary>Updates one FamilyHealth in the database.</summary>
		public static void Update(FamilyHealth familyHealth){
			string command="UPDATE familyhealth SET "
				+"PatNum         =  "+POut.Long  (familyHealth.PatNum)+", "
				+"Relationship   =  "+POut.Int   ((int)familyHealth.Relationship)+", "
				+"DiseaseDefNum  =  "+POut.Long  (familyHealth.DiseaseDefNum)+", "
				+"PersonName     = '"+POut.String(familyHealth.PersonName)+"' "
				+"WHERE FamilyHealthNum = "+POut.Long(familyHealth.FamilyHealthNum);
			Db.NonQ(command);
		}
コード例 #15
0
 ///<summary>Inserts one FamilyHealth into the database.  Returns the new priKey.</summary>
 public static long Insert(FamilyHealth familyHealth)
 {
     return(Insert(familyHealth, false));
 }