private void btnDelete_Click(object sender, EventArgs e)
        {
            Form            form             = new frmChild_BookTitle();
            int             selectedrowindex = dgvSearch.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow      = dgvSearch.Rows[selectedrowindex];

            if (selectedRow.Cells[0].Value != null && selectedRow.Cells[0].Value.ToString() != string.Empty)
            {
                string value  = (string)selectedRow.Cells[0].Value;
                bool   result = false;
                switch (TypeOfSearch)
                {
                case 0:
                    BUS.BookTitleBUS bkTitle = new BUS.BookTitleBUS();
                    result = bkTitle.DeleteBookTitle(value);
                    break;

                case 1:
                    BUS.AuthorBUS author = new BUS.AuthorBUS();
                    result = author.DeleteAuthor(value);
                    break;

                case 2:
                    BUS.CategoryBUS cate = new BUS.CategoryBUS();
                    result = cate.DeleteCategory(value);
                    break;

                case 3:
                    BUS.UserBUS user = new BUS.UserBUS();
                    result = user.DeleteUser(value);
                    break;

                case 4:
                    BUS.BookBUS bk = new BUS.BookBUS();
                    result = bk.DeleteAuthor(value);
                    break;

                case 5:
                    BUS.InventoryBUS inven = new BUS.InventoryBUS();
                    result = inven.DeleteInventory(value);
                    break;
                }
                if (result)
                {
                    LoadData();
                    MessageBox.Show(this, "Delete Successful", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "Delete Fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(this, "Can not delete null cells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            BUS.UserBUS Bus  = new BUS.UserBUS();
            int         role = Bus.CheckLogin(txtUsername.Text, txtPassword.Text);

            if (role == -1)
            {
                MessageBox.Show("Error. Wrong Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //Console.WriteLine(role);
                Form form = new frmRole_User(txtUsername.Text, role);
                switch (role)
                {
                case 2: form = new frmRole_Staff(txtUsername.Text, role); break;

                case 3: form = new frmRole_Manager(txtUsername.Text, role); break;
                }
                this.Hide();
                form.ShowDialog();
                this.Close();
            }
        }
        private void LoadData()
        {
            switch (TypeOfSearch)
            {
            case 0: this.Text = "Book Title"; break;

            case 1: this.Text = "Author"; break;

            case 2: this.Text = "Category"; break;

            case 3: this.Text = "User"; break;

            case 4: this.Text = "Book"; break;

            case 5: this.Text = "Inventory"; break;
            }
            switch (TypeOfSearch)
            {
            case 0:
                BUS.BookTitleBUS bkTitle = new BUS.BookTitleBUS();
                //BUS._MultiTableBUS bus = new BUS._MultiTableBUS();
                bsItem.DataSource = bkTitle.GetAllBookTitleByDataSet();
                //bsItem.DataSource = bus.SelectBookTitleWithTitleOrAuthorNameOrCategoryName("", "", "");
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                this.dgvSearch.Columns["AuthorID"].Visible   = true;
                this.dgvSearch.Columns["CategoryID"].Visible = true;
                break;

            case 1:
                BUS.AuthorBUS author = new BUS.AuthorBUS();
                bsItem.DataSource        = author.GetAllAuthorByDataSet();
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                break;

            case 2:
                BUS.CategoryBUS cate = new BUS.CategoryBUS();
                bsItem.DataSource        = cate.getAllCategoryByDataSet();
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                break;

            case 3:
                BUS.UserBUS user = new BUS.UserBUS();
                bsItem.DataSource        = user.getAllUserByDataSet();
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                break;

            case 4:
                BUS.BookBUS bk = new BUS.BookBUS();
                bsItem.DataSource        = bk.getAllBookIDByDataSet();
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                break;

            case 5:
                BUS.InventoryBUS inven = new BUS.InventoryBUS();
                bsItem.DataSource        = inven.getAllInventoryByDataSet();
                dgvSearch.DataSource     = bsItem;
                bnItemList.BindingSource = bsItem;
                break;
            }

            int width = 0;

            foreach (DataGridViewColumn col in dgvSearch.Columns)
            {
                width += col.Width;
            }
            width += dgvSearch.RowHeadersWidth;

            dgvSearch.ClientSize = new Size(width + 2, dgvSearch.ClientSize.Height);

            if (this.Role == 1 && this.TypeOfSearch != 4 && this.TypeOfSearch != 0 && this.TypeOfSearch != 5)
            {
                btnNew.Enabled    = false;
                btnDelete.Enabled = false;
            }
        }