/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cms.Model.C_article_attribute_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update C_article_attribute_value set "); strSql.Append("sub_title=@sub_title,"); strSql.Append("source=@source,"); strSql.Append("author=@author,"); strSql.Append("goods_no=@goods_no,"); strSql.Append("stock_quantity=@stock_quantity,"); strSql.Append("market_price=@market_price,"); strSql.Append("sell_price=@sell_price,"); strSql.Append("point=@point"); strSql.Append(" where article_id=@article_id "); SqlParameter[] parameters = { new SqlParameter("@sub_title", SqlDbType.NVarChar, 255), new SqlParameter("@source", SqlDbType.NVarChar, 100), new SqlParameter("@author", SqlDbType.NVarChar, 50), new SqlParameter("@goods_no", SqlDbType.NVarChar, 100), new SqlParameter("@stock_quantity", SqlDbType.Int, 4), new SqlParameter("@market_price", SqlDbType.Decimal, 5), new SqlParameter("@sell_price", SqlDbType.Decimal, 5), new SqlParameter("@point", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters[0].Value = model.sub_title; parameters[1].Value = model.source; parameters[2].Value = model.author; parameters[3].Value = model.goods_no; parameters[4].Value = model.stock_quantity; parameters[5].Value = model.market_price; parameters[6].Value = model.sell_price; parameters[7].Value = model.point; parameters[8].Value = model.article_id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cms.Model.C_article_attribute_value DataRowToModel(DataRow row) { Cms.Model.C_article_attribute_value model = new Cms.Model.C_article_attribute_value(); if (row != null) { if (row["article_id"] != null && row["article_id"].ToString() != "") { model.article_id = int.Parse(row["article_id"].ToString()); } if (row["sub_title"] != null) { model.sub_title = row["sub_title"].ToString(); } if (row["source"] != null) { model.source = row["source"].ToString(); } if (row["author"] != null) { model.author = row["author"].ToString(); } if (row["goods_no"] != null) { model.goods_no = row["goods_no"].ToString(); } if (row["stock_quantity"] != null && row["stock_quantity"].ToString() != "") { model.stock_quantity = int.Parse(row["stock_quantity"].ToString()); } if (row["market_price"] != null && row["market_price"].ToString() != "") { model.market_price = decimal.Parse(row["market_price"].ToString()); } if (row["sell_price"] != null && row["sell_price"].ToString() != "") { model.sell_price = decimal.Parse(row["sell_price"].ToString()); } if (row["point"] != null && row["point"].ToString() != "") { model.point = int.Parse(row["point"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Cms.Model.C_article_attribute_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into C_article_attribute_value("); strSql.Append("article_id,sub_title,source,author,goods_no,stock_quantity,market_price,sell_price,point)"); strSql.Append(" values ("); strSql.Append("@article_id,@sub_title,@source,@author,@goods_no,@stock_quantity,@market_price,@sell_price,@point)"); SqlParameter[] parameters = { new SqlParameter("@article_id", SqlDbType.Int, 4), new SqlParameter("@sub_title", SqlDbType.NVarChar, 255), new SqlParameter("@source", SqlDbType.NVarChar, 100), new SqlParameter("@author", SqlDbType.NVarChar, 50), new SqlParameter("@goods_no", SqlDbType.NVarChar, 100), new SqlParameter("@stock_quantity", SqlDbType.Int, 4), new SqlParameter("@market_price", SqlDbType.Decimal, 5), new SqlParameter("@sell_price", SqlDbType.Decimal, 5), new SqlParameter("@point", SqlDbType.Int, 4) }; parameters[0].Value = model.article_id; parameters[1].Value = model.sub_title; parameters[2].Value = model.source; parameters[3].Value = model.author; parameters[4].Value = model.goods_no; parameters[5].Value = model.stock_quantity; parameters[6].Value = model.market_price; parameters[7].Value = model.sell_price; parameters[8].Value = model.point; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cms.Model.C_article_attribute_value GetModel(int article_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 article_id,sub_title,source,author,goods_no,stock_quantity,market_price,sell_price,point from C_article_attribute_value "); strSql.Append(" where article_id=@article_id "); SqlParameter[] parameters = { new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters[0].Value = article_id; Cms.Model.C_article_attribute_value model = new Cms.Model.C_article_attribute_value(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }