Exemple #1
0
        ///<summary>Updates one DefLink 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(DefLink defLink, DefLink oldDefLink)
        {
            string command = "";

            if (defLink.DefNum != oldDefLink.DefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DefNum = " + POut.Long(defLink.DefNum) + "";
            }
            if (defLink.FKey != oldDefLink.FKey)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FKey = " + POut.Long(defLink.FKey) + "";
            }
            if (defLink.LinkType != oldDefLink.LinkType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LinkType = " + POut.Int((int)defLink.LinkType) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE deflink SET " + command
                      + " WHERE DefLinkNum = " + POut.Long(defLink.DefLinkNum);
            Db.NonQ(command);
            return(true);
        }