private void SelectCboSelectedReviewItem(Business.Entities.ProbationAnalysis probationAnalysis)
        {
            foreach (var item in cboSelectedReview.Items)
            {
                if (item is string || ((Utilities.ListItem)item).HiddenObject == null)
                {
                    continue;
                }

                Business.Entities.ProbationAnalysis probationAnalysisItem = (Business.Entities.ProbationAnalysis)(((Utilities.ListItem)item).HiddenObject);
                if (probationAnalysisItem.ProbationAnalysisId == probationAnalysis.ProbationAnalysisId || probationAnalysisItem.ProbationRecognition == probationAnalysis.ProbationRecognition)
                {
                    cboSelectedReview.SelectedItem = item;
                    break;
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (cboSelectedReview.SelectedItem is string || cboSelectedReview.SelectedIndex == -1 || ((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject == null)
            {
                MessageBox.Show("The selected Probation Analysis Review is not available for deletion.", "Attention", MessageBoxButtons.OK);
                return;
            }

            Business.Entities.ProbationAnalysis probationAnalysis = (Business.Entities.ProbationAnalysis)((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject;

            DialogResult result;

            if (probationAnalysis.DatePresented == null)
            {
                result = MessageBox.Show("Are you sure you wish to delete the Probation Analysis Review for " + SelectedFund.Ticker + " that has not been presented?", "Attention", MessageBoxButtons.YesNoCancel);
            }
            else
            {
                result = MessageBox.Show("Are you sure you wish to delete the Probation Analysis Review for " + SelectedFund.Ticker + " presented on " + ((DateTime)probationAnalysis.DatePresented).ToString("MM/dd/yyyy") + "?", "Attention", MessageBoxButtons.YesNoCancel);
            }

            if (result == DialogResult.Yes)
            {
                try
                {
                    probationAnalysis.DeleteDatabaseRecord();
                    MessageBox.Show("Record succesfully deleted!", "Success!", MessageBoxButtons.OK);
                }
                catch (Exception ex)
                {
                    frmError _frmError = new Presentation.Forms.frmError(frmMain_Parent, ex);
                }

                GetAssociatedReviewsFromFundAndPlan(SelectedFund.FundId, SelectedPlan.PlanId);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Business.Entities.ProbationAnalysis probationAnalysis;

            if (cboSelectedReview.SelectedItem is string || cboSelectedReview.SelectedIndex == -1 || ((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject == null)
            {
                probationAnalysis = new Business.Entities.ProbationAnalysis();

                try
                {
                    if (String.IsNullOrWhiteSpace(txtDateApproved.Text))
                    {
                        probationAnalysis.DateApproved = null;
                    }
                    else
                    {
                        probationAnalysis.DateApproved = DateTime.Parse(txtDateApproved.Text);
                    }
                }
                catch
                {
                    MessageBox.Show("Error: The date approved field is not in a propper date format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                    return;
                }

                try
                {
                    if (String.IsNullOrWhiteSpace(txtDatePresented.Text))
                    {
                        probationAnalysis.DatePresented = null;
                    }
                    else
                    {
                        probationAnalysis.DatePresented = DateTime.Parse(txtDatePresented.Text);
                    }
                }
                catch
                {
                    MessageBox.Show("Error: The date presented field is not in a propper date format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                    return;
                }

                probationAnalysis.FundId = SelectedFund.FundId;
                probationAnalysis.PlanId = SelectedPlan.PlanId;

                if (cboSelectedQuarter.SelectedIndex <= 0)
                {
                    probationAnalysis.TimeTableId = null;
                }
                else
                {
                    probationAnalysis.TimeTableId = ((Business.Entities.TimeTable)((Utilities.ListItem)cboSelectedQuarter.SelectedItem).HiddenObject).TimeTableId;
                }

                probationAnalysis.ProbationRecognition         = txtRecognition.Text;
                probationAnalysis.Hypothesis                   = txtHypothesis.Text;
                probationAnalysis.HypothesisSupportandAnalysis = txtHypothesisSupport.Text;
                probationAnalysis.TemporaryVsPermanent         = txtTemporaryPermanent.Text;
                probationAnalysis.SpecialConsiderations        = txtConsiderations.Text;
                probationAnalysis.Recommendations              = txtRecommendation.Text;

                if (cboRecommendedWord.SelectedIndex <= 0)
                {
                    probationAnalysis.RecommendedWordId     = null;
                    probationAnalysis.RecommendedWordIdName = null;
                }
                else
                {
                    probationAnalysis.RecommendedWordId     = new Guid(((Utilities.ListItem)cboRecommendedWord.SelectedItem).HiddenValue);
                    probationAnalysis.RecommendedWordIdName = ((Utilities.ListItem)cboRecommendedWord.SelectedItem).ToString();
                }

                try
                {
                    probationAnalysis.InsertDatabaseRecord(frmMain_Parent.CurrentUser.UserId);
                    btnNewProbationAnalysis.Text = "New";
                    MessageBox.Show("Record succesfully saved!", "Success!", MessageBoxButtons.OK);
                }
                catch (Exception ex)
                {
                    frmError _frmError = new Presentation.Forms.frmError(frmMain_Parent, ex);
                }
            }
            else
            {
                probationAnalysis = (Business.Entities.ProbationAnalysis)((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject;

                try
                {
                    if (String.IsNullOrWhiteSpace(txtDateApproved.Text))
                    {
                        probationAnalysis.DateApproved = null;
                    }
                    else
                    {
                        probationAnalysis.DateApproved = DateTime.Parse(txtDateApproved.Text);
                    }
                }
                catch
                {
                    MessageBox.Show("Error: The date approved field is not in a propper date format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                    return;
                }

                try
                {
                    if (String.IsNullOrWhiteSpace(txtDatePresented.Text))
                    {
                        probationAnalysis.DatePresented = null;
                    }
                    else
                    {
                        probationAnalysis.DatePresented = DateTime.Parse(txtDatePresented.Text);
                    }
                }
                catch
                {
                    MessageBox.Show("Error: The date presented field is not in a propper date format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                    return;
                }

                probationAnalysis.FundId = SelectedFund.FundId;
                probationAnalysis.PlanId = SelectedPlan.PlanId;

                if (cboSelectedQuarter.SelectedIndex <= 0)
                {
                    probationAnalysis.TimeTableId = null;
                }
                else
                {
                    probationAnalysis.TimeTableId = ((Business.Entities.TimeTable)((Utilities.ListItem)cboSelectedQuarter.SelectedItem).HiddenObject).TimeTableId;
                }

                probationAnalysis.ProbationRecognition         = txtRecognition.Text;
                probationAnalysis.Hypothesis                   = txtHypothesis.Text;
                probationAnalysis.HypothesisSupportandAnalysis = txtHypothesisSupport.Text;
                probationAnalysis.TemporaryVsPermanent         = txtTemporaryPermanent.Text;
                probationAnalysis.SpecialConsiderations        = txtConsiderations.Text;
                probationAnalysis.Recommendations              = txtRecommendation.Text;

                if (cboRecommendedWord.SelectedIndex <= 0)
                {
                    probationAnalysis.RecommendedWordId     = null;
                    probationAnalysis.RecommendedWordIdName = null;
                }
                else
                {
                    probationAnalysis.RecommendedWordId     = new Guid(((Utilities.ListItem)cboRecommendedWord.SelectedItem).HiddenValue);
                    probationAnalysis.RecommendedWordIdName = ((Utilities.ListItem)cboRecommendedWord.SelectedItem).ToString();
                }

                if (cboOwner.SelectedIndex <= 0)
                {
                    probationAnalysis.OwnerId = null;
                }
                else
                {
                    probationAnalysis.OwnerId = ((User)((Utilities.ListItem)cboOwner.SelectedItem).HiddenObject).UserId;
                }

                try
                {
                    probationAnalysis.UpdateDatabaseRecord(frmMain_Parent.CurrentUser.UserId);
                    MessageBox.Show("Record succesfully saved!", "Success!", MessageBoxButtons.OK);
                }
                catch (Exception ex)
                {
                    frmError _frmError = new Presentation.Forms.frmError(frmMain_Parent, ex);
                }
            }

            GetAssociatedReviewsFromFundAndPlan(SelectedFund.FundId, SelectedPlan.PlanId);
            SelectCboSelectedReviewItem(probationAnalysis);

            UnsavedChanges = false;
        }
        private void cboSelectedReview_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (UnsavedChanges)
            {
                DialogResult result = MessageBox.Show("There are unsaved changes. Are you sure you wish to change the selected review?", "Attention", MessageBoxButtons.YesNoCancel);

                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (cboSelectedReview.SelectedItem is string)
            {
                return;
            }

            Business.Entities.ProbationAnalysis probationAnalysis = (Business.Entities.ProbationAnalysis)((Utilities.ListItem)cboSelectedReview.SelectedItem).HiddenObject;
            txtRecognition.Text        = probationAnalysis.ProbationRecognition;
            txtHypothesis.Text         = probationAnalysis.Hypothesis;
            txtHypothesisSupport.Text  = probationAnalysis.HypothesisSupportandAnalysis;
            txtTemporaryPermanent.Text = probationAnalysis.TemporaryVsPermanent;
            txtConsiderations.Text     = probationAnalysis.SpecialConsiderations;
            txtRecommendation.Text     = probationAnalysis.Recommendations;
            cboRecommendedWord.Text    = probationAnalysis.RecommendedWordIdName;

            if (probationAnalysis.DateApproved == null)
            {
                txtDateApproved.Text = null;
            }
            else
            {
                txtDateApproved.Text = ((DateTime)probationAnalysis.DateApproved).ToString("MM/dd/yyyy");
            }

            if (probationAnalysis.DatePresented == null)
            {
                txtDatePresented.Text = null;
            }
            else
            {
                txtDatePresented.Text = ((DateTime)probationAnalysis.DatePresented).ToString("MM/dd/yyyy");
            }

            if (probationAnalysis.RecommendedWordId != null)
            {
                foreach (var item in cboRecommendedWord.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    StringMap _stringMap = (StringMap)(((Utilities.ListItem)item).HiddenObject);
                    if (_stringMap.Value == probationAnalysis.RecommendedWordIdName)
                    {
                        cboRecommendedWord.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboRecommendedWord.SelectedIndex = 0;
            }

            if (probationAnalysis.TimeTableId != null)
            {
                foreach (var item in cboSelectedQuarter.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    Business.Entities.TimeTable timeTable = (Business.Entities.TimeTable)(((Utilities.ListItem)item).HiddenObject);

                    if (timeTable.TimeTableId == (Guid)probationAnalysis.TimeTableId)
                    {
                        cboSelectedQuarter.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboSelectedQuarter.SelectedIndex = 0;
            }

            if (probationAnalysis.OwnerId != null)
            {
                foreach (var item in cboOwner.Items)
                {
                    if (((Utilities.ListItem)item).HiddenObject is string || ((Utilities.ListItem)item).HiddenObject == null)
                    {
                        continue;
                    }

                    User owner = (User)(((Utilities.ListItem)item).HiddenObject);

                    if (owner.UserId == (Guid)probationAnalysis.OwnerId)
                    {
                        cboOwner.SelectedItem = item;
                        break;
                    }
                }
            }
            else
            {
                cboOwner.SelectedIndex = 0;
            }

            UnsavedChanges = false;
        }