Ejemplo n.º 1
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <InsVerifyHist> TableToList(DataTable table)
        {
            List <InsVerifyHist> retVal = new List <InsVerifyHist>();
            InsVerifyHist        insVerifyHist;

            foreach (DataRow row in table.Rows)
            {
                insVerifyHist = new InsVerifyHist();
                insVerifyHist.InsVerifyHistNum = PIn.Long(row["InsVerifyHistNum"].ToString());
                insVerifyHist.VerifyUserNum    = PIn.Long(row["VerifyUserNum"].ToString());
                insVerifyHist.InsVerifyNum     = PIn.Long(row["InsVerifyNum"].ToString());
                insVerifyHist.DateLastVerified = PIn.Date(row["DateLastVerified"].ToString());
                insVerifyHist.UserNum          = PIn.Long(row["UserNum"].ToString());
                insVerifyHist.VerifyType       = (OpenDentBusiness.VerifyTypes)PIn.Int(row["VerifyType"].ToString());
                insVerifyHist.FKey             = PIn.Long(row["FKey"].ToString());
                insVerifyHist.DefNum           = PIn.Long(row["DefNum"].ToString());
                insVerifyHist.DateLastAssigned = PIn.Date(row["DateLastAssigned"].ToString());
                insVerifyHist.Note             = PIn.String(row["Note"].ToString());
                insVerifyHist.DateTimeEntry    = PIn.DateT(row["DateTimeEntry"].ToString());
                insVerifyHist.HoursAvailableForVerification = PIn.Double(row["HoursAvailableForVerification"].ToString());
                insVerifyHist.SecDateTEdit = PIn.DateT(row["SecDateTEdit"].ToString());
                retVal.Add(insVerifyHist);
            }
            return(retVal);
        }
Ejemplo n.º 2
0
 ///<summary>Inserts one InsVerifyHist into the database.  Returns the new priKey.</summary>
 public static long Insert(InsVerifyHist insVerifyHist)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         insVerifyHist.InsVerifyHistNum = DbHelper.GetNextOracleKey("insverifyhist", "InsVerifyHistNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(insVerifyHist, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     insVerifyHist.InsVerifyHistNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(insVerifyHist, false));
     }
 }
Ejemplo n.º 3
0
 ///<summary>Inserts one InsVerifyHist into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(InsVerifyHist insVerifyHist)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(insVerifyHist, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             insVerifyHist.InsVerifyHistNum = DbHelper.GetNextOracleKey("insverifyhist", "InsVerifyHistNum");                  //Cacheless method
         }
         return(InsertNoCache(insVerifyHist, true));
     }
 }
Ejemplo n.º 4
0
        ///<summary>Inserts one InsVerifyHist into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(InsVerifyHist insVerifyHist, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO insverifyhist (";

            if (!useExistingPK && isRandomKeys)
            {
                insVerifyHist.InsVerifyHistNum = ReplicationServers.GetKeyNoCache("insverifyhist", "InsVerifyHistNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "InsVerifyHistNum,";
            }
            command += "VerifyUserNum,InsVerifyNum,DateLastVerified,UserNum,VerifyType,FKey,DefNum,DateLastAssigned,Note,DateTimeEntry,HoursAvailableForVerification,SecDateTEdit) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(insVerifyHist.InsVerifyHistNum) + ",";
            }
            command +=
                POut.Long(insVerifyHist.VerifyUserNum) + ","
                + POut.Long(insVerifyHist.InsVerifyNum) + ","
                + POut.Date(insVerifyHist.DateLastVerified) + ","
                + POut.Long(insVerifyHist.UserNum) + ","
                + POut.Int((int)insVerifyHist.VerifyType) + ","
                + POut.Long(insVerifyHist.FKey) + ","
                + POut.Long(insVerifyHist.DefNum) + ","
                + POut.Date(insVerifyHist.DateLastAssigned) + ","
                + DbHelper.ParamChar + "paramNote,"
                + POut.DateT(insVerifyHist.DateTimeEntry) + ","
                + "'" + POut.Double(insVerifyHist.HoursAvailableForVerification) + "',"
                + POut.DateT(insVerifyHist.SecDateTEdit) + ")";
            if (insVerifyHist.Note == null)
            {
                insVerifyHist.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringNote(insVerifyHist.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                insVerifyHist.InsVerifyHistNum = Db.NonQ(command, true, "InsVerifyHistNum", "insVerifyHist", paramNote);
            }
            return(insVerifyHist.InsVerifyHistNum);
        }
Ejemplo n.º 5
0
 ///<summary>Returns true if Update(InsVerifyHist,InsVerifyHist) 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(InsVerifyHist insVerifyHist, InsVerifyHist oldInsVerifyHist)
 {
     if (insVerifyHist.VerifyUserNum != oldInsVerifyHist.VerifyUserNum)
     {
         return(true);
     }
     if (insVerifyHist.InsVerifyNum != oldInsVerifyHist.InsVerifyNum)
     {
         return(true);
     }
     if (insVerifyHist.DateLastVerified.Date != oldInsVerifyHist.DateLastVerified.Date)
     {
         return(true);
     }
     if (insVerifyHist.UserNum != oldInsVerifyHist.UserNum)
     {
         return(true);
     }
     if (insVerifyHist.VerifyType != oldInsVerifyHist.VerifyType)
     {
         return(true);
     }
     if (insVerifyHist.FKey != oldInsVerifyHist.FKey)
     {
         return(true);
     }
     if (insVerifyHist.DefNum != oldInsVerifyHist.DefNum)
     {
         return(true);
     }
     if (insVerifyHist.DateLastAssigned.Date != oldInsVerifyHist.DateLastAssigned.Date)
     {
         return(true);
     }
     if (insVerifyHist.Note != oldInsVerifyHist.Note)
     {
         return(true);
     }
     //DateTimeEntry not allowed to change
     if (insVerifyHist.HoursAvailableForVerification != oldInsVerifyHist.HoursAvailableForVerification)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        ///<summary>Updates one InsVerifyHist in the database.</summary>
        public static void Update(InsVerifyHist insVerifyHist)
        {
            string command = "UPDATE insverifyhist SET "
                             + "VerifyUserNum                =  " + POut.Long(insVerifyHist.VerifyUserNum) + ", "
                             + "InsVerifyNum                 =  " + POut.Long(insVerifyHist.InsVerifyNum) + ", "
                             + "DateLastVerified             =  " + POut.Date(insVerifyHist.DateLastVerified) + ", "
                             + "UserNum                      =  " + POut.Long(insVerifyHist.UserNum) + ", "
                             + "VerifyType                   =  " + POut.Int((int)insVerifyHist.VerifyType) + ", "
                             + "FKey                         =  " + POut.Long(insVerifyHist.FKey) + ", "
                             + "DefNum                       =  " + POut.Long(insVerifyHist.DefNum) + ", "
                             + "DateLastAssigned             =  " + POut.Date(insVerifyHist.DateLastAssigned) + ", "
                             + "Note                         =  " + DbHelper.ParamChar + "paramNote, "
                             //DateTimeEntry not allowed to change
                             + "HoursAvailableForVerification= '" + POut.Double(insVerifyHist.HoursAvailableForVerification) + "' "
                             + "WHERE InsVerifyHistNum = " + POut.Long(insVerifyHist.InsVerifyHistNum);

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

            Db.NonQ(command, paramNote);
        }
Ejemplo n.º 7
0
 ///<summary>Inserts one InsVerifyHist into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(InsVerifyHist insVerifyHist)
 {
     return(InsertNoCache(insVerifyHist, false));
 }
Ejemplo n.º 8
0
        ///<summary>Updates one InsVerifyHist 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(InsVerifyHist insVerifyHist, InsVerifyHist oldInsVerifyHist)
        {
            string command = "";

            if (insVerifyHist.VerifyUserNum != oldInsVerifyHist.VerifyUserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VerifyUserNum = " + POut.Long(insVerifyHist.VerifyUserNum) + "";
            }
            if (insVerifyHist.InsVerifyNum != oldInsVerifyHist.InsVerifyNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "InsVerifyNum = " + POut.Long(insVerifyHist.InsVerifyNum) + "";
            }
            if (insVerifyHist.DateLastVerified.Date != oldInsVerifyHist.DateLastVerified.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateLastVerified = " + POut.Date(insVerifyHist.DateLastVerified) + "";
            }
            if (insVerifyHist.UserNum != oldInsVerifyHist.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(insVerifyHist.UserNum) + "";
            }
            if (insVerifyHist.VerifyType != oldInsVerifyHist.VerifyType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VerifyType = " + POut.Int((int)insVerifyHist.VerifyType) + "";
            }
            if (insVerifyHist.FKey != oldInsVerifyHist.FKey)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FKey = " + POut.Long(insVerifyHist.FKey) + "";
            }
            if (insVerifyHist.DefNum != oldInsVerifyHist.DefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DefNum = " + POut.Long(insVerifyHist.DefNum) + "";
            }
            if (insVerifyHist.DateLastAssigned.Date != oldInsVerifyHist.DateLastAssigned.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateLastAssigned = " + POut.Date(insVerifyHist.DateLastAssigned) + "";
            }
            if (insVerifyHist.Note != oldInsVerifyHist.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            //DateTimeEntry not allowed to change
            if (insVerifyHist.HoursAvailableForVerification != oldInsVerifyHist.HoursAvailableForVerification)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "HoursAvailableForVerification = '" + POut.Double(insVerifyHist.HoursAvailableForVerification) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            if (insVerifyHist.Note == null)
            {
                insVerifyHist.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringNote(insVerifyHist.Note));

            command = "UPDATE insverifyhist SET " + command
                      + " WHERE InsVerifyHistNum = " + POut.Long(insVerifyHist.InsVerifyHistNum);
            Db.NonQ(command, paramNote);
            return(true);
        }