protected void tvBookChapterChangeCallBack_Callback(object sender, CallBackEventArgs e)
        {
            BookChapterBLL objBookChapter = new BookChapterBLL();

            RailExam.Model.BookChapter obj = new RailExam.Model.BookChapter();
            obj = objBookChapter.GetBookChapterInfo(int.Parse(e.Parameters[0]));
            int cout = tvBookChapter.FindNodeById(obj.ParentId.ToString()).Nodes.Count;

            if (e.Parameters[1] == "MoveUp")
            {
                if (obj.OrderIndex <= cout && obj.OrderIndex >= 2)
                {
                    obj.OrderIndex--;
                    if (e.Parameters[2] == "Edit")
                    {
                        obj.IsEdit = true;
                    }
                    else
                    {
                        obj.IsEdit = false;
                    }
                    objBookChapter.UpdateBookChapter(obj);

                    obj = objBookChapter.GetBookChapter(int.Parse(tvBookChapter.FindNodeById(e.Parameters[0]).PreviousSibling.ID));
                    obj.OrderIndex++;
                    objBookChapter.UpdateBookChapter(obj);
                }
            }
            if (e.Parameters[1] == "MoveDown")
            {
                if (obj.OrderIndex <= cout - 1 && obj.OrderIndex >= 1)
                {
                    obj.OrderIndex++;
                    if (e.Parameters[2] == "Edit")
                    {
                        obj.IsEdit = true;
                    }
                    else
                    {
                        obj.IsEdit = false;
                    }
                    objBookChapter.UpdateBookChapter(obj);

                    obj = objBookChapter.GetBookChapter(int.Parse(tvBookChapter.FindNodeById(e.Parameters[0]).NextSibling.ID));
                    obj.OrderIndex--;
                    objBookChapter.UpdateBookChapter(obj);
                }
            }
            if (e.Parameters[1] == "Insert")
            {
                int maxID = objBookChapter.GetMaxChapterIDByBookID(Convert.ToInt32(hfBookID.Value));
                hfMaxID.Value = maxID.ToString();
                hfMaxID.RenderControl(e.Output);
            }

            tvBookChapter.Nodes.Clear();
            BindTree();
            tvBookChapter.RenderControl(e.Output);
        }
Exemple #2
0
        protected void tvBookChapterChangeCallBack_Callback(object sender, CallBackEventArgs e)
        {
            BookChapterBLL objBookChapter = new BookChapterBLL();

            RailExam.Model.BookChapter obj = new RailExam.Model.BookChapter();
            obj = objBookChapter.GetBookChapterInfo(int.Parse(e.Parameters[0]));
            int cout = tvBookChapter.FindNodeById(obj.ParentId.ToString()).Nodes.Count;

            if (e.Parameters[1] == "MoveUp")
            {
                if (obj.OrderIndex <= cout && obj.OrderIndex >= 2)
                {
                    obj.OrderIndex--;
                    if (e.Parameters[2] == "Edit")
                    {
                        obj.IsEdit = true;
                    }
                    else
                    {
                        obj.IsEdit = false;
                    }
                    objBookChapter.UpdateBookChapter(obj);

                    obj = objBookChapter.GetBookChapter(int.Parse(tvBookChapter.FindNodeById(e.Parameters[0]).PreviousSibling.ID));
                    obj.OrderIndex++;
                    objBookChapter.UpdateBookChapter(obj);
                }
            }
            if (e.Parameters[1] == "MoveDown")
            {
                if (obj.OrderIndex <= cout - 1 && obj.OrderIndex >= 1)
                {
                    obj.OrderIndex++;
                    if (e.Parameters[2] == "Edit")
                    {
                        obj.IsEdit = true;
                    }
                    else
                    {
                        obj.IsEdit = false;
                    }
                    objBookChapter.UpdateBookChapter(obj);

                    obj = objBookChapter.GetBookChapter(int.Parse(tvBookChapter.FindNodeById(e.Parameters[0]).NextSibling.ID));
                    obj.OrderIndex--;
                    objBookChapter.UpdateBookChapter(obj);
                }
            }
            if (e.Parameters[1] == "Insert")
            {
                string strSql = "select Max(Chapter_Id) from Book_Chapter where Book_ID=" + hfBookID.Value
                                + " and Parent_ID=" + e.Parameters[0];
                OracleAccess db = new OracleAccess();
                DataSet      ds = db.RunSqlDataSet(strSql);

                hfMaxID.Value = ds.Tables[0].Rows[0][0].ToString();
                hfMaxID.RenderControl(e.Output);
            }

            tvBookChapter.Nodes.Clear();
            BindTree();
            tvBookChapter.RenderControl(e.Output);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            hfChapterID.Value = Request.QueryString["id"];
            hfIsWuhan.Value   = PrjPub.IsWuhan().ToString();

            if (fvBookChapter.CurrentMode == FormViewMode.Insert)
            {
                if (hfInsert.Value == "-1")
                {
                    ((HiddenField)fvBookChapter.FindControl("hfParentID")).Value = Request.QueryString["ParentID"];
                    ((HiddenField)fvBookChapter.FindControl("hfBookID")).Value   = Request.QueryString["BookID"];
                }
                else
                {
                    ((HiddenField)fvBookChapter.FindControl("hfParentId")).Value = hfInsert.Value;
                    ((HiddenField)fvBookChapter.FindControl("hfBookID")).Value   = Request.QueryString["BookID"];
                }
                if (Request.QueryString["Mode"] == "Edit")
                {
                    ((HiddenField)fvBookChapter.FindControl("hfIsEdit")).Value = "true";
                }
                else
                {
                    ((HiddenField)fvBookChapter.FindControl("hfIsEdit")).Value = "false";
                }
            }
            else if (fvBookChapter.CurrentMode == FormViewMode.Edit)
            {
                if (Request.QueryString["Mode"] == "Edit")
                {
                    ((HiddenField)fvBookChapter.FindControl("hfIsEdit")).Value = "true";
                }
                else
                {
                    ((HiddenField)fvBookChapter.FindControl("hfIsEdit")).Value = "false";
                }
            }


            string strRefresh = Request.Form.Get("Refresh");

            if (strRefresh != null & strRefresh != "")
            {
                string strPath = "../Online/Book/" + Request.QueryString["BookID"].ToString() + "/" + Request.QueryString["id"].ToString() + ".htm";

                BookChapterBLL objBill = new BookChapterBLL();
                objBill.UpdateBookChapterUrl(Convert.ToInt32(Request.QueryString["id"].ToString()), strPath);
                RailExam.Model.BookChapter objBookChapter = objBill.GetBookChapter(Convert.ToInt32(Request.QueryString["id"].ToString()));
                string strChapterName = objBookChapter.ChapterName;

                string str = File.ReadAllText(Server.MapPath(strPath), Encoding.UTF8);

                if (str.IndexOf("chaptertitle") < 0)
                {
                    if (objBookChapter.LevelNum < 3)
                    {
                        str = "<link href='book.css' type='text/css' rel='stylesheet' />"
                              + "<body oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' oncopy='document.selection.empty()' onbeforecopy='return false'>"
                              + "<div id='chaptertitle" + objBookChapter.LevelNum + "'>" + strChapterName + "</div>" +
                              "<br>"
                              + str + "</body>";
                    }
                    else
                    {
                        str = "<link href='book.css' type='text/css' rel='stylesheet' />"
                              + "<body oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' oncopy='document.selection.empty()' onbeforecopy='return false'>"
                              + "<div id='chaptertitle3'>" + strChapterName + "</div>" +
                              "<br>"
                              + str + "</body>";
                    }

                    File.WriteAllText(Server.MapPath(strPath), str, Encoding.UTF8);
                }


                BookBLL objBookBill = new BookBLL();
                if (Request.QueryString.Get("Mode") == "Edit")
                {
                    objBookBill.UpdateBookVersion(Convert.ToInt32(Request.QueryString["BookID"].ToString()));
                }
                string strBookName = objBookBill.GetBook(Convert.ToInt32(Request.QueryString["BookID"].ToString())).bookName;

                SystemLogBLL objLogBll = new SystemLogBLL();
                objLogBll.WriteLog("编辑教材《" + strBookName + "》中“" + strChapterName + "”的章节内容");

                fvBookChapter.DataBind();
                Grid1.DataBind();

                objBill.GetIndex(Request.QueryString["BookID"].ToString());

                ItemBLL objBll = new ItemBLL();
                IList <RailExam.Model.Item> objList =
                    objBll.GetItemsByBookChapterId(Convert.ToInt32(Request.QueryString["BookID"]), Convert.ToInt32(Request.QueryString["id"]), 0, 0);

                if (objList.Count > 0)
                {
                    ClientScript.RegisterStartupScript(GetType(),
                                                       "jsSelectFirstNode",
                                                       @"var ret = window.showModalDialog('/RailExamBao/Book/ItemEnabled.aspx?BookID=" + Request.QueryString["BookID"] + @"&ChapterID=" + Request.QueryString["id"] + @"','','help:no; status:no;dialogWidth:300px;dialogHeight:120px;');",
                                                       true);
                }
            }

            string strRefreshGrid = Request.Form.Get("RefreshGrid");

            if (strRefreshGrid != null & strRefreshGrid != "")
            {
                fvBookChapter.DataBind();
                Grid1.DataBind();
            }

            string strDeleteBookChapterUpdateID = Request.Form.Get("DeleteBookChapterUpdateID");

            if (!string.IsNullOrEmpty(strDeleteBookChapterUpdateID))
            {
                DeleteData(int.Parse(strDeleteBookChapterUpdateID));
                Grid1.DataBind();
            }
        }