コード例 #1
0
        private void PostUserComments()
        {
            // generate SQL and executes it to post user comments

            const string CacheKey = "LastComment";
            string       buffer   = Page.Request[fieldComments];

            if (!string.IsNullOrEmpty(buffer))
            {
                string aSQL    = string.Format("{0},{1},{2}", _ItemID, _UserID, EvoDB.dbFormat(buffer, EvoDB.t_txtm, 1000, _Language));
                bool   OK2post = Page.Cache[CacheKey] == null;
                if (!OK2post)
                {
                    OK2post = Convert.ToString(Page.Cache[CacheKey]) != aSQL;
                }
                if (OK2post)
                {
                    Page.Cache[CacheKey] = aSQL;
                    string um = def_Data.dbcolumncomments + ",userid,message";
                    if (def_Data.dbcommentsformid > 0)
                    {
                        aSQL = EvoDB.sqlINSERT(def_Data.dbtablecomments, um + ",formid", String.Format("{0},{1}", aSQL, def_Data.dbcommentsformid));
                    }
                    else
                    {
                        aSQL = EvoDB.sqlINSERT(def_Data.dbtablecomments, um, aSQL);
                    }
                    aSQL += EvoDB.sqlUPDATE(def_Data.dbtable, string.Format(EvoDB.SQL_INCREMENT, SQLColNbComments), EvoDB.IDequals(_ItemID));
                    if (_UserID > 0 && !String.IsNullOrEmpty(def_Data.dbtableusers))
                    {
                        aSQL += EvoDB.sqlUPDATE(def_Data.dbtableusers, string.Format(EvoDB.SQL_INCREMENT, SQLColNbComments), EvoDB.IDequals(_UserID));
                    }
                    buffer = EvoDB.RunSQL(aSQL, SqlConnection, true);
                    if (string.IsNullOrEmpty(buffer))
                    {
                        HeaderMsg = EvoTC.CondiConcat(HeaderMsg, string.Format(EvoLang.ucPostedOn, EvoTC.TextNowTime()), vbCrLf);
                    }
                    else
                    {
                        AddError(buffer);
                    }
                }
            }
        }