コード例 #1
0
        /// <summary>
        /// This method invokes a method having a regular expression that validates the format of the entered PAN Number.
        /// </summary>
        /// <param name="sender">The control that fired the event</param>
        /// <param name="e">The arguments associated with the fired event.</param>
        private void pan_Validating(object sender, CancelEventArgs e)
        {
            string textInput = pan.Text.TrimStart().TrimEnd();

            if (string.IsNullOrEmpty(textInput))
            {
                MessageBox.Show("No PAN has been entered", "Salary Slip Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pan.Focus();
            }
            else if (!(RegularExpressionValidator.IsValidPan(textInput)))
            {
                MessageBox.Show("The entered PAN is not in proper format", "Salary Slip Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pan.Focus();
            }
        }