///<summary>Updates one WebChatSurvey 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(WebChatSurvey webChatSurvey, WebChatSurvey oldWebChatSurvey)
        {
            string command = "";

            if (webChatSurvey.WebChatSessionNum != oldWebChatSurvey.WebChatSessionNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "WebChatSessionNum = " + POut.Long(webChatSurvey.WebChatSessionNum) + "";
            }
            if (webChatSurvey.TechRating != oldWebChatSurvey.TechRating)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TechRating = " + POut.Int((int)webChatSurvey.TechRating) + "";
            }
            if (webChatSurvey.CustomerComment != oldWebChatSurvey.CustomerComment)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CustomerComment = " + DbHelper.ParamChar + "paramCustomerComment";
            }
            if (webChatSurvey.CustomerExperience != oldWebChatSurvey.CustomerExperience)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CustomerExperience = " + DbHelper.ParamChar + "paramCustomerExperience";
            }
            if (command == "")
            {
                return(false);
            }
            if (webChatSurvey.CustomerComment == null)
            {
                webChatSurvey.CustomerComment = "";
            }
            OdSqlParameter paramCustomerComment = new OdSqlParameter("paramCustomerComment", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerComment));

            if (webChatSurvey.CustomerExperience == null)
            {
                webChatSurvey.CustomerExperience = "";
            }
            OdSqlParameter paramCustomerExperience = new OdSqlParameter("paramCustomerExperience", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerExperience));

            command = "UPDATE webchatsurvey SET " + command
                      + " WHERE WebChatSurveyNum = " + POut.Long(webChatSurvey.WebChatSurveyNum);
            Db.NonQ(command, paramCustomerComment, paramCustomerExperience);
            return(true);
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <WebChatSurvey> TableToList(DataTable table)
        {
            List <WebChatSurvey> retVal = new List <WebChatSurvey>();
            WebChatSurvey        webChatSurvey;

            foreach (DataRow row in table.Rows)
            {
                webChatSurvey = new WebChatSurvey();
                webChatSurvey.WebChatSurveyNum   = PIn.Long(row["WebChatSurveyNum"].ToString());
                webChatSurvey.WebChatSessionNum  = PIn.Long(row["WebChatSessionNum"].ToString());
                webChatSurvey.TechRating         = (OpenDentBusiness.TechSurveyRating)PIn.Int(row["TechRating"].ToString());
                webChatSurvey.CustomerComment    = PIn.String(row["CustomerComment"].ToString());
                webChatSurvey.CustomerExperience = PIn.String(row["CustomerExperience"].ToString());
                retVal.Add(webChatSurvey);
            }
            return(retVal);
        }
 ///<summary>Returns true if Update(WebChatSurvey,WebChatSurvey) 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(WebChatSurvey webChatSurvey, WebChatSurvey oldWebChatSurvey)
 {
     if (webChatSurvey.WebChatSessionNum != oldWebChatSurvey.WebChatSessionNum)
     {
         return(true);
     }
     if (webChatSurvey.TechRating != oldWebChatSurvey.TechRating)
     {
         return(true);
     }
     if (webChatSurvey.CustomerComment != oldWebChatSurvey.CustomerComment)
     {
         return(true);
     }
     if (webChatSurvey.CustomerExperience != oldWebChatSurvey.CustomerExperience)
     {
         return(true);
     }
     return(false);
 }
        ///<summary>Inserts one WebChatSurvey into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(WebChatSurvey webChatSurvey, bool useExistingPK)
        {
            string command = "INSERT INTO webchatsurvey (";

            if (useExistingPK)
            {
                command += "WebChatSurveyNum,";
            }
            command += "WebChatSessionNum,TechRating,CustomerComment,CustomerExperience) VALUES(";
            if (useExistingPK)
            {
                command += POut.Long(webChatSurvey.WebChatSurveyNum) + ",";
            }
            command +=
                POut.Long(webChatSurvey.WebChatSessionNum) + ","
                + POut.Int((int)webChatSurvey.TechRating) + ","
                + DbHelper.ParamChar + "paramCustomerComment,"
                + DbHelper.ParamChar + "paramCustomerExperience)";
            if (webChatSurvey.CustomerComment == null)
            {
                webChatSurvey.CustomerComment = "";
            }
            OdSqlParameter paramCustomerComment = new OdSqlParameter("paramCustomerComment", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerComment));

            if (webChatSurvey.CustomerExperience == null)
            {
                webChatSurvey.CustomerExperience = "";
            }
            OdSqlParameter paramCustomerExperience = new OdSqlParameter("paramCustomerExperience", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerExperience));

            if (useExistingPK)
            {
                Db.NonQ(command, paramCustomerComment, paramCustomerExperience);
            }
            else
            {
                webChatSurvey.WebChatSurveyNum = Db.NonQ(command, true, "WebChatSurveyNum", "webChatSurvey", paramCustomerComment, paramCustomerExperience);
            }
            return(webChatSurvey.WebChatSurveyNum);
        }
        ///<summary>Updates one WebChatSurvey in the database.</summary>
        public static void Update(WebChatSurvey webChatSurvey)
        {
            string command = "UPDATE webchatsurvey SET "
                             + "WebChatSessionNum =  " + POut.Long(webChatSurvey.WebChatSessionNum) + ", "
                             + "TechRating        =  " + POut.Int((int)webChatSurvey.TechRating) + ", "
                             + "CustomerComment   =  " + DbHelper.ParamChar + "paramCustomerComment, "
                             + "CustomerExperience=  " + DbHelper.ParamChar + "paramCustomerExperience "
                             + "WHERE WebChatSurveyNum = " + POut.Long(webChatSurvey.WebChatSurveyNum);

            if (webChatSurvey.CustomerComment == null)
            {
                webChatSurvey.CustomerComment = "";
            }
            OdSqlParameter paramCustomerComment = new OdSqlParameter("paramCustomerComment", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerComment));

            if (webChatSurvey.CustomerExperience == null)
            {
                webChatSurvey.CustomerExperience = "";
            }
            OdSqlParameter paramCustomerExperience = new OdSqlParameter("paramCustomerExperience", OdDbType.Text, POut.StringNote(webChatSurvey.CustomerExperience));

            Db.NonQ(command, paramCustomerComment, paramCustomerExperience);
        }
 ///<summary>Inserts one WebChatSurvey into the database.  Returns the new priKey.</summary>
 public static long Insert(WebChatSurvey webChatSurvey)
 {
     return(Insert(webChatSurvey, false));
 }