Esempio n. 1
0
 private void cbCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         var bookList     = new BookDal().GetAll();
         var categoryList = new CategoryDal().GetAll();
         dgvBooks.DataSource =
             bookList
             .Join(categoryList,
                   b => b.CategoryId,
                   c => c.CategoryId,
                   (b, c) => new
         {
             Id           = b.Id,
             Title        = b.Title,
             Description  = b.Description,
             Year         = b.Year,
             CategoryId   = c.CategoryId,
             CategoryName = c.CategoryName
         })
             .Where(b => b.CategoryId == Convert.ToInt32(cbCategories.SelectedValue.ToString()))
             .ToList();
     }
     catch
     {
     }
 }
 public BookReturnForm()
 {
     _bookDal  = new BookDal();
     _orderDal = new OrderDal();
     InitializeComponent();
     FillDataOrder();
 }
Esempio n. 3
0
        private void dgvBooks_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            var row  = dgvBooks.Rows[e.RowIndex];
            var book = new BookDal().GetById(Convert.ToInt32(row.Cells[0].Value.ToString()));

            lblBook.Text = book.ToString();
        }
 public ShowTheBasketForm(int id)
 {
     _id       = id;
     _orderDal = new OrderDal();
     _bookDal  = new BookDal();
     InitializeComponent();
 }
 public OrdersForm(Manager manager)
 {
     _manager     = manager;
     _orderDal    = new OrderDal();
     _customerDal = new CustomerDal();
     _bookDal     = new BookDal();
     InitializeComponent();
 }
Esempio n. 6
0
        public async Task <bool> DeleteAsync(BookDal book)
        {
            using (var connection = connectionFactory.CreateConnection())
            {
                var result = await connection.DeleteAsync(book);

                return(result);
            }
        }
Esempio n. 7
0
 public SaveBookViewModel(IView view)
 {
     _view                    = view;
     _bookDal                 = new BookDal();
     googleApi                = new GoogleApi();
     SaveButtonCommand        = new RelayCommand(SaveButton, () => true);
     CloseWindowCommand       = new RelayCommand <Window>(CloseWindow, window => true);
     GetBookFromAmazonCommand = new RelayCommand(GetBookFromAmazon, CanGetBookInformation);
 }
Esempio n. 8
0
 public MainViewModel()
 {
     bookDal               = new BookDal();
     BooksCollection       = new ObservableCollection <Book>(bookDal.GetBooks());
     googleApi             = new GoogleApi();
     AddBookCommand        = new RelayCommand(AddBook, () => true);
     PurgeAllBooksCommand  = new RelayCommand(PurgeAllDatabase, () => true);
     LoadDummyBooksCommand = new RelayCommand(LoadDummyBooks, () => true);
     ShutdownAppCommand    = new RelayCommand(ShutDownApp, () => true);
 }
Esempio n. 9
0
        /// <summary>
        /// 获得指定数量的书籍,见 bookSize
        /// </summary>
        /// <returns></returns>
        public string GetBooksHtml()
        {
            StringBuilder sb       = new StringBuilder();
            List <Book>   bookList = BookDal.m_BookDal.GetList("1=1", null, "BookId,BookTitle,BookImage,BookAuthor,BookTranslator,BookIntroduce", bookSize);

            foreach (var book in bookList)
            {
                sb.Append(BookDal.GetOneBookHtml(book));
            }
            return(sb.ToString());
        }
Esempio n. 10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string msg = BookDal.AddBook(txtTitle.Text, txtAuthors.Text, Double.Parse(txtPrice.Text), txtPublisher.Text);

            if (msg == null)
            {
                lblMsg.Text = "Book Has Been Added Successfully!";
            }
            else
            {
                lblMsg.Text = "Error -> " + msg;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string msg = BookDal.UpdateBook(Int32.Parse(txtBookid.Text), txtTitle.Text, txtAuthors.Text, Double.Parse(txtPrice.Text), txtPublisher.Text);

            if (msg == null)
            {
                lblMsg.Text = "Updated Book Details Successfully!";
            }
            else
            {
                lblMsg.Text = "Error -> " + msg;
            }
        }
Esempio n. 12
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            String msg = BookDal.DeleteBook(Int32.Parse(txtBookid.Text));

            if (msg == null)
            {
                lblMsg.Text = "Book Has Been Deleted Successfully!";
            }
            else
            {
                lblMsg.Text = "Error -> " + msg;
            }
        }
 public static Book ToBook(this BookDal bookDal)
 {
     return new Book
     {
         Isbn = bookDal.Isbn,
         Author = bookDal.Author,
         Year = bookDal.Year,
         Cost = bookDal.Cost,
         NumbersOfPage = bookDal.NumbersOfPage,
         PublishingHouse = bookDal.PublishingHouse,
         Title = bookDal.Title
     };
 }
 //BookCreatForm Constructor//
 public BookCreatForm(bool isupdate = false, Book book = null)
 {
     _isUpdate = isupdate;
     _book     = book;
     _bookDal  = new BookDal();
     _genreDal = new GenreDal();
     InitializeComponent();
     FillGenreAdd();
     if (_isUpdate)
     {
         FilUpdateData();
     }
 }
Esempio n. 15
0
        public async Task <bool> InsertAsync(BookDal book)
        {
            using (var connection = connectionFactory.CreateConnection())
            {
                try
                {
                    var result = await connection.InsertAsync <BookDal>(book);

                    return(result != 0);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException);
                    return(false);
                }
            }
        }
        protected void btnGetDetails_Click(object sender, EventArgs e)
        {
            Book b = BookDal.GetBook(Int32.Parse(txtBookid.Text));

            if (b != null)
            {
                txtTitle.Text     = b.Title;
                txtAuthors.Text   = b.Authors;
                txtPrice.Text     = b.Price.ToString();
                txtPublisher.Text = b.Publishers;
                btnUpdate.Enabled = true;
            }
            else
            {
                lblMsg.Text       = "Sorry! Book Id Not Found";
                btnUpdate.Enabled = false;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 获得指定数量的书籍
        /// </summary>
        /// <returns></returns>
        public string GetBooksHtml()
        {
            string searchWhat = null;

            if (Request.Form["search_books"] != null)
            {
                searchWhat       = Request.Form["search_books"].ToString();
                BookDal.strWhere = string.Format("BookName like '%{0}%' or BookTitle like '%{0}%' or BookClassfication like '%{0}%'", searchWhat);
            }
            else
            {
                BookDal.strWhere = string.Format("1=1");
            }
            //查询数据
            if (string.IsNullOrEmpty(searchWhat))
            {
                return(BookDal.GetBooksHtml(page));
            }
            else
            {
                return(BookDal.GetBooksHtml(page));
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     GridView1.DataSource = BookDal.GetBooks();
     GridView1.DataBind();
 }
Esempio n. 19
0
 /// <summary>
 /// 获得分页控件
 /// </summary>
 /// <returns></returns>
 public string GetPagerDivided()
 {
     return(PagerDal.GetPagerHtml(page, BookDal.pageShowSize, BookDal.bookSize()));
 }
 public BookForm()
 {
     _bookDal = new BookDal();
     InitializeComponent();
 }
Esempio n. 21
0
 /// <summary>
 /// 获得指定数量的书籍
 /// </summary>
 /// <returns></returns>
 public string GetBooksHtml()
 {
     BookDal.strWhere = string.Format("BookClassfication={0}", AskCategory);
     return(BookDal.GetBooksHtml(page));
 }