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

                case DialogResult.OK:
                    BookTitleStatusBLL bookTitleStatusDLL = new BookTitleStatusBLL();
                    if (BookTitleStatusDAL.getBookTitleStatusItem(bookTitleStatusBLL) != null)
                    {
                        MessageBox.Show("Can't delete! Please delete all book title has status: '" + selectedRow.Cells["clmnName"].Value + "' before delete this status!", "Error");
                        break;
                    }
                    else
                    {
                        BookTitleStatusDAL.deleteBookTitleStatus(bookTitleStatusBLL);
                        this.LoadDataToGridView();
                        break;
                    }
                }
            }
        }
Esempio n. 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);
        }