/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { //取得模板图片MODEL List <Model.good_template_pic> piclist = new DAL.good_template_pic(databaseprefix).GetList(id); //删除图片 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "good_template_pic "); strSql2.Append(" where templateId=@templateId "); SqlParameter[] parameters2 = { new SqlParameter("@templateId", SqlDbType.Int, 4) }; parameters2[0].Value = id; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql2.ToString(), parameters2); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "good_template "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist); if (rowsAffected > 0) { new DAL.good_template_pic(databaseprefix).DeleteFile(piclist); //删除图片 return(true); } else { return(false); } }