/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.ProductRelation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ProductRelation set "); strSql.Append(" ClassId = @ClassId , "); strSql.Append(" ProductId = @ProductId "); strSql.Append(" where ProductRelationId=@ProductRelationId "); SqlParameter[] parameters = { new SqlParameter("@ProductRelationId", model.ProductRelationId), new SqlParameter("@ClassId", model.ClassId), new SqlParameter("@ProductId", model.ProductId) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.ProductRelation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProductRelation("); strSql.Append("ClassId,ProductId"); strSql.Append(") values ("); strSql.Append("@ClassId,@ProductId"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@ClassId", model.ClassId), new SqlParameter("@ProductId", model.ProductId) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.ProductRelation DataRowToModel(DataRow row) { BWJS.Model.ProductRelation model = new BWJS.Model.ProductRelation(); if (row != null) { if (row["ProductRelationId"].ToString() != "") { model.ProductRelationId = int.Parse(row["ProductRelationId"].ToString()); } if (row["ClassId"].ToString() != "") { model.ClassId = int.Parse(row["ClassId"].ToString()); } if (row["ProductId"].ToString() != "") { model.ProductId = int.Parse(row["ProductId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.ProductRelation GetModel(int ProductRelationId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ProductRelationId, ClassId, ProductId "); strSql.Append(" from ProductRelation "); strSql.Append(" where ProductRelationId=@ProductRelationId"); SqlParameter[] parameters = { new SqlParameter("@ProductRelationId", SqlDbType.Int, 4) }; parameters[0].Value = ProductRelationId; BWJS.Model.ProductRelation model = new BWJS.Model.ProductRelation(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.ProductRelation model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.ProductRelation model) { return(dal.Add(model)); }