Ejemplo n.º 1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Brand ReaderBind(IDataReader dataReader)
        {
            Lebi_Brand model = new Lebi_Brand();
            object     ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Count"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Count = Convert.ToInt32(ojb);
            }
            model.Description = dataReader["Description"].ToString();
            model.FirstLetter = dataReader["FirstLetter"].ToString();
            model.ImageUrl    = dataReader["ImageUrl"].ToString();
            ojb = dataReader["IsRecommend"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsRecommend = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsVAT"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsVAT = Convert.ToInt32(ojb);
            }
            model.Name            = dataReader["Name"].ToString();
            model.Pro_Type_id     = dataReader["Pro_Type_id"].ToString();
            model.SEO_Description = dataReader["SEO_Description"].ToString();
            model.SEO_Keywords    = dataReader["SEO_Keywords"].ToString();
            model.SEO_Title       = dataReader["SEO_Title"].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);
            }
            ojb = dataReader["Type_id_BrandStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_BrandStatus = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Type_id_SupplierStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_SupplierStatus = Convert.ToInt32(ojb);
            }
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Brand 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_Brand);
                }
            }
            Lebi_Brand 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_Brand", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Brand model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("FirstLetter") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsRecommend") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsVAT") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Pro_Type_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Keywords") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Title") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_BrandStatus") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_SupplierStatus") + ")");
            strSql.Append(" values (");
            strSql.Append("@Count,@Description,@FirstLetter,@ImageUrl,@IsRecommend,@IsVAT,@Name,@Pro_Type_id,@SEO_Description,@SEO_Keywords,@SEO_Title,@Sort,@Supplier_id,@Type_id_BrandStatus,@Type_id_SupplierStatus);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Count",                  model.Count),
                new SqlParameter("@Description",            model.Description),
                new SqlParameter("@FirstLetter",            model.FirstLetter),
                new SqlParameter("@ImageUrl",               model.ImageUrl),
                new SqlParameter("@IsRecommend",            model.IsRecommend),
                new SqlParameter("@IsVAT",                  model.IsVAT),
                new SqlParameter("@Name",                   model.Name),
                new SqlParameter("@Pro_Type_id",            model.Pro_Type_id),
                new SqlParameter("@SEO_Description",        model.SEO_Description),
                new SqlParameter("@SEO_Keywords",           model.SEO_Keywords),
                new SqlParameter("@SEO_Title",              model.SEO_Title),
                new SqlParameter("@Sort",                   model.Sort),
                new SqlParameter("@Supplier_id",            model.Supplier_id),
                new SqlParameter("@Type_id_BrandStatus",    model.Type_id_BrandStatus),
                new SqlParameter("@Type_id_SupplierStatus", model.Type_id_SupplierStatus)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Brand SafeBindForm(Lebi_Brand model)
 {
     if (HttpContext.Current.Request["Count"] != null)
     {
         model.Count = LB.Tools.RequestTool.RequestInt("Count", 0);
     }
     if (HttpContext.Current.Request["Description"] != null)
     {
         model.Description = LB.Tools.RequestTool.RequestSafeString("Description");
     }
     if (HttpContext.Current.Request["FirstLetter"] != null)
     {
         model.FirstLetter = LB.Tools.RequestTool.RequestSafeString("FirstLetter");
     }
     if (HttpContext.Current.Request["ImageUrl"] != null)
     {
         model.ImageUrl = LB.Tools.RequestTool.RequestSafeString("ImageUrl");
     }
     if (HttpContext.Current.Request["IsRecommend"] != null)
     {
         model.IsRecommend = LB.Tools.RequestTool.RequestInt("IsRecommend", 0);
     }
     if (HttpContext.Current.Request["IsVAT"] != null)
     {
         model.IsVAT = LB.Tools.RequestTool.RequestInt("IsVAT", 0);
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Pro_Type_id"] != null)
     {
         model.Pro_Type_id = LB.Tools.RequestTool.RequestSafeString("Pro_Type_id");
     }
     if (HttpContext.Current.Request["SEO_Description"] != null)
     {
         model.SEO_Description = LB.Tools.RequestTool.RequestSafeString("SEO_Description");
     }
     if (HttpContext.Current.Request["SEO_Keywords"] != null)
     {
         model.SEO_Keywords = LB.Tools.RequestTool.RequestSafeString("SEO_Keywords");
     }
     if (HttpContext.Current.Request["SEO_Title"] != null)
     {
         model.SEO_Title = LB.Tools.RequestTool.RequestSafeString("SEO_Title");
     }
     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["Type_id_BrandStatus"] != null)
     {
         model.Type_id_BrandStatus = LB.Tools.RequestTool.RequestInt("Type_id_BrandStatus", 0);
     }
     if (HttpContext.Current.Request["Type_id_SupplierStatus"] != null)
     {
         model.Type_id_SupplierStatus = LB.Tools.RequestTool.RequestInt("Type_id_SupplierStatus", 0);
     }
     return(model);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Brand model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Count,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count") + "= @Count");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "= @Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",FirstLetter,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("FirstLetter") + "= @FirstLetter");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ImageUrl,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "= @ImageUrl");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsRecommend,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsRecommend") + "= @IsRecommend");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsVAT,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsVAT") + "= @IsVAT");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Pro_Type_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Pro_Type_id") + "= @Pro_Type_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Description") + "= @SEO_Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Keywords,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Keywords") + "= @SEO_Keywords");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",SEO_Title,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("SEO_Title") + "= @SEO_Title");
            }
            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(",Type_id_BrandStatus,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_BrandStatus") + "= @Type_id_BrandStatus");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_SupplierStatus,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_SupplierStatus") + "= @Type_id_SupplierStatus");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                     model.id),
                new SqlParameter("@Count",                  model.Count),
                new SqlParameter("@Description",            model.Description),
                new SqlParameter("@FirstLetter",            model.FirstLetter),
                new SqlParameter("@ImageUrl",               model.ImageUrl),
                new SqlParameter("@IsRecommend",            model.IsRecommend),
                new SqlParameter("@IsVAT",                  model.IsVAT),
                new SqlParameter("@Name",                   model.Name),
                new SqlParameter("@Pro_Type_id",            model.Pro_Type_id),
                new SqlParameter("@SEO_Description",        model.SEO_Description),
                new SqlParameter("@SEO_Keywords",           model.SEO_Keywords),
                new SqlParameter("@SEO_Title",              model.SEO_Title),
                new SqlParameter("@Sort",                   model.Sort),
                new SqlParameter("@Supplier_id",            model.Supplier_id),
                new SqlParameter("@Type_id_BrandStatus",    model.Type_id_BrandStatus),
                new SqlParameter("@Type_id_SupplierStatus", model.Type_id_SupplierStatus)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Brand model)
 {
     D_Lebi_Brand.Instance.Update(model);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Brand model)
 {
     return(D_Lebi_Brand.Instance.Add(model));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Brand SafeBindForm(Lebi_Brand model)
 {
     return(D_Lebi_Brand.Instance.SafeBindForm(model));
 }