private void sbtnSuaDS_Click(object sender, EventArgs e)
        {
            Sach sach = new Sach();

            sach.ma      = grvSach.GetFocusedRowCellValue("ma").ToString();
            sach.ten     = grvSach.GetFocusedRowCellValue("ten").ToString();
            sach.sotrang = int.Parse(grvSach.GetFocusedRowCellValue("sotrang").ToString());
            sach.gia     = int.Parse(grvSach.GetFocusedRowCellValue("gia").ToString());
            sach.soluong = int.Parse(grvSach.GetFocusedRowCellValue("soluong").ToString());
            // sach.ngaynhap = DateTime.Parse(grvSach.GetFocusedRowCellValue("ngaynhap").ToString());
            sach.nhaxuatbanma = grvSach.GetFocusedRowCellValue("nhaxuatbanma").ToString();
            sach.tacgiama     = grvSach.GetFocusedRowCellValue("tacgiama").ToString();
            sach.theloaima    = grvSach.GetFocusedRowCellValue("theloaima").ToString();
            if (bool.Parse(grvSach.GetFocusedRowCellValue("tinhtrang").ToString()) == true)
            {
                sach.tinhtrang = true;
            }
            //sach.tinhtrang = true;
            else
            {
                sach.tinhtrang = false;
            }
            sach.noidungtomtat = grvSach.GetFocusedRowCellValue("noidungtomtat").ToString();
            EditBook edit = new EditBook(sach);

            edit.ShowDialog();
            listSach = controller.getListSach();
            grcDSDauSach.DataSource = listSach;
        }
Exemplo n.º 2
0
        private void ButEditBook_Click(object sender, EventArgs e)
        {
            int idOfBook = Int32.Parse(DataGrid.CurrentRow.Cells[0].Value.ToString());

            EditBook _bookform = new EditBook(this, _db.Books.Single(item => item.Id == idOfBook));

            _bookform.ShowDialog();
            if (_bookform.flag)
            {
                try
                {
                    using (IDbConnection db = new SqlConnection(_connectionString))
                    {
                        var sqlQuery = "UPDATE dbo.Books SET Name = @Name, Author = @Author, Publishing = @Publishing, Year = @Year, Amount = @Amount, Price = @Price, SeriesId = @SeriesId WHERE Id = @Id";
                        db.Execute(sqlQuery, new Books
                        {
                            Name       = _bookform.Name,
                            Author     = Int32.Parse(_bookform.Author),
                            Amount     = _bookform.Amount,
                            Price      = _bookform.Price,
                            SeriesId   = Int32.Parse(_bookform.Serieses),
                            Publishing = _bookform.Publishing,
                            Year       = Int32.Parse(_bookform.Year)
                        });
                    }

                    _db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        public EditBook EditBook(int bookId)
        {
            EditBook editBook = new EditBook();

            editBook = _bookRepository.GetOneBook(bookId);

            return(editBook);
        }
Exemplo n.º 4
0
        internal EditBook GetBookClubs(EditBook editBook)
        {
            List <BookClub.Core.BookClub> bookClubList = new List <BookClub.Core.BookClub>();

            bookClubList = _bookClubRepository.GetBookClubs();

            // add the genreList to the addBook model
            editBook.BookClubList = bookClubList;

            return(editBook);
        }
Exemplo n.º 5
0
        internal EditBook GetGenres(EditBook editBook)
        {
            List <Genre> genreList = new List <Genre>();

            genreList = _genreRepository.GetGenres();

            // add the genreList to the addBook model
            editBook.GenreList = genreList;

            return(editBook);
        }
Exemplo n.º 6
0
        public ActionResult EditBook(int bookId)
        {
            EditBook editBook = service.EditBook(bookId);

            // get list of book clubs and add to model
            editBook = service.GetBookClubs(editBook);

            // get list of genres and add to model
            editBook = service.GetGenres(editBook);

            return(View(editBook));
        }
Exemplo n.º 7
0
 public AddItem(EditBook sender, string name, string author, string pubName, int year, int id, int pubid, bool edit)
 {
     _editBook = sender;
     _author   = author;
     _name     = name;
     _pubName  = pubName;
     _year     = year;
     _id       = id;
     _pubid    = pubid;
     Edit      = true;
     InitializeComponent();
 }
Exemplo n.º 8
0
        private void editBookbtn_Click(object sender, EventArgs e)
        {
            try
            {
                EditBook editBook = new EditBook();
                editBook.bookID = Int32.Parse(booksDataGridView.Rows[booksDataGridView.SelectedRows[0].Index].Cells[0].Value.ToString());
                editBook.ShowDialog();

                InformationForm information = new InformationForm("Selected book is edited.", "Info");
                information.Show();
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please select a row first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.ViewBooks_Load(sender, e);
            }
        }
Exemplo n.º 9
0
        public ActionResult EditBook(EditBook editBook)
        {
            if (ModelState.IsValid)
            {
                service.EditBook(editBook);

                // get the list of books
                List <Book> listOfBooks = service.GetAllBooks();
                return(View("Index", listOfBooks));
            }
            else
            {
                // get list of book clubs and add to model
                editBook = service.GetBookClubs(editBook);

                // get list of genres and add to model
                editBook = service.GetGenres(editBook);

                return(View(editBook));
            }
        }
Exemplo n.º 10
0
 internal void EditBook(EditBook editBook)
 {
     _bookRepository.EditBook(editBook);
 }
Exemplo n.º 11
0
        private void ClickMe(object sender, RoutedEventArgs e)
        {
            EditBook wind = new EditBook();

            wind.Show();
        }
Exemplo n.º 12
0
 private void ExecutePrintCommand()
 {
     _printService.Print(EditBook.ToFixedDocument().DocumentPaginator);
 }
 private void button3_Click(object sender, EventArgs e)
 {
     LibrarianAssistant.EditBook edit = new EditBook();
     edit.ShowDialog();
 }