コード例 #1
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Comment 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_Comment);
                }
            }
            Lebi_Comment 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_Comment", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Images") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ImagesSmall") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsRead") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Keyid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Parentid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Star") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("TableName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@Admin_id,@Admin_UserName,@Content,@Images,@ImagesSmall,@IsRead,@Keyid,@Language_Code,@Parentid,@Product_id,@Star,@Status,@Supplier_id,@Supplier_SubName,@TableName,@Time_Add,@User_id,@User_UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Admin_id",         model.Admin_id),
                new SqlParameter("@Admin_UserName",   model.Admin_UserName),
                new SqlParameter("@Content",          model.Content),
                new SqlParameter("@Images",           model.Images),
                new SqlParameter("@ImagesSmall",      model.ImagesSmall),
                new SqlParameter("@IsRead",           model.IsRead),
                new SqlParameter("@Keyid",            model.Keyid),
                new SqlParameter("@Language_Code",    model.Language_Code),
                new SqlParameter("@Parentid",         model.Parentid),
                new SqlParameter("@Product_id",       model.Product_id),
                new SqlParameter("@Star",             model.Star),
                new SqlParameter("@Status",           model.Status),
                new SqlParameter("@Supplier_id",      model.Supplier_id),
                new SqlParameter("@Supplier_SubName", model.Supplier_SubName),
                new SqlParameter("@TableName",        model.TableName),
                new SqlParameter("@Time_Add",         model.Time_Add),
                new SqlParameter("@User_id",          model.User_id),
                new SqlParameter("@User_UserName",    model.User_UserName)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Comment ReaderBind(IDataReader dataReader)
        {
            Lebi_Comment model = new Lebi_Comment();
            object       ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Admin_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Admin_id = Convert.ToInt32(ojb);
            }
            model.Admin_UserName = dataReader["Admin_UserName"].ToString();
            model.Content        = dataReader["Content"].ToString();
            model.Images         = dataReader["Images"].ToString();
            model.ImagesSmall    = dataReader["ImagesSmall"].ToString();
            ojb = dataReader["IsRead"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsRead = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Keyid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Keyid = Convert.ToInt32(ojb);
            }
            model.Language_Code = dataReader["Language_Code"].ToString();
            ojb = dataReader["Parentid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Parentid = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Product_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Product_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Star"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Star = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Supplier_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_id = Convert.ToInt32(ojb);
            }
            model.Supplier_SubName = dataReader["Supplier_SubName"].ToString();
            model.TableName        = dataReader["TableName"].ToString();
            ojb = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            ojb = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            model.User_UserName = dataReader["User_UserName"].ToString();
            return(model);
        }
コード例 #4
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Comment SafeBindForm(Lebi_Comment model)
 {
     if (HttpContext.Current.Request["Admin_id"] != null)
     {
         model.Admin_id = LB.Tools.RequestTool.RequestInt("Admin_id", 0);
     }
     if (HttpContext.Current.Request["Admin_UserName"] != null)
     {
         model.Admin_UserName = LB.Tools.RequestTool.RequestSafeString("Admin_UserName");
     }
     if (HttpContext.Current.Request["Content"] != null)
     {
         model.Content = LB.Tools.RequestTool.RequestSafeString("Content");
     }
     if (HttpContext.Current.Request["Images"] != null)
     {
         model.Images = LB.Tools.RequestTool.RequestSafeString("Images");
     }
     if (HttpContext.Current.Request["ImagesSmall"] != null)
     {
         model.ImagesSmall = LB.Tools.RequestTool.RequestSafeString("ImagesSmall");
     }
     if (HttpContext.Current.Request["IsRead"] != null)
     {
         model.IsRead = LB.Tools.RequestTool.RequestInt("IsRead", 0);
     }
     if (HttpContext.Current.Request["Keyid"] != null)
     {
         model.Keyid = LB.Tools.RequestTool.RequestInt("Keyid", 0);
     }
     if (HttpContext.Current.Request["Language_Code"] != null)
     {
         model.Language_Code = LB.Tools.RequestTool.RequestSafeString("Language_Code");
     }
     if (HttpContext.Current.Request["Parentid"] != null)
     {
         model.Parentid = LB.Tools.RequestTool.RequestInt("Parentid", 0);
     }
     if (HttpContext.Current.Request["Product_id"] != null)
     {
         model.Product_id = LB.Tools.RequestTool.RequestInt("Product_id", 0);
     }
     if (HttpContext.Current.Request["Star"] != null)
     {
         model.Star = LB.Tools.RequestTool.RequestInt("Star", 0);
     }
     if (HttpContext.Current.Request["Status"] != null)
     {
         model.Status = LB.Tools.RequestTool.RequestInt("Status", 0);
     }
     if (HttpContext.Current.Request["Supplier_id"] != null)
     {
         model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0);
     }
     if (HttpContext.Current.Request["Supplier_SubName"] != null)
     {
         model.Supplier_SubName = LB.Tools.RequestTool.RequestSafeString("Supplier_SubName");
     }
     if (HttpContext.Current.Request["TableName"] != null)
     {
         model.TableName = LB.Tools.RequestTool.RequestSafeString("TableName");
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     if (HttpContext.Current.Request["User_UserName"] != null)
     {
         model.User_UserName = LB.Tools.RequestTool.RequestSafeString("User_UserName");
     }
     return(model);
 }
コード例 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Comment model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Admin_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "= @Admin_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Admin_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "= @Admin_UserName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Content,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "= @Content");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Images,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Images") + "= @Images");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ImagesSmall,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ImagesSmall") + "= @ImagesSmall");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsRead,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsRead") + "= @IsRead");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Keyid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Keyid") + "= @Keyid");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language_Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_Code") + "= @Language_Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Parentid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Parentid") + "= @Parentid");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Product_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "= @Product_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Star,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Star") + "= @Star");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Status,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "= @Status");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_SubName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_SubName") + "= @Supplier_SubName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",TableName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("TableName") + "= @TableName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + "= @User_UserName");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",               model.id),
                new SqlParameter("@Admin_id",         model.Admin_id),
                new SqlParameter("@Admin_UserName",   model.Admin_UserName),
                new SqlParameter("@Content",          model.Content),
                new SqlParameter("@Images",           model.Images),
                new SqlParameter("@ImagesSmall",      model.ImagesSmall),
                new SqlParameter("@IsRead",           model.IsRead),
                new SqlParameter("@Keyid",            model.Keyid),
                new SqlParameter("@Language_Code",    model.Language_Code),
                new SqlParameter("@Parentid",         model.Parentid),
                new SqlParameter("@Product_id",       model.Product_id),
                new SqlParameter("@Star",             model.Star),
                new SqlParameter("@Status",           model.Status),
                new SqlParameter("@Supplier_id",      model.Supplier_id),
                new SqlParameter("@Supplier_SubName", model.Supplier_SubName),
                new SqlParameter("@TableName",        model.TableName),
                new SqlParameter("@Time_Add",         model.Time_Add),
                new SqlParameter("@User_id",          model.User_id),
                new SqlParameter("@User_UserName",    model.User_UserName)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Comment model)
 {
     D_Lebi_Comment.Instance.Update(model);
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Comment model)
 {
     return(D_Lebi_Comment.Instance.Add(model));
 }
コード例 #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Comment SafeBindForm(Lebi_Comment model)
 {
     return(D_Lebi_Comment.Instance.SafeBindForm(model));
 }