private string GetCoursewareTypeNames(string strName, int nID) { string strCoursewareTypeName = string.Empty; if (nID != 0) { CoursewareTypeDAL coursewareTypeDAL = new CoursewareTypeDAL(); CoursewareType coursewareType = coursewareTypeDAL.GetCoursewareType(nID); if (coursewareType.ParentId != 0) { strCoursewareTypeName = GetCoursewareTypeNames("/" + coursewareType.CoursewareTypeName, coursewareType.ParentId) + strName; } else { strCoursewareTypeName = coursewareType.CoursewareTypeName + strName; } } return(strCoursewareTypeName); }
public Courseware GetCourseware(int coursewareID) { Courseware courseware = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, coursewareID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { courseware = CreateModelObject(dataReader); } } sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_S"; DbCommand dbCommand1 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand1, "p_courseware_id", DbType.Int32, coursewareID); sqlCommand = "USP_COURSEWARE_RANGE_ORG_S"; DbCommand dbCommand2 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand2, "p_courseware_id", DbType.Int32, coursewareID); sqlCommand = "USP_COURSEWARE_RANGE_POST_S"; DbCommand dbCommand3 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand3, "p_courseware_id", DbType.Int32, coursewareID); IDataReader dataReader1 = db.ExecuteReader(dbCommand1); IDataReader dataReader2 = db.ExecuteReader(dbCommand2); IDataReader dataReader3 = db.ExecuteReader(dbCommand3); ArrayList trainTypeIDAL = new ArrayList(); ArrayList orgIDAL = new ArrayList(); ArrayList postIDAL = new ArrayList(); string strTrainTypeNames = string.Empty; CoursewareTypeDAL coursewareTypeDAL = new CoursewareTypeDAL(); CoursewareType coursewareType = coursewareTypeDAL.GetCoursewareType(courseware.CoursewareTypeID); courseware.CoursewareTypeNames = GetCoursewareTypeNames("/" + coursewareType.CoursewareTypeName, coursewareType.ParentId); while (dataReader1.Read()) { if (dataReader1["TRAIN_TYPE_ID"].ToString() != "") { trainTypeIDAL.Add(DataConvert.ToInt(dataReader1["TRAIN_TYPE_ID"].ToString())); strTrainTypeNames += GetTrainTypeNames("/" + dataReader1["TRAIN_TYPE_NAME"].ToString(), int.Parse(dataReader1["PARENT_ID"].ToString())) + ","; } } while (dataReader2.Read()) { if (dataReader2["ORG_ID"].ToString() != "") { orgIDAL.Add(DataConvert.ToInt(dataReader2["ORG_ID"].ToString())); } } while (dataReader3.Read()) { if (dataReader3["POST_ID"].ToString() != "") { postIDAL.Add(DataConvert.ToInt(dataReader3["POST_ID"].ToString())); } } if (strTrainTypeNames.Length > 0) { strTrainTypeNames = strTrainTypeNames.Substring(0, strTrainTypeNames.Length - 1); } courseware.TrainTypeIDAL = trainTypeIDAL; courseware.OrgIDAL = orgIDAL; courseware.PostIDAL = postIDAL; courseware.TrainTypeNames = strTrainTypeNames; return(courseware); }