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

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_ExchangeRate") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_Msige") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsLazyLoad") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Path") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Site_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("TopAreaid") + ")");
            strSql.Append(" values (");
            strSql.Append("@Code,@Currency_ExchangeRate,@Currency_id,@Currency_Msige,@ImageUrl,@IsLazyLoad,@Name,@Path,@Site_id,@Sort,@Theme_id,@TopAreaid);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",                  model.Code),
                new SqlParameter("@Currency_ExchangeRate", model.Currency_ExchangeRate),
                new SqlParameter("@Currency_id",           model.Currency_id),
                new SqlParameter("@Currency_Msige",        model.Currency_Msige),
                new SqlParameter("@ImageUrl",              model.ImageUrl),
                new SqlParameter("@IsLazyLoad",            model.IsLazyLoad),
                new SqlParameter("@Name",                  model.Name),
                new SqlParameter("@Path",                  model.Path),
                new SqlParameter("@Site_id",               model.Site_id),
                new SqlParameter("@Sort",                  model.Sort),
                new SqlParameter("@Theme_id",              model.Theme_id),
                new SqlParameter("@TopAreaid",             model.TopAreaid)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Language ReaderBind(IDataReader dataReader)
        {
            Lebi_Language model = new Lebi_Language();
            object        ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Code = dataReader["Code"].ToString();
            ojb        = dataReader["Currency_ExchangeRate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Currency_ExchangeRate = (decimal)ojb;
            }
            ojb = dataReader["Currency_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Currency_id = Convert.ToInt32(ojb);
            }
            model.Currency_Msige = dataReader["Currency_Msige"].ToString();
            model.ImageUrl       = dataReader["ImageUrl"].ToString();
            ojb = dataReader["IsLazyLoad"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsLazyLoad = Convert.ToInt32(ojb);
            }
            model.Name = dataReader["Name"].ToString();
            model.Path = dataReader["Path"].ToString();
            ojb        = dataReader["Site_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Site_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Theme_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Theme_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["TopAreaid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TopAreaid = Convert.ToInt32(ojb);
            }
            return(model);
        }
Beispiel #3
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Language SafeBindForm(Lebi_Language model)
 {
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["Currency_ExchangeRate"] != null)
     {
         model.Currency_ExchangeRate = LB.Tools.RequestTool.RequestDecimal("Currency_ExchangeRate", 0);
     }
     if (HttpContext.Current.Request["Currency_id"] != null)
     {
         model.Currency_id = LB.Tools.RequestTool.RequestInt("Currency_id", 0);
     }
     if (HttpContext.Current.Request["Currency_Msige"] != null)
     {
         model.Currency_Msige = LB.Tools.RequestTool.RequestSafeString("Currency_Msige");
     }
     if (HttpContext.Current.Request["ImageUrl"] != null)
     {
         model.ImageUrl = LB.Tools.RequestTool.RequestSafeString("ImageUrl");
     }
     if (HttpContext.Current.Request["IsLazyLoad"] != null)
     {
         model.IsLazyLoad = LB.Tools.RequestTool.RequestInt("IsLazyLoad", 0);
     }
     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["Site_id"] != null)
     {
         model.Site_id = LB.Tools.RequestTool.RequestInt("Site_id", 0);
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Theme_id"] != null)
     {
         model.Theme_id = LB.Tools.RequestTool.RequestInt("Theme_id", 0);
     }
     if (HttpContext.Current.Request["TopAreaid"] != null)
     {
         model.TopAreaid = LB.Tools.RequestTool.RequestInt("TopAreaid", 0);
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Language 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_Language);
                }
            }
            Lebi_Language 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_Language", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Language 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(",Currency_ExchangeRate,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_ExchangeRate") + "= @Currency_ExchangeRate");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Currency_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_id") + "= @Currency_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Currency_Msige,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Currency_Msige") + "= @Currency_Msige");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ImageUrl,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ImageUrl") + "= @ImageUrl");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsLazyLoad,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsLazyLoad") + "= @IsLazyLoad");
            }
            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(",Site_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Site_id") + "= @Site_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Theme_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Theme_id") + "= @Theme_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",TopAreaid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("TopAreaid") + "= @TopAreaid");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                    model.id),
                new SqlParameter("@Code",                  model.Code),
                new SqlParameter("@Currency_ExchangeRate", model.Currency_ExchangeRate),
                new SqlParameter("@Currency_id",           model.Currency_id),
                new SqlParameter("@Currency_Msige",        model.Currency_Msige),
                new SqlParameter("@ImageUrl",              model.ImageUrl),
                new SqlParameter("@IsLazyLoad",            model.IsLazyLoad),
                new SqlParameter("@Name",                  model.Name),
                new SqlParameter("@Path",                  model.Path),
                new SqlParameter("@Site_id",               model.Site_id),
                new SqlParameter("@Sort",                  model.Sort),
                new SqlParameter("@Theme_id",              model.Theme_id),
                new SqlParameter("@TopAreaid",             model.TopAreaid)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Language model)
 {
     D_Lebi_Language.Instance.Update(model);
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Language model)
 {
     return(D_Lebi_Language.Instance.Add(model));
 }
Beispiel #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Language SafeBindForm(Lebi_Language model)
 {
     return(D_Lebi_Language.Instance.SafeBindForm(model));
 }