private void BtnOKTestCode_Click(object sender, RoutedEventArgs e) { try { if (Convert.ToInt32(txtTestCode.Text) < 10000000) { throw new Exception("Non-valid test code. Please enter a valid test code."); } var found = bl.findById(Convert.ToInt32(txtTestCode.Text)); if (action == "update") { string content = "Update"; test myTest = new test(content, Convert.ToInt32(txtTestCode.Text)); this.Close(); myTest.Show(); } else { string content = "View"; tester myTest = new tester(content, Convert.ToInt32(txtTestCode.Text)); this.Close(); myTest.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); txtTestCode.Text = ""; txtTestCode.Visibility = System.Windows.Visibility.Hidden; labelTestCode.Visibility = System.Windows.Visibility.Hidden; btnOKTestCode.Visibility = System.Windows.Visibility.Hidden; } }
private void BtnOKID_Click(object sender, RoutedEventArgs e) { try { if (Convert.ToInt32(txtID.Text) < 100000000 || Convert.ToInt32(txtID.Text) > 999999999) { throw new Exception("Non-valid Id. Please enter a valid Id."); } var found = bl.findById(Convert.ToInt32(txtID.Text)); if (action == "remove") { string content = "Remove"; trainee MyTrainee = new trainee(content, Convert.ToInt32(txtID.Text)); this.Close(); MyTrainee.Show(); } else if (action == "update") { string content = "Update"; trainee myTrainee = new trainee(content, Convert.ToInt32(txtID.Text)); this.Close(); myTrainee.Show(); } else { string content = "View"; trainee myTrainee = new trainee(content, Convert.ToInt32(txtID.Text)); this.Close(); myTrainee.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); txtID.Text = ""; txtID.Visibility = System.Windows.Visibility.Hidden; labelid.Visibility = System.Windows.Visibility.Hidden; btnOKID.Visibility = System.Windows.Visibility.Hidden; } }
private void btnDialogOk_Click(object sender, RoutedEventArgs e) { try { var found = bl.findById(Convert.ToInt32(txtAnswer.Text)); if (found is BE.Test) { MessageBox.Show(((BE.Test)found).ToString()); } else if (found is BE.Tester) { MessageBox.Show(((BE.Tester)found).ToString()); } else if (found is BE.Trainee) { MessageBox.Show(((BE.Trainee)found).ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }