예제 #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_ImageSize ReaderBind(IDataReader dataReader)
        {
            Lebi_ImageSize model = new Lebi_ImageSize();
            object         ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Height"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Height = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            ojb = dataReader["Width"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Width = Convert.ToInt32(ojb);
            }
            return(model);
        }
예제 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_ImageSize model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Height,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Height") + "= @Height");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            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("@Height",   model.Height),
                new SqlParameter("@Time_Add", model.Time_Add),
                new SqlParameter("@Width",    model.Width)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_ImageSize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Height") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Width") + ")");
            strSql.Append(" values (");
            strSql.Append("@Height,@Time_Add,@Width);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Height",   model.Height),
                new SqlParameter("@Time_Add", model.Time_Add),
                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
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_ImageSize SafeBindForm(Lebi_ImageSize model)
 {
     if (HttpContext.Current.Request["Height"] != null)
     {
         model.Height = LB.Tools.RequestTool.RequestInt("Height", 0);
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Width"] != null)
     {
         model.Width = LB.Tools.RequestTool.RequestInt("Width", 0);
     }
     return(model);
 }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_ImageSize 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_ImageSize);
                }
            }
            Lebi_ImageSize 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_ImageSize", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
예제 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_ImageSize model)
 {
     D_Lebi_ImageSize.Instance.Update(model);
 }
예제 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_ImageSize model)
 {
     return(D_Lebi_ImageSize.Instance.Add(model));
 }
예제 #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_ImageSize SafeBindForm(Lebi_ImageSize model)
 {
     return(D_Lebi_ImageSize.Instance.SafeBindForm(model));
 }