private void btnRegistration_Click(object sender, EventArgs e) { //add customer id and product id attributes to the registration object and pass that to the BLL RegistrationBLL regBLL = new RegistrationBLL(); Registration registration = new Registration(); int selectedCustomer = (int)cboCustomerName.SelectedValue; string selectedProduct = (string)cboProductName.SelectedValue; registration.CustomerID = selectedCustomer; registration.ProductCode = selectedProduct; registration.RegistrationDate = (DateTime)DateTime.Today; bool addRegistration = regBLL.AddNewRegistration(registration); //returns true or false depending on weather the registration was successful or not if (addRegistration == true) //record insertion successful! { //CHANGE THESE MESSAGE BOX CONSTRUCTORS MessageBox.Show("The Product was successfully registered", "Add Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The registration already exists", "Add Registration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnRegistration_Click(object sender, EventArgs e) { Registration aRegistration = new Registration(); RegistrationBLL regBLL = new RegistrationBLL(); aRegistration.CustomerID = int.Parse(cboName.SelectedValue.ToString()); aRegistration.ProductCode = cboProduct.SelectedValue.ToString(); aRegistration.RegistrationDate = (DateTime)DateTime.Today; if (regBLL.AddNewRegistration(aRegistration) == true) { MessageBox.Show("The product was successfuly registered.", "Add Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The registration already exists.", "Add Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } }