Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_shop_category_catalog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_shop_category_catalog set ");
            strSql.Append("categoryId=@categoryId,");
            strSql.Append("catalogId=@catalogId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryId", SqlDbType.Int, 4),
                new SqlParameter("@catalogId",  SqlDbType.Int, 4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.categoryId;
            parameters[1].Value = model.catalogId;
            parameters[2].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_shop_category_catalog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_shop_category_catalog(");
            strSql.Append("categoryId,catalogId)");
            strSql.Append(" values (");
            strSql.Append("@categoryId,@catalogId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryId", SqlDbType.Int, 4),
                new SqlParameter("@catalogId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.categoryId;
            parameters[1].Value = model.catalogId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_shop_category_catalog DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_shop_category_catalog model = new XCWeiXin.Model.wx_shop_category_catalog();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["categoryId"] != null && row["categoryId"].ToString() != "")
         {
             model.categoryId = int.Parse(row["categoryId"].ToString());
         }
         if (row["catalogId"] != null && row["catalogId"].ToString() != "")
         {
             model.catalogId = int.Parse(row["catalogId"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.wx_shop_category_catalog GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,categoryId,catalogId from wx_shop_category_catalog ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }