예제 #1
0
 private void reserveBtn_Click(object sender, EventArgs e)
 {
     try
     {
         Model.Item item = controller.GetItem(int.Parse(itemIdTB.Text.Trim()));
         if (item == null)
         {
             updateMsg("The requested item does not exist.", true);
             return;
         }
         Model.Borrower borrower = controller.GetBorrower(int.Parse(borrowerIdTB.Text.Trim()));
         if (borrower == null)
         {
             updateMsg(string.Format("A customer with the id {0}\r\ndoes not exist.", borrowerIdTB.Text), true);
             return;
         }
         Model.State itemState = item.State;
         if (itemState == Model.State.Available)
         {
             updateMsg("The requested item is currently available.", true);
         }
         else
         {
             controller.Reserve(borrower.Id, item.ItemId);
             updateMsg("Reserved successfully.", false);
         }
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.StackTrace);
         updateMsg("Invalid input format.", true);
     }
 }
 private void removeBtn_Click(object sender, EventArgs e)
 {
     try
     {
         int id = int.Parse(borrowerIdTB.Text);
         if (controller.RemoveItem(id))
         {
             updateMsg((controller.GetBorrower(id) is Model.Student ? "Student" : "Teacher") + " successfully deleted.", false);
         }
         else
         {
             updateMsg("Borrower does not exist.", true);
         }
     }
     catch (FormatException ex)
     {
         updateMsg("Invalid Format", true);
     }
 }