コード例 #1
0
        private void setFeedbackV2(PersonV2 p)
        {
            String s = "";

            s += $"\n Name: {p.FName} {p.MName} {p.LName}";
            s += $"\n Address: {p.StreetOne} {p.StreetTwo} , {p.City} {p.StateCode} , {p.ZipCode}";
            s += $"\n Phone Number: {p.PhoneNum} ,\n Cell Number: {p.CellNum}";
            s += $"\n Email: {p.EmailAddress} , \n Instagram : {p.InstagramURL}";
            lblFeedback.Text = s;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Person Class Validation Example");

            PersonV2 person = new PersonV2();

            Console.Write("Enter first name: ");
            person.FirstName = Console.ReadLine();

            Console.Write("Enter middle name: ");
            person.MiddleName = Console.ReadLine();

            Console.Write("Enter last name: ");
            person.LastName = Console.ReadLine();

            Console.Write("Enter address line 1: ");
            person.Street1 = Console.ReadLine();

            Console.Write("Enter address line 2: ");
            person.Street2 = Console.ReadLine();

            Console.Write("Enter city: ");
            person.City = Console.ReadLine();

            Console.Write("Enter state (XX):");
            person.State = Console.ReadLine();

            Console.Write("Enter zip code (nnnnn) or (nnnnn-nnnn): ");
            person.Zip = Console.ReadLine();

            Console.Write("Enter phone number ((nnn)nnn-nnnn): ");
            person.Phone = Console.ReadLine();

            Console.Write("Enter email: ");
            person.Email = Console.ReadLine();

            Console.Write("Enter cell phone: ");
            person.CellPhone = Console.ReadLine();

            Console.Write("Enter FaceBook url: ");
            person.FaceBook = Console.ReadLine();

            Console.WriteLine("\n");
            if (person.Feedback != "")
            {
                Console.WriteLine(person.Feedback);
            }
            else
            {
                person.Output();
            }

            Util.Pause();
        }
コード例 #3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            PersonV2 pv2 = new PersonV2();

            pv2.FName        = txtFName.Text;
            pv2.MName        = txtMName.Text;
            pv2.LName        = txtLName.Text;
            pv2.StreetOne    = txtStreetOne.Text;
            pv2.StreetTwo    = txtStreetTwo.Text;
            pv2.City         = txtCity.Text;
            pv2.StateCode    = txtStateCode.Text;
            pv2.ZipCode      = txtZipCode.Text;
            pv2.PhoneNum     = txtPhoneNum.Text;
            pv2.EmailAddress = txtEmailAddress.Text;
            //New
            pv2.CellNum      = txtCellPhoneNum.Text;
            pv2.InstagramURL = txtInstagramURL.Text;
            //This code vastly shortened by moving error feedback to object
            if (pv2.Feedback.Contains("Error"))
            {
                lblErrorMsg.Text = pv2.Feedback;
                pv2.Feedback     = "";
            }
            //Successful submission code
            else
            {
                lblErrorMsg.Text     = "Input Errors: NONE";
                txtFName.Text        = "";
                txtMName.Text        = "";
                txtLName.Text        = "";
                txtStreetOne.Text    = "";
                txtStreetTwo.Text    = "";
                txtCity.Text         = "";
                txtStateCode.Text    = "";
                txtZipCode.Text      = "";
                txtPhoneNum.Text     = "";
                txtEmailAddress.Text = "";

                txtCellPhoneNum.Text = "";
                txtInstagramURL.Text = "";

                setFeedbackV2(pv2);
                people.Add(pv2);
            }
        }