Example #1
0
 ///<summary>Inserts one ToothGridDef into the database.  Returns the new priKey.</summary>
 public static long Insert(ToothGridDef toothGridDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         toothGridDef.ToothGridDefNum = DbHelper.GetNextOracleKey("toothgriddef", "ToothGridDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(toothGridDef, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     toothGridDef.ToothGridDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(toothGridDef, false));
     }
 }
        ///<summary>Updates one ToothGridDef in the database.</summary>
        public static void Update(ToothGridDef toothGridDef)
        {
            string command = "UPDATE toothgriddef SET "
                             + "SheetFieldDefNum=  " + POut.Long(toothGridDef.SheetFieldDefNum) + ", "
                             + "NameInternal    = '" + POut.String(toothGridDef.NameInternal) + "', "
                             + "NameShowing     = '" + POut.String(toothGridDef.NameShowing) + "', "
                             + "CellType        =  " + POut.Int((int)toothGridDef.CellType) + ", "
                             + "ItemOrder       =  " + POut.Int(toothGridDef.ItemOrder) + ", "
                             + "ColumnWidth     =  " + POut.Int(toothGridDef.ColumnWidth) + ", "
                             + "CodeNum         =  " + POut.Long(toothGridDef.CodeNum) + ", "
                             + "ProcStatus      =  " + POut.Int((int)toothGridDef.ProcStatus) + " "
                             + "WHERE ToothGridDefNum = " + POut.Long(toothGridDef.ToothGridDefNum);

            Db.NonQ(command);
        }
Example #3
0
 ///<summary>Inserts one ToothGridDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ToothGridDef toothGridDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(toothGridDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             toothGridDef.ToothGridDefNum = DbHelper.GetNextOracleKey("toothgriddef", "ToothGridDefNum");                  //Cacheless method
         }
         return(InsertNoCache(toothGridDef, true));
     }
 }
Example #4
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ToothGridDef> TableToList(DataTable table){
			List<ToothGridDef> retVal=new List<ToothGridDef>();
			ToothGridDef toothGridDef;
			for(int i=0;i<table.Rows.Count;i++) {
				toothGridDef=new ToothGridDef();
				toothGridDef.ToothGridDefNum = PIn.Long  (table.Rows[i]["ToothGridDefNum"].ToString());
				toothGridDef.SheetFieldDefNum= PIn.Long  (table.Rows[i]["SheetFieldDefNum"].ToString());
				toothGridDef.NameInternal    = PIn.String(table.Rows[i]["NameInternal"].ToString());
				toothGridDef.NameShowing     = PIn.String(table.Rows[i]["NameShowing"].ToString());
				toothGridDef.CellType        = (OpenDentBusiness.ToothGridCellType)PIn.Int(table.Rows[i]["CellType"].ToString());
				toothGridDef.ItemOrder       = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				toothGridDef.ColumnWidth     = PIn.Int   (table.Rows[i]["ColumnWidth"].ToString());
				toothGridDef.CodeNum         = PIn.Long  (table.Rows[i]["CodeNum"].ToString());
				toothGridDef.ProcStatus      = (OpenDentBusiness.ProcStat)PIn.Int(table.Rows[i]["ProcStatus"].ToString());
				retVal.Add(toothGridDef);
			}
			return retVal;
		}
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ToothGridDef> TableToList(DataTable table)
        {
            List <ToothGridDef> retVal = new List <ToothGridDef>();
            ToothGridDef        toothGridDef;

            foreach (DataRow row in table.Rows)
            {
                toothGridDef = new ToothGridDef();
                toothGridDef.ToothGridDefNum  = PIn.Long(row["ToothGridDefNum"].ToString());
                toothGridDef.SheetFieldDefNum = PIn.Long(row["SheetFieldDefNum"].ToString());
                toothGridDef.NameInternal     = PIn.String(row["NameInternal"].ToString());
                toothGridDef.NameShowing      = PIn.String(row["NameShowing"].ToString());
                toothGridDef.CellType         = (OpenDentBusiness.ToothGridCellType)PIn.Int(row["CellType"].ToString());
                toothGridDef.ItemOrder        = PIn.Int(row["ItemOrder"].ToString());
                toothGridDef.ColumnWidth      = PIn.Int(row["ColumnWidth"].ToString());
                toothGridDef.CodeNum          = PIn.Long(row["CodeNum"].ToString());
                toothGridDef.ProcStatus       = (OpenDentBusiness.ProcStat)PIn.Int(row["ProcStatus"].ToString());
                retVal.Add(toothGridDef);
            }
            return(retVal);
        }
Example #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ToothGridDef> TableToList(DataTable table)
        {
            List <ToothGridDef> retVal = new List <ToothGridDef>();
            ToothGridDef        toothGridDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                toothGridDef = new ToothGridDef();
                toothGridDef.ToothGridDefNum  = PIn.Long(table.Rows[i]["ToothGridDefNum"].ToString());
                toothGridDef.SheetFieldDefNum = PIn.Long(table.Rows[i]["SheetFieldDefNum"].ToString());
                toothGridDef.NameInternal     = PIn.String(table.Rows[i]["NameInternal"].ToString());
                toothGridDef.NameShowing      = PIn.String(table.Rows[i]["NameShowing"].ToString());
                toothGridDef.CellType         = (ToothGridCellType)PIn.Int(table.Rows[i]["CellType"].ToString());
                toothGridDef.ItemOrder        = PIn.Int(table.Rows[i]["ItemOrder"].ToString());
                toothGridDef.ColumnWidth      = PIn.Int(table.Rows[i]["ColumnWidth"].ToString());
                toothGridDef.CodeNum          = PIn.Long(table.Rows[i]["CodeNum"].ToString());
                toothGridDef.ProcStatus       = (ProcStat)PIn.Int(table.Rows[i]["ProcStatus"].ToString());
                retVal.Add(toothGridDef);
            }
            return(retVal);
        }
        ///<summary>Inserts one ToothGridDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ToothGridDef toothGridDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO toothgriddef (";

            if (!useExistingPK && isRandomKeys)
            {
                toothGridDef.ToothGridDefNum = ReplicationServers.GetKeyNoCache("toothgriddef", "ToothGridDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ToothGridDefNum,";
            }
            command += "SheetFieldDefNum,NameInternal,NameShowing,CellType,ItemOrder,ColumnWidth,CodeNum,ProcStatus) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(toothGridDef.ToothGridDefNum) + ",";
            }
            command +=
                POut.Long(toothGridDef.SheetFieldDefNum) + ","
                + "'" + POut.String(toothGridDef.NameInternal) + "',"
                + "'" + POut.String(toothGridDef.NameShowing) + "',"
                + POut.Int((int)toothGridDef.CellType) + ","
                + POut.Int(toothGridDef.ItemOrder) + ","
                + POut.Int(toothGridDef.ColumnWidth) + ","
                + POut.Long(toothGridDef.CodeNum) + ","
                + POut.Int((int)toothGridDef.ProcStatus) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                toothGridDef.ToothGridDefNum = Db.NonQ(command, true, "ToothGridDefNum", "toothGridDef");
            }
            return(toothGridDef.ToothGridDefNum);
        }
 ///<summary>Returns true if Update(ToothGridDef,ToothGridDef) 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(ToothGridDef toothGridDef, ToothGridDef oldToothGridDef)
 {
     if (toothGridDef.SheetFieldDefNum != oldToothGridDef.SheetFieldDefNum)
     {
         return(true);
     }
     if (toothGridDef.NameInternal != oldToothGridDef.NameInternal)
     {
         return(true);
     }
     if (toothGridDef.NameShowing != oldToothGridDef.NameShowing)
     {
         return(true);
     }
     if (toothGridDef.CellType != oldToothGridDef.CellType)
     {
         return(true);
     }
     if (toothGridDef.ItemOrder != oldToothGridDef.ItemOrder)
     {
         return(true);
     }
     if (toothGridDef.ColumnWidth != oldToothGridDef.ColumnWidth)
     {
         return(true);
     }
     if (toothGridDef.CodeNum != oldToothGridDef.CodeNum)
     {
         return(true);
     }
     if (toothGridDef.ProcStatus != oldToothGridDef.ProcStatus)
     {
         return(true);
     }
     return(false);
 }
Example #9
0
		///<summary>Inserts one ToothGridDef into the database.  Returns the new priKey.</summary>
		public static long Insert(ToothGridDef toothGridDef){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				toothGridDef.ToothGridDefNum=DbHelper.GetNextOracleKey("toothgriddef","ToothGridDefNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(toothGridDef,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							toothGridDef.ToothGridDefNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(toothGridDef,false);
			}
		}
        ///<summary>Updates one ToothGridDef 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(ToothGridDef toothGridDef, ToothGridDef oldToothGridDef)
        {
            string command = "";

            if (toothGridDef.SheetFieldDefNum != oldToothGridDef.SheetFieldDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SheetFieldDefNum = " + POut.Long(toothGridDef.SheetFieldDefNum) + "";
            }
            if (toothGridDef.NameInternal != oldToothGridDef.NameInternal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "NameInternal = '" + POut.String(toothGridDef.NameInternal) + "'";
            }
            if (toothGridDef.NameShowing != oldToothGridDef.NameShowing)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "NameShowing = '" + POut.String(toothGridDef.NameShowing) + "'";
            }
            if (toothGridDef.CellType != oldToothGridDef.CellType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CellType = " + POut.Int((int)toothGridDef.CellType) + "";
            }
            if (toothGridDef.ItemOrder != oldToothGridDef.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(toothGridDef.ItemOrder) + "";
            }
            if (toothGridDef.ColumnWidth != oldToothGridDef.ColumnWidth)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ColumnWidth = " + POut.Int(toothGridDef.ColumnWidth) + "";
            }
            if (toothGridDef.CodeNum != oldToothGridDef.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(toothGridDef.CodeNum) + "";
            }
            if (toothGridDef.ProcStatus != oldToothGridDef.ProcStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcStatus = " + POut.Int((int)toothGridDef.ProcStatus) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE toothgriddef SET " + command
                      + " WHERE ToothGridDefNum = " + POut.Long(toothGridDef.ToothGridDefNum);
            Db.NonQ(command);
            return(true);
        }
 ///<summary>Inserts one ToothGridDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ToothGridDef toothGridDef)
 {
     return(InsertNoCache(toothGridDef, false));
 }
Example #12
0
		///<summary>Inserts one ToothGridDef into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ToothGridDef toothGridDef,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				toothGridDef.ToothGridDefNum=ReplicationServers.GetKey("toothgriddef","ToothGridDefNum");
			}
			string command="INSERT INTO toothgriddef (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ToothGridDefNum,";
			}
			command+="SheetFieldDefNum,NameInternal,NameShowing,CellType,ItemOrder,ColumnWidth,CodeNum,ProcStatus) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(toothGridDef.ToothGridDefNum)+",";
			}
			command+=
				     POut.Long  (toothGridDef.SheetFieldDefNum)+","
				+"'"+POut.String(toothGridDef.NameInternal)+"',"
				+"'"+POut.String(toothGridDef.NameShowing)+"',"
				+    POut.Int   ((int)toothGridDef.CellType)+","
				+    POut.Int   (toothGridDef.ItemOrder)+","
				+    POut.Int   (toothGridDef.ColumnWidth)+","
				+    POut.Long  (toothGridDef.CodeNum)+","
				+    POut.Int   ((int)toothGridDef.ProcStatus)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				toothGridDef.ToothGridDefNum=Db.NonQ(command,true);
			}
			return toothGridDef.ToothGridDefNum;
		}
Example #13
0
		///<summary>Updates one ToothGridDef 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(ToothGridDef toothGridDef,ToothGridDef oldToothGridDef){
			string command="";
			if(toothGridDef.SheetFieldDefNum != oldToothGridDef.SheetFieldDefNum) {
				if(command!=""){ command+=",";}
				command+="SheetFieldDefNum = "+POut.Long(toothGridDef.SheetFieldDefNum)+"";
			}
			if(toothGridDef.NameInternal != oldToothGridDef.NameInternal) {
				if(command!=""){ command+=",";}
				command+="NameInternal = '"+POut.String(toothGridDef.NameInternal)+"'";
			}
			if(toothGridDef.NameShowing != oldToothGridDef.NameShowing) {
				if(command!=""){ command+=",";}
				command+="NameShowing = '"+POut.String(toothGridDef.NameShowing)+"'";
			}
			if(toothGridDef.CellType != oldToothGridDef.CellType) {
				if(command!=""){ command+=",";}
				command+="CellType = "+POut.Int   ((int)toothGridDef.CellType)+"";
			}
			if(toothGridDef.ItemOrder != oldToothGridDef.ItemOrder) {
				if(command!=""){ command+=",";}
				command+="ItemOrder = "+POut.Int(toothGridDef.ItemOrder)+"";
			}
			if(toothGridDef.ColumnWidth != oldToothGridDef.ColumnWidth) {
				if(command!=""){ command+=",";}
				command+="ColumnWidth = "+POut.Int(toothGridDef.ColumnWidth)+"";
			}
			if(toothGridDef.CodeNum != oldToothGridDef.CodeNum) {
				if(command!=""){ command+=",";}
				command+="CodeNum = "+POut.Long(toothGridDef.CodeNum)+"";
			}
			if(toothGridDef.ProcStatus != oldToothGridDef.ProcStatus) {
				if(command!=""){ command+=",";}
				command+="ProcStatus = "+POut.Int   ((int)toothGridDef.ProcStatus)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE toothgriddef SET "+command
				+" WHERE ToothGridDefNum = "+POut.Long(toothGridDef.ToothGridDefNum);
			Db.NonQ(command);
			return true;
		}
Example #14
0
		///<summary>Updates one ToothGridDef in the database.</summary>
		public static void Update(ToothGridDef toothGridDef){
			string command="UPDATE toothgriddef SET "
				+"SheetFieldDefNum=  "+POut.Long  (toothGridDef.SheetFieldDefNum)+", "
				+"NameInternal    = '"+POut.String(toothGridDef.NameInternal)+"', "
				+"NameShowing     = '"+POut.String(toothGridDef.NameShowing)+"', "
				+"CellType        =  "+POut.Int   ((int)toothGridDef.CellType)+", "
				+"ItemOrder       =  "+POut.Int   (toothGridDef.ItemOrder)+", "
				+"ColumnWidth     =  "+POut.Int   (toothGridDef.ColumnWidth)+", "
				+"CodeNum         =  "+POut.Long  (toothGridDef.CodeNum)+", "
				+"ProcStatus      =  "+POut.Int   ((int)toothGridDef.ProcStatus)+" "
				+"WHERE ToothGridDefNum = "+POut.Long(toothGridDef.ToothGridDefNum);
			Db.NonQ(command);
		}