Exemplo n.º 1
0
        ///<summary>Inserts one JobActiveLink into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(JobActiveLink jobActiveLink, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO jobactivelink (";

            if (!useExistingPK && isRandomKeys)
            {
                jobActiveLink.JobActiveLinkNum = ReplicationServers.GetKeyNoCache("jobactivelink", "JobActiveLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "JobActiveLinkNum,";
            }
            command += "JobNum,UserNum,DateTimeEntry,DateTimeEnd) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(jobActiveLink.JobActiveLinkNum) + ",";
            }
            command +=
                POut.Long(jobActiveLink.JobNum) + ","
                + POut.Long(jobActiveLink.UserNum) + ","
                + DbHelper.Now() + ","
                + POut.DateT(jobActiveLink.DateTimeEnd) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                jobActiveLink.JobActiveLinkNum = Db.NonQ(command, true, "JobActiveLinkNum", "jobActiveLink");
            }
            return(jobActiveLink.JobActiveLinkNum);
        }
Exemplo n.º 2
0
        ///<summary>Inserts one JobActiveLink into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(JobActiveLink jobActiveLink, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                jobActiveLink.JobActiveLinkNum = ReplicationServers.GetKey("jobactivelink", "JobActiveLinkNum");
            }
            string command = "INSERT INTO jobactivelink (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "JobActiveLinkNum,";
            }
            command += "JobNum,UserNum,DateTimeEntry,DateTimeEnd) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(jobActiveLink.JobActiveLinkNum) + ",";
            }
            command +=
                POut.Long(jobActiveLink.JobNum) + ","
                + POut.Long(jobActiveLink.UserNum) + ","
                + DbHelper.Now() + ","
                + POut.DateT(jobActiveLink.DateTimeEnd) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                jobActiveLink.JobActiveLinkNum = Db.NonQ(command, true, "JobActiveLinkNum", "jobActiveLink");
            }
            return(jobActiveLink.JobActiveLinkNum);
        }
Exemplo n.º 3
0
        ///<summary>Updates one JobActiveLink in the database.</summary>
        public static void Update(JobActiveLink jobActiveLink)
        {
            string command = "UPDATE jobactivelink SET "
                             + "JobNum          =  " + POut.Long(jobActiveLink.JobNum) + ", "
                             + "UserNum         =  " + POut.Long(jobActiveLink.UserNum) + ", "
                             //DateTimeEntry not allowed to change
                             + "DateTimeEnd     =  " + POut.DateT(jobActiveLink.DateTimeEnd) + " "
                             + "WHERE JobActiveLinkNum = " + POut.Long(jobActiveLink.JobActiveLinkNum);

            Db.NonQ(command);
        }
Exemplo n.º 4
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <JobActiveLink> TableToList(DataTable table)
        {
            List <JobActiveLink> retVal = new List <JobActiveLink>();
            JobActiveLink        jobActiveLink;

            foreach (DataRow row in table.Rows)
            {
                jobActiveLink = new JobActiveLink();
                jobActiveLink.JobActiveLinkNum = PIn.Long(row["JobActiveLinkNum"].ToString());
                jobActiveLink.JobNum           = PIn.Long(row["JobNum"].ToString());
                jobActiveLink.UserNum          = PIn.Long(row["UserNum"].ToString());
                jobActiveLink.DateTimeEntry    = PIn.DateT(row["DateTimeEntry"].ToString());
                jobActiveLink.DateTimeEnd      = PIn.DateT(row["DateTimeEnd"].ToString());
                retVal.Add(jobActiveLink);
            }
            return(retVal);
        }
Exemplo n.º 5
0
 ///<summary>Returns true if Update(JobActiveLink,JobActiveLink) 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(JobActiveLink jobActiveLink, JobActiveLink oldJobActiveLink)
 {
     if (jobActiveLink.JobNum != oldJobActiveLink.JobNum)
     {
         return(true);
     }
     if (jobActiveLink.UserNum != oldJobActiveLink.UserNum)
     {
         return(true);
     }
     //DateTimeEntry not allowed to change
     if (jobActiveLink.DateTimeEnd != oldJobActiveLink.DateTimeEnd)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        ///<summary>Updates one JobActiveLink 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(JobActiveLink jobActiveLink, JobActiveLink oldJobActiveLink)
        {
            string command = "";

            if (jobActiveLink.JobNum != oldJobActiveLink.JobNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "JobNum = " + POut.Long(jobActiveLink.JobNum) + "";
            }
            if (jobActiveLink.UserNum != oldJobActiveLink.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(jobActiveLink.UserNum) + "";
            }
            //DateTimeEntry not allowed to change
            if (jobActiveLink.DateTimeEnd != oldJobActiveLink.DateTimeEnd)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeEnd = " + POut.DateT(jobActiveLink.DateTimeEnd) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE jobactivelink SET " + command
                      + " WHERE JobActiveLinkNum = " + POut.Long(jobActiveLink.JobActiveLinkNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 7
0
 ///<summary>Inserts one JobActiveLink into the database.  Returns the new priKey.</summary>
 public static long Insert(JobActiveLink jobActiveLink)
 {
     return(Insert(jobActiveLink, false));
 }