/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_albums_photo DataRowToModel(DataRow row) { WechatBuilder.Model.wx_albums_photo model = new WechatBuilder.Model.wx_albums_photo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["aId"] != null && row["aId"].ToString() != "") { model.aId = int.Parse(row["aId"].ToString()); } if (row["pName"] != null) { model.pName = row["pName"].ToString(); } if (row["photoPic"] != null) { model.photoPic = row["photoPic"].ToString(); } if (row["pContent"] != null) { model.pContent = row["pContent"].ToString(); } if (row["seq"] != null && row["seq"].ToString() != "") { model.seq = int.Parse(row["seq"].ToString()); } if (row["isHidden"] != null && row["isHidden"].ToString() != "") { if ((row["isHidden"].ToString() == "1") || (row["isHidden"].ToString().ToLower() == "true")) { model.isHidden = true; } else { model.isHidden = false; } } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["createPerson"] != null) { model.createPerson = row["createPerson"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WechatBuilder.Model.wx_albums_photo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_albums_photo set "); strSql.Append("aId=@aId,"); strSql.Append("pName=@pName,"); strSql.Append("photoPic=@photoPic,"); strSql.Append("pContent=@pContent,"); strSql.Append("seq=@seq,"); strSql.Append("isHidden=@isHidden,"); strSql.Append("createDate=@createDate,"); strSql.Append("createPerson=@createPerson"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@aId", SqlDbType.Int, 4), new SqlParameter("@pName", SqlDbType.VarChar, 200), new SqlParameter("@photoPic", SqlDbType.VarChar, 1000), new SqlParameter("@pContent", SqlDbType.VarChar, 500), new SqlParameter("@seq", SqlDbType.Int, 4), new SqlParameter("@isHidden", SqlDbType.Bit, 1), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@createPerson", SqlDbType.VarChar, 200), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.aId; parameters[1].Value = model.pName; parameters[2].Value = model.photoPic; parameters[3].Value = model.pContent; parameters[4].Value = model.seq; parameters[5].Value = model.isHidden; parameters[6].Value = model.createDate; parameters[7].Value = model.createPerson; parameters[8].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_albums_photo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_albums_photo("); strSql.Append("aId,pName,photoPic,pContent,seq,isHidden,createDate,createPerson)"); strSql.Append(" values ("); strSql.Append("@aId,@pName,@photoPic,@pContent,@seq,@isHidden,@createDate,@createPerson)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@aId", SqlDbType.Int, 4), new SqlParameter("@pName", SqlDbType.VarChar, 200), new SqlParameter("@photoPic", SqlDbType.VarChar, 1000), new SqlParameter("@pContent", SqlDbType.VarChar, 500), new SqlParameter("@seq", SqlDbType.Int, 4), new SqlParameter("@isHidden", SqlDbType.Bit, 1), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@createPerson", SqlDbType.VarChar, 200) }; parameters[0].Value = model.aId; parameters[1].Value = model.pName; parameters[2].Value = model.photoPic; parameters[3].Value = model.pContent; parameters[4].Value = model.seq; parameters[5].Value = model.isHidden; parameters[6].Value = model.createDate; parameters[7].Value = model.createPerson; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_albums_photo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,aId,pName,photoPic,pContent,seq,isHidden,createDate,createPerson from wx_albums_photo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WechatBuilder.Model.wx_albums_photo model = new WechatBuilder.Model.wx_albums_photo(); 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_albums_photo DataRowToModel(DataRow row) { WechatBuilder.Model.wx_albums_photo model=new WechatBuilder.Model.wx_albums_photo(); if (row != null) { if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["aId"]!=null && row["aId"].ToString()!="") { model.aId=int.Parse(row["aId"].ToString()); } if(row["pName"]!=null) { model.pName=row["pName"].ToString(); } if(row["photoPic"]!=null) { model.photoPic=row["photoPic"].ToString(); } if(row["pContent"]!=null) { model.pContent=row["pContent"].ToString(); } if(row["seq"]!=null && row["seq"].ToString()!="") { model.seq=int.Parse(row["seq"].ToString()); } if(row["isHidden"]!=null && row["isHidden"].ToString()!="") { if((row["isHidden"].ToString()=="1")||(row["isHidden"].ToString().ToLower()=="true")) { model.isHidden=true; } else { model.isHidden=false; } } if(row["createDate"]!=null && row["createDate"].ToString()!="") { model.createDate=DateTime.Parse(row["createDate"].ToString()); } if(row["createPerson"]!=null) { model.createPerson=row["createPerson"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public WechatBuilder.Model.wx_albums_photo GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,aId,pName,photoPic,pContent,seq,isHidden,createDate,createPerson from wx_albums_photo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; WechatBuilder.Model.wx_albums_photo model=new WechatBuilder.Model.wx_albums_photo(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }