コード例 #1
0
        private void EditorSelector_Clicked(object sender, MouseButtonEventArgs e)
        {
            var    panel     = sender as Grid;
            string panelName = panel.Name;

            switch (panelName)
            {
            case "jobInfoChangedGrid":
                HideAllEditingPlanes();
                SetJobBoxesToReadWrite();
                companyNameBox.IsReadOnly = false;
                break;

            case "locationInfoChangedGrid":
                HideAllEditingPlanes();
                SetLocationBoxesToReadWrite();
                break;

            case "recruiterInfoChangedGrid":
                HideAllEditingPlanes();
                MessageBoxResult result;
                if (IsRecruiterInitialized == false)
                {
                    result = MessageBox.Show("This job was not created with a recruiter. Would you like to add one?", "Recruiter", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        Recruiter recruiter = new Recruiter()
                        {
                            RecruiterName = "",
                            PhoneNumber   = "",
                            LinkedInLink  = "",
                            Email         = ""
                        };
                        SQLConnections sql            = new SQLConnections();
                        int            newRecruiterID = sql.AddRecruiterGetID(recruiter);
                        sql.UpdateJobWithRecruiterID(newRecruiterID, jobsModel.SelectedJob.CompanyId);
                        jobsModel              = new JobsModel();
                        jobsModel.SelectedJob  = jobsModel.AllJobs.Where(x => x.CompanyId == SelectedJobID).FirstOrDefault();
                        IsRecruiterInitialized = true;
                    }
                    else
                    {
                        ShowAllEditingPlanes();
                        return;
                    }
                }

                SetRecruiterBoxesToReadWrite();
                break;
            }
        }
コード例 #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;

            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;
            }
        }