Exemplo n.º 1
0
        /// <summary>
        /// Validates the firstname, lastname and telephone numbers.
        /// </summary>
        /// <returns>returns true if all the three fields are validated, false
        /// otherwise</returns>
        private bool ValidateInputFields()
        {
            //calls checkstring method of inpututility class
            if (!InputUtility.CheckString(txtCustomerFirstName.Text))
            {
                MessageBox.Show("First name cannot be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblFirstName.Text = "First Name*";
                return(false);
            }
            if (!InputUtility.CheckString(txtCustomerLastName.Text))
            {
                MessageBox.Show("Last name cannot be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblLastName.Text = "Last Name*";
                return(false);
            }
            //validation for phone numbers
            if (!ValidationForPhoneNumbers())
            {
                return(false);
            }
            //to validate email
            if (!ValidateEmail())
            {
                MessageBox.Show("Enter a valid E-mail address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblLastName.Text = "Email*";
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// To perform the validation for city and street names
 /// </summary>
 /// <returns></returns>
 public bool CheckData()
 {
     if (!InputUtility.CheckString(m_city))
     {
         m_strErrMessage = "Enter proper City name";
         return(false);
     }
     else if (!InputUtility.CheckString(m_street))
     {
         m_strErrMessage = "Street name cannot be empty!";
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// validate all input fields
 /// </summary>
 /// <returns></returns>
 private bool ValidateInputFields()
 {
     //calls checkstring method of inpututility class
     if (!InputUtility.CheckString(txtNumber.Text))
     {
         MessageBox.Show("Number cannot be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         lblNumber.Text = "Number*";
         return(false);
     }
     if (cmbFrom.SelectedItem.ToString() == cmbTo.SelectedItem.ToString())
     {
         MessageBox.Show("Select different Stations", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         lblFrom.Text = "From*";
         lblTo.Text   = "To*";
         return(false);
     }
     return(true);
 }