private void frmConfirmBorrow_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { Loan loan = new Loan(); loan.fkBook = bookid; loan.fkReader = readerid; loan.dateOut = System.DateTime.Now; _controller.Insert(loan); _controller.Update(loan); } }