private void dgvViewAuthor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var dgv = (DataGridView)sender;

            if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex != currentIndex)
            {
                currentIndex      = e.RowIndex;
                txtID.Text        = dgvViewAuthor["AuthorID", e.RowIndex].Value.ToString();
                txtAbout.Text     = dgvViewAuthor["About", e.RowIndex].Value.ToString();
                txtFirstName.Text = dgvViewAuthor["FirstName", e.RowIndex].Value.ToString();
                txtLastName.Text  = dgvViewAuthor["LastName", e.RowIndex].Value.ToString();
                int count = new AuthorDAO().getBookByAuthorID(txtID.Text).Count;
                txtTotalOfBooks.Text = count.ToString();
                dgvBook.Refresh();
                List <Book> lst = new AuthorDAO().getBookByAuthorID(txtID.Text);

                dgvBook.DataSource = lst;
            }
        }
예제 #2
0
 public SearchBookPanel(Form containerForm)
 {
     this.containerForm = containerForm;
     authors            = AuthorDAO.SelectAllAuthors();
     publishers         = PublisherDAO.SelectAllPublishers();
     categories         = CategoryDAO.SelectAllCategories();
     Size     = new Size(1205, 265);
     groupBox = new GroupBox()
     {
         Text     = "Search Book",
         Location = new Point(12, 12),
         Size     = new Size(1190, 250)
     };
     labelTitle = new Label()
     {
         Text     = "Title",
         AutoSize = true,
         Location = new Point(6, 23),
         Size     = new Size(27, 13)
     };
     textBoxTitle = new TextBox()
     {
         Location = new Point(69, 19),
         Size     = new Size(175, 20)
     };
     labelAuthor = new Label()
     {
         Text     = "Author",
         AutoSize = true,
         Location = new Point(6, 49),
         Size     = new Size(38, 13)
     };
     comboBoxAuthors = new ComboBox()
     {
         Location = new Point(69, 46),
         Size     = new Size(175, 21)
     };
     labelPublisher = new Label()
     {
         Text     = "Publisher",
         AutoSize = true,
         Location = new Point(6, 76),
         Size     = new Size(30, 13)
     };
     comboBoxPublishers = new ComboBox()
     {
         Location = new Point(69, 73),
         Size     = new Size(175, 21)
     };
     labelCategories = new Label()
     {
         Text     = "Categories",
         AutoSize = true,
         Location = new Point(6, 103),
         Size     = new Size(57, 13)
     };
     checkedListBoxCategories = new CheckedListBox()
     {
         ScrollAlwaysVisible = true,
         Location            = new Point(69, 103),
         Size = new Size(175, 94)
     };
     labelPublicationDate = new Label()
     {
         Text     = "Publication Date",
         AutoSize = true,
         Location = new Point(6, 204),
         Size     = new Size(85, 13)
     };
     comboBoxPublicationDate = new ComboBox()
     {
         Location = new Point(9, 221),
         Size     = new Size(82, 21)
     };
     labelMonth = new Label()
     {
         Text     = "Month",
         AutoSize = true,
         Location = new Point(97, 204),
         Size     = new Size(37, 13)
     };
     comboBoxMonth = new ComboBox()
     {
         Location = new Point(97, 221),
         Size     = new Size(72, 21)
     };
     labelYear = new Label()
     {
         Text     = "Year",
         AutoSize = true,
         Location = new Point(172, 204),
         Size     = new Size(29, 13)
     };
     numericUpDownYear = new NumericUpDown()
     {
         Location = new Point(175, 222),
         Size     = new Size(69, 20)
     };
     labelSearchResult = new Label()
     {
         Text     = "Search Result",
         AutoSize = true,
         Location = new Point(250, 16),
         Size     = new Size(74, 13)
     };
     dataGridViewSearchResult = new DataGridView()
     {
         AllowUserToAddRows    = false,
         AllowUserToDeleteRows = false,
         AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.AllCells,
         Location = new Point(253, 32),
         Size     = new Size(600, 210)
     };
     AddControls();
     AddItemsToComboBoxAuthors();
     AddItemsToComboBoxPublishers();
     AddItemsToCheckedListBoxCategories();
     AddItemsToComboBoxPublicationDate();
     AddItemsToComboBoxMonth();
     AddItemsToNumericUpDownYear();
     AddEventsToControls();
     UpdateDataGridViewSearchResult();
 }