private void Click_SubmitButton(object sender, RoutedEventArgs e)
        {
            SQLConnections sqlconnection = new SQLConnections();

            // get comobox
            var comboBoxRating   = boxRating as ComboBox;
            var comboBoxPosition = boxPosition as ComboBox;
            var comboBoxLocation = boxLocation as ComboBox;

            //set selected value to string
            string ratingSelected   = comboBoxRating.SelectedItem as string;
            string positionSelected = comboBoxPosition.SelectedItem as string;
            string locationSelected = comboBoxLocation.SelectedItem as string;

            int?recruiterID = null;

            if (!string.IsNullOrEmpty(txtRecruiterName.Text) || !string.IsNullOrEmpty(txtRecruiterEmail.Text) || !string.IsNullOrEmpty(txtRecruiterPhoneNumber.Text) || !string.IsNullOrEmpty(txtLinkedIn.Text))
            {
                //Assign properties for new recruiter
                recruiterModel.NewRecruiter = new Recruiter();
                recruiterModel.NewRecruiter.RecruiterName = txtRecruiterName.Text;
                recruiterModel.NewRecruiter.PhoneNumber   = txtRecruiterPhoneNumber.Text;
                recruiterModel.NewRecruiter.Email         = txtRecruiterEmail.Text;
                recruiterModel.NewRecruiter.LinkedInLink  = txtLinkedIn.Text;
                recruiterID = sqlconnection.AddRecruiterGetID(recruiterModel.NewRecruiter);
            }


            //Assign properties for job entry
            jobsModel.NewJobEntry                  = new Jobs();
            jobsModel.NewJobEntry.CompanyName      = txtCompanyName.Text;
            jobsModel.NewJobEntry.SalaryRange      = txtSalary.Text;
            jobsModel.NewJobEntry.CEOName          = txtCEO.Text;
            jobsModel.NewJobEntry.MissionStatement = txtMissionStatement.Text;
            jobsModel.NewJobEntry.Benefits         = txtBenefits.Text;
            jobsModel.NewJobEntry.Comments         = txtComments.Text;
            jobsModel.NewJobEntry.JobLink          = txtJobLink.Text;
            jobsModel.NewJobEntry.RecruiterId      = recruiterID;


            //Update positionModel to reflect updates on positions
            positionModel = new PositionModel();
            var position = positionModel.AllPositions.Where(x => x.JobTitle == positionSelected);

            foreach (var item in position)
            {
                jobsModel.NewJobEntry.PositionId = item.PositionID;
            }
            var location = locationView.AllLocations.Where(x => x.City == locationSelected);

            foreach (var item in location)
            {
                jobsModel.NewJobEntry.LocationId = item.LocationId;
            }
            int ratingId = GetRatingID(ratingSelected);

            jobsModel.NewJobEntry.RatingId = ratingId;



            // Validation
            if (string.IsNullOrEmpty(txtCompanyName.Text) || positionSelected is null || locationSelected is null || ratingSelected is null)
            {
                MessageBox.Show("Please make sure Company Name, Postion, Rating, and Location are all filled out.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Insert to Jobs table in database
            sqlconnection.NewJob(jobsModel.NewJobEntry);
            MessageBoxResult result = MessageBox.Show("Submission complete!", "Success!", MessageBoxButton.OKCancel, MessageBoxImage.None);

            if (result == MessageBoxResult.OK)
            {
                //clear text boxes
                txtBenefits.Clear();
                txtCEO.Clear();
                txtComments.Clear();
                txtCompanyName.Clear();
                txtJobLink.Clear();
                txtMissionStatement.Clear();
                txtRecruiterEmail.Clear();
                txtRecruiterName.Clear();
                txtRecruiterPhoneNumber.Clear();
                txtSalary.Clear();
                boxLocation.SelectedItem = null;
                boxPosition.SelectedItem = null;
                txtLinkedIn.Clear();

                boxRating.SelectedItem     = null;
                canceledMessage.Visibility = Visibility.Hidden;
            }
            else
            {
                sqlconnection.DeleteLastJobRecord();
                canceledMessage.Visibility = Visibility.Visible;
            }
        }
Example #2
0
        private void Click_SubmitButton(object sender, RoutedEventArgs e)
        {
            SQLConnections sqlconnection = new SQLConnections();

            // get comobox
            var comboBoxRating   = boxRating as ComboBox;
            var comboBoxPosition = boxPosition as ComboBox;
            var comboBoxLocation = boxLocation as ComboBox;

            //set selected value to string
            string ratingSelected   = comboBoxRating.SelectedItem as string;
            string positionSelected = comboBoxPosition.SelectedItem as string;
            string locationSelected = comboBoxLocation.SelectedItem as string;

            // get Indentity value for sql query
            int ratingValue = AssignRatingValue(ratingSelected);

            //int positionValue = 0;
            //if (!(positionSelected is null))
            //{
            //    positionValue = sqlconnection.FindPositionID(positionSelected);
            //}

            //Assign properties in static class
            JobInfo.CompanyName      = txtCompanyName.Text;
            JobInfo.Position         = positionSelected;
            JobInfo.Location         = locationSelected;
            JobInfo.SalaryRange      = txtSalary.Text;
            JobInfo.CEOName          = txtCEO.Text;
            JobInfo.MissionStatement = txtMissionStatement.Text;
            JobInfo.Rating           = ratingValue;
            JobInfo.Benefits         = txtBenefits.Text;
            JobInfo.Comments         = txtComments.Text;
            JobInfo.Recruiter        = txtRecruiterName.Text;
            JobInfo.JobLink          = txtJobLink.Text;

            // Validation
            if (ratingValue == 5)
            {
                MessageBox.Show("You must select a Rating in order to submit the job information", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(txtCompanyName.Text) || positionSelected is null || locationSelected is null)
            {
                MessageBox.Show("Please make sure Company Name, Postion, and Location are all filled out.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Insert to Jobs table in database
            sqlconnection.NewJob();
            MessageBoxResult result = MessageBox.Show("Submission complete!", "Success!", MessageBoxButton.OKCancel, MessageBoxImage.None);

            if (result == MessageBoxResult.OK)
            {
                //clear text boxes
                txtBenefits.Clear();
                txtCEO.Clear();
                txtComments.Clear();
                txtCompanyName.Clear();
                txtJobLink.Clear();
                txtMissionStatement.Clear();
                txtRecruiterEmail.Clear();
                txtRecruiterName.Clear();
                txtRecruiterPhoneNumber.Clear();
                txtSalary.Clear();
                boxLocation.SelectedItem   = null;
                boxPosition.SelectedItem   = null;
                boxGenderBox.SelectedItem  = null;
                boxRating.SelectedItem     = null;
                canceledMessage.Visibility = Visibility.Hidden;
            }
            else
            {
                sqlconnection.DeleteLastJobRecord();
                canceledMessage.Visibility = Visibility.Visible;
            }
        }