コード例 #1
0
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            string   bookName  = cmbBookName.Text;
            string   reader    = cmbReader.Text;
            DateTime getDate   = dtGetDate.Value;
            DateTime deadeline = dtDeadline.Value;

            if (!string.IsNullOrWhiteSpace(bookName) && !string.IsNullOrWhiteSpace(reader))
            {
                lblError.Visible = false;
                Reader_to_Book reader_To_Book = new Reader_to_Book();
                reader_To_Book.BookId   = _context.Books.First(b => b.Book_Name == bookName).Id;
                reader_To_Book.ReaderId = _context.Readers.First(r => r.Fullname == reader).Id;
                reader_To_Book.Get_Book = getDate;
                reader_To_Book.Deadline = deadeline;
                _context.Reader_to_Book.Add(reader_To_Book);
                _context.SaveChanges();
                FillElements();
            }
            else
            {
                lblError.Visible = true;
            }
            ButtonVisible("addBook");
        }
コード例 #2
0
ファイル: OrderBook.cs プロジェクト: fatime443/UnivesityApp
        private void btnSelect_Click(object sender, EventArgs e)
        {
            string         bookName       = cmbBookName.Text;
            string         fullName       = txtFullname.Text;
            DateTime       getDate        = dtGetBook.Value;
            DateTime       deadLine       = dtDeadline.Value;
            Reader_to_Book reader_To_Book = new Reader_to_Book();

            if (!string.IsNullOrWhiteSpace(bookName) && !string.IsNullOrWhiteSpace(fullName))
            {
                lblError.Visible        = false;
                reader_To_Book.BookId   = _context.Books.First(a => a.Book_Name == bookName).Id;
                reader_To_Book.ReaderId = _context.Readers.First(a => a.Fullname == fullName).Id;
                reader_To_Book.Deadline = deadLine;
                reader_To_Book.Get_Book = getDate;
                _context.Reader_to_Book.Add(reader_To_Book);
                _context.SaveChanges();
                MessageBox.Show("Book selected successfully!", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FillField();
            }
            else
            {
                lblError.Visible = true;
            }
        }
コード例 #3
0
        private void dtgReaderToBook_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            ButtonVisible("add");
            int orderId = (int)dtgReaderToBook.Rows[e.RowIndex].Cells[0].Value;

            selected         = _context.Reader_to_Book.First(rtb => rtb.Id == orderId);
            cmbBookName.Text = selected.Book.Book_Name;
            cmbReader.Text   = selected.Reader.Fullname;
            dtDeadline.Value = selected.Deadline;
            dtGetDate.Value  = selected.Get_Book;
        }
コード例 #4
0
ファイル: OrderBook.cs プロジェクト: fatime443/UnivesityApp
        private void dtgOrderBook_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            buttonVisible("add");
            int bookId = (int)dtgOrderBook.Rows[e.RowIndex].Cells[0].Value;

            selectedName     = _context.Reader_to_Book.First(b => b.Id == bookId);
            txtFullname.Text = selectedName.Reader.Fullname;
            cmbBookName.Text = selectedName.Book.Book_Name;
            dtDeadline.Value = selectedName.Deadline;
            dtGetBook.Value  = selectedName.Get_Book;
        }