コード例 #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();
        }
コード例 #2
0
        // DELETE: api/Book/5
        public HttpResponseMessage Delete(int id)
        {
            if (!BookBLL.DeleteBook(id))
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
コード例 #3
0
ファイル: BookInfo.aspx.cs プロジェクト: ZB347954263/RailExam
        // <summary>
        // 发布教材
        // </summary>
        // <param name="strID"></param>
        //private void GetIndex(string strID)
        //{
        //    string  strItem;

        //    BookBLL objBll = new BookBLL();
        //    RailExam.Model.Book objBook = objBll.GetBook(Convert.ToInt32(strID));

        //    string strBookName = objBook.bookName;
        //    string strBookUrl = objBook.url;

        //    if (strBookUrl == "" || objBook.url == null)
        //    {
        //        strItem = "var TREE_ITEMS = [ ['" + strBookName + "', 'empty.htm',";
        //    }
        //    else
        //    {
        //        strItem = "var TREE_ITEMS = [ ['" + strBookName + "', 'cover.htm',";
        //    }


        //    BookChapterBLL objBookChapterBll = new BookChapterBLL();
        //    IList<RailExam.Model.BookChapter> objBookChapter = objBookChapterBll.GetBookChapterByBookID(Convert.ToInt32(strID));

        //    foreach (RailExam.Model.BookChapter chapter in objBookChapter)
        //    {
        //        if(chapter.ParentId == 0)
        //        {
        //            if (chapter.Url == "" || chapter.Url == null)
        //            {
        //                strItem += "['" + chapter.ChapterName + "', 'empty.htm',";
        //            }
        //            else
        //            {
        //                strItem += "['" + chapter.ChapterName + "', '" + chapter.ChapterId + ".htm',";
        //            }

        //            strItem = Get(chapter.ChapterId, strItem);
        //        }
        //    }

        //    strItem += "]];";

        //    string strPath = "../Online/Book/" + strID + "/tree_items.js";
        //    File.Delete(Server.MapPath(strPath));
        //    File.AppendAllText(Server.MapPath(strPath), strItem, System.Text.Encoding.UTF8);

        //    string[] strIndex = File.ReadAllLines(Server.MapPath("../Online/Book/" + strID + "/index.html"), System.Text.Encoding.Default);

        //    for (int i = 0; i < strIndex.Length; i++)
        //    {
        //        if (strIndex[i].IndexOf("<title>") != -1)
        //        {
        //            strIndex[i] = "\t<title> " + strBookName + " </title>";
        //        }
        //    }

        //    File.WriteAllLines(Server.MapPath("../Online/Book/" + strID + "/index.html"), strIndex, System.Text.Encoding.UTF8);

        //    ViewState["NowID"] = strID;
        //    Response.Write("<script>var re = window.open('Book/"+strID+"/index.html','index','top=0,left=0,width='+(window.screen.width-10)+',height='+(window.screen.height-65)+',resizable=yes,status=no');re.focus();</script>");
        //}

        //private string Get(int strParentID, string strItem)
        //{
        //    BookChapterBLL objBookChapterBll = new BookChapterBLL();
        //    IList<RailExam.Model.BookChapter> objBookChapter = objBookChapterBll.GetBookChapterByParentID(strParentID);

        //    foreach (RailExam.Model.BookChapter chapter in objBookChapter)
        //    {
        //        if (chapter.Url == "" || chapter.Url == null)
        //        {
        //            strItem += "['" + chapter.ChapterName + "', 'empty.htm'";
        //        }
        //        else
        //        {
        //            strItem += "['" + chapter.ChapterName + "', '" + chapter.ChapterId + ".htm'";
        //        }

        //        strItem = Get(chapter.ChapterId, strItem);
        //    }

        //    strItem += "],";

        //    return strItem;
        //}

        // <summary>
        // 复写Render方法
        // </summary>
        // <param name="writer">书写器</param>
        //protected override void Render(HtmlTextWriter writer)
        //{
        //    base.Render(writer);

        //    if ((string)ViewState["NowID"] != "false")
        //    {
        //        ViewState["NowCheck"] = "false";
        //        writer.Write("<script>var re = window.open('../Online/Book/" + ViewState["NowID"].ToString() + "/index.html','index','top=0,left=0,width='+(window.screen.width-10)+',height='+(window.screen.height-65)+',resizable=yes,status=no');re.focus();</script>");
        //    }
        //}
        #endregion

        private void DelBook(string strID)
        {
            ItemBLL objItemBll = new ItemBLL();

            objItemBll.UpdateItemEnabled(Convert.ToInt32(strID), 0, 2);

            BookBLL objBll = new BookBLL();

            objBll.DeleteBook(Convert.ToInt32(strID));
        }
コード例 #4
0
 public ResultModel Delete(int id)
 {
     try
     {
         _bookBLL.DeleteBook(id);
         return(new ResultModel(Code.OK, "thành công"));
     }
     catch (Exception)
     {
         return(new ResultModel(Code.SVERROR, "lỗi hệ thống"));
     }
 }