/// <summary> /// 标记为已读 /// </summary> /// <param name="kid">知识点ID</param> /// <param name="userID">用户ID</param> /// <param name="tag">1 已读 0未读</param> public int SetReadTag(int kid, int userID, int tag) { Entities.QueryKLReadTag query = new QueryKLReadTag(); query.KLID = kid; query.UserID = userID; int totalCount = 0; DataTable dt = BLL.KLReadTag.Instance.GetKLReadTag(query, "", 1, 999, out totalCount); if (dt != null && dt.Rows.Count > 0) { //有,就更改标志 return(Dal.KLReadTag.Instance.ModifyReadTag(kid, userID, tag)); } else { //没有,就插入 Entities.KLReadTag newModel = new Entities.KLReadTag(); newModel.KLID = kid; newModel.UserID = userID; newModel.ReadTag = tag; newModel.CreateTime = DateTime.Now; newModel.CreateUserID = userID; return(Dal.KLReadTag.Instance.Insert(newModel)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entities.KLReadTag GetKLReadTag(long RecID) { QueryKLReadTag query = new QueryKLReadTag(); query.RecID = RecID; DataTable dt = new DataTable(); int count = 0; dt = GetKLReadTag(query, string.Empty, 1, 1, out count); if (count > 0) { return(LoadSingleKLReadTag(dt.Rows[0])); } else { return(null); } }
/// <summary> /// 是否存在该记录 /// </summary> public bool IsExistsByRecID(long RecID) { QueryKLReadTag query = new QueryKLReadTag(); query.RecID = RecID; DataTable dt = new DataTable(); int count = 0; dt = GetKLReadTag(query, string.Empty, 1, 1, out count); if (count > 0) { return(true); } else { return(false); } }
/// <summary> /// 按照查询条件查询 /// </summary> /// <param name="query">查询条件</param> /// <param name="order">排序</param> /// <param name="currentPage">页号,-1不分页</param> /// <param name="pageSize">每页记录数</param> /// <param name="totalCount">总行数</param> /// <returns>集合</returns> public DataTable GetKLReadTag(QueryKLReadTag query, string order, int currentPage, int pageSize, out int totalCount) { string where = string.Empty; if (query.KLID != Constant.INT_INVALID_VALUE) { where += " AND KLID =" + query.KLID + ""; } if (query.UserID != Constant.INT_INVALID_VALUE) { where += " AND UserID =" + query.UserID + ""; } if (query.ReadTag != Constant.INT_INVALID_VALUE) { where += " AND ReadTag =" + query.ReadTag + ""; } DataSet ds; SqlParameter[] parameters = { new SqlParameter("@where", SqlDbType.NVarChar, 40000), new SqlParameter("@order", SqlDbType.NVarChar, 200), new SqlParameter("@pagesize", SqlDbType.Int, 4), new SqlParameter("@indexpage", SqlDbType.Int, 4), new SqlParameter("@totalRecorder", SqlDbType.Int, 4) }; parameters[0].Value = where; parameters[1].Value = order; parameters[2].Value = pageSize; parameters[3].Value = currentPage; parameters[4].Direction = ParameterDirection.Output; ds = SqlHelper.ExecuteDataset(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_KLREADTAG_SELECT, parameters); totalCount = (int)(parameters[4].Value); return(ds.Tables[0]); }
/// <summary> /// 按照查询条件查询 /// </summary> /// <param name="query">查询条件</param> /// <param name="order">排序</param> /// <param name="currentPage">页号,-1不分页</param> /// <param name="pageSize">每页记录数</param> /// <param name="totalCount">总行数</param> /// <returns>集合</returns> public DataTable GetKLReadTag(QueryKLReadTag query, string order, int currentPage, int pageSize, out int totalCount) { return(Dal.KLReadTag.Instance.GetKLReadTag(query, order, currentPage, pageSize, out totalCount)); }