/// <summary> /// 得到一个对象实体 /// </summary> public Cms.Model.C_order_integralsub DataRowToModel(DataRow row) { Cms.Model.C_order_integralsub model = new Cms.Model.C_order_integralsub(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["user_id"] != null && row["user_id"].ToString() != "") { model.user_id = int.Parse(row["user_id"].ToString()); } if (row["order_id"] != null && row["order_id"].ToString() != "") { model.order_id = int.Parse(row["order_id"].ToString()); } if (row["order_num"] != null) { model.order_num = row["order_num"].ToString(); } if (row["article_id"] != null && row["article_id"].ToString() != "") { model.article_id = int.Parse(row["article_id"].ToString()); } if (row["title"] != null) { model.title = row["title"].ToString(); } if (row["price"] != null && row["price"].ToString() != "") { model.price = decimal.Parse(row["price"].ToString()); } if (row["quantity"] != null && row["quantity"].ToString() != "") { model.quantity = int.Parse(row["quantity"].ToString()); } if (row["integral"] != null && row["integral"].ToString() != "") { model.integral = int.Parse(row["integral"].ToString()); } if (row["property_value"] != null) { model.property_value = row["property_value"].ToString(); } if (row["note"] != null) { model.note = row["note"].ToString(); } if (row["updateTime"] != null && row["updateTime"].ToString() != "") { model.updateTime = DateTime.Parse(row["updateTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cms.Model.C_order_integralsub model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update C_order_integralsub set "); strSql.Append("user_id=@user_id,"); strSql.Append("order_id=@order_id,"); strSql.Append("order_num=@order_num,"); strSql.Append("article_id=@article_id,"); strSql.Append("title=@title,"); strSql.Append("price=@price,"); strSql.Append("quantity=@quantity,"); strSql.Append("integral=@integral,"); strSql.Append("property_value=@property_value,"); strSql.Append("note=@note,"); strSql.Append("updateTime=@updateTime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@order_id", SqlDbType.Int, 4), new SqlParameter("@order_num", SqlDbType.VarChar, 350), new SqlParameter("@article_id", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.VarChar, -1), new SqlParameter("@price", SqlDbType.Money, 8), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@integral", SqlDbType.Int, 4), new SqlParameter("@property_value", SqlDbType.VarChar, 550), new SqlParameter("@note", SqlDbType.VarChar, -1), new SqlParameter("@updateTime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.user_id; parameters[1].Value = model.order_id; parameters[2].Value = model.order_num; parameters[3].Value = model.article_id; parameters[4].Value = model.title; parameters[5].Value = model.price; parameters[6].Value = model.quantity; parameters[7].Value = model.integral; parameters[8].Value = model.property_value; parameters[9].Value = model.note; parameters[10].Value = model.updateTime; parameters[11].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Cms.Model.C_order_integralsub model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into C_order_integralsub("); strSql.Append("user_id,order_id,order_num,article_id,title,price,quantity,integral,property_value,note,updateTime)"); strSql.Append(" values ("); strSql.Append("@user_id,@order_id,@order_num,@article_id,@title,@price,@quantity,@integral,@property_value,@note,@updateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@order_id", SqlDbType.Int, 4), new SqlParameter("@order_num", SqlDbType.VarChar, 350), new SqlParameter("@article_id", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.VarChar, -1), new SqlParameter("@price", SqlDbType.Money, 8), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@integral", SqlDbType.Int, 4), new SqlParameter("@property_value", SqlDbType.VarChar, 550), new SqlParameter("@note", SqlDbType.VarChar, -1), new SqlParameter("@updateTime", SqlDbType.DateTime) }; parameters[0].Value = model.user_id; parameters[1].Value = model.order_id; parameters[2].Value = model.order_num; parameters[3].Value = model.article_id; parameters[4].Value = model.title; parameters[5].Value = model.price; parameters[6].Value = model.quantity; parameters[7].Value = model.integral; parameters[8].Value = model.property_value; parameters[9].Value = model.note; parameters[10].Value = model.updateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cms.Model.C_order_integralsub GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,user_id,order_id,order_num,article_id,title,price,quantity,integral,property_value,note,updateTime from C_order_integralsub "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Cms.Model.C_order_integralsub model = new Cms.Model.C_order_integralsub(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }