private void btnRegister_Click(object sender, EventArgs e) { string productID = Convert.ToString(cBoxProduct.SelectedValue); int customerID = Convert.ToInt32(cBoxCustName.SelectedValue); try { RegistrationDB regDB = new RegistrationDB(); if (regDB.ProductRegistration(customerID, productID)) { MessageBox.Show("Registration Exists", "Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Registration aRegistration = new Registration(); DateTime myDateTime = DateTime.Now; string sqlFormattedDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"); aRegistration.RegistrationDate = myDateTime; regDB.AddRegistration(aRegistration); MessageBox.Show("Registrationd Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }