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

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsPic"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsPic = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsShow"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsShow = Convert.ToInt32(ojb);
            }
            model.Language     = dataReader["Language"].ToString();
            model.Language_ids = dataReader["Language_ids"].ToString();
            model.Logo         = dataReader["Logo"].ToString();
            model.Name         = dataReader["Name"].ToString();
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            model.Url = dataReader["Url"].ToString();
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_FriendLink model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPic") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Logo") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Url") + ")");
            strSql.Append(" values (");
            strSql.Append("@IsPic,@IsShow,@Language,@Language_ids,@Logo,@Name,@Sort,@Url);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IsPic",        model.IsPic),
                new SqlParameter("@IsShow",       model.IsShow),
                new SqlParameter("@Language",     model.Language),
                new SqlParameter("@Language_ids", model.Language_ids),
                new SqlParameter("@Logo",         model.Logo),
                new SqlParameter("@Name",         model.Name),
                new SqlParameter("@Sort",         model.Sort),
                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));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_FriendLink model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",IsPic,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPic") + "= @IsPic");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsShow,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "= @IsShow");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "= @Language");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language_ids,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "= @Language_ids");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Logo,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Logo") + "= @Logo");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            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("@IsPic",        model.IsPic),
                new SqlParameter("@IsShow",       model.IsShow),
                new SqlParameter("@Language",     model.Language),
                new SqlParameter("@Language_ids", model.Language_ids),
                new SqlParameter("@Logo",         model.Logo),
                new SqlParameter("@Name",         model.Name),
                new SqlParameter("@Sort",         model.Sort),
                new SqlParameter("@Url",          model.Url)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_FriendLink 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_FriendLink);
                }
            }
            Lebi_FriendLink 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_FriendLink", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Beispiel #5
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_FriendLink SafeBindForm(Lebi_FriendLink model)
 {
     if (HttpContext.Current.Request["IsPic"] != null)
     {
         model.IsPic = LB.Tools.RequestTool.RequestInt("IsPic", 0);
     }
     if (HttpContext.Current.Request["IsShow"] != null)
     {
         model.IsShow = LB.Tools.RequestTool.RequestInt("IsShow", 0);
     }
     if (HttpContext.Current.Request["Language"] != null)
     {
         model.Language = LB.Tools.RequestTool.RequestSafeString("Language");
     }
     if (HttpContext.Current.Request["Language_ids"] != null)
     {
         model.Language_ids = LB.Tools.RequestTool.RequestSafeString("Language_ids");
     }
     if (HttpContext.Current.Request["Logo"] != null)
     {
         model.Logo = LB.Tools.RequestTool.RequestSafeString("Logo");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Url"] != null)
     {
         model.Url = LB.Tools.RequestTool.RequestSafeString("Url");
     }
     return(model);
 }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_FriendLink model)
 {
     D_Lebi_FriendLink.Instance.Update(model);
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_FriendLink model)
 {
     return(D_Lebi_FriendLink.Instance.Add(model));
 }
Beispiel #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_FriendLink SafeBindForm(Lebi_FriendLink model)
 {
     return(D_Lebi_FriendLink.Instance.SafeBindForm(model));
 }