Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Mofang.Model.ProductCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductCategory set ");

            strSql.Append(" CategoryName = @CategoryName , ");
            strSql.Append(" OrderId = @OrderId , ");
            strSql.Append(" ParentId = @ParentId  ");
            strSql.Append(" where ProductCategoryId=@ProductCategoryId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductCategoryId", model.ProductCategoryId),
                new SqlParameter("@CategoryName",      model.CategoryName),
                new SqlParameter("@OrderId",           model.OrderId),
                new SqlParameter("@ParentId",          model.ParentId)
            };

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Mofang.Model.ProductCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductCategory(");
            strSql.Append("CategoryName,OrderId,ParentId");
            strSql.Append(") values (");
            strSql.Append("@CategoryName,@OrderId,@ParentId");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CategoryName", model.CategoryName),
                new SqlParameter("@OrderId",      model.OrderId),
                new SqlParameter("@ParentId",     model.ParentId)
            };


            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public Mofang.Model.ProductCategory DataRowToModel(DataRow row)
        {
            Mofang.Model.ProductCategory model = new Mofang.Model.ProductCategory();

            if (row != null)
            {
                if (row["ProductCategoryId"].ToString() != "")
                {
                    model.ProductCategoryId = int.Parse(row["ProductCategoryId"].ToString());
                }
                model.CategoryName = row["CategoryName"].ToString();
                if (row["OrderId"].ToString() != "")
                {
                    model.OrderId = int.Parse(row["OrderId"].ToString());
                }
                if (row["ParentId"].ToString() != "")
                {
                    model.ParentId = int.Parse(row["ParentId"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mofang.Model.ProductCategory GetModel(int ProductCategoryId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ProductCategoryId, CategoryName, OrderId, ParentId  ");
            strSql.Append("  from ProductCategory ");
            strSql.Append(" where ProductCategoryId=@ProductCategoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductCategoryId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProductCategoryId;


            Mofang.Model.ProductCategory model = new Mofang.Model.ProductCategory();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Mofang.Model.ProductCategory model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Mofang.Model.ProductCategory model)
 {
     return(dal.Add(model));
 }