Example #1
0
        ///<summary>Inserts one ProcCodeNote into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(ProcCodeNote procCodeNote, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                procCodeNote.ProcCodeNoteNum = ReplicationServers.GetKey("proccodenote", "ProcCodeNoteNum");
            }
            string command = "INSERT INTO proccodenote (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ProcCodeNoteNum,";
            }
            command += "CodeNum,ProvNum,Note,ProcTime) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(procCodeNote.ProcCodeNoteNum) + ",";
            }
            command +=
                POut.Long(procCodeNote.CodeNum) + ","
                + POut.Long(procCodeNote.ProvNum) + ","
                + "'" + POut.String(procCodeNote.Note) + "',"
                + "'" + POut.String(procCodeNote.ProcTime) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                procCodeNote.ProcCodeNoteNum = Db.NonQ(command, true);
            }
            return(procCodeNote.ProcCodeNoteNum);
        }
Example #2
0
 ///<summary>Inserts one ProcCodeNote into the database.  Returns the new priKey.</summary>
 public static long Insert(ProcCodeNote procCodeNote)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         procCodeNote.ProcCodeNoteNum = DbHelper.GetNextOracleKey("proccodenote", "ProcCodeNoteNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(procCodeNote, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     procCodeNote.ProcCodeNoteNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(procCodeNote, false));
     }
 }
Example #3
0
 ///<summary>Inserts one ProcCodeNote into the database.  Returns the new priKey.</summary>
 internal static long Insert(ProcCodeNote procCodeNote)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         procCodeNote.ProcCodeNoteNum=DbHelper.GetNextOracleKey("proccodenote","ProcCodeNoteNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(procCodeNote,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     procCodeNote.ProcCodeNoteNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(procCodeNote,false);
     }
 }
Example #4
0
 ///<summary>Inserts one ProcCodeNote into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ProcCodeNote procCodeNote,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         procCodeNote.ProcCodeNoteNum=ReplicationServers.GetKey("proccodenote","ProcCodeNoteNum");
     }
     string command="INSERT INTO proccodenote (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ProcCodeNoteNum,";
     }
     command+="CodeNum,ProvNum,Note,ProcTime) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(procCodeNote.ProcCodeNoteNum)+",";
     }
     command+=
              POut.Long  (procCodeNote.CodeNum)+","
         +    POut.Long  (procCodeNote.ProvNum)+","
         +"'"+POut.String(procCodeNote.Note)+"',"
         +"'"+POut.String(procCodeNote.ProcTime)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         procCodeNote.ProcCodeNoteNum=Db.NonQ(command,true);
     }
     return procCodeNote.ProcCodeNoteNum;
 }
Example #5
0
        ///<summary>Updates one ProcCodeNote 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(ProcCodeNote procCodeNote, ProcCodeNote oldProcCodeNote)
        {
            string command = "";

            if (procCodeNote.CodeNum != oldProcCodeNote.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(procCodeNote.CodeNum) + "";
            }
            if (procCodeNote.ProvNum != oldProcCodeNote.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(procCodeNote.ProvNum) + "";
            }
            if (procCodeNote.Note != oldProcCodeNote.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            if (procCodeNote.ProcTime != oldProcCodeNote.ProcTime)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcTime = '" + POut.String(procCodeNote.ProcTime) + "'";
            }
            if (procCodeNote.ProcStatus != oldProcCodeNote.ProcStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcStatus = " + POut.Int((int)procCodeNote.ProcStatus) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (procCodeNote.Note == null)
            {
                procCodeNote.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(procCodeNote.Note));

            command = "UPDATE proccodenote SET " + command
                      + " WHERE ProcCodeNoteNum = " + POut.Long(procCodeNote.ProcCodeNoteNum);
            Db.NonQ(command, paramNote);
            return(true);
        }
        ///<summary></summary>
        public static void Insert(ProcCodeNote note)
        {
            string command = "INSERT INTO proccodenote (CodeNum,ProvNum,Note,ProcTime) VALUES("
                             + "'" + POut.PInt(note.CodeNum) + "', "
                             + "'" + POut.PInt(note.ProvNum) + "', "
                             + "'" + POut.PString(note.Note) + "', "
                             + "'" + POut.PString(note.ProcTime) + "')";

            note.ProcCodeNoteNum = General.NonQ(command, true);
        }
        ///<summary></summary>
        public static void Update(ProcCodeNote note)
        {
            string command = "UPDATE proccodenote SET "
                             + "CodeNum = '" + POut.PInt(note.CodeNum) + "'"
                             + ",ProvNum = '" + POut.PInt(note.ProvNum) + "'"
                             + ",Note = '" + POut.PString(note.Note) + "'"
                             + ",ProcTime = '" + POut.PString(note.ProcTime) + "'"
                             + " WHERE ProcCodeNoteNum = " + POut.PInt(note.ProcCodeNoteNum);

            General.NonQ(command);
        }
Example #8
0
        ///<summary>Updates one ProcCodeNote in the database.</summary>
        internal static void Update(ProcCodeNote procCodeNote)
        {
            string command = "UPDATE proccodenote SET "
                             + "CodeNum        =  " + POut.Long(procCodeNote.CodeNum) + ", "
                             + "ProvNum        =  " + POut.Long(procCodeNote.ProvNum) + ", "
                             + "Note           = '" + POut.String(procCodeNote.Note) + "', "
                             + "ProcTime       = '" + POut.String(procCodeNote.ProcTime) + "' "
                             + "WHERE ProcCodeNoteNum = " + POut.Long(procCodeNote.ProcCodeNoteNum);

            Db.NonQ(command);
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ProcCodeNote> TableToList(DataTable table){
			List<ProcCodeNote> retVal=new List<ProcCodeNote>();
			ProcCodeNote procCodeNote;
			for(int i=0;i<table.Rows.Count;i++) {
				procCodeNote=new ProcCodeNote();
				procCodeNote.ProcCodeNoteNum= PIn.Long  (table.Rows[i]["ProcCodeNoteNum"].ToString());
				procCodeNote.CodeNum        = PIn.Long  (table.Rows[i]["CodeNum"].ToString());
				procCodeNote.ProvNum        = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				procCodeNote.Note           = PIn.String(table.Rows[i]["Note"].ToString());
				procCodeNote.ProcTime       = PIn.String(table.Rows[i]["ProcTime"].ToString());
				retVal.Add(procCodeNote);
			}
			return retVal;
		}
Example #10
0
 ///<summary>Inserts one ProcCodeNote into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcCodeNote procCodeNote)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(procCodeNote, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             procCodeNote.ProcCodeNoteNum = DbHelper.GetNextOracleKey("proccodenote", "ProcCodeNoteNum");                  //Cacheless method
         }
         return(InsertNoCache(procCodeNote, true));
     }
 }
Example #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ProcCodeNote> TableToList(DataTable table)
        {
            List <ProcCodeNote> retVal = new List <ProcCodeNote>();
            ProcCodeNote        procCodeNote;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                procCodeNote = new ProcCodeNote();
                procCodeNote.ProcCodeNoteNum = PIn.Long(table.Rows[i]["ProcCodeNoteNum"].ToString());
                procCodeNote.CodeNum         = PIn.Long(table.Rows[i]["CodeNum"].ToString());
                procCodeNote.ProvNum         = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                procCodeNote.Note            = PIn.String(table.Rows[i]["Note"].ToString());
                procCodeNote.ProcTime        = PIn.String(table.Rows[i]["ProcTime"].ToString());
                retVal.Add(procCodeNote);
            }
            return(retVal);
        }
Example #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProcCodeNote> TableToList(DataTable table)
        {
            List <ProcCodeNote> retVal = new List <ProcCodeNote>();
            ProcCodeNote        procCodeNote;

            foreach (DataRow row in table.Rows)
            {
                procCodeNote = new ProcCodeNote();
                procCodeNote.ProcCodeNoteNum = PIn.Long(row["ProcCodeNoteNum"].ToString());
                procCodeNote.CodeNum         = PIn.Long(row["CodeNum"].ToString());
                procCodeNote.ProvNum         = PIn.Long(row["ProvNum"].ToString());
                procCodeNote.Note            = PIn.String(row["Note"].ToString());
                procCodeNote.ProcTime        = PIn.String(row["ProcTime"].ToString());
                procCodeNote.ProcStatus      = (OpenDentBusiness.ProcStat)PIn.Int(row["ProcStatus"].ToString());
                retVal.Add(procCodeNote);
            }
            return(retVal);
        }
Example #13
0
        ///<summary>Updates one ProcCodeNote in the database.</summary>
        public static void Update(ProcCodeNote procCodeNote)
        {
            string command = "UPDATE proccodenote SET "
                             + "CodeNum        =  " + POut.Long(procCodeNote.CodeNum) + ", "
                             + "ProvNum        =  " + POut.Long(procCodeNote.ProvNum) + ", "
                             + "Note           =  " + DbHelper.ParamChar + "paramNote, "
                             + "ProcTime       = '" + POut.String(procCodeNote.ProcTime) + "', "
                             + "ProcStatus     =  " + POut.Int((int)procCodeNote.ProcStatus) + " "
                             + "WHERE ProcCodeNoteNum = " + POut.Long(procCodeNote.ProcCodeNoteNum);

            if (procCodeNote.Note == null)
            {
                procCodeNote.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(procCodeNote.Note));

            Db.NonQ(command, paramNote);
        }
Example #14
0
        private static List <ProcCodeNote> RefreshAndFill(string command)
        {
            DataTable           table  = General.GetTable(command);
            List <ProcCodeNote> retVal = new List <ProcCodeNote>();
            ProcCodeNote        note;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                note = new ProcCodeNote();
                note.ProcCodeNoteNum = PIn.PInt(table.Rows[i][0].ToString());
                note.CodeNum         = PIn.PInt(table.Rows[i][1].ToString());
                note.ProvNum         = PIn.PInt(table.Rows[i][2].ToString());
                note.Note            = PIn.PString(table.Rows[i][3].ToString());
                note.ProcTime        = PIn.PString(table.Rows[i][4].ToString());
                retVal.Add(note);
            }
            return(retVal);
        }
Example #15
0
        ///<summary>Updates one ProcCodeNote 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(ProcCodeNote procCodeNote, ProcCodeNote oldProcCodeNote)
        {
            string command = "";

            if (procCodeNote.CodeNum != oldProcCodeNote.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(procCodeNote.CodeNum) + "";
            }
            if (procCodeNote.ProvNum != oldProcCodeNote.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(procCodeNote.ProvNum) + "";
            }
            if (procCodeNote.Note != oldProcCodeNote.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(procCodeNote.Note) + "'";
            }
            if (procCodeNote.ProcTime != oldProcCodeNote.ProcTime)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcTime = '" + POut.String(procCodeNote.ProcTime) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE proccodenote SET " + command
                      + " WHERE ProcCodeNoteNum = " + POut.Long(procCodeNote.ProcCodeNoteNum);
            Db.NonQ(command);
        }
Example #16
0
        ///<summary>Inserts one ProcCodeNote into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ProcCodeNote procCodeNote, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO proccodenote (";

            if (!useExistingPK && isRandomKeys)
            {
                procCodeNote.ProcCodeNoteNum = ReplicationServers.GetKeyNoCache("proccodenote", "ProcCodeNoteNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ProcCodeNoteNum,";
            }
            command += "CodeNum,ProvNum,Note,ProcTime,ProcStatus) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(procCodeNote.ProcCodeNoteNum) + ",";
            }
            command +=
                POut.Long(procCodeNote.CodeNum) + ","
                + POut.Long(procCodeNote.ProvNum) + ","
                + DbHelper.ParamChar + "paramNote,"
                + "'" + POut.String(procCodeNote.ProcTime) + "',"
                + POut.Int((int)procCodeNote.ProcStatus) + ")";
            if (procCodeNote.Note == null)
            {
                procCodeNote.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(procCodeNote.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                procCodeNote.ProcCodeNoteNum = Db.NonQ(command, true, "ProcCodeNoteNum", "procCodeNote", paramNote);
            }
            return(procCodeNote.ProcCodeNoteNum);
        }
Example #17
0
 ///<summary>Returns true if Update(ProcCodeNote,ProcCodeNote) 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(ProcCodeNote procCodeNote, ProcCodeNote oldProcCodeNote)
 {
     if (procCodeNote.CodeNum != oldProcCodeNote.CodeNum)
     {
         return(true);
     }
     if (procCodeNote.ProvNum != oldProcCodeNote.ProvNum)
     {
         return(true);
     }
     if (procCodeNote.Note != oldProcCodeNote.Note)
     {
         return(true);
     }
     if (procCodeNote.ProcTime != oldProcCodeNote.ProcTime)
     {
         return(true);
     }
     if (procCodeNote.ProcStatus != oldProcCodeNote.ProcStatus)
     {
         return(true);
     }
     return(false);
 }
Example #18
0
 ///<summary>Inserts one ProcCodeNote into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcCodeNote procCodeNote)
 {
     return(InsertNoCache(procCodeNote, false));
 }
Example #19
0
 ///<summary>Updates one ProcCodeNote in the database.</summary>
 internal static void Update(ProcCodeNote procCodeNote)
 {
     string command="UPDATE proccodenote SET "
         +"CodeNum        =  "+POut.Long  (procCodeNote.CodeNum)+", "
         +"ProvNum        =  "+POut.Long  (procCodeNote.ProvNum)+", "
         +"Note           = '"+POut.String(procCodeNote.Note)+"', "
         +"ProcTime       = '"+POut.String(procCodeNote.ProcTime)+"' "
         +"WHERE ProcCodeNoteNum = "+POut.Long(procCodeNote.ProcCodeNoteNum);
     Db.NonQ(command);
 }
Example #20
0
 ///<summary>Updates one ProcCodeNote 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(ProcCodeNote procCodeNote,ProcCodeNote oldProcCodeNote)
 {
     string command="";
     if(procCodeNote.CodeNum != oldProcCodeNote.CodeNum) {
         if(command!=""){ command+=",";}
         command+="CodeNum = "+POut.Long(procCodeNote.CodeNum)+"";
     }
     if(procCodeNote.ProvNum != oldProcCodeNote.ProvNum) {
         if(command!=""){ command+=",";}
         command+="ProvNum = "+POut.Long(procCodeNote.ProvNum)+"";
     }
     if(procCodeNote.Note != oldProcCodeNote.Note) {
         if(command!=""){ command+=",";}
         command+="Note = '"+POut.String(procCodeNote.Note)+"'";
     }
     if(procCodeNote.ProcTime != oldProcCodeNote.ProcTime) {
         if(command!=""){ command+=",";}
         command+="ProcTime = '"+POut.String(procCodeNote.ProcTime)+"'";
     }
     if(command==""){
         return;
     }
     command="UPDATE proccodenote SET "+command
         +" WHERE ProcCodeNoteNum = "+POut.Long(procCodeNote.ProcCodeNoteNum);
     Db.NonQ(command);
 }