コード例 #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                StudentInformationClass.SetFullName  = FullName(txtLastname.Text, txtFirstname.Text, txtMiddleInitial.Text);
                StudentInformationClass.SetStudentNo = StudentNumber(txtStudentNo.Text);
                StudentInformationClass.SetProgram   = cbPrograms.Text;
                StudentInformationClass.SetGender    = cbGender.Text;
                StudentInformationClass.SetContactNo = ContactNo(txtContactNo.Text);
                StudentInformationClass.SetAge       = Age(txtAge.Text);
                StudentInformationClass.SetBirthday  = datePickerBirthday.Value.ToString("yyyy-MM-dd");

                frmConfirmation frm = new frmConfirmation();
                frm.ShowDialog();
            }
            catch (FormatException fe)
            {
                MessageBox.Show(fe.Message);
            }
            catch (ArgumentNullException ae)
            {
                MessageBox.Show(ae.Message);
            }
            catch (OverflowException oe)
            {
                MessageBox.Show(oe.Message);
            }
            catch (IndexOutOfRangeException ie)
            {
                MessageBox.Show(ie.Message);
            }
        }
コード例 #2
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                StudentInformationClass.SetFullName  = FullName(txtLastName.Text, txtFirstName.Text, txtMiddleInitial.Text);
                StudentInformationClass.SetStudentNo = StudentNumber(txtStudentNo.Text);
                StudentInformationClass.SetProgram   = cbPrograms.Text;
                StudentInformationClass.SetGender    = cbGender.Text;
                StudentInformationClass.SetContactNo = ContactNo(txtContactNo.Text);
                StudentInformationClass.SetAge       = Age(txtAge.Text);
                StudentInformationClass.SetBirthday  = datePickerBirthday.Value.ToString("yyyy-MM-dd");

                frmConfirmation frm = new frmConfirmation();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    cbPrograms.ResetText();
                    txtLastName.ResetText();
                    txtFirstName.ResetText();
                    txtMiddleInitial.ResetText();
                    txtStudentNo.ResetText();
                    txtAge.ResetText();
                    txtContactNo.ResetText();
                    cbGender.ResetText();
                    frm.Hide();
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show("String format error", ex.Message);
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show("Null detected error", ex.Message);
            }
            catch (OverflowException ex)
            {
                MessageBox.Show("Integer overflow error", ex.Message);
            }
            catch (IndexOutOfRangeException ex)
            {
                MessageBox.Show("Array invalid index error", ex.Message);
            }
            finally
            {
                MessageBox.Show("Code completed");
            }
        }