コード例 #1
0
ファイル: D_Lebi_Advert.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Advert ReaderBind(IDataReader dataReader)
        {
            Lebi_Advert model = new Lebi_Advert();
            object      ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Description = dataReader["Description"].ToString();
            ojb = dataReader["Height"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Height = Convert.ToInt32(ojb);
            }
            model.Image          = dataReader["Image"].ToString();
            model.ImageSmall     = dataReader["ImageSmall"].ToString();
            model.Language_Codes = dataReader["Language_Codes"].ToString();
            model.Language_ids   = dataReader["Language_ids"].ToString();
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            model.Tatget            = dataReader["Tatget"].ToString();
            model.Theme_Advert_Code = dataReader["Theme_Advert_Code"].ToString();
            ojb = dataReader["Theme_Advert_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Theme_Advert_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Theme_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Theme_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            model.Title = dataReader["Title"].ToString();
            model.URL   = dataReader["URL"].ToString();
            ojb         = dataReader["Width"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Width = Convert.ToInt32(ojb);
            }
            return(model);
        }
コード例 #2
0
ファイル: D_Lebi_Advert.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Advert 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_Advert);
                }
            }
            Lebi_Advert 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_Advert", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
コード例 #3
0
ファイル: D_Lebi_Advert.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Advert model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Height") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Image") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageSmall") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_Codes") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Tatget") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_Advert_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_Advert_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Title") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("URL") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Width") + ")");
            strSql.Append(" values (");
            strSql.Append("@Description,@Height,@Image,@ImageSmall,@Language_Codes,@Language_ids,@Sort,@Tatget,@Theme_Advert_Code,@Theme_Advert_id,@Theme_id,@Time_Add,@Title,@URL,@Width);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Description",       model.Description),
                new SqlParameter("@Height",            model.Height),
                new SqlParameter("@Image",             model.Image),
                new SqlParameter("@ImageSmall",        model.ImageSmall),
                new SqlParameter("@Language_Codes",    model.Language_Codes),
                new SqlParameter("@Language_ids",      model.Language_ids),
                new SqlParameter("@Sort",              model.Sort),
                new SqlParameter("@Tatget",            model.Tatget),
                new SqlParameter("@Theme_Advert_Code", model.Theme_Advert_Code),
                new SqlParameter("@Theme_Advert_id",   model.Theme_Advert_id),
                new SqlParameter("@Theme_id",          model.Theme_id),
                new SqlParameter("@Time_Add",          model.Time_Add),
                new SqlParameter("@Title",             model.Title),
                new SqlParameter("@URL",               model.URL),
                new SqlParameter("@Width",             model.Width)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
ファイル: D_Lebi_Advert.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Advert SafeBindForm(Lebi_Advert model)
 {
     if (HttpContext.Current.Request["Description"] != null)
     {
         model.Description = LB.Tools.RequestTool.RequestSafeString("Description");
     }
     if (HttpContext.Current.Request["Height"] != null)
     {
         model.Height = LB.Tools.RequestTool.RequestInt("Height", 0);
     }
     if (HttpContext.Current.Request["Image"] != null)
     {
         model.Image = LB.Tools.RequestTool.RequestSafeString("Image");
     }
     if (HttpContext.Current.Request["ImageSmall"] != null)
     {
         model.ImageSmall = LB.Tools.RequestTool.RequestSafeString("ImageSmall");
     }
     if (HttpContext.Current.Request["Language_Codes"] != null)
     {
         model.Language_Codes = LB.Tools.RequestTool.RequestSafeString("Language_Codes");
     }
     if (HttpContext.Current.Request["Language_ids"] != null)
     {
         model.Language_ids = LB.Tools.RequestTool.RequestSafeString("Language_ids");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Tatget"] != null)
     {
         model.Tatget = LB.Tools.RequestTool.RequestSafeString("Tatget");
     }
     if (HttpContext.Current.Request["Theme_Advert_Code"] != null)
     {
         model.Theme_Advert_Code = LB.Tools.RequestTool.RequestSafeString("Theme_Advert_Code");
     }
     if (HttpContext.Current.Request["Theme_Advert_id"] != null)
     {
         model.Theme_Advert_id = LB.Tools.RequestTool.RequestInt("Theme_Advert_id", 0);
     }
     if (HttpContext.Current.Request["Theme_id"] != null)
     {
         model.Theme_id = LB.Tools.RequestTool.RequestInt("Theme_id", 0);
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Title"] != null)
     {
         model.Title = LB.Tools.RequestTool.RequestSafeString("Title");
     }
     if (HttpContext.Current.Request["URL"] != null)
     {
         model.URL = LB.Tools.RequestTool.RequestSafeString("URL");
     }
     if (HttpContext.Current.Request["Width"] != null)
     {
         model.Width = LB.Tools.RequestTool.RequestInt("Width", 0);
     }
     return(model);
 }
コード例 #5
0
ファイル: D_Lebi_Advert.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Advert model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Description,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Description") + "= @Description");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Height,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Height") + "= @Height");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Image,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Image") + "= @Image");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ImageSmall,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageSmall") + "= @ImageSmall");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language_Codes,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_Codes") + "= @Language_Codes");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language_ids,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "= @Language_ids");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Tatget,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Tatget") + "= @Tatget");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Theme_Advert_Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_Advert_Code") + "= @Theme_Advert_Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Theme_Advert_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_Advert_id") + "= @Theme_Advert_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Theme_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_id") + "= @Theme_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Title,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Title") + "= @Title");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",URL,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("URL") + "= @URL");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Width,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Width") + "= @Width");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                model.id),
                new SqlParameter("@Description",       model.Description),
                new SqlParameter("@Height",            model.Height),
                new SqlParameter("@Image",             model.Image),
                new SqlParameter("@ImageSmall",        model.ImageSmall),
                new SqlParameter("@Language_Codes",    model.Language_Codes),
                new SqlParameter("@Language_ids",      model.Language_ids),
                new SqlParameter("@Sort",              model.Sort),
                new SqlParameter("@Tatget",            model.Tatget),
                new SqlParameter("@Theme_Advert_Code", model.Theme_Advert_Code),
                new SqlParameter("@Theme_Advert_id",   model.Theme_Advert_id),
                new SqlParameter("@Theme_id",          model.Theme_id),
                new SqlParameter("@Time_Add",          model.Time_Add),
                new SqlParameter("@Title",             model.Title),
                new SqlParameter("@URL",               model.URL),
                new SqlParameter("@Width",             model.Width)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Advert model)
 {
     D_Lebi_Advert.Instance.Update(model);
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Advert model)
 {
     return(D_Lebi_Advert.Instance.Add(model));
 }
コード例 #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Advert SafeBindForm(Lebi_Advert model)
 {
     return(D_Lebi_Advert.Instance.SafeBindForm(model));
 }