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

                case DialogResult.OK:

                    if (BookStatusDAL.getBookStatusItem(bookStatusBLL) != null)
                    {
                        MessageBox.Show("Can't delete! Please delete all book has status " + selectedRow.Cells["clmnName"].Value + " before delete this status!", "Error");
                        break;
                    }
                    else
                    {
                        BookStatusDAL.deleteBookStatus(bookStatusBLL);
                        MessageBox.Show("Delete complete!", "Success");
                        this.LoadDataToGridView();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string key = this.txtSearch.Text;

            if (key == "".Trim())
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            string catalog = "";

            if (this.cboSearch.SelectedItem.ToString() == "Name")
            {
                catalog = "tentinhtrangsach";
            }
            BookStatusBLL        bookStatusBLL = new BookStatusBLL();
            List <BookStatusBLL> bookStatusArr = new List <BookStatusBLL>();

            bookStatusArr = BookStatusDAL.search(catalog, key);
            this.dgvBookStatus.Rows.Clear();
            if (bookStatusArr.Count != null)
            {
                foreach (BookStatusBLL row in bookStatusArr)
                {
                    this.dgvBookStatus.Rows.Add(row.BookStatusId, row.Name);
                }
            }
            this.GetSelectedValue();

            this.dgvBookStatus.CellClick += new DataGridViewCellEventHandler(this.dgvBookStatus_CellClick);
        }
Ejemplo n.º 3
0
        private void LoadDataToGridView()
        {
            this.dgvBookStatus.Rows.Clear();
            BookStatusBLL        bookStatusBLL = new BookStatusBLL();
            List <BookStatusBLL> bookStatusArr = new List <BookStatusBLL>();

            bookStatusArr = BookStatusDAL.getBookStatusList();
            foreach (BookStatusBLL row in bookStatusArr)
            {
                this.dgvBookStatus.Rows.Add(row.BookStatusId, row.Name);
            }
            this.GetSelectedValue();
            this.dgvBookStatus.CellClick += new DataGridViewCellEventHandler(dgvBookStatus_CellClick);
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            BookStatusBLL bookStatusBLL = new BookStatusBLL();

            bookStatusBLL.Name = this.txtBookStatusName.Text;
            if (bookStatusBLL.Name == "")
            {
                MessageBox.Show("Book status name is not null!", "Notice");
                return;
            }
            BookStatusDAL.addBookStatus(bookStatusBLL);
            MessageBox.Show("Add success!", "Success");
            this.LoadDataToGridView();
        }
Ejemplo n.º 5
0
        private void LoadDataToDataGridView()
        {
            this.dgvBook.Rows.Clear();
            List <BookBLL> bookList = new List <BookBLL>();

            bookList = BookDAL.getBookList(this._bookTitleBLL);
            foreach (BookBLL row in bookList)
            {
                BookTitleBLL bookTitleBLL = new BookTitleBLL();
                bookTitleBLL = BookTitleDAL.getBookTitleItem(row.BookTitleId);
                BookStatusBLL bookStatusBLL = new BookStatusBLL();
                bookStatusBLL = BookStatusDAL.getBookStatusItem(row.BookStatusId);
                this.dgvBook.Rows.Add(row.BookId, bookTitleBLL.Name, bookTitleBLL.BookTitleId, bookStatusBLL.Name, bookStatusBLL.BookStatusId);
            }
        }
Ejemplo n.º 6
0
        public List <ComboboxItem> getComboboxItemBookStatus()
        {
            List <BookStatusBLL> bookStatusList = new List <BookStatusBLL>();

            bookStatusList = BookStatusDAL.getBookStatusList();
            List <ComboboxItem> comboboxItemList = new List <ComboboxItem>();

            for (int i = 0; i < bookStatusList.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Value = bookStatusList[i].BookStatusId;
                item.Text  = bookStatusList[i].Name;
                comboboxItemList.Add(item);
            }
            return(comboboxItemList);
        }
Ejemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dgvBookStatus.SelectedCells.Count > 0)
            {
                int selectedrowindex = this.dgvBookStatus.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = this.dgvBookStatus.Rows[selectedrowindex];

                BookStatusBLL bookStatusBLL = new BookStatusBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), this.txtBookStatusName.Text);

                if (bookStatusBLL.Name == "")
                {
                    MessageBox.Show("Book status name is not null!", "Notice");
                    return;
                }
                BookStatusDAL.updateBookStatus(bookStatusBLL);
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToGridView();
            }
        }