コード例 #1
0
        ///<summary>Inserts one WebChatPref into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(WebChatPref webChatPref, bool useExistingPK)
        {
            string command = "INSERT INTO webchatpref (";

            if (useExistingPK)
            {
                command += "WebChatPrefNum,";
            }
            command += "PrefName,ValueString) VALUES(";
            if (useExistingPK)
            {
                command += POut.Long(webChatPref.WebChatPrefNum) + ",";
            }
            command +=
                "'" + POut.String(webChatPref.PrefName) + "',"
                + "'" + POut.String(webChatPref.ValueString) + "')";
            if (useExistingPK)
            {
                Db.NonQ(command);
            }
            else
            {
                webChatPref.WebChatPrefNum = Db.NonQ(command, true, "WebChatPrefNum", "webChatPref");
            }
            return(webChatPref.WebChatPrefNum);
        }
コード例 #2
0
        ///<summary>Updates one WebChatPref 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(WebChatPref webChatPref, WebChatPref oldWebChatPref)
        {
            string command = "";

            if (webChatPref.PrefName != oldWebChatPref.PrefName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PrefName = '" + POut.String(webChatPref.PrefName) + "'";
            }
            if (webChatPref.ValueString != oldWebChatPref.ValueString)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ValueString = '" + POut.String(webChatPref.ValueString) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE webchatpref SET " + command
                      + " WHERE WebChatPrefNum = " + POut.Long(webChatPref.WebChatPrefNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #3
0
        ///<summary>Updates one WebChatPref in the database.</summary>
        public static void Update(WebChatPref webChatPref)
        {
            string command = "UPDATE webchatpref SET "
                             + "PrefName      = '" + POut.String(webChatPref.PrefName) + "', "
                             + "ValueString   = '" + POut.String(webChatPref.ValueString) + "' "
                             + "WHERE WebChatPrefNum = " + POut.Long(webChatPref.WebChatPrefNum);

            Db.NonQ(command);
        }
コード例 #4
0
 ///<summary>Returns true if Update(WebChatPref,WebChatPref) 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(WebChatPref webChatPref, WebChatPref oldWebChatPref)
 {
     if (webChatPref.PrefName != oldWebChatPref.PrefName)
     {
         return(true);
     }
     if (webChatPref.ValueString != oldWebChatPref.ValueString)
     {
         return(true);
     }
     return(false);
 }
コード例 #5
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <WebChatPref> TableToList(DataTable table)
        {
            List <WebChatPref> retVal = new List <WebChatPref>();
            WebChatPref        webChatPref;

            foreach (DataRow row in table.Rows)
            {
                webChatPref = new WebChatPref();
                webChatPref.WebChatPrefNum = PIn.Long(row["WebChatPrefNum"].ToString());
                webChatPref.PrefName       = PIn.String(row["PrefName"].ToString());
                webChatPref.ValueString    = PIn.String(row["ValueString"].ToString());
                retVal.Add(webChatPref);
            }
            return(retVal);
        }
コード例 #6
0
 ///<summary>Inserts one WebChatPref into the database.  Returns the new priKey.</summary>
 public static long Insert(WebChatPref webChatPref)
 {
     return(Insert(webChatPref, false));
 }