private void btnBorrow_Click(object sender, EventArgs e) { QLTVDTO.borrowbook borrowDTO = new QLTVDTO.borrowbook(); bookDTO book = new bookDTO(); ReaderDTO reader = new ReaderDTO(); book.MaSach = tbBookCode.Text; reader.IdReader = int.Parse(tbReaderCode.Text); string temp1 = tbReaderCode.Text; borrowDTO.NgayTraSachThuc = dtpReturnBookDate.Value; borrowDTO.Idborrowbook = tbReturnBook.Text; //add into db bool result = returnBUS.Tra(borrowDTO, book, reader); if (result == true) { MessageBox.Show("Trả thành công"); } else { MessageBox.Show("Trả sách thất bại"); } }
private void btnBorrow_Click(object sender, EventArgs e) { QLTVDTO.borrowbook borrowDTO = new QLTVDTO.borrowbook(); bookDTO book = new bookDTO(); ReaderDTO reader = new ReaderDTO(); DateTimePicker myPicker = new DateTimePicker(); myPicker.Value = DateTime.Now; int k = myPicker.Value.Month - reader.DateCreateReader.Month; int SoSachMuon = ReaderBUS.SoSachMuon(reader); int SoSachMax = ReaderBUS.getMaxofBorrowBook(); reader.IdReader = int.Parse(tbReaderCode.Text); string temp = tbReaderCode.Text; if ((k > ReaderBUS.getTimeofReader()) && (SoSachMuon > SoSachMax)) { MessageBox.Show("Đã Hết hạn mượn Thẻ "); } else { book.MaSach = tbBookCode.Text; borrowDTO.NgayMuonSach = DateBorrowdtp.Value; borrowDTO.Idborrowbook = tbIdBorrowBook.Text; borrowDTO.NgayTraSach = DateBorrowdtp.Value.AddDays(borrowBUS.SoNgayMuonToiDa()); //add into db bool result = borrowBUS.add(borrowDTO, book, reader); if (result == true) { MessageBox.Show("Mượn thành công"); } else { MessageBox.Show("Mượn thất bại"); } } }