Exemple #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dgvTypeOfBook.SelectedCells.Count > 0)
            {
                int             selectedrowindex = this.dgvTypeOfBook.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = this.dgvTypeOfBook.Rows[selectedrowindex];
                TypeOfBookBLL   typeOfBookBLL    = new TypeOfBookBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnId"].Value.ToString());
                DialogResult    result           = MessageBox.Show("Do you want to delete type of book: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel);
                switch (result)
                {
                case DialogResult.Cancel:
                    break;

                case DialogResult.OK:
                    if (TypeOfBookDAL.getTypeOfBookItem(typeOfBookBLL) != null)
                    {
                        MessageBox.Show("Can't delete! Please delete all book title has type " + selectedRow.Cells["clmnName"].Value + " before delete this type!", "Error");
                        break;
                    }
                    else
                    {
                        TypeOfBookDAL.deleteTypeOfBook(typeOfBookBLL);
                        MessageBox.Show("Delete complete!", "Success");
                        this.LoadDataToGridView();
                        break;
                    }
                }
            }
        }
Exemple #2
0
        private void LoadDataToDataGridViewBookTitle()
        {
            this.dgvBookTitle.Rows.Clear();
            List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>();

            bookTitleList = BookTitleDAL.getBookTitleList();
            TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL();

            foreach (BookTitleBLL row in bookTitleList)
            {
                typeOfBookBLL = TypeOfBookDAL.getTypeOfBookItem(row.TypeOfBookId);
                PublisherBLL publisherBLL = new PublisherBLL();
                publisherBLL = PublisherDAL.getPublisherItem(row.PublisherId);
                BookTitleStatusBLL status = new BookTitleStatusBLL();
                status = BookTitleStatusDAL.getBookTitleStatusItem(row.BookTitleStatusId);
                this.dgvBookTitle.Rows.Add(row.BookTitleId, row.Name, row.TypeOfBookId, typeOfBookBLL.Name, row.PublisherId, publisherBLL.Name, row.BookTitleStatusId, status.Name, row.Summary);
            }
            GetSelectedValueDataGridViewBookTitle();
            this.dgvBookTitle.SelectionChanged += new EventHandler(dgvBookTitle_SelectionChanged);
        }
        public List <BookTitleBLL> search(string catalog, string key)
        {
            if (catalog == "matinhtrang")
            {
                List <BookTitleBLL>       bookTitleList       = new List <BookTitleBLL>();
                List <BookTitleStatusBLL> bookTitleStatusList = new List <BookTitleStatusBLL>();
                bookTitleStatusList = BookTitleStatusDAL.getBookTitleStatusItem(key);
                if (bookTitleStatusList != null)
                {
                    foreach (BookTitleStatusBLL bookTitleStatusBLL in bookTitleStatusList)
                    {
                        List <BookTitleBLL> results = new List <BookTitleBLL>();
                        results = BookTitleDAL.getBookTitleList(catalog, bookTitleStatusBLL.BookTitleStatusId);
                        if (results != null)
                        {
                            foreach (BookTitleBLL bookTitleBLL in results)
                            {
                                bookTitleList.Add(bookTitleBLL);
                            }
                        }
                    }

                    return(bookTitleList);
                }
                return(null);
            }
            else if (catalog == "manxb")
            {
                List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>();
                List <PublisherBLL> publisherList = new List <PublisherBLL>();
                publisherList = PublisherDAL.getPublisherItem(key);
                if (publisherList != null)
                {
                    foreach (PublisherBLL publisherBLL in publisherList)
                    {
                        List <BookTitleBLL> results = new List <BookTitleBLL>();
                        results = BookTitleDAL.getBookTitleList(catalog, publisherBLL.PublisherId);
                        if (results != null)
                        {
                            foreach (BookTitleBLL bookTitleBLL in results)
                            {
                                bookTitleList.Add(bookTitleBLL);
                            }
                        }
                        return(bookTitleList);
                    }
                }
                return(null);
            }
            else if (catalog == "matheloai")
            {
                List <BookTitleBLL>  bookTitleList  = new List <BookTitleBLL>();
                List <TypeOfBookBLL> typeOfBookList = new List <TypeOfBookBLL>();
                typeOfBookList = TypeOfBookDAL.getTypeOfBookItem(key);
                if (typeOfBookList != null)
                {
                    foreach (TypeOfBookBLL typeOfBookBLL in typeOfBookList)
                    {
                        List <BookTitleBLL> results = new List <BookTitleBLL>();
                        results = BookTitleDAL.getBookTitleList(catalog, typeOfBookBLL.TypeOfBookId);
                        if (results != null)
                        {
                            foreach (BookTitleBLL bookTitleBLL in results)
                            {
                                bookTitleList.Add(bookTitleBLL);
                            }
                        }
                        return(bookTitleList);
                    }
                }
                return(null);
            }
            else if (catalog == "tensach" || catalog == "tomtat")
            {
                List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>();
                bookTitleList = BookTitleDAL.search(catalog, key);
                return(bookTitleList);
            }
            return(null);
        }