/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.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); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.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)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_shop_category_catalog DataRowToModel(DataRow row) { WeiXinPF.Model.wx_shop_category_catalog model = new WeiXinPF.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); }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.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; WeiXinPF.Model.wx_shop_category_catalog model = new WeiXinPF.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); } }