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

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

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Project model)
        {
            StringBuilder strSql = new StringBuilder();

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

            string[] arrcols = model.UpdateCols.ToLower().Split(',');
            foreach (string c in arrcols)
            {
                upcols.Add(c);
            }
            if (upcols.Contains("name") || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (upcols.Contains("supplier_ids") || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_ids") + "= @Supplier_ids");
            }
            if (upcols.Contains("sort") || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort");
            }
            if (upcols.Contains("site_ids") || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Site_ids") + "= @Site_ids");
            }
            if (upcols.Contains("pro_type_ids") || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Pro_Type_ids") + "= @Pro_Type_ids");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           model.id),
                new SqlParameter("@Name",         model.Name),
                new SqlParameter("@Supplier_ids", model.Supplier_ids),
                new SqlParameter("@Sort",         model.Sort),
                new SqlParameter("@Site_ids",     model.Site_ids),
                new SqlParameter("@Pro_Type_ids", model.Pro_Type_ids)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Project GetModel(string strWhere, string strFieldShow, int seconds = 0)
        {
            if (strWhere.IndexOf("lbsql{") > 0)
            {
                SQLPara para = new SQLPara(strWhere, "", "");
                return(GetModel(para, seconds));
            }
            string strTableName = TableName;

            strFieldShow = strFieldShow == "" ? "*" : strFieldShow;
            string cachekey = "";
            string cachestr = "";

            if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0)
            {
                cachestr = "select " + strFieldShow + " " + 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_Project);
                }
            }
            Lebi_Project 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, strFieldShow);
                    if (cachekey != "")
                    {
                        LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Project", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体 by SQLpara
        /// </summary>
        public Lebi_Project GetModel(SQLPara para, int seconds = 0)
        {
            string strTableName = TableName;
            string strFieldShow = para.ShowField;
            string strWhere     = para.Where;
            string cachestr     = "";
            string cachekey     = "";

            if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0)
            {
                cachestr = "select " + strFieldShow + " " + TableName + " where " + para.Where + "|" + para.ValueString + "|" + seconds;
                cachekey = LB.Tools.Utils.MD5(cachestr);
                var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey);
                if (obj != null)
                {
                    return(obj as Lebi_Project);
                }
            }
            Lebi_Project model = null;

            using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, para.Para))
            {
                if (dataReader == null)
                {
                    return(null);
                }
                while (dataReader.Read())
                {
                    model = ReaderBind(dataReader, strFieldShow);
                    if (cachekey != "")
                    {
                        LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Project", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
示例#5
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Project SafeBindForm(Lebi_Project model)
 {
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Supplier_ids"] != null)
     {
         model.Supplier_ids = LB.Tools.RequestTool.RequestSafeString("Supplier_ids");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0);
     }
     if (HttpContext.Current.Request["Site_ids"] != null)
     {
         model.Site_ids = LB.Tools.RequestTool.RequestSafeString("Site_ids");
     }
     if (HttpContext.Current.Request["Pro_Type_ids"] != null)
     {
         model.Pro_Type_ids = LB.Tools.RequestTool.RequestSafeString("Pro_Type_ids");
     }
     return(model);
 }
示例#6
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Project ReaderBind(IDataReader dataReader, string strFieldShow)
        {
            Lebi_Project  model = new Lebi_Project();
            object        ojb;
            List <string> upcols = new List <string>();

            string[] arrcols = strFieldShow.ToLower().Split(',');
            bool     isall   = false;

            if (strFieldShow == "*")
            {
                isall = true;
            }
            else
            {
                foreach (string c in arrcols)
                {
                    upcols.Add(c);
                }
            }
            if (isall || upcols.Contains("id"))
            {
                ojb = dataReader["id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.id = Convert.ToInt32(ojb);
                }
            }
            if (isall || upcols.Contains("name"))
            {
                ojb = dataReader["Name"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Name = dataReader["Name"].ToString();
                }
            }
            if (isall || upcols.Contains("supplier_ids"))
            {
                ojb = dataReader["Supplier_ids"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Supplier_ids = dataReader["Supplier_ids"].ToString();
                }
            }
            if (isall || upcols.Contains("sort"))
            {
                ojb = dataReader["Sort"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Sort = Convert.ToInt32(ojb);
                }
            }
            if (isall || upcols.Contains("site_ids"))
            {
                ojb = dataReader["Site_ids"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Site_ids = dataReader["Site_ids"].ToString();
                }
            }
            if (isall || upcols.Contains("pro_type_ids"))
            {
                ojb = dataReader["Pro_Type_ids"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Pro_Type_ids = dataReader["Pro_Type_ids"].ToString();
                }
            }
            return(model);
        }
示例#7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Project model)
 {
     D_Lebi_Project.Instance.Update(model);
 }
示例#8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Project model)
 {
     return(D_Lebi_Project.Instance.Add(model));
 }
示例#9
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Project SafeBindForm(Lebi_Project model)
 {
     return(D_Lebi_Project.Instance.SafeBindForm(model));
 }