public static bool Update(Model.ResourcesDownload model) { string strSql = "update ResourcesDownload set ResourceName=@ResourceName where ID = " + model.ID.ToString(); SqlParameter ResourceName = new SqlParameter("ResourceName", SqlDbType.NVarChar); ResourceName.Value = model.ResourceName; return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { ResourceName }, connectionString) == 1 ? true : false); }
/// <summary> /// 添加一条新闻到数据库中 /// </summary> /// <returns></returns> public static bool Add(Model.ResourcesDownload rd) { string strSql = "insert into ResourcesDownload(ResourceName,ResourcePath,DownloadTimes,UploadUser,UploadTime,IsDeleted,Remark) values(@ResourceName,@ResourcePath,@DownloadTimes,@UploadUser,@UploadTime,@IsDeleted,@Remark)"; SqlParameter ResourceName = new SqlParameter("@ResourceName", SqlDbType.NVarChar, 50); ResourceName.Value = rd.ResourceName; SqlParameter ResourcePath = new SqlParameter("@ResourcePath", SqlDbType.NVarChar, 500); ResourcePath.Value = rd.ResourcePath; SqlParameter DownloadTimes = new SqlParameter("@DownloadTimes", SqlDbType.Int); DownloadTimes.Value = rd.DownloadTimes; SqlParameter UploadUser = new SqlParameter("@UploadUser", SqlDbType.VarChar,50); UploadUser.Value = rd.UploadUser; SqlParameter UploadTime = new SqlParameter("@UploadTime", SqlDbType.DateTime); UploadTime.Value = rd.UploadTime; SqlParameter IsDeleted = new SqlParameter("@IsDeleted", SqlDbType.Bit); IsDeleted.Value = rd.IsDeleted; SqlParameter Remark = new SqlParameter("@Remark", SqlDbType.NVarChar,500); Remark.Value = rd.Remark; return DBHelperSQL.GetNums(strSql, new SqlParameter[] { ResourceName, ResourcePath, DownloadTimes, UploadUser, UploadTime, IsDeleted, Remark }, connectionString) == 1 ? true : false; }
/// <summary> /// 得到一个实体对象 /// </summary> /// <param name="Id"></param> /// <returns></returns> public static Model.ResourcesDownload GetModel(int ID) { string strSql = "select * from ResourcesDownload where ID = " + ID.ToString(); Model.ResourcesDownload model = new Model.ResourcesDownload(); DataSet ds = DBHelperSQL.GetDataSet(strSql, connectionString); model.ID = ID; if (ds.Tables[0].Rows.Count > 0) { model.ResourceName = Convert.ToString(ds.Tables[0].Rows[0]["ResourceName"]); model.ResourcePath = Convert.ToString(ds.Tables[0].Rows[0]["ResourcePath"]); model.DownloadTimes = Convert.ToInt32(ds.Tables[0].Rows[0]["DownloadTimes"]); model.UploadUser = Convert.ToString(ds.Tables[0].Rows[0]["UploadUser"]); model.UploadTime = (DateTime)ds.Tables[0].Rows[0]["UploadTime"]; model.IsDeleted = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsDeleted"]); model.Remark = Convert.ToString(ds.Tables[0].Rows[0]["Remark"]); return model; } else { return null; } }