Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (ldb.CountBorrow(textID.Text) > LibraryDB.MaxBorrow)
            {
                MessageBox.Show("You can only borrow 3 books! ");
            }

            else if (ldb.BookStock(textbno.Text) == 0)
            {
                string erd = ldb.EarliestReturn(textbno.Text);
                MessageBox.Show("Out of stock, the earliest return date is " + erd);
            }

            else if (ldb.Borrowed(textID.Text, textbno.Text))
            {
                MessageBox.Show("You can only borrow the same book once! ");
            }


            else
            {
                ldb.Borrow(textID.Text, textbno.Text);
                refreshlistview();
                MessageBox.Show("Borrow succeed! ");
            }
        }
Esempio n. 2
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (listCard.SelectedItems.Count == 0)
     {
         MessageBox.Show("Please select a card.");
     }
     else
     {
         string cno = listCard.SelectedItems[0].Text;
         if (ldb.CountBorrow(cno) == 0)
         {
             if (MessageBox.Show(string.Format("Delete {0} ?", cno.Trim()),
                                 "Delete", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 ldb.DeleteCard(cno);
                 refreshlistview();
             }
         }
         else
         {
             MessageBox.Show("Can't delete this card. Please return all the book! ");
         }
     }
 }