Ejemplo n.º 1
0
        //Submit Button
        private void Click_SubmitButton(object sender, RoutedEventArgs e)
        {
            SQLConnections sql = new SQLConnections();

            // Update Recruiter Information
            if (recNameBox.IsReadOnly == false)
            {
                Recruiter newRecruiter = new Recruiter();

                newRecruiter.RecruiterId   = jobsModel.LinkedRecruiter.RecruiterId;
                newRecruiter.RecruiterName = recNameBox.Text;
                newRecruiter.Email         = recEmailBox.Text;
                newRecruiter.LinkedInLink  = recLinkBox.Text;
                newRecruiter.PhoneNumber   = recPhoneBox.Text;
                sql.UpdateRecruiter(newRecruiter);

                ReinitializeCurrentJob();
                SetAllTextBoxes();
            }

            // Update Location Information
            if (cityCBox.IsHitTestVisible == true)
            {
                sql.UpdateJobLocationID(locationModel.NewLocation.LocationId, jobsModel.SelectedJob.CompanyId);
                ReinitializeCurrentJob();
                SetAllTextBoxes();
            }

            // Update Job Information
            if (companyNameBox.IsReadOnly == false)
            {
                jobsModel.NewJobEntry                  = new Jobs();
                jobsModel.NewJobEntry.CompanyId        = SelectedJobID;
                jobsModel.NewJobEntry.CompanyName      = companyNameBox.Text;
                jobsModel.NewJobEntry.SalaryRange      = salaryBox.Text;
                jobsModel.NewJobEntry.CEOName          = ceoNameBox.Text;
                jobsModel.NewJobEntry.MissionStatement = missionStatementBox.Text;
                jobsModel.NewJobEntry.Benefits         = benefitsBox.Text;
                jobsModel.NewJobEntry.Comments         = commentsBox.Text;
                jobsModel.NewJobEntry.JobLink          = runLinkBox.Text;

                PositionModel positionModel = new PositionModel();
                var           position      = positionModel.AllPositions.Where(x => x.JobTitle == positionCBox.Text);
                foreach (var item in position)
                {
                    jobsModel.NewJobEntry.PositionId = item.PositionID;
                }

                int ratingId = sql.GetCompanyRatingID(ratingCBox.SelectedItem.ToString());
                jobsModel.NewJobEntry.RatingId = ratingId;

                // Validation
                if (string.IsNullOrEmpty(companyNameBox.Text) || string.IsNullOrEmpty(positionCBox.Text) || string.IsNullOrEmpty(ratingCBox.Text))
                {
                    MessageBox.Show("Please make sure Company Name, Postion, and Rating are all filled out.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                sql.UpdateJobInformation(jobsModel.NewJobEntry);
            }

            //button visibility
            HideAllEditingButtons();
            HideAllEditingPlanes();
            SetRecruiterBoxesToReadOnly();
            SetLocationBoxToReadOnly();
            SetJobBoxesToReadOnly();
        }