Пример #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Currency ReaderBind(IDataReader dataReader)
        {
            Lebi_Currency model = new Lebi_Currency();
            object        ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Code = dataReader["Code"].ToString();
            ojb        = dataReader["DecimalLength"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DecimalLength = Convert.ToInt32(ojb);
            }
            ojb = dataReader["ExchangeRate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ExchangeRate = (decimal)ojb;
            }
            ojb = dataReader["IsDefault"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsDefault = Convert.ToInt32(ojb);
            }
            model.Msige = dataReader["Msige"].ToString();
            model.Name  = dataReader["Name"].ToString();
            ojb         = dataReader["Sort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Sort = Convert.ToInt32(ojb);
            }
            return(model);
        }
Пример #2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Currency SafeBindForm(Lebi_Currency model)
 {
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = LB.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["DecimalLength"] != null)
     {
         model.DecimalLength = LB.Tools.RequestTool.RequestInt("DecimalLength", 0);
     }
     if (HttpContext.Current.Request["ExchangeRate"] != null)
     {
         model.ExchangeRate = LB.Tools.RequestTool.RequestDecimal("ExchangeRate", 0);
     }
     if (HttpContext.Current.Request["IsDefault"] != null)
     {
         model.IsDefault = LB.Tools.RequestTool.RequestInt("IsDefault", 0);
     }
     if (HttpContext.Current.Request["Msige"] != null)
     {
         model.Msige = LB.Tools.RequestTool.RequestSafeString("Msige");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Currency model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("DecimalLength") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ExchangeRate") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsDefault") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Msige") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + ")");
            strSql.Append(" values (");
            strSql.Append("@Code,@DecimalLength,@ExchangeRate,@IsDefault,@Msige,@Name,@Sort);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Code",          model.Code),
                new SqlParameter("@DecimalLength", model.DecimalLength),
                new SqlParameter("@ExchangeRate",  model.ExchangeRate),
                new SqlParameter("@IsDefault",     model.IsDefault),
                new SqlParameter("@Msige",         model.Msige),
                new SqlParameter("@Name",          model.Name),
                new SqlParameter("@Sort",          model.Sort)
            };

            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 void Update(Lebi_Currency 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(",DecimalLength,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("DecimalLength") + "= @DecimalLength");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",ExchangeRate,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ExchangeRate") + "= @ExchangeRate");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsDefault,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsDefault") + "= @IsDefault");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Msige,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Msige") + "= @Msige");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",            model.id),
                new SqlParameter("@Code",          model.Code),
                new SqlParameter("@DecimalLength", model.DecimalLength),
                new SqlParameter("@ExchangeRate",  model.ExchangeRate),
                new SqlParameter("@IsDefault",     model.IsDefault),
                new SqlParameter("@Msige",         model.Msige),
                new SqlParameter("@Name",          model.Name),
                new SqlParameter("@Sort",          model.Sort)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Currency 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_Currency);
                }
            }
            Lebi_Currency 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_Currency", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Currency model)
 {
     D_Lebi_Currency.Instance.Update(model);
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Currency model)
 {
     return(D_Lebi_Currency.Instance.Add(model));
 }
Пример #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Currency SafeBindForm(Lebi_Currency model)
 {
     return(D_Lebi_Currency.Instance.SafeBindForm(model));
 }