Example #1
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Theme_Page SafeBindForm(Lebi_Theme_Page model)
 {
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["IsAllowHtml"] != null)
     {
         model.IsAllowHtml = LB.Tools.RequestTool.RequestInt("IsAllowHtml", 0);
     }
     if (HttpContext.Current.Request["IsCustom"] != null)
     {
         model.IsCustom = LB.Tools.RequestTool.RequestInt("IsCustom", 0);
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["PageName"] != null)
     {
         model.PageName = LB.Tools.RequestTool.RequestSafeString("PageName");
     }
     if (HttpContext.Current.Request["PageParameter"] != null)
     {
         model.PageParameter = LB.Tools.RequestTool.RequestSafeString("PageParameter");
     }
     if (HttpContext.Current.Request["SEO_Description"] != null)
     {
         model.SEO_Description = LB.Tools.RequestTool.RequestSafeString("SEO_Description");
     }
     if (HttpContext.Current.Request["SEO_Keywords"] != null)
     {
         model.SEO_Keywords = LB.Tools.RequestTool.RequestSafeString("SEO_Keywords");
     }
     if (HttpContext.Current.Request["SEO_Title"] != null)
     {
         model.SEO_Title = LB.Tools.RequestTool.RequestSafeString("SEO_Title");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["StaticPageName"] != null)
     {
         model.StaticPageName = LB.Tools.RequestTool.RequestSafeString("StaticPageName");
     }
     if (HttpContext.Current.Request["StaticPath"] != null)
     {
         model.StaticPath = LB.Tools.RequestTool.RequestSafeString("StaticPath");
     }
     if (HttpContext.Current.Request["Type_id_PublishType"] != null)
     {
         model.Type_id_PublishType = LB.Tools.RequestTool.RequestInt("Type_id_PublishType", 0);
     }
     return(model);
 }
Example #2
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Theme_Page GetModel(string strWhere, int seconds = 0)
        {
            if (strWhere.IndexOf("lbsql{") > 0)
            {
                SQLPara para = new SQLPara(strWhere, "", "");
                return(GetModel(para, seconds));
            }
            string strTableName = TableName;
            string strFieldShow = "*";
            string cachekey     = "";
            string cachestr     = "";

            if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0)
            {
                cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds;
                cachekey = LB.Tools.Utils.MD5(cachestr);
                var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey);
                if (obj != null)
                {
                    return(obj as Lebi_Theme_Page);
                }
            }
            Lebi_Theme_Page model = null;

            using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null))
            {
                if (dataReader == null)
                {
                    return(null);
                }
                while (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                    if (cachekey != "")
                    {
                        LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Theme_Page", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Theme_Page ReaderBind(IDataReader dataReader)
        {
            Lebi_Theme_Page model = new Lebi_Theme_Page();
            object          ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Code = dataReader["Code"].ToString();
            ojb        = dataReader["IsAllowHtml"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsAllowHtml = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsCustom"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsCustom = Convert.ToInt32(ojb);
            }
            model.Name            = dataReader["Name"].ToString();
            model.PageName        = dataReader["PageName"].ToString();
            model.PageParameter   = dataReader["PageParameter"].ToString();
            model.SEO_Description = dataReader["SEO_Description"].ToString();
            model.SEO_Keywords    = dataReader["SEO_Keywords"].ToString();
            model.SEO_Title       = dataReader["SEO_Title"].ToString();
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            model.StaticPageName = dataReader["StaticPageName"].ToString();
            model.StaticPath     = dataReader["StaticPath"].ToString();
            ojb = dataReader["Type_id_PublishType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_PublishType = Convert.ToInt32(ojb);
            }
            return(model);
        }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Theme_Page model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsAllowHtml") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCustom") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("PageName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("PageParameter") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Keywords") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Title") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("StaticPageName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("StaticPath") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_PublishType") + ")");
            strSql.Append(" values (");
            strSql.Append("@Code,@IsAllowHtml,@IsCustom,@Name,@PageName,@PageParameter,@SEO_Description,@SEO_Keywords,@SEO_Title,@Sort,@StaticPageName,@StaticPath,@Type_id_PublishType);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",                model.Code),
                new SqlParameter("@IsAllowHtml",         model.IsAllowHtml),
                new SqlParameter("@IsCustom",            model.IsCustom),
                new SqlParameter("@Name",                model.Name),
                new SqlParameter("@PageName",            model.PageName),
                new SqlParameter("@PageParameter",       model.PageParameter),
                new SqlParameter("@SEO_Description",     model.SEO_Description),
                new SqlParameter("@SEO_Keywords",        model.SEO_Keywords),
                new SqlParameter("@SEO_Title",           model.SEO_Title),
                new SqlParameter("@Sort",                model.Sort),
                new SqlParameter("@StaticPageName",      model.StaticPageName),
                new SqlParameter("@StaticPath",          model.StaticPath),
                new SqlParameter("@Type_id_PublishType", model.Type_id_PublishType)
            };

            object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Theme_Page model)
 {
     D_Lebi_Theme_Page.Instance.Update(model);
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Theme_Page model)
 {
     return(D_Lebi_Theme_Page.Instance.Add(model));
 }
Example #7
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Theme_Page SafeBindForm(Lebi_Theme_Page model)
 {
     return(D_Lebi_Theme_Page.Instance.SafeBindForm(model));
 }
Example #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Theme_Page model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + TableName + " set ");
            List <string> cols = new List <string>();

            if (("," + model.UpdateCols + ",").IndexOf(",Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "= @Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsAllowHtml,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsAllowHtml") + "= @IsAllowHtml");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsCustom,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsCustom") + "= @IsCustom");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",PageName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("PageName") + "= @PageName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",PageParameter,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("PageParameter") + "= @PageParameter");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Description") + "= @SEO_Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Keywords,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Keywords") + "= @SEO_Keywords");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Title,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Title") + "= @SEO_Title");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",StaticPageName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("StaticPageName") + "= @StaticPageName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",StaticPath,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("StaticPath") + "= @StaticPath");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_PublishType,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_PublishType") + "= @Type_id_PublishType");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                  model.id),
                new SqlParameter("@Code",                model.Code),
                new SqlParameter("@IsAllowHtml",         model.IsAllowHtml),
                new SqlParameter("@IsCustom",            model.IsCustom),
                new SqlParameter("@Name",                model.Name),
                new SqlParameter("@PageName",            model.PageName),
                new SqlParameter("@PageParameter",       model.PageParameter),
                new SqlParameter("@SEO_Description",     model.SEO_Description),
                new SqlParameter("@SEO_Keywords",        model.SEO_Keywords),
                new SqlParameter("@SEO_Title",           model.SEO_Title),
                new SqlParameter("@Sort",                model.Sort),
                new SqlParameter("@StaticPageName",      model.StaticPageName),
                new SqlParameter("@StaticPath",          model.StaticPath),
                new SqlParameter("@Type_id_PublishType", model.Type_id_PublishType)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }