public string IssueBook(string isbn) { BookDAL bb = new BookDAL(); int bkID = 0; bkID = ba.GetBookID(isbn); if (bkID > 0) { CatalogClass lc = new CatalogClass(); lc.bookId = bkID; lc.ISBN = isbn; bool tMsg = bb.UpdateBookStatus(lc, -1); if (tMsg) { return(bkID.ToString()); } else { return("NotIssued"); } } else { return("NotAvailable"); } }
public string Returnbook(int bId) { BookDAL bb = new BookDAL(); string status = bb.GetBookStatus(bId); string isbn = bb.GetIsbn(bId); if (status.Equals("False")) { CatalogClass lc = new CatalogClass(); lc.bookId = bId; lc.ISBN = isbn; bool tMsg = bb.UpdateBookStatus(lc, 1); if (tMsg) { return("Success"); } else { return("Failed"); } } else { return("AlreadyReturned"); } }
public void GetDados() { var bookDAL = new BookDAL(); List <Book> books = bookDAL.GetAll(); Assert.NotEmpty(books); }
private void BookDetail(object sender, EventArgs e) { if (this.book.bkId == 0) { return; } Book tmp_book = new Book(); if (dataGridView1.SelectedRows.Count <= 0) { MessageBox.Show("Not Exist!"); return; } if (resultTable.Rows.Count <= 0) { MessageBox.Show("Not Exist!"); return; } DataTable rt = BookDAL.GetBookById(book.bkId); tmp_book = Book.RowsToBook(rt.Rows); BookDetailForm bdf = new BookDetailForm(tmp_book); bdf.Show(); }
private void GenerateBooks() { var random = new Random(); List <Author> authors = (List <Author>)Session["Authors"]; Session["Books"] = new List <Book>(); int nbAuthors = authors.Count; DateTime startDate = new DateTime(1800, 01, 01); DateTime endDate = new DateTime(2017, 06, 09); var dal = new BookDAL((List <Book>)Session["Books"]); for (int i = 0; i < random.Next(10, 20); i++) { String bookTitle = random.NextLoremIpsum(2); DateTime date = random.NextDate(startDate, endDate); String edition = random.NextString(8); int quantity = random.Next(10); String thematic = random.NextString(8); var selectedIndexAuthor = random.Next(0, nbAuthors - 1); Author selectedAuthor = authors.ElementAt(selectedIndexAuthor); Book book = new Book() { Author = selectedAuthor, AvailableQuantity = quantity, Edition = edition, PublicationDate = date, Thematic = thematic, Title = bookTitle }; dal.Add(book); } }
//UPDATE THE BOOK FROM BOOK TABLE =>BL /* public string UpdateBookBL(int bookId, string bookName, string bookAuthor, string bookISBN, double bookPrice, int bookCopies) * { * string isBookValid = BookValidate(bookName, bookAuthor, bookISBN, bookPrice, bookCopies); * if (isBookValid == "true") * { * BookDAL bookDAL = new BookDAL(); * bool isDone = bookDAL.UpdateBookDAL(bookId, bookName, bookAuthor, bookISBN, bookPrice, bookCopies); * if (isDone != true) * { * return "Server error, "; * } * else * { * return "true"; * } * } * else * { * return isBookValid; * } * }*/ public bool UpdateBookBL(int bookId, string bookName, string bookAuthor, string bookISBN, double bookPrice, int bookCopies) { BookDAL bookDAL = new BookDAL(); bool isDone = bookDAL.UpdateBookDAL(bookId, bookName, bookAuthor, bookISBN, bookPrice, bookCopies); return(isDone); }
public IActionResult BookDetail(int id) { BookDAL dal = new BookDAL(); BookModel character = dal.GetBook(id); return(View(character)); }
public List <Author> GetAuthorsForEdition() { string bookName = Helper.ReadString("Introduce the name of the book:"); while (!BookDAL.CheckBook(bookName)) { Helper.DisplayError("\n Wrong book name!"); Console.ForegroundColor = ConsoleColor.Red; bookName = Helper.ReadString("Reintroduce the name of the book:"); } List <Author> authors = null; int PublicationYear = Helper.ReadYear("Introduce the year of publishing:"); string PublishingHouseName = Helper.ReadString("Introduce publishing house name:"); while (!EditionDAL.CheckEdition(bookName, PublishingHouseName, PublicationYear)) { Helper.DisplayError("\n Edition doesn't exist!"); Console.ForegroundColor = ConsoleColor.Red; PublicationYear = Helper.ReadYear("Reintroduce the year of publishing:"); PublishingHouseName = Helper.ReadString("Reintroduce publishing house name:"); } authors = AuthorDAL.GetAuthorsForBook(bookName, PublicationYear, PublishingHouseName); return(authors); }
protected void Page_Load(object sender, EventArgs e) { if (Session["AID"] == null) { Response.Redirect("Default.aspx"); } if (!IsPostBack) { //绑定类别 this.DropDownList1.DataSource = CategoryDAL.getBSCategoryList(); this.DropDownList1.DataTextField = "BSName"; this.DropDownList1.DataValueField = "BSID"; this.DropDownList1.DataBind(); //根据图书ID查询出商品 string a = Request.QueryString["BID"]; int BID = Convert.ToInt32(a); Book b = BookDAL.selectByID(BID)[0]; this.txtName.Text = b.BName; this.txtAuthor.Text = b.BAuthor; this.txtbisd.Text = b.BISBN.ToString(); this.txtPrice.Text = b.BPrice.ToString(); Session ["FileName"] = b.BPic.ToString(); //this.labFileName.Text = b.BPic.ToString(); this.txtBcount.Text = b.BCount.ToString(); this.DropDownList1.SelectedValue = b.BSID.ToString(); } }
public BookController(IDataStore dataStore, IDbHelper dbHelper, INotificationRegister notificationRegister) { _dataStore = dataStore; _dbHelper = dbHelper; _bookDAL = new BookDAL(_dbHelper); _notificationRegister = notificationRegister; }
protected void btnIssue_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { CheckBox cb = (CheckBox)row.FindControl("ckbSelBook"); if (cb.Checked) { IssueDAL issueDAL = new IssueDAL(); BookDAL bookDAL = new BookDAL(); //Calculate issued copy and retrieve number of copies int bookID = Convert.ToInt16(row.Cells[1].Text); int issuedCopies = issueDAL.CountCopies(bookID); int NumberOfCopies = bookDAL.GetNumberOfCopies(bookID); if (issuedCopies < NumberOfCopies) { issueDAL.IssueBook(Convert.ToInt16(Session["UserID"]), Convert.ToInt16(row.Cells[1].Text)); //@TODO add userID lblStatus.Text = "Book has been Issued Successfully"; } else { lblStatus.Text = "The Book is not available at the moment"; } } } }
//RETURN THE COMPLETE BOOKS FROM BOOK TABLE =>BL public DataSet GetAllBooksBL() { BookDAL bookDal = new BookDAL(); DataSet ds = bookDal.GetAllBooksDAL(); return(ds); }
protected void TextBox1_Changed(object sender, EventArgs args) { foreach (RepeaterItem item in Repeater1.Items) { TextBox txt = item.FindControl("TextBox1") as TextBox; Label lblPrice = item.FindControl("lblPrice") as Label; Label lblSum = item.FindControl("lblSum") as Label; //检查库存 LinkButton lbt = item.FindControl("LinkButton1") as LinkButton; //Response.Write(lbt.CommandName); int BID = int.Parse(lbt.CommandName); List <Book> list = BookDAL.selectByID(BID); if (Convert.ToInt32(txt.Text) > list[0].BCount) { Alert(""); txt.Text = list[0].BCount.ToString(); return; } //根据数量改变总价lblSum lblSum.Text = (Convert.ToDouble(lblPrice.Text) * Convert.ToInt32(txt.Text)).ToString(); //根据商品数量变动修改购物车商品数量 if (TradeDAL.UpdateByTID(BID, Convert.ToInt32(txt.Text)) > 0) { //Response.Write("购物车数量改变") } else { Alert("请重新操作"); } } }
//INCREMENT THE BOOK COPIES OF A BOOK BY 1 =>BL public bool IncBookCopyBL(int bookId) { BookDAL bookDAL = new BookDAL(); bool isDone = bookDAL.IncBookCopyDAL(bookId); return(isDone); }
/*public bool UpdateBookBL(int bookId, string bookName, string bookAuthor, string bookISBN, double bookPrice, int bookCopies) * { * BookDAL bookDAL = new BookDAL(); * bool isDone = bookDAL.UpdateBookDAL(bookId, bookName, bookAuthor, bookISBN, bookPrice, bookCopies); * return isDone; * }*/ //DELETE THE BOOK FROM BOOK TABLE =>BL public bool DeleteBookBL(int bookId) { BookDAL bookDAL = new BookDAL(); bool isDone = bookDAL.DeleteBookDAL(bookId); return(isDone); }
public ActionResult Create(Book bk, HttpPostedFileBase coverimg) { string filePath = ""; if (coverimg.ContentLength > 0) { TempData["Message"] = Helper.MsgBox.GetMsg("success", "IF ", "Your data has been added"); string filename = Guid.NewGuid().ToString() + "_" + coverimg.FileName; filePath = Path.Combine(HttpContext.Server.MapPath("~/Content/Images"), filename); bk.CoverImage = filename; coverimg.SaveAs(filePath); } using (BookDAL svBooks = new BookDAL()) { try { svBooks.Add(bk); TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data has been added"); } catch (Exception ex) { TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error !", ex.Message); } } return(RedirectToAction("Index")); }
public void BorrowEdition() { string email = Helper.ReadString("Introduce user's email: "); while (!UserDAL.CheckUser(email)) { Helper.DisplayError("\n User not found!"); Console.ForegroundColor = ConsoleColor.Red; email = Helper.ReadString("\nReintroduce email: "); } string bookName = Helper.ReadString("Introduce the name of the book: "); while (!BookDAL.CheckBook(bookName)) { Helper.DisplayError("\n Book not found!"); Console.ForegroundColor = ConsoleColor.Red; bookName = Helper.ReadString("Introduce the name of the book: "); } int publicationYear = Helper.ReadYear("Introduce the year of publishing: "); string publishingHouseName = Helper.ReadString("Introduce publishing house name: "); while (!EditionDAL.CheckEdition(bookName, publishingHouseName, publicationYear)) { Helper.DisplayError("\n Edition not found!"); Console.ForegroundColor = ConsoleColor.Red; publicationYear = Helper.ReadYear("Introduce the year of publishing: "); publishingHouseName = Helper.ReadString("Introduce publishing house name: "); } string authorName = Helper.ReadString("Introduce the name of the author: "); Author author = new Author(authorName); while (!AuthorDAL.CheckAuthor(author)) { Helper.DisplayError("\n Wrong author!"); Console.ForegroundColor = ConsoleColor.Red; authorName = Helper.ReadString("Introduce the name of the author: "); author = new Author(authorName); } if (ValidBorrow(email, bookName, publishingHouseName, publicationYear)) { Edition edition = new Edition() { PublicationYear = publicationYear, PublishingHouseName = publishingHouseName, Name = bookName, }; int daysLeft = Helper.ReadInteger("Introduce the number of days of the borrow: "); DateTime endDate = DateTime.Now.AddDays(daysLeft); EditionDAL.BorrowEdition(email, edition, author, endDate); Console.WriteLine("\n Operation completed succesfully!"); } }
public ActionResult Detail(int id) { using (BookDAL service = new BookDAL()) { var result = service.GetDetailWithAuthors(id); return(View(result)); } }
public ActionResult Search(string SelectKriteria, string txtSearch) { using (BookDAL svBooks = new BookDAL()) { var result = svBooks.SearchByKriteria(SelectKriteria, txtSearch).ToList(); return(View("Indeks", result)); } }
public static Book GetBookById(int id) { BookDTO bookDto = BookDAL.GetById(id); Book book = new Book(bookDto); return(book); }
public int BookDelete(int id, string name, string cbs, decimal prices, int store) { int count = 0; BookDAL bookdal = new BookDAL(); count = bookdal.BookDeleteByinformation(id, name, cbs, prices, store); return(count); }
public BookUnitTest() { _context = new LibrayContextFactory("AegisDBTest").Create(); _author_dal = new AuthorDAL(_context); _book_dal = new BookDAL(_context); Cleanup(); }
public ActionResult Index(int?page) { int pageSize = 9; int pageNumber = (page ?? 1); var newBooks = BookDAL.GetNewBooks().ToPagedList(pageNumber, pageSize); return(View(newBooks)); }
public ActionResult OthersBookPublisher() { int bookPublisherID = PublisherDAL.GetBookPublisher(); ViewBag.BookPublishers = BookDAL.GetBooksBelongToBookPublisher(bookPublisherID); var bookPublishers = PublisherDAL.GetPublishers(); return(View(bookPublishers)); }
public ActionResult OthersBookCategory() { int bookCategoryID = BookCategoryDAL.GetBookCategory(); ViewBag.BookCategories = BookDAL.GetBooksBelongToBookCategory(bookCategoryID); var bookCategories = BookCategoryDAL.GetBookCategories(); return(View(bookCategories)); }
static DependencyResolver() { UserDAL = new UserDAL(); UserLogic = new UserLogic(UserDAL); BookDAL = new BookDAL(); BookLogic = new BookLogic(BookDAL); BookModelDAL = new BookModelDAL(); BookModelLogic = new BookModelLogic(BookModelDAL); }
public void DeleteBook() { var bookDAL = new BookDAL(); bool success; string idBook = "eBAVuw7ob14C000"; success = bookDAL.Delete(idBook); Assert.False(success); }
public ActionResult Details(int id) // Affichage des informations d'un livre { BookDAL bookDAL = new BookDAL((List <Book>)Session["Books"]); Book book = bookDAL.Read(id); // R2cupération des infos d'un livre pour un id donné ShowBookModelView model = new ShowBookModelView(book); return(View(model)); }
public Cart(int bookID) { var book = BookDAL.GetBook(bookID); this.BookID = bookID; this.Name = book.Name; this.Image = book.Image; this.Price = book.Price.Value; }
protected void ImageButton1_Click(object sender, EventArgs e) { if (Session["login"] == null) { Alert("请先登录"); Response.Redirect("Login.aspx?url=goods.aspx&id=" + Request.QueryString["id"]); } int BID = int.Parse(Request.QueryString["id"]); int MID = Convert.ToInt32(Session["login"]); int number = 1; //获取数量 TextBox lbl = Repeater1.Items[0].FindControl("TextBox1") as TextBox; number = Convert.ToInt32(lbl.Text); Trade t = new Trade() { BID = BID, MID = MID, BCount = number }; bool ecits = TradeDAL.Exits(t); if (ecits == true) { int id = TradeDAL.update_Bcount(t); if (id > 0) { Alert("商品已加入购物车"); } } else { if (TradeDAL.addTrade(BID, MID, number) > 0) { Alert("商品已加入购物车"); int id = TradeDAL.updateBcountByid(number, BID); if (id > 0) { if (Request.QueryString["id"] == null) { return; } //绑定数据 List <Book> list = BookDAL.selectByID(int.Parse(Request.QueryString["id"])); this.Repeater1.DataSource = list; this.Repeater1.DataBind(); } //Response.Redirect("flow.aspx"); if (Request.QueryString["url"] != null) { Response.Redirect(Request.QueryString["url"]); } } } }