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

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.head  = dataReader["head"].ToString();
            model.Image = dataReader["Image"].ToString();
            ojb         = dataReader["IsPublic"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsPublic = Convert.ToInt32(ojb);
            }
            ojb = dataReader["IsShow"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsShow = Convert.ToInt32(ojb);
            }
            model.longbar  = dataReader["longbar"].ToString();
            model.Name     = dataReader["Name"].ToString();
            model.Path     = dataReader["Path"].ToString();
            model.shortbar = dataReader["shortbar"].ToString();
            ojb            = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            model.type = dataReader["type"].ToString();
            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Supplier_Skin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("head") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Image") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPublic") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("longbar") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Path") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("shortbar") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("type") + ")");
            strSql.Append(" values (");
            strSql.Append("@head,@Image,@IsPublic,@IsShow,@longbar,@Name,@Path,@shortbar,@Sort,@type);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@head",     model.head),
                new SqlParameter("@Image",    model.Image),
                new SqlParameter("@IsPublic", model.IsPublic),
                new SqlParameter("@IsShow",   model.IsShow),
                new SqlParameter("@longbar",  model.longbar),
                new SqlParameter("@Name",     model.Name),
                new SqlParameter("@Path",     model.Path),
                new SqlParameter("@shortbar", model.shortbar),
                new SqlParameter("@Sort",     model.Sort),
                new SqlParameter("@type",     model.type)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Supplier_Skin SafeBindForm(Lebi_Supplier_Skin model)
 {
     if (HttpContext.Current.Request["head"] != null)
     {
         model.head = LB.Tools.RequestTool.RequestSafeString("head");
     }
     if (HttpContext.Current.Request["Image"] != null)
     {
         model.Image = LB.Tools.RequestTool.RequestSafeString("Image");
     }
     if (HttpContext.Current.Request["IsPublic"] != null)
     {
         model.IsPublic = LB.Tools.RequestTool.RequestInt("IsPublic", 0);
     }
     if (HttpContext.Current.Request["IsShow"] != null)
     {
         model.IsShow = LB.Tools.RequestTool.RequestInt("IsShow", 0);
     }
     if (HttpContext.Current.Request["longbar"] != null)
     {
         model.longbar = LB.Tools.RequestTool.RequestSafeString("longbar");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Path"] != null)
     {
         model.Path = LB.Tools.RequestTool.RequestSafeString("Path");
     }
     if (HttpContext.Current.Request["shortbar"] != null)
     {
         model.shortbar = LB.Tools.RequestTool.RequestSafeString("shortbar");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["type"] != null)
     {
         model.type = LB.Tools.RequestTool.RequestSafeString("type");
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Supplier_Skin 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_Supplier_Skin);
                }
            }
            Lebi_Supplier_Skin 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_Supplier_Skin", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Supplier_Skin model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",head,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("head") + "= @head");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Image,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Image") + "= @Image");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsPublic,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPublic") + "= @IsPublic");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsShow,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "= @IsShow");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",longbar,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("longbar") + "= @longbar");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Path,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Path") + "= @Path");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",shortbar,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("shortbar") + "= @shortbar");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",type,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("type") + "= @type");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       model.id),
                new SqlParameter("@head",     model.head),
                new SqlParameter("@Image",    model.Image),
                new SqlParameter("@IsPublic", model.IsPublic),
                new SqlParameter("@IsShow",   model.IsShow),
                new SqlParameter("@longbar",  model.longbar),
                new SqlParameter("@Name",     model.Name),
                new SqlParameter("@Path",     model.Path),
                new SqlParameter("@shortbar", model.shortbar),
                new SqlParameter("@Sort",     model.Sort),
                new SqlParameter("@type",     model.type)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Supplier_Skin model)
 {
     D_Lebi_Supplier_Skin.Instance.Update(model);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Supplier_Skin model)
 {
     return(D_Lebi_Supplier_Skin.Instance.Add(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Supplier_Skin SafeBindForm(Lebi_Supplier_Skin model)
 {
     return(D_Lebi_Supplier_Skin.Instance.SafeBindForm(model));
 }