/// <summary> /// 更新一条数据 /// </summary> public bool Update(WechatBuilder.Model.wx_shop_albums model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_shop_albums set "); strSql.Append("productId=@productId,"); strSql.Append("thumb_path=@thumb_path,"); strSql.Append("original_path=@original_path,"); strSql.Append("remark=@remark,"); strSql.Append("add_time=@add_time,"); strSql.Append("wid=@wid"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@thumb_path", SqlDbType.VarChar, 800), new SqlParameter("@original_path", SqlDbType.VarChar, 800), new SqlParameter("@remark", SqlDbType.VarChar, 500), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.productId; parameters[1].Value = model.thumb_path; parameters[2].Value = model.original_path; parameters[3].Value = model.remark; parameters[4].Value = model.add_time; parameters[5].Value = model.wid; parameters[6].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WechatBuilder.Model.wx_shop_albums model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_shop_albums("); strSql.Append("productId,thumb_path,original_path,remark,add_time,wid)"); strSql.Append(" values ("); strSql.Append("@productId,@thumb_path,@original_path,@remark,@add_time,@wid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@thumb_path", SqlDbType.VarChar, 800), new SqlParameter("@original_path", SqlDbType.VarChar, 800), new SqlParameter("@remark", SqlDbType.VarChar, 500), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@wid", SqlDbType.Int, 4) }; parameters[0].Value = model.productId; parameters[1].Value = model.thumb_path; parameters[2].Value = model.original_path; parameters[3].Value = model.remark; parameters[4].Value = model.add_time; parameters[5].Value = model.wid; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_shop_albums DataRowToModel(DataRow row) { WechatBuilder.Model.wx_shop_albums model = new WechatBuilder.Model.wx_shop_albums(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["productId"] != null && row["productId"].ToString() != "") { model.productId = int.Parse(row["productId"].ToString()); } if (row["thumb_path"] != null) { model.thumb_path = row["thumb_path"].ToString(); } if (row["original_path"] != null) { model.original_path = row["original_path"].ToString(); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_shop_albums GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,productId,thumb_path,original_path,remark,add_time,wid from wx_shop_albums "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WechatBuilder.Model.wx_shop_albums model = new WechatBuilder.Model.wx_shop_albums(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_shop_albums DataRowToModel(DataRow row) { WechatBuilder.Model.wx_shop_albums model=new WechatBuilder.Model.wx_shop_albums(); if (row != null) { if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["productId"]!=null && row["productId"].ToString()!="") { model.productId=int.Parse(row["productId"].ToString()); } if(row["thumb_path"]!=null) { model.thumb_path=row["thumb_path"].ToString(); } if(row["original_path"]!=null) { model.original_path=row["original_path"].ToString(); } if(row["remark"]!=null) { model.remark=row["remark"].ToString(); } if(row["add_time"]!=null && row["add_time"].ToString()!="") { model.add_time=DateTime.Parse(row["add_time"].ToString()); } if(row["wid"]!=null && row["wid"].ToString()!="") { model.wid=int.Parse(row["wid"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_shop_albums GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,productId,thumb_path,original_path,remark,add_time,wid from wx_shop_albums "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; WechatBuilder.Model.wx_shop_albums model=new WechatBuilder.Model.wx_shop_albums(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }