/* * 获取与知识点相关联的章 */ public static DataTable getChapterByKName(string kName, string courseName) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] parms = { new SqlParameter("@KName", kName), new SqlParameter("@CourseName", courseName) }; DataTable dt = db.ExecuteDataTable(trans, "Command_GetChapterByKName", parms); trans.Commit(); db.Close(); return dt; } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); return null; } }
/* * 根据ID获取文件类型 */ public static int getCateByCaseID(int id) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] parms = { new SqlParameter("@ID", id) }; int cate = (int)db.ExecuteScalar(trans, "Command_GetCateByCaseID", parms); trans.Commit(); db.Close(); return cate; } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); return 0; } }
public static void saveKnowledge(int type, int identity, List<string> list, string courseName) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] delete = { new SqlParameter("@ID", identity), }; string obj = ""; if (type == CHAPTER) obj = "Chapter"; else if (type == SECTION) obj = "Section"; else return; db.ExecuteNonQuery(trans, "Command_Delete" + obj + "Knowledge", delete); if (list != null) { for (int i = 0; i < list.Count; i++) { SqlParameter[] add = { new SqlParameter("@ID", identity), new SqlParameter("KName", list[i]), new SqlParameter("CourseName", courseName) }; db.ExecuteNonQuery(trans, "Command_Add" + obj + "Knowledge", add); } } trans.Commit(); db.Close(); } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); } }
/* * 获取包含某知识点的用户未看过的文件 */ public static DataTable getUnreadFileByKID(int kID, string userName) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] parms = { new SqlParameter("@KID", kID), new SqlParameter("@UserName", userName) }; DataTable dt = db.ExecuteDataTable(trans, "Command_GetUnreadFileByKID", parms); trans.Commit(); db.Close(); return dt; } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); return null; } }
/* * 获取与该文件关联的章知识点 */ public static DataTable getSectionKnowledgeFromFile(int fID) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] parms = { new SqlParameter("@FID", fID) }; DataTable dt = db.ExecuteDataTable(trans, "Command_GetSectionKnowledgeFromFile", parms); trans.Commit(); db.Close(); return dt; } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); return null; } }
/* * 获取某一知识点出现的文件数目 */ public static int getFileNumByKName(string kName, string courseName) { SqlTransaction trans = null; DB db = null; try { db = new DB(); trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted); SqlParameter[] parms = { new SqlParameter("@KName", kName), new SqlParameter("@CourseName", courseName) }; int num = (int)db.ExecuteScalar(trans, "Command_GetFileNumByKName", parms); trans.Commit(); db.Close(); return num; } catch { if (trans != null) trans.Rollback(); if (db != null) db.Close(); return 0; } }