/// <summary> /// 增加一条数据 /// </summary> public bool Add(KryptonAccessController.AccessDataBase.Model.EventPictureInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into EventPictureInfo("); strSql.Append("EventPictureID,EventPictureName,EventPictureComercial,EventPictureType,EventPictureImage)"); strSql.Append(" values ("); strSql.Append("@EventPictureID,@EventPictureName,@EventPictureComercial,@EventPictureType,@EventPictureImage)"); SqlParameter[] parameters = { new SqlParameter("@EventPictureID", SqlDbType.Int, 4), new SqlParameter("@EventPictureName", SqlDbType.NVarChar, 50), new SqlParameter("@EventPictureComercial", SqlDbType.Int, 4), new SqlParameter("@EventPictureType", SqlDbType.Int, 4), new SqlParameter("@EventPictureImage", SqlDbType.Image) }; parameters[0].Value = model.EventPictureID; parameters[1].Value = model.EventPictureName; parameters[2].Value = model.EventPictureComercial; parameters[3].Value = model.EventPictureType; parameters[4].Value = model.EventPictureImage; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.EventPictureInfo DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.EventPictureInfo model = new KryptonAccessController.AccessDataBase.Model.EventPictureInfo(); if (row != null) { if (row["EventPictureID"] != null && row["EventPictureID"].ToString() != "") { model.EventPictureID = int.Parse(row["EventPictureID"].ToString()); } if (row["EventPictureName"] != null) { model.EventPictureName = row["EventPictureName"].ToString(); } if (row["EventPictureComercial"] != null && row["EventPictureComercial"].ToString() != "") { model.EventPictureComercial = int.Parse(row["EventPictureComercial"].ToString()); } if (row["EventPictureType"] != null && row["EventPictureType"].ToString() != "") { model.EventPictureType = int.Parse(row["EventPictureType"].ToString()); } if (row["EventPictureImage"] != null && row["EventPictureImage"].ToString() != "") { model.EventPictureImage = (byte[])row["EventPictureImage"]; } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(KryptonAccessController.AccessDataBase.Model.EventPictureInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update EventPictureInfo set "); strSql.Append("EventPictureName=@EventPictureName,"); strSql.Append("EventPictureComercial=@EventPictureComercial,"); strSql.Append("EventPictureType=@EventPictureType,"); strSql.Append("EventPictureImage=@EventPictureImage"); strSql.Append(" where EventPictureID=@EventPictureID "); SqlParameter[] parameters = { new SqlParameter("@EventPictureName", SqlDbType.NVarChar, 50), new SqlParameter("@EventPictureComercial", SqlDbType.Int, 4), new SqlParameter("@EventPictureType", SqlDbType.Int, 4), new SqlParameter("@EventPictureImage", SqlDbType.Image), new SqlParameter("@EventPictureID", SqlDbType.Int, 4) }; parameters[0].Value = model.EventPictureName; parameters[1].Value = model.EventPictureComercial; parameters[2].Value = model.EventPictureType; parameters[3].Value = model.EventPictureImage; parameters[4].Value = model.EventPictureID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.EventPictureInfo GetModel(int EventPictureID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EventPictureID,EventPictureName,EventPictureComercial,EventPictureType,EventPictureImage from EventPictureInfo "); strSql.Append(" where EventPictureID=@EventPictureID "); SqlParameter[] parameters = { new SqlParameter("@EventPictureID", SqlDbType.Int, 4) }; parameters[0].Value = EventPictureID; KryptonAccessController.AccessDataBase.Model.EventPictureInfo model = new KryptonAccessController.AccessDataBase.Model.EventPictureInfo(); 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 KryptonAccessController.AccessDataBase.Model.EventPictureInfo DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.EventPictureInfo model=new KryptonAccessController.AccessDataBase.Model.EventPictureInfo(); if (row != null) { if(row["EventPictureID"]!=null && row["EventPictureID"].ToString()!="") { model.EventPictureID=int.Parse(row["EventPictureID"].ToString()); } if(row["EventPictureName"]!=null) { model.EventPictureName=row["EventPictureName"].ToString(); } if(row["EventPictureComercial"]!=null && row["EventPictureComercial"].ToString()!="") { model.EventPictureComercial=int.Parse(row["EventPictureComercial"].ToString()); } if(row["EventPictureType"]!=null && row["EventPictureType"].ToString()!="") { model.EventPictureType=int.Parse(row["EventPictureType"].ToString()); } if(row["EventPictureImage"]!=null && row["EventPictureImage"].ToString()!="") { model.EventPictureImage=(byte[])row["EventPictureImage"]; } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.EventPictureInfo GetModel(int EventPictureID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 EventPictureID,EventPictureName,EventPictureComercial,EventPictureType,EventPictureImage from EventPictureInfo "); strSql.Append(" where EventPictureID=@EventPictureID "); SqlParameter[] parameters = { new SqlParameter("@EventPictureID", SqlDbType.Int,4) }; parameters[0].Value = EventPictureID; KryptonAccessController.AccessDataBase.Model.EventPictureInfo model=new KryptonAccessController.AccessDataBase.Model.EventPictureInfo(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }