コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_DT_Product model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Count_Sales,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count_Sales") + "= @Count_Sales");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Count_Views,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count_Views") + "= @Count_Views");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",DT_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "= @DT_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Parentid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Parentid") + "= @Parentid");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Price,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "= @Price");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Price_Market,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Price_Market") + "= @Price_Market");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Product_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "= @Product_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + "= @UserName");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           model.id),
                new SqlParameter("@Count_Sales",  model.Count_Sales),
                new SqlParameter("@Count_Views",  model.Count_Views),
                new SqlParameter("@DT_id",        model.DT_id),
                new SqlParameter("@Parentid",     model.Parentid),
                new SqlParameter("@Price",        model.Price),
                new SqlParameter("@Price_Market", model.Price_Market),
                new SqlParameter("@Product_id",   model.Product_id),
                new SqlParameter("@User_id",      model.User_id),
                new SqlParameter("@UserName",     model.UserName)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_DT_Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count_Sales") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Count_Views") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("DT_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Parentid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Price_Market") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@Count_Sales,@Count_Views,@DT_id,@Parentid,@Price,@Price_Market,@Product_id,@User_id,@UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Count_Sales",  model.Count_Sales),
                new SqlParameter("@Count_Views",  model.Count_Views),
                new SqlParameter("@DT_id",        model.DT_id),
                new SqlParameter("@Parentid",     model.Parentid),
                new SqlParameter("@Price",        model.Price),
                new SqlParameter("@Price_Market", model.Price_Market),
                new SqlParameter("@Product_id",   model.Product_id),
                new SqlParameter("@User_id",      model.User_id),
                new SqlParameter("@UserName",     model.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_DT_Product ReaderBind(IDataReader dataReader)
        {
            Lebi_DT_Product model = new Lebi_DT_Product();
            object          ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Count_Sales"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Count_Sales = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Count_Views"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Count_Views = Convert.ToInt32(ojb);
            }
            ojb = dataReader["DT_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DT_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Parentid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Parentid = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Price"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Price = (decimal)ojb;
            }
            ojb = dataReader["Price_Market"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Price_Market = (decimal)ojb;
            }
            ojb = dataReader["Product_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Product_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            model.UserName = dataReader["UserName"].ToString();
            return(model);
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_DT_Product 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_DT_Product);
                }
            }
            Lebi_DT_Product 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_DT_Product", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
コード例 #5
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_DT_Product SafeBindForm(Lebi_DT_Product model)
 {
     if (HttpContext.Current.Request["Count_Sales"] != null)
     {
         model.Count_Sales = LB.Tools.RequestTool.RequestInt("Count_Sales", 0);
     }
     if (HttpContext.Current.Request["Count_Views"] != null)
     {
         model.Count_Views = LB.Tools.RequestTool.RequestInt("Count_Views", 0);
     }
     if (HttpContext.Current.Request["DT_id"] != null)
     {
         model.DT_id = LB.Tools.RequestTool.RequestInt("DT_id", 0);
     }
     if (HttpContext.Current.Request["Parentid"] != null)
     {
         model.Parentid = LB.Tools.RequestTool.RequestInt("Parentid", 0);
     }
     if (HttpContext.Current.Request["Price"] != null)
     {
         model.Price = LB.Tools.RequestTool.RequestDecimal("Price", 0);
     }
     if (HttpContext.Current.Request["Price_Market"] != null)
     {
         model.Price_Market = LB.Tools.RequestTool.RequestDecimal("Price_Market", 0);
     }
     if (HttpContext.Current.Request["Product_id"] != null)
     {
         model.Product_id = LB.Tools.RequestTool.RequestInt("Product_id", 0);
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     if (HttpContext.Current.Request["UserName"] != null)
     {
         model.UserName = LB.Tools.RequestTool.RequestSafeString("UserName");
     }
     return(model);
 }
コード例 #6
0
ファイル: B_Lebi_DT_Product.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_DT_Product model)
 {
     D_Lebi_DT_Product.Instance.Update(model);
 }
コード例 #7
0
ファイル: B_Lebi_DT_Product.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_DT_Product model)
 {
     return(D_Lebi_DT_Product.Instance.Add(model));
 }
コード例 #8
0
ファイル: B_Lebi_DT_Product.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_DT_Product SafeBindForm(Lebi_DT_Product model)
 {
     return(D_Lebi_DT_Product.Instance.SafeBindForm(model));
 }