private string GetKnowledgeNames(string strName, int nID) { string strKnowledgeName = string.Empty; if (nID != 0) { KnowledgeDAL knowledgeDAL = new KnowledgeDAL(); Knowledge knowledge = knowledgeDAL.GetKnowledge(nID); if (knowledge.ParentId != 0) { strKnowledgeName = GetKnowledgeNames("/" + knowledge.KnowledgeName, knowledge.ParentId) + strName; } else { strKnowledgeName = knowledge.KnowledgeName + strName; } } else { strKnowledgeName = strName.Replace("/", ""); } return(strKnowledgeName); }
public Book GetBook(int bookID) { Book book = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_BOOK_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_book_id", DbType.Int32, bookID); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { book = CreateModelObject(dataReader); book.Version = Convert.ToInt32(dataReader[GetMappingFieldName("Version")].ToString()); } } sqlCommand = "USP_BOOK_RANGE_ORG_S"; DbCommand dbCommand1 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand1, "p_book_id", DbType.Int32, bookID); sqlCommand = "USP_BOOK_RANGE_POST_S"; DbCommand dbCommand2 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand2, "p_book_id", DbType.Int32, bookID); sqlCommand = "USP_BOOK_TRAIN_TYPE_S"; DbCommand dbCommand3 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand3, "p_book_id", DbType.Int32, bookID); IDataReader dataReader1 = db.ExecuteReader(dbCommand1); IDataReader dataReader2 = db.ExecuteReader(dbCommand2); IDataReader dataReader3 = db.ExecuteReader(dbCommand3); ArrayList orgidAL = new ArrayList(); ArrayList postidAL = new ArrayList(); ArrayList trainTypeidAL = new ArrayList(); string strTrainTypeNames = string.Empty; KnowledgeDAL knowledgeDAL = new KnowledgeDAL(); Knowledge knowledge = knowledgeDAL.GetKnowledge(book.knowledgeId); book.KnowledgeNames = GetKnowledgeNames("/" + knowledge.KnowledgeName, knowledge.ParentId); while (dataReader1.Read()) { if (dataReader1["ORG_ID"].ToString() != "") { orgidAL.Add(DataConvert.ToInt(dataReader1["ORG_ID"].ToString())); } } while (dataReader2.Read()) { if (dataReader2["POST_ID"].ToString() != "") { postidAL.Add(DataConvert.ToInt(dataReader2["POST_ID"].ToString())); } } while (dataReader3.Read()) { if (dataReader3["TRAIN_TYPE_ID"].ToString() != "") { trainTypeidAL.Add(DataConvert.ToInt(dataReader3["TRAIN_TYPE_ID"].ToString())); strTrainTypeNames += GetTrainTypeNames("/" + dataReader3["TRAIN_TYPE_NAME"].ToString(), int.Parse(dataReader3["PARENT_ID"].ToString())) + ","; } } if (strTrainTypeNames.Length > 0) { strTrainTypeNames = strTrainTypeNames.Substring(0, strTrainTypeNames.Length - 1); } book.orgidAL = orgidAL; book.postidAL = postidAL; book.trainTypeidAL = trainTypeidAL; book.trainTypeNames = strTrainTypeNames; return(book); }