Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_ProPerty model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("parentid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("parentSort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Tag") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("taobaoid") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_ProPertyType") + ")");
            strSql.Append(" values (");
            strSql.Append("@Code,@ImageUrl,@Name,@parentid,@parentSort,@Price,@Remark,@Sort,@Supplier_id,@Tag,@taobaoid,@Type_id_ProPertyType);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",                 model.Code),
                new SqlParameter("@ImageUrl",             model.ImageUrl),
                new SqlParameter("@Name",                 model.Name),
                new SqlParameter("@parentid",             model.parentid),
                new SqlParameter("@parentSort",           model.parentSort),
                new SqlParameter("@Price",                model.Price),
                new SqlParameter("@Remark",               model.Remark),
                new SqlParameter("@Sort",                 model.Sort),
                new SqlParameter("@Supplier_id",          model.Supplier_id),
                new SqlParameter("@Tag",                  model.Tag),
                new SqlParameter("@taobaoid",             model.taobaoid),
                new SqlParameter("@Type_id_ProPertyType", model.Type_id_ProPertyType)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_ProPerty SafeBindForm(Lebi_ProPerty model)
 {
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["ImageUrl"] != null)
     {
         model.ImageUrl = LB.Tools.RequestTool.RequestSafeString("ImageUrl");
     }
     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["parentSort"] != null)
     {
         model.parentSort = LB.Tools.RequestTool.RequestInt("parentSort", 0);
     }
     if (HttpContext.Current.Request["Price"] != null)
     {
         model.Price = LB.Tools.RequestTool.RequestDecimal("Price", 0);
     }
     if (HttpContext.Current.Request["Remark"] != null)
     {
         model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Supplier_id"] != null)
     {
         model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0);
     }
     if (HttpContext.Current.Request["Tag"] != null)
     {
         model.Tag = LB.Tools.RequestTool.RequestSafeString("Tag");
     }
     if (HttpContext.Current.Request["taobaoid"] != null)
     {
         model.taobaoid = LB.Tools.RequestTool.RequestSafeString("taobaoid");
     }
     if (HttpContext.Current.Request["Type_id_ProPertyType"] != null)
     {
         model.Type_id_ProPertyType = LB.Tools.RequestTool.RequestInt("Type_id_ProPertyType", 0);
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_ProPerty ReaderBind(IDataReader dataReader)
        {
            Lebi_ProPerty model = new Lebi_ProPerty();
            object        ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Code     = dataReader["Code"].ToString();
            model.ImageUrl = dataReader["ImageUrl"].ToString();
            model.Name     = dataReader["Name"].ToString();
            ojb            = dataReader["parentid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.parentid = Convert.ToInt32(ojb);
            }
            ojb = dataReader["parentSort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.parentSort = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Price"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Price = (decimal)ojb;
            }
            model.Remark = dataReader["Remark"].ToString();
            ojb          = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Supplier_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_id = Convert.ToInt32(ojb);
            }
            model.Tag      = dataReader["Tag"].ToString();
            model.taobaoid = dataReader["taobaoid"].ToString();
            ojb            = dataReader["Type_id_ProPertyType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_ProPertyType = Convert.ToInt32(ojb);
            }
            return(model);
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_ProPerty 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_ProPerty);
                }
            }
            Lebi_ProPerty 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_ProPerty", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_ProPerty model)
 {
     D_Lebi_ProPerty.Instance.Update(model);
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_ProPerty model)
 {
     return(D_Lebi_ProPerty.Instance.Add(model));
 }
Example #7
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_ProPerty SafeBindForm(Lebi_ProPerty model)
 {
     return(D_Lebi_ProPerty.Instance.SafeBindForm(model));
 }
Example #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_ProPerty 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(",ImageUrl,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "= @ImageUrl");
            }
            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(",parentSort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("parentSort") + "= @parentSort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Price,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "= @Price");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Tag,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Tag") + "= @Tag");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",taobaoid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("taobaoid") + "= @taobaoid");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_ProPertyType,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_ProPertyType") + "= @Type_id_ProPertyType");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                   model.id),
                new SqlParameter("@Code",                 model.Code),
                new SqlParameter("@ImageUrl",             model.ImageUrl),
                new SqlParameter("@Name",                 model.Name),
                new SqlParameter("@parentid",             model.parentid),
                new SqlParameter("@parentSort",           model.parentSort),
                new SqlParameter("@Price",                model.Price),
                new SqlParameter("@Remark",               model.Remark),
                new SqlParameter("@Sort",                 model.Sort),
                new SqlParameter("@Supplier_id",          model.Supplier_id),
                new SqlParameter("@Tag",                  model.Tag),
                new SqlParameter("@taobaoid",             model.taobaoid),
                new SqlParameter("@Type_id_ProPertyType", model.Type_id_ProPertyType)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }