示例#1
0
        private void FillData(string filter, int userID)
        {
            TradingDAO tradingDAO = new TradingDAO();
            BookDAO    bookDAO    = new BookDAO();
            UserDAO    userDAO    = new UserDAO();

            if (filter == "Pending")
            {
                tradings   = tradingDAO.GetPendingBorrowing(userID, page);
                totalPages = tradingDAO.getPages("PendingBR", userID);
            }
            else if (filter == "Borrowing")
            {
                tradings   = tradingDAO.GetBorrowing(userID, page);
                totalPages = tradingDAO.getPages("Borrowing", userID);
            }
            else if (filter == "Completed")
            {
                tradings   = tradingDAO.GetCompletedBorrow(userID, page);
                totalPages = tradingDAO.getPages("Borrowing", userID);
            }

            foreach (Trading t in tradings)
            {
                books.Add(bookDAO.GetById(t.BookID));
                users.Add(userDAO.GetById(t.LenderID));
            }
        }
        public ActionResult Edit(int id)
        {
            BookDAO bookDAO = new BookDAO();
            Book    book    = bookDAO.FetchOne(id);

            return(View("Create", book));
        }
示例#3
0
        //BookManagementEntities db = new BookManagementEntities();
        //
        // GET: /Home/
        public ActionResult Index(string searchkey, int?page)
        {
            BookDAO book = new BookDAO();

            ViewBag.SearchString = searchkey;
            return(View(book.ListBook(searchkey, page ?? 1, 12)));
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // set title for page
            Page.Title = "Search result - BookShare";

            if (!IsPostBack)
            {
                // check query search is null or not thing then redirect to home page
                if (Request.QueryString["query"] == null || Request.QueryString["query"].Trim() == "")
                {
                    Response.Redirect("Home.aspx");
                }

                listQuery.Add("All");
                listQuery.Add("Title");
                listQuery.Add("Author");
                listQuery.Add("ISBN");

                string query = Request.QueryString["query"];
                filter = Request.QueryString["filter"] == null ? "All" : Request.QueryString["filter"];
                page   = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

                BookDAO bookDAO = new BookDAO();
                books     = bookDAO.searchBook(query, filter, page).ToList();
                totalPage = bookDAO.getPages(filter, query);
                //
            }
        }
示例#5
0
        public async Task <IActionResult> PutBook(Guid id, BookDAO book)
        {
            if (id != book.BookID)
            {
                return(BadRequest());
            }


            try
            {
                _service.Update(book);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#6
0
        public void readFromTxtFile(string name)
        {
            var     context = new DiseaseEntities1();
            BookDAO bookDAO = new BookDAO(context);
            Regex   regex   = new Regex(@"(.+?) (.+?) (.+?) (.+?) (.+?)");

            using (StreamReader fs = new StreamReader(name))
            {
                //for (int i = 0; i < 1000; i++)
                //{
                while (!fs.EndOfStream)
                {
                    List <string> infoTemp = new List <string>();
                    string        temp     = fs.ReadLine();
                    string[]      result   = regex.Split(temp);
                    foreach (var item in result)
                    {
                        if (item.Length > 0)
                        {
                            infoTemp.Add(item);
                        }
                    }
                    bookDAO.Save(new Book
                    {
                        Title       = infoTemp[0],
                        IdAuthor    = Int32.Parse(infoTemp[1]),
                        Pages       = Int32.Parse(infoTemp[2]),
                        Price       = Int32.Parse(infoTemp[3]),
                        IdPublisher = Int32.Parse(infoTemp[4])
                    });
                }
            }
        }
示例#7
0
        public static DataTable getDataTableBooksLoading(int _h)
        {
            DataTable dataTable = new DataTable();

            var context = new DiseaseEntities1();

            BookDAO bookDAO = new BookDAO(context);

            Book[] book = context.Books.ToArray();

            dataTable.Columns.Add("Id");
            dataTable.Columns.Add("Title");
            dataTable.Columns.Add("LastName");
            dataTable.Columns.Add("FirstName");
            dataTable.Columns.Add("Pages");
            dataTable.Columns.Add("Price");
            dataTable.Columns.Add("Publisher");

            for (int i = 0; i < book.Length; i += _h)
            {
                DataRow row = dataTable.NewRow();

                row[0] = book[i].Id;
                row[1] = book[i].Title;
                row[2] = book[i].Author.LastName;
                row[3] = book[i].Author.FirstName;
                row[4] = book[i].Pages;
                row[5] = book[i].Price;
                row[6] = book[i].Publisher.PublisherName;
                dataTable.Rows.Add(row);
            }
            return(dataTable);
        }
示例#8
0
        private void btnMuon_Click(object sender, EventArgs e)
        {
            btnMuon.Enabled   = false;
            btnTra.Enabled    = true;
            btnGiaHan.Enabled = true;
            panel3.Enabled    = true;
            PhieuMuonDAO pm          = new PhieuMuonDAO();
            string       maphieumuon = txtCTMaPhieuMuon.Text;
            string       madg        = (cbMaDGMuon.SelectedItem as DocGia).MaDG;
            DateTime     ngaymuon    = dateTimeCTMuonMuon.Value;
            DateTime     ngaytra     = dateTimeCTTraMuon.Value;
            string       manhanvien  = LoginAccount.MaNhanVien;
            int          trangthai   = 0;
            string       masach      = (cbMaSachMuon.SelectedItem as Book).MaSach;
            int          soluong     = (int)numSLMuon.Value;

            BookDAO book = new BookDAO();

            if (book.CheckBookNumberByMaSach(masach) < soluong)
            {
                MessageBox.Show("Sách không đủ");
            }
            else
            {
                if (pm.InsertPhieuMuon(maphieumuon, madg, ngaymuon, ngaytra, manhanvien, trangthai, masach, soluong))
                {
                    MessageBox.Show("Thêm Thành công");
                    ShowMuon();
                }
                else
                {
                    MessageBox.Show("Có lỗi khi thêm");
                }
            }
        }
示例#9
0
        void addMaSachToCB()
        {
            BookDAO book = new BookDAO();

            cbMaSachMuon.DataSource    = book.GetListBook();
            cbMaSachMuon.DisplayMember = "MaSach";
        }
示例#10
0
        public ActionResult Delete(int id)
        {
            var dao = new BookDAO();

            dao.handleDelete(id);
            return(RedirectToAction("Management"));
        }
示例#11
0
        public ActionResult Edit(Book book, FormCollection formcollection)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "AccountAdmin"));
            }
            string imageURL = null;

            try
            {
                imageURL = formcollection["txtImageURL"].ToString();
            }
            catch
            {
                imageURL = "/Content/images/Image.jpg";
            }
            if (ModelState.IsValid)
            {
                var dao = new BookDAO();
                var rs  = dao.Update(book, imageURL);
                db.Entry(book).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ImageBoolID = new SelectList(db.Images, "ImageBoolID", "ImageBoolID", book.ImageBoolID);
            //ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "Name", book.Authors.First().AuthorID);
            //ViewBag.PublisherID = new SelectList(db.Publishers, "PublisherID", "Name", book.PublisherID);
            ViewBag.AuthorID    = new SelectList(db.Authors.Where(x => x.isDeleted == false), "AuthorID", "Name");
            ViewBag.CategoryID  = new SelectList(db.Categories.Where(x => x.isDeleted == false), "CategoryID", "Name");
            ViewBag.PublisherID = new SelectList(db.Publishers.Where(x => x.isDeleted == false), "PublisherID", "Name");
            return(View(book));
        }
示例#12
0
        public ActionResult Insert(BOOK entity)
        {
            var dao = new BookDAO();

            dao.handleInsert(entity);
            return(RedirectToAction("Management"));
        }
示例#13
0
        public ActionResult Update(int id)
        {
            var dao = new BookDAO();
            var ob  = dao.getBookById(id);

            return(View(ob));
        }
示例#14
0
        //
        // GET: /Books/

        public ActionResult Management()
        {
            var dao   = new BookDAO();
            var model = dao.getAllBooks();

            return(View(model));
        }
示例#15
0
        public ActionResult Edit(Book book, FormCollection formcollection)
        {
            string imageURL = null;

            try
            {
                imageURL = formcollection["txtImageURL"].ToString();
            }
            catch
            {
                imageURL = "/Content/images/Image.jpg";
            }
            if (ModelState.IsValid)
            {
                var dao = new BookDAO();
                var rs  = dao.Update(book, imageURL);
                db.Entry(book).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ImageBoolID = new SelectList(db.ImageBools, "ImageBoolID", "ImageBoolID", book.ImageBoolID);
            ViewBag.AuthorID    = new SelectList(db.Authors, "AuthorID", "Name", book.Authors.First().AuthorID);
            ViewBag.PublisherID = new SelectList(db.Publishers, "PublisherID", "Name", book.PublisherID);
            return(View(book));
        }
示例#16
0
        public ActionResult UpdateBook(int id, HttpPostedFileBase file)
        {
            setViewBagForBook();

            Book book = new BookDAO().getBookById(id);

            List <int> list = new List <int>();

            var bookView = new BookViewModel();

            foreach (var item in book.Authors)
            {
                list.Add(item.ID);
            }
            bookView.SelectedValuesAuthor = list.ToArray();
            bookView.Name            = book.Name;
            bookView.Alias           = book.Alias;
            bookView.Category        = book.CategoryID;
            bookView.Content         = book.Content;
            bookView.Price           = book.Price;
            bookView.BookCover       = book.BookCover;
            bookView.NumberPages     = book.NumberPages;
            bookView.Publisher       = book.PublisherID;
            bookView.PublicationDate = book.PublicationDate;
            bookView.Size            = book.Size;
            bookView.Quanlity        = book.Quanlity;
            bookView.Image           = book.Image;
            return(View(bookView));
        }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // get total number of users
            UserDAO userDao = new UserDAO();

            UserNum = userDao.GetRowCount();

            // get total pending books
            BookDAO bookDao = new BookDAO();

            TotalPendings = bookDao.GetRowCountBookByStatus(Book.STATUS_PENDING);
            TotalAccepted = bookDao.GetRowCountBookByStatus(Book.STATUS_ACCEPTED);

            // get number of lastest avaible tradings
            TradingDAO tradingDao = new TradingDAO(5);

            N_LastestAvailableTradings = tradingDao.Get_N_BookNumByStatus(tradingNum, Trading.STATUS_AVAILABLE);

            // get list of Lastest Tradings
            LastestCompletedTradings = tradingDao.GetTradingByCommand("select top 5 * from Trading order by (completedTime) desc");
            foreach (Trading trading in LastestCompletedTradings)
            {
                Lenders.Add(userDao.GetById(trading.LenderID));
                Borrowers.Add(userDao.GetById(trading.BorrowerID));
                Books.Add(bookDao.GetById(trading.BookID));
            }

            // set status
        }
示例#18
0
        public JsonResult loadData(string searchText, string statusSelect, int page, int pageSize = 3)
        {
            BookDAO bookDAO = new BookDAO();

            IEnumerable <BookViewModel> model;

            if (!string.IsNullOrEmpty(searchText))
            {
                model = bookDAO.getListBookBySearchText(searchText);
            }
            else
            {
                model = bookDAO.getListBook();
            }

            if (!string.IsNullOrEmpty(statusSelect))
            {
                var status = bool.Parse(statusSelect);
                model = model.Where(x => x.Status == status);
            }

            var totalRow = model.Count();

            //model = model.OrderByDescending(x => x.CreatedDate).Skip((page - 1) * pageSize).Take(pageSize);
            return(Json(new
            {
                data = model,
                totalRow = totalRow,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
示例#19
0
        public static DataTable getDataTableBooks(string word)
        {
            DataTable dataTable = new DataTable();

            var context = new DiseaseEntities1();

            BookDAO bookDAO = new BookDAO(context);

            Book[] book = context.Books.ToArray();

            List <Book> books = bookDAO.FindListInAuthorLastName(word, book);

            dataTable.Columns.Add("Id");
            dataTable.Columns.Add("Title");
            dataTable.Columns.Add("LastName");
            dataTable.Columns.Add("Pages");
            dataTable.Columns.Add("Price");
            dataTable.Columns.Add("Publisher");

            foreach (var item in books)
            {
                DataRow row = dataTable.NewRow();

                row[0] = item.Id;
                row[1] = item.Title;
                row[2] = item.Author.LastName;
                row[3] = item.Pages;
                row[4] = item.Price;
                row[5] = item.Publisher.PublisherName;
                dataTable.Rows.Add(row);
            }
            return(dataTable);
        }
示例#20
0
 private void btnCategoryUpdateExecute_Click(object sender, EventArgs e)
 {
     if (txtAfter.Text.Trim() == "")
     {
         MessageBox.Show("카테고리를 입력해주세요.");
         return;
     }
     if (MessageBox.Show("정말 카테고리를 수정하시겠습니까?", "카테고리 수정", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         BookDAO bookDAO = BookDAO.getInstance();
         if (txtAfter.Text.Trim() != null)
         {
             if (bookDAO.updateCategory(txtBefore.Text, replaceAll(txtAfter.Text)))
             {
                 MessageBox.Show("수정 완료");
                 form.categoryListShow();
                 Hide();
             }
             else
             {
                 MessageBox.Show("수정 실패");
             }
         }
         else
         {
             MessageBox.Show("수정할 카테고리 명을 입력해주세요.");
         }
     }
 }
示例#21
0
        private void View()
        {
            DataTable dt = BookDAO.GetDataTable();

            dv = new DataView(dt);
            dataGridView1.DataSource = dv;
        }
示例#22
0
        /// <summary>
        /// This calls on the dao to get the results depending on the mode we are currently in
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="value"></param>
        public void Search(Constants.SearchMode mode, string value)
        {
            MainForm main = (MainForm)this.ParentForm.MdiParent;
            BookDAO  dao  = new BookDAO(main.CurrentDatabase.FullName);

            this.gridBooks.DataSource = dao.SearchBooks(_mode, mode, value).Tables[0];
        }
 protected void btnChkCondition_Click(object sender, EventArgs e)
 {
     if (txtBookNumber.Text == null || txtBookNumber.Text.Equals(""))
     {
         lblError.Text = "Book Number is not allow to be null";
         txtBookNumber.Focus();
     }
     else if (DAO.checkInt(txtBookNumber.Text) == false)
     {
         lblError.Text = "Book Number is numberic";
         txtBookNumber.Focus();
     }
     else
     {
         DataView dv = new DataView(BookDAO.GetDataTableBook());
         dv.RowFilter = "bookNumber = " + txtBookNumber.Text;
         if (dv.Count != 0)                                                               //book exist
         {
             int availableCopy = CopyDAO.getAvailableCopy(int.Parse(txtBookNumber.Text)); //số lượng bản copy A
             if (availableCopy > 0)
             {
                 lblError.Text = "This book having " + availableCopy + " copies available, you can borrow them";
             }
             else
             {
                 lblError.Text      = "";
                 btnReserve.Enabled = true;
             }
         }
         else
         {
             lblError.Text = "Oops! this book number is not exist!";
         }
     }
 }
        public ActionResult Detail(String Url)
        {
            var dao  = new BookDAO();
            var book = dao.getBookByUrl(Url);

            return(View(book));
        }
        public ActionResult Details(int id)
        {
            BookDAO bookDAO = new BookDAO();
            Book    book    = bookDAO.FetchOne(id);

            return(View("Details", book));
        }
示例#26
0
 private void btnPublisherUpdateExecute_Click(object sender, EventArgs e)
 {
     if (txtAfter.Text.Trim() == "")
     {
         MessageBox.Show("출판사를 입력해주세요.");
         return;
     }
     if (MessageBox.Show("정말 출판사를 수정하시겠습니까?", "출판사 수정", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         BookDAO bookDAO = BookDAO.getInstance();
         if (txtAfter.Text.Trim() != null)
         {
             if (bookDAO.updatePublisher(txtBefore.Text, replaceAll(txtAfter.Text)))
             {
                 MessageBox.Show("출판사 수정 성공");
                 bookAdmin.selectPublisherList();
                 Hide();
                 Dispose();
             }
             else
             {
                 MessageBox.Show("출판사 수정 실패");
             }
         }
         else
         {
             MessageBox.Show("수정할 카테고리 명을 입력해주세요.");
         }
     }
 }
示例#27
0
        public ActionResult ListBookByAuthor(int authorID, int?page)
        {
            BookDAO _book = new BookDAO();

            Session.Add("AUTHOR_ID", authorID);
            return(View(_book.GetByAuthor(authorID, page ?? 1, 12)));
        }
示例#28
0
        public async Task <ActionResult> Create(Book book, FormCollection formcollection)
        {
            string imageURL = null;

            try
            {
                imageURL = formcollection["txtImageURL"].ToString();
            }
            catch
            {
                imageURL = "/Content/images/Image.jpg";
            }
            if (ModelState.IsValid)
            {
                var dao = new BookDAO();
                var rs  = dao.Insert(book, imageURL);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ImageBoolID = new SelectList(db.ImageBools, "ImageBoolID", "ImageBoolID", book.ImageBoolID);
            //ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "Name", book.Authors.First().AuthorID);
            ViewBag.PublisherID = new SelectList(db.Publishers, "PublisherID", "Name", book.PublisherID);
            return(View(book));
        }
        // GET: Detail
        public ActionResult Index()
        {
            string id_raw = Request.QueryString["bookid"];

            if (id_raw == null)
            {
                id_raw = Session["id"].ToString();
            }
            int id = Int32.Parse(id_raw);

            Session.Remove("id");


            commentDAO     cbd      = new commentDAO();
            List <comment> comments = cbd.getbyBook(id);
            List <author>  authors  = new AuthorDAO().getAuthorByBookID(id);
            categoryDAO    cd       = new categoryDAO();
            BookDAO        db       = new BookDAO();
            int            count    = comments.Count;
            dynamic        dy       = new ExpandoObject();

            dy.book           = db.getOne(id);
            ViewData["count"] = count;
            dy.cates          = cd.getAll();
            dy.comments       = comments;
            dy.authors        = authors;
            if (Session["user"] != null)
            {
                account a = (account)Session["user"];
                new historyDAO().addHistory(a.username, id);
            }
            return(View(dy));
        }
示例#30
0
        public ActionResult Category(int cateid)
        {
            var category = new CategoryDAO().ViewDetail(cateid);

            ViewBag.Category = category;

/*            int totalRecord = 0;*/
            var model = new BookDAO().ListByCategoryId(cateid /*ref totalRecord, /*page, pageSize*/);

/*            ViewBag.Total = totalRecord;
 *//*            ViewBag.Page = page;*//*
 *
 *          int maxPage = 5;
 *          int totalPage = 0;
 *
 *          totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize));
 *          ViewBag.TotalPage = totalPage;
 *          ViewBag.MaxPage = maxPage;
 *          ViewBag.First = 1;
 *          ViewBag.Last = totalPage;
 *          ViewBag.Next = page + 1;
 *          ViewBag.Prev = page - 1;
 *
 */
            return(View(model));
        }
示例#31
0
        public static BookDAO GetBookDAO()
        {
            if (BookDAO == null)
            {
                BookSqlCeDAOImpl bookDAOImpl = new BookSqlCeDAOImpl();
                bookDAOImpl.dbContext = DBContextProvider.getDBContext();

                BookDAO = bookDAOImpl;
            }

            return BookDAO;
        }
示例#32
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
               //setup
            IMemberDAO memberDAO = new MemberDAO(new MemberHelper());
            IBookDAO bookDAO = new BookDAO(new BookHelper());
            ILoanDAO loanDAO = new LoanDAO(new LoanHelper());

            IMember mem = memberDAO.AddMember("John", "Smith", "*****@*****.**", "02 622 94753");

            IBook book1 = bookDAO.AddBook("Robert Heinlein", "Space Cadet", "HEI 3.645");
            IBook book2 = bookDAO.AddBook("Charles Stross", "The Laundry Files", "STR 7.593");
            IBook book3 = bookDAO.AddBook("James Cambias", "A Darkling Sea", "CAM 5.657");
            IBook book4 = bookDAO.AddBook("John Steinbeck", "Cannery Row", "STE 9.531");
            IBook book5 = bookDAO.AddBook("Terry Pratchett", "Raising Steam", "PRA 1.739");
            IBook book6 = bookDAO.AddBook("Vernor Vinge", "Fire Upon the Deep", "VIN 8.927");
            /*
            IBook b = bookDAO.GetBookByID(1);
            b = bookDAO.GetBookByID(2);
            b = bookDAO.GetBookByID(3);
            b = bookDAO.GetBookByID(4);

            DateTime borrowDate = DateTime.Now;
            TimeSpan loanPeriod = new TimeSpan(LoanConstants.LOAN_PERIOD, 0, 0, 0);
            DateTime dueDate = borrowDate.Add(loanPeriod);

            loanDAO.CreateNewPendingList(mem);
            loanDAO.CreatePendingLoan(mem, book1, borrowDate, dueDate);
            loanDAO.CreatePendingLoan(mem, book2, borrowDate, dueDate);
            loanDAO.CreatePendingLoan(mem, book3, borrowDate, dueDate);
            loanDAO.CreatePendingLoan(mem, book4, borrowDate, dueDate);
            loanDAO.CreatePendingLoan(mem, book5, borrowDate, dueDate);
            loanDAO.CommitPendingLoans(mem);

            DateTime checkDate = dueDate.Add(new TimeSpan(1, 0, 0, 0));
            loanDAO.UpdateOverDueStatus(checkDate);

            mem.AddFine(10.00f);
            */
            BorrowBookUI gui = new BorrowBookUI();
            BorrowBookCTL ctl = new BorrowBookCTL(bookDAO, memberDAO,loanDAO, gui);

            ctl.Initialise();
            Application.Run(gui);
        }
 public LibraryController()
 {
     BookDAO = BookDAOFactory.GetBookDAO();
     AuthorDAO = AuthorDAOFactory.GetAuthorDAO();
     GenreDAO = GenreDAOFactory.GetGenreDAO();
 }
 public EditBooksController()
 {
     BookDAO = BookDAOFactory.GetBookDAO();
     AuthorDAO = AuthorDAOFactory.GetAuthorDAO();
     GenreDAO = GenreDAOFactory.GetGenreDAO();
 }