private void txtCustomerID_Validating(object sender, CancelEventArgs e) { //This method is to check if the customerID exists in database try { int ID = Convert.ToInt32(txtCustomerID.Text); customer = VideoDb.SelectCustomer_by_ID(ID); if (customer == null) { MessageBox.Show("No customer found with this ID. " + "Please try again.", "Customer Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GetCustomer_by_ID(int customerID) { try { customer = VideoDb.SelectCustomer_by_ID(customerID); if (customer == null) { MessageBox.Show("No customer found with this ID. " + "Please try again.", "Customer Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Displaycustomer(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }