/// <summary> /// RegisterBook, opens the register book form and adds adds information upon confirmation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RegisterBookBtn_Click(object sender, EventArgs e) { Confirmation confirm = new Confirmation(); DialogResult result = confirm.ShowDialog(); if (result == DialogResult.OK) { //Get the customer Customer c = (Customer)customerNameBx.SelectedItem; Book b = (Book)bookNameBx.SelectedItem; Registration reggyBooky = new Registration() { CustomerID = c.CustomerID, ISBN = b.ISBN, RegDate = dateRegisterDtp.Value }; newReg = reggyBooky; //Add the variable object to the database BookRegistrationDB.RegisterBook(reggyBooky); } }
private void btnRegisterBook_Click(object sender, EventArgs e) { Registration addReg = new Registration() { CustomerID = Convert.ToString(((Customer)cboxCustomer.SelectedItem).Title) , ISBN = ((Book)cboxBook.SelectedItem).ISBN , RegDate = Convert.ToDateTime(dateTimePicker1.Value) }; try { if (addReg != null) { BookRegistrationDB.RegisterBook(addReg); MessageBox.Show("Registration added!!!"); } } catch (SqlException ex) { MessageBox.Show("We are having server issues, please try again later"); } }