private void borrowButton_Click(object sender, EventArgs e) { try { if (mediaLogic.ListBorrow(media.MediaId).Count <= 0) { DateTime todayDate = DateTime.Today; string todaysDate = todayDate.ToString("dd/MM/yyyy"); //change this according to the computers date layout either dd/MM/yyyy or MM/dd/yyyy DateTime expDate = todayDate.AddDays(30); string expiryDate = expDate.ToString("dd/MM/yyyy"); //change this according to the computers date layout either dd/MM/yyyy or MM/dd/yyyy int affectedRows = mediaLogic.InsertBorrow(CurrentUser.UserID, media.MediaId, todaysDate, expiryDate); MessageBox.Show("You have borrowed " + media.MediaName); //NEED CONDITION TO DELETE RESERVE int affectedRows2 = mediaLogic.DeleteReserveOnReturn(media.MediaId); } else { MessageBox.Show(media.MediaName + " is already borrowed"); } returnComboBox.DataSource = mediaLogic.ListReturn(CurrentUser.UserID); returnComboBox.DisplayMember = "PairName"; returnComboBox.ValueMember = "PairId"; RefreshUserList(); } catch (Exception ex) { MessageBox.Show("Please select a media"); } }
//BORROW BUTTON 25-05-2017 private void borrowButton_Click(object sender, EventArgs e) { if (mediaLogic.ListBorrow(media.MediaId).Count <= 0) { DateTime todayDate = DateTime.Today; string todaysDate = todayDate.ToString("MM/dd/yyyy"); DateTime expDate = todayDate.AddDays(15); string expireDate = expDate.ToString("MM/dd/yyyy"); int affectedRows = mediaLogic.InsertBorrow(CurrentUser.UserID, media.MediaId, todaysDate, expireDate); MessageBox.Show(media.MediaName + "has been borrowed for you!"); } else { MessageBox.Show(media.MediaName + " sorry but you cannot borrow this media, it has already been reserved"); } RefreshUserList(); }