/// <summary> /// 更新相册 /// </summary> /// <param name="pType"></param> /// <returns></returns> public int UpdatePhotoType(PhotoType pType) { string sql = "update PhotoType set TypeName='"+ pType.TypeName + "', TypeDes='"+ pType.TypeDes + "' where TypeId="+pType.TypeId; //SqlParameter[] param = { // new SqlParameter("@TypeName",SqlDbType.NVarChar){Value=pType.TypeName }, // new SqlParameter("@TypeDes",SqlDbType.NVarChar){Value=pType.TypeDes } //}; return SQLHelper.ExecuteNonQuery(sql); }
/// <summary> /// 添加相册 /// </summary> /// <param name="pType"></param> /// <returns></returns> public int AddPhotoType(PhotoType pType) { string sql = "insert into PhotoType (TypeName,TypeDes) values (@TypeName,@TypeDes)"; SqlParameter[] param = { new SqlParameter("@TypeName",SqlDbType.NVarChar) {Value=pType.TypeName }, new SqlParameter("@TypeDes",SqlDbType.NVarChar) {Value=pType.TypeDes } }; return SQLHelper.ExecuteNonQuery(sql, CommandType.Text, param); }
/// <summary> /// 将DataTable表转换为list集合 /// </summary> /// <param name="dt">DataTable表</param> /// <returns>list集合</returns> private List<PhotoType> DTToList(DataTable dt) { List<PhotoType> list = new List<PhotoType>(); foreach (DataRow dr in dt.Rows) { PhotoType pT = new PhotoType(); pT.TypeId=Convert.ToInt32( dr["TypeId"]); pT.TypeName=dr["TypeName"].ToString(); pT.TypeDes=dr["TypeDes"].ToString(); pT.TCover = dr["TCover"].ToString(); list.Add(pT); } return list; }
private List<PhotoType> DTToList(DataTable dt) { List<PhotoType> list = new List<PhotoType>(); foreach (DataRow dr in dt.Rows) { PhotoType pt = new PhotoType(); pt.TypeId = int.Parse(dr["TypeId"].ToString()); pt.TypeName = dr["TypeName"].ToString(); pt.TypeDes = dr["TypeDes"].ToString(); pt.TCover = dr["TCover"].ToString(); //pt.TCount = int.Parse(dr["TCount"].ToString()); list.Add(pt); } return list; }
/// <summary> /// 更新相册 /// </summary> /// <param name="pType"></param> /// <returns></returns> public bool UpdatePhotoType(PhotoType pType) { return pTDAL.UpdatePhotoType(pType) > 0 ? true : false; }
/// <summary> /// 添加相册 /// </summary> /// <param name="pType"></param> /// <returns></returns> public bool AddPhotoType(PhotoType pType) { return pTDAL.AddPhotoType(pType) > 0 ? true : false; }