/// <summary> /// 新增書籍 /// </summary> /// <param name="arg"></param> /// <returns></returns> public int AddBook(BMS.Model.BookAddArg arg) { int bookId; using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString())) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; 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.CommandText = @"INSERT INTO BOOK_DATA ( BOOK_NAME, BOOK_AUTHOR, BOOK_PUBLISHER, BOOK_BOUGHT_DATE, BOOK_NOTE, BOOK_CLASS_ID, BOOK_STATUS, BOOK_KEEPER, CREATE_DATE, CREATE_USER ) VALUES ( @BookName, @BookAuthor, @BookPublisher, @BookBoughtDate, @BookNote, @BookClassID, 'A', '', GETDATE(), '3008' ) SELECT SCOPE_IDENTITY()"; bookId = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); } return(bookId); }
public int AddBook(BMS.Model.BookAddArg arg) { return(bookDao.AddBook(arg)); }
public JsonResult Add(BMS.Model.BookAddArg arg) { bookService.AddBook(arg); return(Json("success")); }