/// <summary> /// Inserts a course category into the database /// </summary> /// <param name="entity"></param> /// <returns></returns> /// public override bool InsertCourseCategory(ref CourseCategoryInfo entity) { DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString); cmd.CommandText = "dbo.mon_elrn_INSERT_COURSE_CATEGORY"; cmd.AddInputParam("@CourseId", DbType.Int32, entity.CourseId); cmd.AddInputParam("@CategoryId", DbType.Int32, entity.CategoryId); int result; try { result = Convert.ToInt32(cmd.ExecuteSelectTable().Rows[0].ItemArray[0].ToString()); if (result > 0) return true; else return false; } catch (Exception ex) { throw ex; } }
//Course Category related functions public static bool InsertCourseCategory(ref CourseCategoryInfo entity) { return Instance.InsertCourseCategory(ref entity); }
public abstract bool InsertCourseCategory(ref CourseCategoryInfo entity);
protected void CategoryCheckBoxList_SelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < CategoryCheckBoxList.Items.Count; i++) { CourseCategoryInfo Categoryentity = new CourseCategoryInfo(); Categoryentity.CourseId = Convert.ToInt32(this.Id); if (CategoryCheckBoxList.Items[i].Selected == false) { Categoryentity.CategoryId = Convert.ToInt32(CategoryCheckBoxList.Items[i].Value.ToString()); ClassroomController.DeleteCourseCategory(Categoryentity.CourseId, Categoryentity.CategoryId); } } for (int i = 0; i < CategoryCheckBoxList.Items.Count; i++) { CourseCategoryInfo Categoryentity = new CourseCategoryInfo(); Categoryentity.CourseId = Convert.ToInt32(this.Id); if (CategoryCheckBoxList.Items[i].Selected == true) { Categoryentity.CategoryId = Convert.ToInt32(CategoryCheckBoxList.Items[i].Value.ToString()); ClassroomController.InsertCourseCategory(ref Categoryentity); } } }