Example #1
0
        /// <summary>
        /// 通过页面信息的填写来创建BBS
        /// </summary>
        public ActionResult CreateBBS()
        {
            BBS bbs = new BBS();

            bbs.BBSName = GetString("bbsName");
            bbs.WelcomeText = GetString("bbsWelcomeText");
            //bbs.ImageUrl = 取得用户指定的ID
            //bbs.ClassID = 取该班班级ID
            //bbs.OwnerID = 用户设定的管理员

            CQGJ.AddToBBS(bbs);
            CQGJ.SaveChanges();

            // 跳转到ListBBS页面,查看创建是否成功, 用于测试
            return RedirectToAction("ListBBS");
        }
Example #2
0
        /// <summary>
        /// 自动创建一个班级论坛,当新建班级的时候,调用此函数来创建该班级的BBS
        /// </summary>
        /// <param name="owerID">BBS论坛的管理员的ID</param>
        /// <param name="bBSName">BBS论坛的名称</param>
        /// <param name="classID">对应班级的ID</param>
        /// <param name="welcomeText">BBS论坛的欢迎语</param>
        public void AddBBS(int owerID, string bbsName, int classID, string welcomeText)
        {
            BBS bbs = new BBS();

            bbs.OwnerID = owerID;

            // 10号
            bbs.Classes.ClassID = classID;
            bbs.BBSName = bbsName;
            bbs.WelcomeText = welcomeText;

            // BBS图标默认
            bbs.ImageUrl = "/Content//UploadFiles/BBSFiles/Icon/defaultIcon.gif";

            CQGJ.AddToBBS(bbs);
            CQGJ.SaveChanges();
        }
Example #3
0
        /// <summary>
        /// 培训机构正式开班
        /// 基本信息确认
        /// </summary>
        /// <param name="planClassID">计划班级ID</param>
        public ActionResult OpenClass(int id)
        {
            TrainOpenClassViewData viewData = new TrainOpenClassViewData();

            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();

            if (Request.RequestType == "POST")
            {
                classes.ClassName = GetString("className");
                classes.SubClassName = GetString("subClassName");
                classes.ClassTerm = GetString("ClassTerm");
                classes.TrainObject = GetString("subClassName");
                classes.TrainPlace = GetString("TrainPlace");
                classes.TrainSubject = GetString("TrainSubject");
                classes.BeginDate = GetDate("BeginDate");
                classes.EndDate = GetDate("EndDate");
                classes.TrainSubject = GetString("TrainSubject");
                classes.TrainContent = GetString("dntb");
                classes.Status = (int)ClassStatus.Open;

                //自动开通班级论坛
                BBS bbs = new BBS();
                bbs.BBSName = classes.ClassName + "[" + classes.SubClassName + "](" + classes.ClassTerm + ")";
                bbs.Classes = classes;
                bbs.WelcomeText = "欢迎加入本班级论坛";
                CQGJ.AddToBBS(bbs);

                CQGJ.SaveChanges();
                //开班时不设置课程和教材,课程设置和教材
                //在报名前和班级结束过程中都可以设置、修改
                //return RedirectToAction("setcourse/" + classes.ClassID, "train");
                return RedirectToAction("classlist");
            }

            viewData.Classes = classes;
            return View("OpenClass", viewData);
        }
Example #4
0
        /// <summary>
        /// 修改BBS论坛相关信息,
        /// 修改内容包括论坛欢迎语与论坛管理员
        /// </summary>
        /// <param name="bbsID">bbs的ID</param>
        public ActionResult 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();

                return View("EditedBBS", bbsViewData);

            }
            catch (ArgumentNullException)
            {
                //Response.Write(nullException.ToString());
                Response.Write("</br>该记录已被删除!或数据库中不存在该班级");
            }
            catch (InvalidOperationException)
            {
                //Response.Write(invalidOperationException.ToString());
                Response.Write("</br>该记录已被删除!或数据库中不存在该班级");
            }

            return null;
        }
Example #5
0
        /// <summary>
        /// 从数据库中删除一个班级BBS论坛
        /// </summary>
        /// <param name="bbsID">被删除的BBS的ID</param>
        public ActionResult RemoveBBS(int id)
        {
            BBS bbs = new BBS();

            try
            {
                bbs = (from b in CQGJ.BBS where b.BBSID == id select b).First();

                CQGJ.DeleteObject(bbs);
                CQGJ.SaveChanges();

                // 定义BBS列表BBSListViewData,用于保存从数据库中读取到的所有的BBS
                BBSListViewData BBSListViewData = new BBSListViewData();

                // 从数据库中读取到的所有的BBS
                BBSListViewData.BBSList = (from bbsList in CQGJ.BBS select bbsList).ToList();

                // 将BBS列表以BBSListViewData对象的形式绑定到ListBBS.aspx页面
                return View("ListBBS", BBSListViewData);
            }
            catch (ArgumentNullException)
            {
                //Response.Write(nullException.ToString());
                Response.Write("</br>该记录已删除!");
            }
            catch (InvalidOperationException)
            {
                //Response.Write(invalidOperationException.ToString());
                Response.Write("</br>该记录已删除!");
            }
            return null;
        }
Example #6
0
        /// <summary>
        /// 修改BBS信息
        /// </summary>
        /// <param name="name">BBSID</param>
        /// <param name="welcomeText">BBS标题</param>
        /// <param name="ownerId">BBS管理员ID</param>
        public void ModifyBBSInfo(int bbsId, string name, string welcomeText, int ownerId, string imgUrl)
        {
            BBS ModifiedBBS = new BBS();
            try
            {
                ModifiedBBS = (from bbs in CQGJ.BBS where bbs.BBSID == bbsId select bbs).First();

                ModifiedBBS.BBSName = name;
                ModifiedBBS.OwnerID = ownerId;
                ModifiedBBS.WelcomeText = welcomeText;
                ModifiedBBS.ImageUrl = imgUrl;
                CQGJ.SaveChanges();
            }
            catch
            {
            }
        }