Ejemplo n.º 1
0
        protected void btnInput_Click(object sender, EventArgs e)
        {
            BookBLL bookBLL = new BookBLL();

            for (int i = 0; i < gvBook.Rows.Count; i++)
            {
                bool bChecked = ((CheckBox)gvBook.Rows[i].FindControl("chSelect")).Checked;

                if (bChecked)
                {
                    ItemBLL objBll = new ItemBLL();
                    IList <RailExam.Model.Item> objItemList = objBll.GetItemsByBookBookId(Convert.ToInt32(gvBook.DataKeys[i].Value.ToString()));

                    foreach (RailExam.Model.Item item in objItemList)
                    {
                        item.StatusId = 2;
                        objBll.UpdateItem(item);
                    }
                    if (Directory.Exists(Server.MapPath("../Online/Book/" + gvBook.DataKeys[i].Value + "/")))
                    {
                        DeleteFile(Server.MapPath("../Online/Book/" + gvBook.DataKeys[i].Value + "/"));
                    }
                    bookBLL.DeleteBook(Convert.ToInt32(gvBook.DataKeys[i].Value.ToString()));
                }
            }
            BindGrid();
        }
Ejemplo n.º 2
0
        private void BindGrid()
        {
            if (!string.IsNullOrEmpty(hfChapterID.Value) && hfChapterID.Value != "0")
            {
                int bookID    = Convert.ToInt32(Request.QueryString["BookID"]);
                int chapterID = Convert.ToInt32(hfChapterID.Value);

                ItemBLL objItemBll = new ItemBLL();
                IList <RailExam.Model.Item> objItemList = objItemBll.GetItemsByBookChapterId(bookID, chapterID, 0, int.MaxValue);

                itemsGrid.DataSource = objItemList;
                itemsGrid.DataBind();
            }
            else
            {
                int bookID = Convert.ToInt32(Request.QueryString["BookID"]);

                ItemBLL objItemBll = new ItemBLL();
                IList <RailExam.Model.Item> objItemList = objItemBll.GetItemsByBookBookId(bookID);

                itemsGrid.DataSource = objItemList;
                itemsGrid.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected void btnInput_Click(object sender, EventArgs e)
        {
            string strSql;

            for (int i = 0; i < gvBook.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)gvBook.Rows[i].FindControl("chSelect");

                string strKnowledgeId = ((HiddenField)gvBook.Rows[i].FindControl("hfKownledgeId")).Value;

                if (chk.Checked)
                {
                    strSql = "select a.*,b.Short_Name from Book a inner join Org b on a.Publish_Org=b.Org_ID where a.Book_ID=" + gvBook.DataKeys[i].Value.ToString();
                    DataSet ds = RunSqlDataSet(strSql);
                    DataRow dr = ds.Tables[0].Rows[0];

                    BookBLL             objBookbll = new BookBLL();
                    RailExam.Model.Book objBookNew = new RailExam.Model.Book();
                    objBookNew.bookId = Convert.ToInt32(dr["Book_ID"].ToString());

                    string strPath    = Server.MapPath(ConfigurationManager.AppSettings["BookDesigner"].ToString() + objBookNew.bookId + "/");
                    string strAimPath = Server.MapPath("../Online/Book/" + objBookNew.bookId + "/");
                    if (!Directory.Exists(strPath))
                    {
                        SessionSet.PageMessage = "有教材还未创建内容,暂不能导入!";
                        return;
                    }

                    objBookNew.bookName       = dr["Book_Name"].ToString();
                    objBookNew.bookNo         = dr["Book_No"].ToString();
                    objBookNew.authors        = dr["Authors"].ToString();
                    objBookNew.bookmaker      = dr["BookMaker"].ToString();
                    objBookNew.publishOrg     = Convert.ToInt32(dr["Publish_Org"].ToString());
                    objBookNew.publishOrgName = dr["Short_Name"].ToString();
                    objBookNew.revisers       = dr["Revisers"].ToString();
                    objBookNew.coverDesigner  = dr["Cover_Designer"].ToString();
                    objBookNew.keyWords       = dr["Keywords"].ToString();
                    objBookNew.pageCount      = Convert.ToInt32(dr["Page_Count"].ToString());
                    objBookNew.wordCount      = Convert.ToInt32(dr["Word_Count"].ToString());
                    objBookNew.Description    = dr["Description"].ToString();
                    objBookNew.url            = "../Book/" + dr["Book_ID"].ToString() + "/index.html";
                    objBookNew.Memo           = dr["Remark"].ToString();
                    objBookNew.knowledgeId    = Convert.ToInt32(strKnowledgeId);

                    //objBookbll.UpdateBook(objBookNew, ref errorCode);

                    strSql = "select * from Book_Chapter where Book_ID=" + gvBook.DataKeys[i].Value.ToString();
                    ds     = RunSqlDataSet(strSql);

                    BookChapterBLL objBookChapterBll = new BookChapterBLL();

                    //取得Access数据库中当前教材的所有的章节ID
                    ArrayList objAccessChapterList = new ArrayList();

                    //取得当前教材在oracle数据中所有章节ID
                    ArrayList objList = GetBookChapterList(Convert.ToInt32(gvBook.DataKeys[i].Value.ToString()));
                    foreach (DataRow dr1 in ds.Tables[0].Rows)
                    {
                        RailExam.Model.BookChapter objBookChapter = new RailExam.Model.BookChapter();

                        objBookChapter.ChapterId           = Convert.ToInt32(dr1["Chapter_ID"].ToString());
                        objBookChapter.BookId              = Convert.ToInt32(dr1["Book_ID"].ToString());
                        objBookChapter.ChapterName         = dr1["Chapter_Name"].ToString();
                        objBookChapter.ParentId            = Convert.ToInt32(dr1["Parent_ID"].ToString());
                        objBookChapter.LevelNum            = Convert.ToInt32(dr1["Level_Num"].ToString());
                        objBookChapter.OrderIndex          = Convert.ToInt32(dr1["Order_Index"].ToString());
                        objBookChapter.ReferenceRegulation = dr1["REFERENCE_REGULATION"].ToString();
                        objBookChapter.Description         = dr1["Description"].ToString();
                        objBookChapter.Memo = dr1["Remark"].ToString();
                        objBookChapter.Url  = "../Book/" + dr1["Book_ID"].ToString() + "/" + dr1["Chapter_ID"].ToString() + ".htm";

                        //如果该章节的ID已存在当前oracle数据库中则只需修改章节信息,否则添加信息
                        if (objList.IndexOf(objBookChapter.ChapterId) != -1)
                        {
                            objBookChapterBll.UpdateBookChapter(objBookChapter);
                        }
                        else
                        {
                            objBookChapterBll.AddBookChapter(objBookChapter);
                        }

                        objAccessChapterList.Add(objBookChapter.ChapterId);
                    }

                    //取得当前教材在oracle中的所有教材信息


                    IList <RailExam.Model.BookChapter> objOracleBookChapterList =
                        objBookChapterBll.GetBookChapterByBookID(objBookNew.bookId);

                    foreach (RailExam.Model.BookChapter chapter in objOracleBookChapterList)
                    {
                        //如果oracle数据库中某章节ID不在Access数据库中
                        if (objAccessChapterList.IndexOf(chapter.ChapterId) == -1)
                        {
                            ItemBLL objItemBll = new ItemBLL();
                            IList <RailExam.Model.Item> objItemList = objItemBll.GetItemsByBookBookId(objBookNew.bookId);

                            foreach (RailExam.Model.Item item in objItemList)
                            {
                                item.StatusId = 2;
                                objItemBll.UpdateItem(item);
                            }

                            objBookChapterBll.DeleteBookChapter(chapter.ChapterId);
                        }
                    }

                    if (Directory.Exists(Server.MapPath("../Online/Book/" + objBookNew.bookId + "/")))
                    {
                        //Directory.Delete(Server.MapPath("../Online/Book/" + objBookNew.bookId + "/"), true);
                        DeleteFile(Server.MapPath("../Online/Book/" + objBookNew.bookId + "/"));
                    }

                    CopyTemplate(strPath, strAimPath);
                }
            }
            BindGrid();
        }