protected void Submit_Click(object sender, EventArgs e)
        {
            //gather the entered data
            string fullname    = FullName.Text;
            string email       = EmailAddress.Text;
            string phonenumber = PhoneNumber.Text;
            string time        = FullOrPartTime.SelectedValue;

            //create a message string containing the data
            string msg = string.Format("Name: {0} Email: {1} Phone: {2} Time: {3}",
                                       fullname, email, phonenumber, time);

            //to handle the checkbox list, traverse the list and obtain the data that was selected
            //after the traverse, add the string of jobs OR an error message to the other message data string
            string jobs  = " Jobs: ";
            bool   found = false;

            foreach (ListItem placeholderitem in Jobs.Items)
            {
                if (placeholderitem.Selected)
                {
                    found = true;
                    jobs += placeholderitem.Value + " ";
                }
            }
            if (!found)
            {
                //no job requested
                jobs += " you did not select a job. Application rejected.";
            }
            else
            {
                //list of jobs requested, save application
                AppList.Add(new JobApps(FullName.Text, email, phonenumber, time, jobs));
            }

            //display the message string in the output message control
            Message.Text = msg + jobs;

            //display all collected applications
            JobApplicationList.DataSource = AppList; //only assigns the data
            JobApplicationList.DataBind();           //physical display of the data
        }
예제 #2
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            //need to collect the entered data
            //string fullname = FullName.Text;
            string email = EmailAddress.Text;
            string phone = PhoneNumber.Text;
            string time  = FullOrPartTime.SelectedValue;
            //create a message containing the entered data
            string msg = string.Format("Name: {0} Email: {1}, Phone: {2} Time: {3}",
                                       FullName.Text, email, phone, time);
            //to handle the checkbox list, traverse the list
            //    and obtain the data that was selected
            //during the traverse create a string of jobs selected
            //add the job string or reject msg to the other data
            string jobs  = " Jobs: ";
            bool   found = false;

            foreach (ListItem item in Jobs.Items)
            {
                if (item.Selected)
                {
                    jobs += item.Value + " ";
                    found = true;
                }
            }
            if (!found)
            {
                jobs += " you did not select a job. Application rejected";
            }
            else
            {
                //collect the job application into a collection List<T>
                AppList.Add(new JobApps(FullName.Text, email, phone, time, jobs));
            }
            //display the complete message
            Message.Text = msg + jobs;

            //display all collected applications
            JobApplicationList.DataSource = AppList;
            JobApplicationList.DataBind();
        }
예제 #3
0
        }//EOClear

        protected void Submit_Click(object sender, EventArgs e)
        {
            //need to collect data
            //string fullname = FullName.Text;
            string email       = EmailAddress.Text;
            string phonenumber = PhoneNumber.Text;
            string time        = FullOrPartTime.SelectedValue;

            //need to create a message containing the entered data
            string msg = string.Format("Name: {0} Email: {1} Phone: {2} Time: {3}",
                                       FullName.Text, email, phonenumber, time);
            //need to traverse the checkboxlist and
            //     obtain the data that was selected
            //need to add the data from the checkboxlist to the message
            string jobs  = " Jobs: ";
            bool   found = false;

            foreach (ListItem item in Jobs.Items)
            {
                if (item.Selected)
                {
                    jobs += item.Value + " ";
                    found = true;
                }
            }
            if (!found)
            {
                jobs += " you did NOT select a job. Application rejected.";
            }
            else
            {
                //saving application once submitted
                AppList.Add(new JobApps(FullName.Text, email, phonenumber, time, jobs));
            }
            //set the message label to the message
            Message.Text = msg + jobs;

            //display the current job application collection
            JobApplicationList.DataSource = AppList;
            JobApplicationList.DataBind();
        }//EOSubmit
예제 #4
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            //when submit button is clicked
            //gather entered data and display the values.

            //task 1: collect the entered data
            string fullname = FullName.Text;
            string email    = EmailAddress.Text;
            string phone    = PhoneNumber.Text;
            string time     = FullOrPartTime.SelectedValue;

            string msg = "";

            //list data inputed
            //if no name or email is enetered,
            //say an error message
            if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(email))
            {
                Message.Text = "Please enter your name and email";
            }
            else
            {
                msg = string.Format("Name: {0}\n Email: {1}\n Phone: {2}\n Time: {3}\n",
                                    fullname, email, phone, time);

                string jobs  = "Jobs: ";
                bool   found = false;

                //list selected jobs:
                foreach (ListItem item in Jobs.Items)
                {
                    if (item.Selected)
                    {
                        found = true;
                        jobs += item.Value + ", ";
                    }
                }
                // if no jobs were selected:
                if (!found)
                {
                    //tell the user
                    jobs += "No job selected";
                }

                else
                {
                    //store entered data
                    AppList.Add(new JobApps(fullname, email, phone, time, jobs));
                }


                //task 2: message the user

                Message.Text = msg + jobs;

                //task 3: display all collected data applications
                JobApplicationList.DataSource = AppList; //only assigns the data
                JobApplicationList.DataBind();           //physical display of data
            }



            //to handle the check box list, we nee to TRAVERSE the list,
            //  and obtain the data that was selected.
            //during the traverese, create a string of jobs selected.
            //after the traverese, add the string of jobs OR an error message to
            //  the other message data string
            //display the message string in the output message control
        }