コード例 #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_weixin_menu ReaderBind(IDataReader dataReader)
        {
            Lebi_weixin_menu model = new Lebi_weixin_menu();
            object           ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["DT_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DT_id = Convert.ToInt32(ojb);
            }
            model.name = dataReader["name"].ToString();
            ojb        = dataReader["parentid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.parentid = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            model.type = dataReader["type"].ToString();
            model.url  = dataReader["url"].ToString();
            return(model);
        }
コード例 #2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_weixin_menu SafeBindForm(Lebi_weixin_menu model)
 {
     if (HttpContext.Current.Request["DT_id"] != null)
     {
         model.DT_id = LB.Tools.RequestTool.RequestInt("DT_id", 0);
     }
     if (HttpContext.Current.Request["name"] != null)
     {
         model.name = LB.Tools.RequestTool.RequestSafeString("name");
     }
     if (HttpContext.Current.Request["parentid"] != null)
     {
         model.parentid = LB.Tools.RequestTool.RequestInt("parentid", 0);
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["type"] != null)
     {
         model.type = LB.Tools.RequestTool.RequestSafeString("type");
     }
     if (HttpContext.Current.Request["url"] != null)
     {
         model.url = LB.Tools.RequestTool.RequestSafeString("url");
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_weixin_menu model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("parentid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("type") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("url") + ")");
            strSql.Append(" values (");
            strSql.Append("@DT_id,@name,@parentid,@Sort,@type,@url);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DT_id",    model.DT_id),
                new SqlParameter("@name",     model.name),
                new SqlParameter("@parentid", model.parentid),
                new SqlParameter("@Sort",     model.Sort),
                new SqlParameter("@type",     model.type),
                new SqlParameter("@url",      model.url)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_weixin_menu model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",DT_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "= @DT_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("name") + "= @name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",parentid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("parentid") + "= @parentid");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",type,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("type") + "= @type");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",url,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("url") + "= @url");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       model.id),
                new SqlParameter("@DT_id",    model.DT_id),
                new SqlParameter("@name",     model.name),
                new SqlParameter("@parentid", model.parentid),
                new SqlParameter("@Sort",     model.Sort),
                new SqlParameter("@type",     model.type),
                new SqlParameter("@url",      model.url)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_weixin_menu 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_weixin_menu);
                }
            }
            Lebi_weixin_menu 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_weixin_menu", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_weixin_menu model)
 {
     D_Lebi_weixin_menu.Instance.Update(model);
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_weixin_menu model)
 {
     return(D_Lebi_weixin_menu.Instance.Add(model));
 }
コード例 #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_weixin_menu SafeBindForm(Lebi_weixin_menu model)
 {
     return(D_Lebi_weixin_menu.Instance.SafeBindForm(model));
 }