Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Supplier_Power model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_Group_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Group_id") + "= @Supplier_Group_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_Limit_Code,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Limit_Code") + "= @Supplier_Limit_Code");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Supplier_Limit_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Limit_id") + "= @Supplier_Limit_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Url,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Url") + "= @Url");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                  model.id),
                new SqlParameter("@Supplier_Group_id",   model.Supplier_Group_id),
                new SqlParameter("@Supplier_Limit_Code", model.Supplier_Limit_Code),
                new SqlParameter("@Supplier_Limit_id",   model.Supplier_Limit_id),
                new SqlParameter("@Url",                 model.Url)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Supplier_Power model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Group_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Limit_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_Limit_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Url") + ")");
            strSql.Append(" values (");
            strSql.Append("@Supplier_Group_id,@Supplier_Limit_Code,@Supplier_Limit_id,@Url);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Supplier_Group_id",   model.Supplier_Group_id),
                new SqlParameter("@Supplier_Limit_Code", model.Supplier_Limit_Code),
                new SqlParameter("@Supplier_Limit_id",   model.Supplier_Limit_id),
                new SqlParameter("@Url",                 model.Url)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Supplier_Power 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_Power);
                }
            }
            Lebi_Supplier_Power 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_Power", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Exemple #4
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Supplier_Power SafeBindForm(Lebi_Supplier_Power model)
 {
     if (HttpContext.Current.Request["Supplier_Group_id"] != null)
     {
         model.Supplier_Group_id = LB.Tools.RequestTool.RequestInt("Supplier_Group_id", 0);
     }
     if (HttpContext.Current.Request["Supplier_Limit_Code"] != null)
     {
         model.Supplier_Limit_Code = LB.Tools.RequestTool.RequestSafeString("Supplier_Limit_Code");
     }
     if (HttpContext.Current.Request["Supplier_Limit_id"] != null)
     {
         model.Supplier_Limit_id = LB.Tools.RequestTool.RequestInt("Supplier_Limit_id", 0);
     }
     if (HttpContext.Current.Request["Url"] != null)
     {
         model.Url = LB.Tools.RequestTool.RequestSafeString("Url");
     }
     return(model);
 }
Exemple #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Supplier_Power ReaderBind(IDataReader dataReader)
        {
            Lebi_Supplier_Power model = new Lebi_Supplier_Power();
            object ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Supplier_Group_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_Group_id = Convert.ToInt32(ojb);
            }
            model.Supplier_Limit_Code = dataReader["Supplier_Limit_Code"].ToString();
            ojb = dataReader["Supplier_Limit_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Supplier_Limit_id = Convert.ToInt32(ojb);
            }
            model.Url = dataReader["Url"].ToString();
            return(model);
        }
Exemple #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Supplier_Power model)
 {
     D_Lebi_Supplier_Power.Instance.Update(model);
 }
Exemple #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Supplier_Power model)
 {
     return(D_Lebi_Supplier_Power.Instance.Add(model));
 }
Exemple #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Supplier_Power SafeBindForm(Lebi_Supplier_Power model)
 {
     return(D_Lebi_Supplier_Power.Instance.SafeBindForm(model));
 }