/// <summary> /// 修改書籍 /// </summary> /// <param name="arg"></param> /// <returns></returns> public string UpdateBook(BMS.Model.BookUpdateArg arg) { using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString())) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.Parameters.Add(new SqlParameter("@BookId", arg.BookId)); cmd.Parameters.Add(new SqlParameter("@BookName", arg.BookName)); cmd.Parameters.Add(new SqlParameter("@BookAuthor", arg.BookAuthor)); cmd.Parameters.Add(new SqlParameter("@BookPublisher", arg.BookPublisher)); cmd.Parameters.Add(new SqlParameter("@BookBoughtDate", arg.BookBoughtDate)); cmd.Parameters.Add(new SqlParameter("@BookNote", arg.BookNote)); cmd.Parameters.Add(new SqlParameter("@BookClassId", arg.BookClass)); cmd.Parameters.Add(new SqlParameter("@BookStatus", arg.BookStatus)); cmd.Parameters.Add(new SqlParameter("@BookKeeper", arg.BookKeeper ?? string.Empty)); cmd.CommandText = @"UPDATE BOOK_DATA SET BOOK_NAME = @BookName, BOOK_AUTHOR = @BookAuthor, BOOK_PUBLISHER = @BookPublisher, BOOK_BOUGHT_DATE = @BookBoughtDate, BOOK_NOTE = @BookNote, BOOK_CLASS_ID = @BookClassId, BOOK_STATUS = @BookStatus, BOOK_KEEPER = @BookKeeper, MODIFY_DATE = GETDATE(), MODIFY_USER = '******' WHERE BOOK_ID = @BookId"; cmd.ExecuteNonQuery(); conn.Close(); } return(arg.BookId); }
/// <summary> /// Map書籍資料進Model /// </summary> /// <param name="bookItem"></param> /// <returns></returns> private BMS.Model.BookUpdateArg MapBookToModel(DataTable bookItem) { BMS.Model.BookUpdateArg result = new BMS.Model.BookUpdateArg(); result.BookId = bookItem.Rows[0]["BOOK_ID"].ToString(); result.BookName = bookItem.Rows[0]["BOOK_NAME"].ToString(); result.BookAuthor = bookItem.Rows[0]["BOOK_AUTHOR"].ToString(); result.BookPublisher = bookItem.Rows[0]["BOOK_PUBLISHER"].ToString(); result.BookNote = bookItem.Rows[0]["BOOK_NOTE"].ToString(); result.BookBoughtDate = bookItem.Rows[0]["BOOK_BOUGHT_DATE"].ToString(); result.BookClass = bookItem.Rows[0]["BOOK_CLASS_ID"].ToString(); result.BookStatus = bookItem.Rows[0]["BOOK_STATUS"].ToString(); result.BookKeeper = bookItem.Rows[0]["BOOK_KEEPER"].ToString(); return(result); }
public string UpdateBook(BMS.Model.BookUpdateArg arg) { return(bookDao.UpdateBook(arg)); }
public JsonResult Update(BMS.Model.BookUpdateArg arg) { bookService.UpdateBook(arg); return(Json("success")); }