/// <summary> /// 根据班级ID取得BBS信息 /// </summary> /// <param name="id"></param> public BBSViewData GetBBSByClassID(int id) { BBSViewData BBSVD = new BBSViewData(); try { // 取得BBS相关信息 BBSVD.BBS = (from b in CQGJ.BBS where b.Classes.ClassID == id select b).First(); // 取得BBS所属班级 BBSVD.ClassName = (from c in CQGJ.Classes where c.ClassID == id select c.ClassName).First(); } catch { // 错误处理 } return BBSVD; }
/// <summary> /// 修改BBS论坛相关信息, /// 修改内容包括论坛欢迎语与论坛管理员 /// </summary> /// <param name="bbsID">bbs的ID</param> public void EditBBS(int id) { BBSViewData bbsViewData = new BBSViewData(); BBS bbs = new BBS(); /* //管理员的选择应该以下拉列表的形式提供给修改者来修改 // 根据管理员姓名取得其ID bbs.OwnerID = bbsAdmin; //取得图片的保存路径, 并保存到bbsAdmin中 string bbsImageUrl = */ try { bbs = (from b in CQGJ.BBS where b.BBSID == id select b).First(); bbs.WelcomeText = GetString("bbsWelcomeText"); CQGJ.SaveChanges(); bbsViewData.BBS = (from b in CQGJ.BBS where b.BBSID == id select b).First(); RenderView("EditedBBS", bbsViewData); } catch (ArgumentNullException) { //Response.Write(nullException.ToString()); Response.Write("</br>该记录已被删除!或数据库中不存在该班级"); } catch (InvalidOperationException) { //Response.Write(invalidOperationException.ToString()); Response.Write("</br>该记录已被删除!或数据库中不存在该班级"); } }
/// <summary> /// 获取BBS相关信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public BBSViewData GetBBSByBBSID(int id) { BBSViewData BBSVD = new BBSViewData(); try { // 取得BBS相关信息 BBSVD.BBS = (from b in CQGJ.BBS where b.BBSID == id select b).First(); // 取得BBS所属班级 //BBSVD.ClassName = (from c in CQGJ.Classes where c.ClassID == id select c.ClassName).First(); int classID = (int)(from b in CQGJ.BBS where b.BBSID == id select b.Classes.ClassID).First(); BBSVD.ClassName = (from c in CQGJ.Classes where c.ClassID == classID select c.ClassName).First(); } catch { BBSVD.ClassName = ""; } return BBSVD; }
/// <summary> /// 跳转至修改BBS论坛的相关信息页面 /// </summary> public void ShowEditBBS(int id) { BBSViewData bbsView = new BBSViewData(); try { bbsView.BBS = (from b in CQGJ.BBS where b.BBSID == id select b).First(); bbsView.ClassName = (from b in CQGJ.BBS where b.BBSID == id join c in CQGJ.Classes on b.Classes.ClassID equals c.ClassID select c.ClassName).First().ToString(); //bbsView.AdminName = RenderView("ShowEditBBS", bbsView); } catch (ArgumentNullException) { //Response.Write(nullException.ToString()); Response.Write("</br>ArgumentNullException该记录已被删除!或数据库中不存在该班级"); } catch (InvalidOperationException) { //Response.Write(invalidOperationException.ToString()); Response.Write("</br>InvalidOperationException该记录已被删除!或数据库中不存在该班级"); } }