void uiBook_DrawItem(object sender, DrawItemEventArgs e) { // Get the data if (e.Index < 0) { return; } BookListItem book = uiBook.Items[e.Index] as BookListItem; if (book == null) { return; } string[] parts = book.PartsFound(searchText); // Get the drawing tools Font theFont = GetBookFont(book); Color theColor = book.isPresent ? e.ForeColor : emptyBooksColor; // Calculate field widths if necessary CalcFieldWidths(e.Graphics); // Draw ListBox Item using (Font searchFont = new Font(theFont, searchTextStyle)) { e.DrawBackground(); e.DrawFocusRectangle(); DrawBookParts(parts, e.Graphics, e.Bounds, theColor, searchFont, theFont); } }
public void BookListItemTest() //POJO测试 { BookListItem item = new BookListItem(); item.Author = "test"; Assert.IsTrue(item.Author.Equals("test")); item.CurPageNo = 100; Assert.IsTrue(item.CurPageNo == 100); }
public void BookServiceInsertBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 bool ret = service.insert(book); //边界测试1,插入,Book内容为空 Assert.IsTrue(ret == false); }
public void BookServiceUpdateBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 bool ret3 = service.update(book); //边界测试4,更新,Book内容为空 Assert.IsTrue(ret3 == false); }
public void BookServiceSearchBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 List <BookListItem> list; list = service.searchByISBN(book.ISBN, ""); Assert.IsTrue(list == null); //边界测试2,查询,username为空 }
public void BookServiceDeleteBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 bool ret2 = service.delete(book, ""); //边界测试3,删除,username为空 Assert.IsTrue(ret2 == false); }
public static List <BookListItem> LoadAll(IDbConnection dbConnection) { var itemResultSet = dbConnection.Take("booklist").OrderBy("id").Execute(); var itemList = new List <BookListItem>(); for (var i = 0; i < itemResultSet[0].Count; i++) { BookListItem item = Int32.TryParse(itemResultSet[0][i], out int id) ? LoadOneItem(itemResultSet, i) : new BookListItem(); itemList.Add(item); } return(itemList); }
public ActionResult Create(BookListItem bli) { try { dbContext.Add(bli.Book.Title, bli.Author.FirstName, bli.Author.LastName, bli.Book.ISBN); dbContext.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void BookServiceUpdateFuncTest() //BookService功能测试 { BookService service = BookService.getInstance(); List <BookListItem> list; list = service.searchByISBN("10010", "TestUser"); //正常测试需要的数据 BookListItem book2 = list[0]; book2.Author = "TestAuthorx"; bool ret5 = service.update(book2); //正常测试3,更新 Assert.IsTrue(ret5 == true); }
private BookListItem CreateBookListItem(Book book) { var state = _bb.GetCustomerBookState(book.BookId); var item = new BookListItem { BookId = book.BookId.ToString(), BookNumber = book.BookNumber, Title = UserOperationFactory.CreateBookDetailOperation(book.BookType.Title, book.BookNumber), Publisher = book.BookType.Publisher, State = state.State, Operation = state.Operation, BorrowedBy = state.BorrowedBy, ReturnDate = state.ReturnDate, SubscribedBy = state.SubscribedBy }; return(item); }
public void BookServiceInsertFuncTest() //BookService功能测试 { BookService service = BookService.getInstance(); BookListItem book2 = new BookListItem(); //正常测试需要的数据 book2.UserId = "TestUser"; book2.Title = "TestBook"; book2.PageNo = 100; book2.CurPageNo = 0; book2.Id = 0; book2.Publisher = "TestPublisher"; book2.Author = "TestAuthor"; book2.ISBN = "10010"; bool ret4 = service.insert(book2); //正常测试1,插入 Assert.IsTrue(ret4 == true); }
public void BookServiceDeleteFuncTest() //BookService功能测试 { BookService service = BookService.getInstance(); BookListItem book2 = new BookListItem(); //正常测试需要的数据 book2.UserId = "TestUser"; book2.Title = "TestBook"; book2.PageNo = 100; book2.CurPageNo = 0; book2.Id = 0; book2.Publisher = "TestPublisher"; book2.Author = "TestAuthor"; book2.ISBN = "10010"; bool ret6 = service.delete(book2, "TestUser"); //正常测试4,删除 Assert.IsTrue(ret6 == true); }
public ActionResult Edit(BookListItem book) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44371/api/Book"); string token = DeserializeToken(); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var putTask = client.PutAsJsonAsync <BookListItem>("book", book); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(book)); }
public void BookServiceSearchFuncTest() //BookService功能测试 { BookService service = BookService.getInstance(); List <BookListItem> list; BookListItem book2 = new BookListItem(); //正常测试需要的数据 book2.UserId = "TestUser"; book2.Title = "TestBook"; book2.PageNo = 100; book2.CurPageNo = 0; book2.Id = 0; book2.Publisher = "TestPublisher"; book2.Author = "TestAuthor"; book2.ISBN = "10010"; list = service.searchByISBN(book2.ISBN, "TestUser"); Assert.IsTrue(list.Count == 1); //正常测试2,查询 }
public ActionResult Edit(int id, BookListItem bli) { try { BookListItem b = dbContext.Books.Select(x => new BookListItem { Id = x.Id, Book = x, Author = x.Author, }).First(x => x.Id == id); b.Book.ISBN = bli.Book.ISBN; b.Book.Title = bli.Book.Title; b.Author.FirstName = bli.Author.FirstName; b.Author.LastName = bli.Author.LastName; dbContext.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id) { BookListItem book = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44371/api/"); string token = DeserializeToken(); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var responseTask = client.PostAsJsonAsync("Book?id=" + id.ToString(), id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <BookListItem>(); readTask.Wait(); book = readTask.Result; } } return(View(book)); }
Font GetBookFont(BookListItem book) { return(book.isPresent ? Font : emptyBooksFont); }
public VerseControl() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); if (Platform.IsLinux) { // Set a smaller font on Linux. (Stops 'J''s being clipped) uiBook.Font = new Font("Microsoft Sans Serif", 8F, FontStyle.Regular, GraphicsUnit.Point, 0); // Also increase the ItemHeight as to stop clipping of items in the drop down menu.. uiBook.ItemHeight += 2; } // Create reference and set to English versification curRef = new VerseRef(ScrVers.English); // Add books... allBooks = new BookListItem[Canon.LastBook]; InitializeBooks(); //...to internal data structure PopulateBooks(); //...and to combobox list uiBook.GotFocus += control_GotFocus; uiChapter.GotFocus += control_GotFocus; uiVerse.GotFocus += control_GotFocus; // Cause Drop down list to be initally populated. // (stop intial click on Combo box drop down beinging ignored on mono) // TODO: fix mono bug where dropdown isn't shown if list is empty even // if dropdown event handlers populate list. if (Platform.IsMono) { uiBook.BeforeMouseDown += (sender, e) => { if (uiBook.Items.Count == 0) { PopulateBooks(); } } } ; } #endregion #region Helpers and Initializers void InitializeBooks() { int i = 0; StringBuilder abbrevs = new StringBuilder(); foreach (string abbrev in Canon.AllBookIds) { abbrevs.Append(abbrev); abbrevs.Append(","); BookListItem item = new BookListItem(abbrev); item.isPresent = booksPresentSet.IsSelected(i + Canon.FirstBook); allBooks[i] = item; i++; } abbreviations = abbrevs.ToString(); RelocalizeBooks(); }
// GET: Book public ActionResult Index() { var model = new BookListItem[0]; return(View(model)); }
// GET: Book public ActionResult Create() { var model = new BookListItem[0]; return(View()); }