//update
        public Book_Maintain_Ajax.Model.BookUpdate GetUpdateBook(int id)
        {
            string sql = @"SELECT bd.BOOK_ID AS BookID,bd.BOOK_NAME AS BookName,bd.BOOK_AUTHOR AS BookAuthor,bd.BOOK_PUBLISHER AS BookPublisher,bd.BOOK_NOTE AS Note,
							CONVERT(varchar, bd.BOOK_BOUGHT_DATE, 111) AS BoughtDate,bc.BOOK_CLASS_ID AS BookClassId,
							bcd.CODE_ID AS BookStatusId,mm.USER_ID AS BookKeeperId
						   FROM BOOK_DATA bd
								INNER JOIN  BOOK_CLASS bc
									ON bd.BOOK_CLASS_ID = bc.BOOK_CLASS_ID
								INNER JOIN BOOK_CODE bcd
									ON bd.BOOK_STATUS = bcd.CODE_ID AND bcd.CODE_TYPE = 'BOOK_STATUS'
								LEFT OUTER JOIN  MEMBER_M mm
									ON bd.BOOK_KEEPER = mm.[USER_ID]
							WHERE BOOK_ID = @BOOK_ID"                            ;

            using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString()))
            {
                var TempUpdateBook = conn.Query <Book_Maintain_Ajax.Model.BookUpdate>(sql, new { BOOK_ID = id });
                Book_Maintain_Ajax.Model.BookUpdate UpdateBook = new Model.BookUpdate();
                foreach (var updateBook in TempUpdateBook)
                {
                    UpdateBook = updateBook;
                }
                return(UpdateBook);
            }
        }
 public JsonResult ShowBookDetail(string id)
 {
     if (bookService.IsIdExist(id))
     {
         Model.BookUpdate bookdetail = bookService.GetBookDetail(Convert.ToInt32(id));
         return(Json(bookdetail, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(null, JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult UpdateBook(Model.BookUpdate bookUpdate, string IniBookStatus, string LaterBookStatus)
 {
     //借閱人借閱狀態關係
     if ((bookUpdate.BookStatusId == "B" || bookUpdate.BookStatusId == "C") && (bookUpdate.BookKeeperId == "" || bookUpdate.BookKeeperId == null))
     {
         return(Json("此借閱狀態,借閱人不能為空"));
     }
     else
     {
         //insert 借閱紀錄
         if ((IniBookStatus == "A" || IniBookStatus == "U") && (LaterBookStatus == "B" || LaterBookStatus == "C"))
         {
             Model.LendRecordInsert lendRecordInsert = new Model.LendRecordInsert();
             lendRecordInsert.BookKeeperId = bookUpdate.BookKeeperId;
             bookService.InsertLendRecord(lendRecordInsert);
         }
         //update 書本資料
         bookService.UpdateBook(bookUpdate);
         return(Json("編輯成功"));
     }
 }
Ejemplo n.º 4
0
        public void Clean()
        {
            //Arrange
            Book_Maintain_Ajax.Model.BookUpdate bookUpdateClean = new Model.BookUpdate
            {
                BookName      = "hello world",
                BookAuthor    = "Marz",
                BookPublisher = "南一",
                Note          = "112233",
                BoughtDate    = "2019/03/15",
                BookClassId   = "BK",
                BookStatusId  = "A",
                BookKeeperId  = ""
            };
            //Act
            //bookDao.UpdateBook(InsertId, bookUpdate);
            bookDao.UpdateBook(InsertId, bookUpdateClean);
            string IfDelete = bookDao.DecideDelete(Convert.ToString(InsertId));

            System.Diagnostics.Debug.WriteLine("TestClean:" + InsertId);
            System.Diagnostics.Debug.WriteLine("************TestClean SUCCESS*************");
            //Alert
            Assert.AreEqual("刪除成功", IfDelete);
        }
        public JsonResult GetUpdateData(string id)
        {
            Model.BookUpdate bookupdate = bookService.GetUpdateBook(Convert.ToInt32(id));

            return(Json(bookupdate, JsonRequestBehavior.AllowGet));
        }